2024-03-28 13:46:35 +08:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
2024-06-03 13:50:07 +08:00
|
|
|
import 'package:flutter/services.dart';
|
2024-04-11 17:59:19 +08:00
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
2024-09-11 10:43:59 +08:00
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
2024-03-28 13:46:35 +08:00
|
|
|
import 'package:get/get.dart';
|
2024-05-04 18:16:08 +08:00
|
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
2025-02-18 14:20:10 +08:00
|
|
|
import 'package:star_lock/main/lockDetail/lockDetail/device_network_info.dart';
|
|
|
|
|
import 'package:star_lock/talk/starChart/star_chart_manage.dart';
|
2024-04-11 17:59:19 +08:00
|
|
|
import 'package:star_lock/tools/showTFView.dart';
|
2024-03-28 13:46:35 +08:00
|
|
|
|
|
|
|
|
import 'showDeleteAdministratorIsHaveAllDataWidget.dart';
|
|
|
|
|
|
|
|
|
|
typedef BlockIsHaveAllDataCallback = void Function(bool isAllData);
|
|
|
|
|
|
|
|
|
|
class ShowTipView {
|
2024-04-07 14:03:59 +08:00
|
|
|
// 只有一个确定按钮
|
2024-06-07 15:58:24 +08:00
|
|
|
void showSureAlertDialog(String contentStr,
|
|
|
|
|
{String? tipTitle, String? sureStr}) {
|
2024-03-28 13:46:35 +08:00
|
|
|
showCupertinoDialog(
|
|
|
|
|
context: Get.context!,
|
2024-05-29 14:31:38 +08:00
|
|
|
builder: (BuildContext context) {
|
2024-03-28 13:46:35 +08:00
|
|
|
return CupertinoAlertDialog(
|
2024-06-07 10:53:24 +08:00
|
|
|
title: Text(tipTitle ?? ''),
|
2024-03-28 13:46:35 +08:00
|
|
|
content: Text(contentStr),
|
2024-05-29 14:31:38 +08:00
|
|
|
actions: <Widget>[
|
2024-03-28 13:46:35 +08:00
|
|
|
CupertinoDialogAction(
|
2024-07-26 09:21:22 +08:00
|
|
|
child: Text(sureStr ?? '确定'.tr,
|
2024-06-15 17:20:55 +08:00
|
|
|
style: TextStyle(color: AppColors.mainColor)),
|
2024-06-07 10:53:24 +08:00
|
|
|
onPressed: Get.back,
|
2024-03-28 13:46:35 +08:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-07 14:03:59 +08:00
|
|
|
// 授权管理员调用是否删除数据
|
2024-05-04 15:46:41 +08:00
|
|
|
void showDeleteAdministratorIsHaveAllDataDialog(String contentStr,
|
|
|
|
|
BlockIsHaveAllDataCallback blockIsHaveAllDataCallback) {
|
2024-03-28 13:46:35 +08:00
|
|
|
bool selet = false;
|
|
|
|
|
showDialog(
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return CupertinoAlertDialog(
|
2024-06-07 10:53:24 +08:00
|
|
|
title: Text('提示'.tr),
|
2024-03-28 13:46:35 +08:00
|
|
|
content: SizedBox(
|
|
|
|
|
// height: 100.h,
|
|
|
|
|
child: ShowDeleteAdministratorIsHaveAllDataWidget(
|
2024-04-02 17:30:44 +08:00
|
|
|
contentStr: contentStr,
|
2024-05-29 14:31:38 +08:00
|
|
|
blockIsHaveAllDataCallback: (bool a) {
|
2024-03-28 13:46:35 +08:00
|
|
|
selet = a;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
2024-05-29 14:31:38 +08:00
|
|
|
actions: <Widget>[
|
2024-03-28 13:46:35 +08:00
|
|
|
CupertinoDialogAction(
|
2024-07-26 09:57:44 +08:00
|
|
|
child: Text('取消'.tr),
|
2024-06-07 10:53:24 +08:00
|
|
|
onPressed: Get.back,
|
2024-03-28 13:46:35 +08:00
|
|
|
),
|
|
|
|
|
CupertinoDialogAction(
|
2024-07-26 09:21:22 +08:00
|
|
|
child: Text('确定'.tr),
|
2024-03-28 13:46:35 +08:00
|
|
|
onPressed: () {
|
|
|
|
|
Get.back();
|
2024-04-02 17:30:44 +08:00
|
|
|
blockIsHaveAllDataCallback(selet);
|
2024-03-28 13:46:35 +08:00
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-07 14:03:59 +08:00
|
|
|
// 有取消和确定按钮
|
2024-03-29 18:32:33 +08:00
|
|
|
void showIosTipWithContentDialog(String contentStr, Function sureClick) {
|
|
|
|
|
showCupertinoDialog(
|
|
|
|
|
context: Get.context!,
|
2024-05-29 14:31:38 +08:00
|
|
|
builder: (BuildContext context) {
|
2024-03-29 18:32:33 +08:00
|
|
|
return CupertinoAlertDialog(
|
2024-11-05 09:55:04 +08:00
|
|
|
content: Text(contentStr.tr),
|
2024-05-29 14:31:38 +08:00
|
|
|
actions: <Widget>[
|
2024-03-29 18:32:33 +08:00
|
|
|
CupertinoDialogAction(
|
2024-11-05 09:55:04 +08:00
|
|
|
child:
|
|
|
|
|
Text('取消'.tr, style: TextStyle(color: AppColors.mainColor)),
|
2024-05-29 14:31:38 +08:00
|
|
|
onPressed: Get.back,
|
2024-03-29 18:32:33 +08:00
|
|
|
),
|
|
|
|
|
CupertinoDialogAction(
|
2024-11-05 09:55:04 +08:00
|
|
|
child:
|
|
|
|
|
Text('确定'.tr, style: TextStyle(color: AppColors.mainColor)),
|
2024-03-29 18:32:33 +08:00
|
|
|
onPressed: () {
|
|
|
|
|
Get.back();
|
|
|
|
|
sureClick();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-27 14:36:35 +08:00
|
|
|
TextEditingController getController = TextEditingController();
|
2025-02-18 14:20:10 +08:00
|
|
|
|
2024-06-15 17:20:55 +08:00
|
|
|
void showTFViewAlertDialog(TextEditingController controller, String title,
|
|
|
|
|
String tipTitle, Function sureClick,
|
|
|
|
|
{List<TextInputFormatter>? inputFormatters, bool? isShowSuffixIcon}) {
|
2024-04-11 17:59:19 +08:00
|
|
|
// 点击删除 开始扫描
|
2024-07-27 14:36:35 +08:00
|
|
|
getController = controller;
|
2024-04-11 17:59:19 +08:00
|
|
|
showDialog(
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return ShowTFView(
|
|
|
|
|
title: title,
|
2024-06-03 13:50:07 +08:00
|
|
|
tipTitle: tipTitle,
|
|
|
|
|
inputFormatters: inputFormatters,
|
2024-04-11 17:59:19 +08:00
|
|
|
controller: controller,
|
2024-06-07 10:53:24 +08:00
|
|
|
isShowSuffixIcon: isShowSuffixIcon ?? false,
|
2024-04-11 17:59:19 +08:00
|
|
|
sureClick: () {
|
|
|
|
|
if (controller.text.isEmpty) {
|
|
|
|
|
EasyLoading.showToast(tipTitle, duration: 2000.milliseconds);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sureClick();
|
2025-02-18 14:20:10 +08:00
|
|
|
StartChartManage().lockNetworkInfo = DeviceNetworkInfo();
|
2024-04-11 17:59:19 +08:00
|
|
|
},
|
|
|
|
|
cancelClick: () {
|
|
|
|
|
// 取消的时候停止扫描
|
|
|
|
|
Get.back();
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-06-07 15:58:24 +08:00
|
|
|
|
2024-11-05 09:55:04 +08:00
|
|
|
void resetGetController() {
|
2024-07-27 14:36:35 +08:00
|
|
|
getController.text = '';
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-07 15:58:24 +08:00
|
|
|
// 只有一个确定按钮
|
2024-06-15 17:20:55 +08:00
|
|
|
void showSureBtnTipsAlert(
|
|
|
|
|
{required String tipsText, required String sureText}) {
|
2024-06-07 15:58:24 +08:00
|
|
|
showCupertinoDialog(
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return CupertinoAlertDialog(
|
|
|
|
|
content: Text(tipsText),
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
CupertinoDialogAction(
|
|
|
|
|
child:
|
|
|
|
|
Text('确定'.tr, style: TextStyle(color: AppColors.mainColor)),
|
|
|
|
|
onPressed: Get.back,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-09-11 10:43:59 +08:00
|
|
|
|
|
|
|
|
//输入框的弹窗
|
|
|
|
|
void showTipWithInputDialog({
|
|
|
|
|
required String title,
|
|
|
|
|
required String sureText,
|
|
|
|
|
required String contentText,
|
|
|
|
|
required Function(String) sureClick,
|
|
|
|
|
String cancelText = '取消',
|
|
|
|
|
VoidCallback? onCancel,
|
|
|
|
|
}) {
|
|
|
|
|
final TextEditingController controller = TextEditingController();
|
|
|
|
|
controller.text = contentText;
|
|
|
|
|
|
|
|
|
|
showDialog(
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
barrierDismissible: true,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return CupertinoAlertDialog(
|
|
|
|
|
title: Text(
|
|
|
|
|
title,
|
|
|
|
|
style: TextStyle(color: AppColors.blackColor),
|
|
|
|
|
),
|
|
|
|
|
content: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
CupertinoTextField(
|
|
|
|
|
controller: controller,
|
|
|
|
|
placeholder: '请输入',
|
|
|
|
|
style: TextStyle(color: AppColors.blackColor),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
CupertinoDialogAction(
|
|
|
|
|
child: Text(
|
|
|
|
|
cancelText,
|
|
|
|
|
style: TextStyle(color: AppColors.blackColor),
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (onCancel != null) {
|
|
|
|
|
onCancel();
|
|
|
|
|
}
|
|
|
|
|
Get.back();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
CupertinoDialogAction(
|
|
|
|
|
child: Text(
|
|
|
|
|
sureText,
|
|
|
|
|
style: const TextStyle(color: AppColors.blueTextTipsColor),
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
sureClick(controller.text);
|
|
|
|
|
// Get.back(); // 关闭弹窗
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-05-04 15:46:41 +08:00
|
|
|
}
|