import 'dart:math';

import 'package:flutter/material.dart';

import '../theme/app_theme_light.dart';

// MEDIA
extension ContextExtension on BuildContext {
  MediaQueryData get mediaQuery => MediaQuery.of(this);
}

// VALUES
extension MediaQueryExtension on BuildContext {
  double get height => mediaQuery.size.height;
  double get width => mediaQuery.size.width;

  double get lowValue => height * 0.01;
  double get normalValue => height * 0.02;
  double get mediumValue => height * 0.04;
  double get highValue => height * 0.1;

  double dynamicWidth(double val) => width * val;
  double dynamicHeight(double val) => height * val;
}

// THEME
extension ThemeExtension on BuildContext {
  ThemeData get theme => Theme.of(this);
  TextTheme get textTheme => theme.textTheme;
  ColorScheme get colors => AppThemeLight.instance.theme.colorScheme;
}

// PADDING ALLL
extension PaddingExtensionAll on BuildContext {
  EdgeInsets get paddingLow => EdgeInsets.all(lowValue);
  EdgeInsets get paddingNormal => EdgeInsets.all(normalValue);
  EdgeInsets get paddingMedium => EdgeInsets.all(mediumValue);
  EdgeInsets get paddingHigh => EdgeInsets.all(highValue);
  EdgeInsets dynamicPadding(double val) => EdgeInsets.all(val);
  // double dynamicPadding(double val) => height * val;
}

// PADDING SYMETRIC
extension PaddingExtensionSymetric on BuildContext {
  // VERTICAL PADDİNG
  EdgeInsets get paddingLowVertical => EdgeInsets.symmetric(vertical: lowValue);
  EdgeInsets get paddingNormalVertical =>
      EdgeInsets.symmetric(vertical: normalValue);
  EdgeInsets get paddingMediumVertical =>
      EdgeInsets.symmetric(vertical: mediumValue);
  EdgeInsets get paddingHighVertical =>
      EdgeInsets.symmetric(vertical: highValue);

  // HORIZONTAL PADDİNG
  EdgeInsets get paddingLowHorizontal =>
      EdgeInsets.symmetric(horizontal: lowValue);
  EdgeInsets get paddingNormalHorizontal =>
      EdgeInsets.symmetric(horizontal: normalValue);
  EdgeInsets get paddingMediumHorizontal =>
      EdgeInsets.symmetric(horizontal: mediumValue);
  EdgeInsets get paddingHighHorizontal =>
      EdgeInsets.symmetric(horizontal: highValue);
}

// RANDOM COLOR
extension PageExtension on BuildContext {
  Color get randomColor => Colors.primaries[Random().nextInt(17)];
}

// DURATION
extension DurationExtension on BuildContext {
  Duration get lowDuration => const Duration(milliseconds: 150);
  Duration get normalDuration => const Duration(milliseconds: 500);
  Duration dynamicSecondDuration(int seconds) => Duration(seconds: seconds);
  Duration dynamicMinutesDuration(int minutes) => Duration(minutes: minutes);

}

// RADIUS
extension RadiusExtension on BuildContext {
  Radius get lowRadius => Radius.circular(width * 0.02);
  Radius get normalRadius => Radius.circular(width * 0.05);
  Radius get highRadius => Radius.circular(width * 0.1);
}

extension TextStyleExtention on BuildContext {
  TextStyle get labelSmallTextStyle => Theme.of(this).textTheme.labelSmall!;
  TextStyle get labelMediumTextStyle => Theme.of(this).textTheme.labelMedium!;
  TextStyle get labelLargeTextStyle => Theme.of(this).textTheme.labelLarge!;
  TextStyle get bodySmallTextStyle => Theme.of(this).textTheme.bodySmall!;
  TextStyle get bodyMediumTextStyle => Theme.of(this).textTheme.bodyMedium!;
  TextStyle get bodyLargeTextStyle => Theme.of(this).textTheme.bodyLarge!;
  TextStyle get titleSmallTextStyle => Theme.of(this).textTheme.titleSmall!;
  TextStyle get titleMediumTextStyle => Theme.of(this).textTheme.titleMedium!;
  TextStyle get titleLargeTextStyle => Theme.of(this).textTheme.titleLarge!;
  TextStyle get headlineSmallTextStyle =>
      Theme.of(this).textTheme.headlineSmall!;
  TextStyle get headlineMediumTextStyle =>
      Theme.of(this).textTheme.headlineMedium!;
  TextStyle get headlineLargeTextStyle =>
      Theme.of(this).textTheme.headlineLarge!;
}

