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

class Utils {
  static void showSnackBarSuccess({required String message}) {
    if (Get.isSnackbarOpen) Get.back();
    Get.snackbar('', message,
        icon: const Icon(
          Icons.done,
          color: Colors.white,
        ),
        snackPosition: SnackPosition.BOTTOM,
        backgroundColor: Colors.green);
  }

  static void showSnackBarError({required String message}) {
    if (Get.isSnackbarOpen) Get.back();
    Get.snackbar('', message,
        icon: const Icon(
          Icons.error,
          color: Colors.white,
        ),
        snackPosition: SnackPosition.BOTTOM,
        backgroundColor: Colors.red);
  }

  static void showSnackBarWarning({required String message}) {
    if (Get.isSnackbarOpen) Get.back();
    Get.snackbar('', message,
        icon: const Icon(
          Icons.warning,
          color: Colors.yellow,
        ),
        snackPosition: SnackPosition.BOTTOM,
        backgroundColor: Colors.yellow[50]);
  }

  static void showDialog(
      {required String title, required String message, required String textConfirm, required String textCancel, required Function() onConfirm}) {
    if (Get.isDialogOpen ?? false) Get.back();
    Get.defaultDialog(
      title: title,
      middleText: message,
      textConfirm: textConfirm,
      textCancel: textCancel,
      confirmTextColor: Colors.white,
      onConfirm: onConfirm,
    );
  }

  static void showDialogConfirmSupply({required Function() onConfirm}) {
    if (Get.isDialogOpen ?? false) Get.back();
    Get.defaultDialog(
        title: "Vật tư chưa được thêm",
        middleText: "Bạn có muốn cập nhật?",
        textConfirm: "Tiếp tục",
        textCancel: "Xem lại",
        confirmTextColor: Colors.white,
        onConfirm: onConfirm);
  }
}
