import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hyper_local/config/theme/theme_bloc/theme_bloc.dart';

extension ContextSize on BuildContext {
  double get height => MediaQuery.of(this).size.height;
  double get width => MediaQuery.of(this).size.width;

  Size get size => MediaQuery.of(this).size;
}

extension ThemeContext on BuildContext {
  bool get isDarkMode => select((ThemeBloc bloc) => bloc.isDarkMode);
}

extension CustomAnimation on Widget {
  Animate fadeAndSlideAnimation({Key? key}) {
    return animate(key: key).fade(duration: 400.milliseconds).slideY(begin: 0.04, end: 0, curve: Curves.easeOutCubic);
  }

  Widget animateFadeSlide({
    Key? key,
    Duration delay = Duration.zero,
    Duration duration = const Duration(milliseconds: 500),
    double beginY = 0.4,
  }) {
    return animate(
      key: key,
      delay: delay,
    ).fade(duration: duration).slideY(begin: beginY, end: 0, duration: duration, curve: Curves.easeOutCubic);
  }
}
