import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../utils/logs_utils.dart';

extension BuildContextExt on BuildContext? {
  //

  showSnakBar({required String msg}) {
    if (msg.isEmpty) {
      dp("Mess age is empty", msg);
      return;
    }
    ScaffoldMessenger.of(this!).showSnackBar(SnackBar(
      content: Text(
        msg,
        style: Get.context?.textTheme.bodyMedium!.copyWith(
          fontSize: 12,
          fontWeight: FontWeight.w600,
        ),
      ),
      backgroundColor: Colors.white,
      behavior: SnackBarBehavior.floating,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(12),
      ),
      duration: const Duration(seconds: 4),
    ));
  }

  showGeneralDialog(List<Widget>? children, {bool isShowOverly = false, bool dissmiss = true}) {
    showDialog(
      context: this!,
      barrierDismissible: dissmiss,
      barrierColor: isShowOverly ? Get.context.themeData.colorScheme.secondary.withOpacity(0.4) : null,
      builder: (context) {
        return SimpleDialog(
          alignment: Alignment.center,
          backgroundColor: Get.context.themeData.colorScheme.secondary,
          children: children,
        );
      },
    );
  }

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

  double get getHeight => MediaQuery.of(this!).size.height;

  double get getWidth => MediaQuery.of(this!).size.width;

  TextTheme get textTheme => Theme.of(this!).textTheme;

  ThemeData get themeData => Theme.of(this!);

  bool get isSmall => MediaQuery.of(this!).size.height <= 690;

  bool get isVSmall => MediaQuery.of(this!).size.height <= 550;

  bool get isMedium => MediaQuery.of(this!).size.height < 750;
}
