更新
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
|
||||
getOnePicker(context, List arr, int checkIndex, Function onSelectedItemChanged,
|
||||
@@ -780,3 +782,133 @@ void showPermissionInfoDialog(BuildContext context, List data) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void showProgressDialog(
|
||||
BuildContext context,
|
||||
ValueNotifier<double> progressNotifier,
|
||||
ValueNotifier<bool> failureNotifier,
|
||||
) {
|
||||
ThemeController themeController = Get.find();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false, // 点击对话框外部不可关闭
|
||||
builder: (BuildContext dialogContext) {
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
top: MediaQuery.of(context).size.height * 0.4,
|
||||
left: MediaQuery.of(context).size.width * 0.05,
|
||||
right: MediaQuery.of(context).size.width * 0.05,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
insetPadding: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: ValueListenableBuilder<double>(
|
||||
valueListenable: progressNotifier,
|
||||
builder: (context, progress, _) {
|
||||
return ValueListenableBuilder<bool>(
|
||||
valueListenable: failureNotifier,
|
||||
builder: (context, isFailure, __) {
|
||||
// 关闭弹窗的逻辑
|
||||
if (isFailure) {
|
||||
// 延迟关闭弹窗和提示错误
|
||||
Future.delayed(Duration(milliseconds: 300), () {
|
||||
if (Navigator.canPop(dialogContext)) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
}
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "设备校准失败".tr,
|
||||
textColor: Colors.red,
|
||||
);
|
||||
});
|
||||
} else if (progress >= 1.0) {
|
||||
// 延迟关闭弹窗和提示成功(可选)
|
||||
Future.delayed(Duration(milliseconds: 300), () {
|
||||
if (Navigator.canPop(dialogContext)) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
}
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "设备校准完成".tr,
|
||||
textColor: themeController.currentColor.sc3,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
isFailure
|
||||
? '失败'.tr
|
||||
: '${(progress * 100).toStringAsFixed(0)}%',
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: isFailure
|
||||
? Colors.red
|
||||
: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 40.rpx),
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 21.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: stringToColor("#D9D9D9"),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().button_container_radius,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: progress *
|
||||
MediaQuery.of(context).size.width *
|
||||
0.8,
|
||||
height: 10.rpx,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: isFailure
|
||||
? [themeController.currentColor.sc9]
|
||||
: [
|
||||
themeController
|
||||
.currentColor.sc1,
|
||||
themeController
|
||||
.currentColor.sc2,
|
||||
],
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
),
|
||||
borderRadius:
|
||||
BorderRadius.circular(5.rpx),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user