2024-03-18 13:23:58 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
2024-03-19 08:59:08 +08:00
|
|
|
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
|
|
|
import 'package:sk_base_mobile/app_theme.dart';
|
|
|
|
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
2024-03-18 13:23:58 +08:00
|
|
|
|
|
|
|
class LoadingUtil {
|
2024-03-19 08:59:08 +08:00
|
|
|
LoadingUtil();
|
2024-03-18 13:23:58 +08:00
|
|
|
|
|
|
|
static Future<void> show({String? status}) async {
|
|
|
|
return showLoading(status: status ?? 'Loading...');
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<void> dismiss() async {
|
|
|
|
return hideLoading();
|
|
|
|
}
|
|
|
|
|
2024-03-19 08:59:08 +08:00
|
|
|
static showLoading({String? status}) async {
|
|
|
|
await showDialog(
|
|
|
|
context: Get.context!,
|
|
|
|
barrierColor: AppTheme.barrierColor,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return WillPopScope(
|
|
|
|
onWillPop: () async => false,
|
|
|
|
child: GestureDetector(
|
|
|
|
child: Container(
|
|
|
|
color: Colors.black54,
|
|
|
|
child: Center(
|
|
|
|
child: LoadingAnimationWidget.fourRotatingDots(
|
|
|
|
color: AppTheme.primaryColor,
|
|
|
|
size: ScreenAdaper.sp(50),
|
|
|
|
),
|
|
|
|
),
|
2024-03-18 13:23:58 +08:00
|
|
|
),
|
2024-03-19 08:59:08 +08:00
|
|
|
onTap: () {
|
|
|
|
// 点击是否退出模态框
|
|
|
|
// Navigator.of(context).pop();
|
|
|
|
},
|
2024-03-18 13:23:58 +08:00
|
|
|
),
|
2024-03-19 08:59:08 +08:00
|
|
|
);
|
|
|
|
},
|
2024-03-18 13:23:58 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static hideLoading() {
|
2024-03-19 08:59:08 +08:00
|
|
|
Navigator.of(Get.context!).pop();
|
2024-03-18 13:23:58 +08:00
|
|
|
}
|
|
|
|
}
|