import 'package:flutter_easyloading/flutter_easyloading.dart';

class BaseEasyLoading {
  static void configLoading() {
    EasyLoading.instance
      // 当loading展示的时候，是否允许用户操作.
      ..userInteractions = false
      // 点击背景是否关闭.
      ..dismissOnTap = false;
  }

  static void toast(String? value, {bool? dismissOnTap, bool show = true}) {
    EasyLoading.instance.userInteractions = true;
    if (show && value != null) {
      EasyLoading.showToast(
        value,
        dismissOnTap: dismissOnTap,
        maskType: EasyLoadingMaskType.none,
      );
    }
  }

  static void loading({
    String? value,
    bool show = true,
  }) {
    EasyLoading.instance.userInteractions = false;
    if (show) EasyLoading.show(status: value);
  }

  static void dismiss({bool dismiss = true}) {
    if (dismiss) EasyLoading.dismiss();
  }
}
