WallPaper_FSX_Flutter/lib/common/components/easy_loading.dart
fengshengxiong 73bb10f7f3 first commit
2024-05-08 16:35:29 +08:00

73 lines
2.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Author: fengshengxiong
// Date: 2024/5/7
// Description: 加载、进度、提示框
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../theme/colors.dart';
/// EasyLoading配置
void configLoading() {
EasyLoading.instance
// loading的样式, 默认[EasyLoadingStyle.dark].
..loadingStyle = EasyLoadingStyle.custom
// loading的指示器类型默认[EasyLoadingIndicatorType.fadingCircle].
..indicatorType = EasyLoadingIndicatorType.ring
// loading的遮罩类型, 默认[EasyLoadingMaskType.none].
..maskType = EasyLoadingMaskType.none
// toast的位置, 默认 [EasyLoadingToastPosition.center].
..toastPosition = EasyLoadingToastPosition.center
// 动画类型, 默认 [EasyLoadingAnimationStyle.opacity].
..animationStyle = EasyLoadingAnimationStyle.opacity
// 文本的对齐方式 , 默认[TextAlign.center].
..textAlign = TextAlign.center
// 文本的样式 , 默认 null
..textStyle = null
// 指示器的大小, 默认40.0.
..indicatorSize = 26.0
// loading的圆角大小, 默认5.0.
..radius = 5.0
// 文本大小, 默认15.0.
..fontSize = 14.0
// 进度条指示器的宽度, 默认2.0.
..progressWidth = 2.0
// 指示器的宽度, 默认4.0, 仅对[EasyLoadingIndicatorType.ring, EasyLoadingIndicatorType.dualRing]有效.
..lineWidth = 2.0
// [showSuccess] [showError] [showInfo]的展示时间, 默认2000ms.
..displayDuration = const Duration(milliseconds: 1000)
// 动画时间, 默认200ms.
..animationDuration = const Duration(milliseconds: 200)
// 文本的颜色, 仅对[EasyLoadingStyle.custom]有效.
..textColor = white
// 指示器的颜色, 仅对[EasyLoadingStyle.custom]有效.
..indicatorColor = white
// 进度条指示器的颜色, 仅对[EasyLoadingStyle.custom]有效.
..progressColor = white
// loading的背景色, 仅对[EasyLoadingStyle.custom]有效.
..backgroundColor = loadingBg
// 遮罩的背景色, 仅对[EasyLoadingMaskType.custom]有效.
..maskColor = black.withOpacity(0.3)
// 当loading展示的时候是否允许用户操作.
..userInteractions = false
// 点击背景是否关闭.
..dismissOnTap = false;
}
void toast(String? value, {bool isShow = true}) {
if (isShow) {
EasyLoading.showToast(value ?? '');
}
}
void loading({String? value, bool isShow = true}) {
if (isShow) {
EasyLoading.show(status: value);
}
}
void dismiss({bool isDismiss = true}) {
if (isDismiss) {
EasyLoading.dismiss();
}
}