123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import 'package:flutter/material.dart';
- import 'package:flutter_easyloading/flutter_easyloading.dart';
- import 'package:flyinsonolite/infrastructure/scale.dart';
- import 'package:flyinsonolite/infrastructure/storage.dart';
- ///弹出框位置
- enum PromptBoxSnackbarPosition {
- //上部弹出
- top,
- //底部弹出
- bottom,
- }
- ///弹出框
- class PromptBox {
- PromptBox._();
- static void init() {
- EasyLoading.instance
- ..displayDuration = const Duration(milliseconds: 2000)
- ..indicatorType = EasyLoadingIndicatorType.ring
- ..loadingStyle = EasyLoadingStyle.custom
- ..indicatorSize = 35.s
- ..lineWidth = 2.s
- ..radius = 10.s
- ..progressColor = Colors.white
- ..backgroundColor = Storage.currentTheme.themeData.indicatorColor
- ..indicatorColor = Colors.white
- ..textColor = Colors.white
- ..maskColor = Colors.black.withOpacity(0.6)
- ..successWidget = Icon(Icons.done, color: Colors.green, size: 35.s)
- ..errorWidget = Icon(Icons.close, color: Colors.red, size: 35.s)
- ..userInteractions = true
- ..fontSize = 24.s
- ..dismissOnTap = false
- ..progressWidth = 2.s
- ..textPadding = EdgeInsets.only(bottom: 10.s)
- ..contentPadding = EdgeInsets.symmetric(
- vertical: 15.s,
- horizontal: 20.s,
- );
- }
- static bool _enable = true;
- static void $SetEnable(bool val) {
- _enable = val;
- }
- /// 等待提示
- ///
- /// [text] 自定义提示文案
- //static void loading([String? text]) {
- // if (!_enable) return;
- // _setLoadingStyle();
- // EasyLoading.show(
- // indicator: LoadingWidget(text: text ?? '${i18nBook.common.loading.t}...'),
- // maskType: EasyLoadingMaskType.custom,
- // status: "",
- // );
- // }
- /// 轻提示
- ///
- /// [text] 提示内容
- static void toast(String text) {
- if (!_enable) return;
- EasyLoading.showToast(text);
- }
- /// 成功提示
- ///
- /// [text] 自定义提示文案
- static void success(String text) {
- if (!_enable) return;
- EasyLoading.showSuccess(text);
- }
- /// 错误提示
- ///
- /// [text] 自定义提示文案
- static void error(String text) {
- if (!_enable) return;
- EasyLoading.showError(text);
- }
- /// 停止提示
- static void dismiss() {
- EasyLoading.instance.userInteractions = true;
- EasyLoading.dismiss();
- }
- /// 提示框(带标题)
- ///
- /// [message] 提示内容
- ///
- /// [title] 标题
- ///
- /// [position] 弹出位置
- //static void snackbar(
- // String message, {
- // String? title,
- // PromptBoxSnackbarPosition position = PromptBoxSnackbarPosition.Top,
- //}) {
- // final isTop = PromptBoxSnackbarPosition.Top == position;
- // Get.snackbar(
- // title ?? i18nBook.common.tip.t,
- // message,
- // maxWidth: kIsWeb ? Sizer.ins.size.width - 40 : 400,
- // snackPosition: isTop ? SnackPosition.TOP : SnackPosition.BOTTOM,
- // margin: isTop
- // ? const EdgeInsets.only(top: 36)
- // : const EdgeInsets.only(bottom: 48),
- // );
- //}
- }
|