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

class UtilWidget {
  static void showLoading() {
    if (Get.isDialogOpen!) Get.back();

    Get.dialog(
      WillPopScope(
        onWillPop: () async => false,
        child: Center(
          child: Container(
            width: 60,
            height: 60,
            decoration: BoxDecoration(
              color: Colors.transparent,
              borderRadius: BorderRadius.circular(8),
            ),
            child: LoadingIndicator(
              indicatorType: Indicator.ballClipRotate,
              colors: [
                AppColors.BLUE,
              ],
            ),
          ),
        ),
      ),
      barrierDismissible: false,
    );
  }

  static void hideLoading() {
    if (Get.isDialogOpen!) Get.back();
  }

  static void hideDialog() {
    if (Get.isDialogOpen!) Get.back();
  }
}
