更新传感器升级
This commit is contained in:
@@ -1638,3 +1638,291 @@ Future<String?> showUnShareMessageDialog({
|
||||
barrierDismissible: true,
|
||||
);
|
||||
}
|
||||
|
||||
//升级传感器弹窗
|
||||
void showConfirmUpDialog(
|
||||
BuildContext context,
|
||||
Widget widget,
|
||||
String title, {
|
||||
required VoidCallback onConfirm,
|
||||
required VoidCallback onCancel,
|
||||
Color? backgroundColor, // ✅ 可选背景色
|
||||
String confirmText = "是", // ✅ 新增:确认按钮文字
|
||||
String cancelText = "否", // ✅ 新增:取消按钮文字
|
||||
}) {
|
||||
ThemeController themeController = Get.find();
|
||||
try {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
barrierColor: Colors.black.withOpacity(0.5), // 背景模糊色
|
||||
builder: (BuildContext context) {
|
||||
return FrostedDialog(
|
||||
blurSigma: 3.0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor ?? themeController.currentColor.sc17,
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
),
|
||||
padding: EdgeInsetsDirectional.fromSTEB(31.rpx, 0, 31.rpx, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.656,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
33.rpx, 60.rpx, 33.rpx, 33.rpx),
|
||||
// 如果以后要显示标题,可以在这里加回 Text(title)
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
33.rpx, 0.rpx, 33.rpx, 0.rpx),
|
||||
child: widget,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
33.rpx, 58.rpx, 33.rpx, 60.rpx),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// ✅ 确认按钮
|
||||
CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
onConfirm();
|
||||
},
|
||||
colors: AppConstants().mhtNormalButton,
|
||||
child: Container(
|
||||
// width: MediaQuery.sizeOf(context).width * 0.215,
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 160.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
confirmText.tr, // ✅ 支持传参
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
// ❌ 取消按钮
|
||||
CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
onCancel();
|
||||
},
|
||||
colors: [Colors.transparent],
|
||||
child: Container(
|
||||
// width: MediaQuery.sizeOf(context).width * 0.115,
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, // 背景色
|
||||
border: Border.all(
|
||||
color: stringToColor("#929699"), // 边框颜色
|
||||
width: 1.rpx, // 边框宽度
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().button_container_radius), // 圆角
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 160.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
cancelText.tr, // ✅ 支持传参
|
||||
style: TextStyle(
|
||||
color: stringToColor("#333333"),
|
||||
fontFamily: 'Inter',
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(height: 19.rpx)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
//取消升级弹窗
|
||||
void showConfirmCancelDialog(
|
||||
BuildContext context,
|
||||
Widget widget,
|
||||
String title, {
|
||||
required VoidCallback onConfirm,
|
||||
required VoidCallback onCancel,
|
||||
Color? backgroundColor, // ✅ 整个弹窗背景色
|
||||
String confirmText = "是", // ✅ 确认按钮文字
|
||||
String cancelText = "否", // ✅ 取消按钮文字
|
||||
Color? confirmButtonColor, // ✅ 新增:确认按钮背景色
|
||||
Color? cancelButtonColor, // ✅ 新增:取消按钮背景色
|
||||
}) {
|
||||
ThemeController themeController = Get.find();
|
||||
try {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
barrierColor: Colors.black.withOpacity(0.5), // 背景模糊色
|
||||
builder: (BuildContext context) {
|
||||
return FrostedDialog(
|
||||
blurSigma: 3.0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor ?? themeController.currentColor.sc17,
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
),
|
||||
padding: EdgeInsetsDirectional.fromSTEB(31.rpx, 0, 31.rpx, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.656,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
33.rpx, 60.rpx, 33.rpx, 33.rpx),
|
||||
// 如果以后要显示标题,可以在这里加回 Text(title)
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
33.rpx, 0.rpx, 33.rpx, 0.rpx),
|
||||
child: widget,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
33.rpx, 58.rpx, 33.rpx, 60.rpx),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// ✅ 确认按钮
|
||||
CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
onConfirm();
|
||||
},
|
||||
colors: confirmButtonColor != null
|
||||
? [confirmButtonColor] // 使用自定义背景
|
||||
: AppConstants().mhtNormalButton, // 默认背景
|
||||
child: Container(
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 160.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
confirmText.tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// ❌ 取消按钮
|
||||
CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
onCancel();
|
||||
},
|
||||
colors: [Colors.transparent],
|
||||
child: Container(
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
decoration: BoxDecoration(
|
||||
color: cancelButtonColor ??
|
||||
Colors.white, // ✅ 可传入自定义背景色
|
||||
border: Border.all(
|
||||
color: stringToColor("#929699"),
|
||||
width: 1.rpx,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().button_container_radius,
|
||||
),
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 160.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
cancelText.tr,
|
||||
style: TextStyle(
|
||||
color: stringToColor("#333333"),
|
||||
fontFamily: 'Inter',
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(height: 19.rpx)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user