44 lines
1.4 KiB
Dart
44 lines
1.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
|
typedef SCLoadingManager = SCProgressIndicator;
|
|
|
|
class SCProgressIndicator {
|
|
// 显示全局 Loading
|
|
static void show({String? message, BuildContext? context, bool cancelable = false}) {
|
|
SmartDialog.dismiss(status: SmartStatus.loading);
|
|
SmartDialog.showLoading(
|
|
alignment: Alignment.center,
|
|
maskColor: Colors.transparent,
|
|
animationType: SmartAnimationType.fade,
|
|
clickMaskDismiss: cancelable, // 使用新的参数
|
|
backType: cancelable ? SmartBackType.normal : SmartBackType.block,
|
|
builder: (_) {
|
|
return Center(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.black26,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
width: 55.w,
|
|
height: 55.w,
|
|
child: CupertinoActivityIndicator(color: Colors.white24,),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
// static bool _backInterceptor(bool stopDefaultButtonEvent, RouteInfo info) {
|
|
// // 拦截返回键
|
|
// return true; // 返回 true 表示已处理该事件
|
|
// }
|
|
|
|
// 隐藏全局 Loading
|
|
static void hide() {
|
|
SmartDialog.dismiss(status: SmartStatus.loading);
|
|
}
|
|
}
|