216 lines
6.2 KiB
Dart
Executable File
216 lines
6.2 KiB
Dart
Executable File
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:star_lock/tools/showTFView.dart';
|
|
|
|
import 'showDeleteAdministratorIsHaveAllDataWidget.dart';
|
|
|
|
typedef BlockIsHaveAllDataCallback = void Function(bool isAllData);
|
|
|
|
class ShowTipView {
|
|
// 只有一个确定按钮
|
|
void showSureAlertDialog(String contentStr,
|
|
{String? tipTitle, String? sureStr}) {
|
|
showCupertinoDialog(
|
|
context: Get.context!,
|
|
builder: (BuildContext context) {
|
|
return CupertinoAlertDialog(
|
|
title: Text(tipTitle ?? ''),
|
|
content: Text(contentStr),
|
|
actions: <Widget>[
|
|
CupertinoDialogAction(
|
|
child: Text(sureStr ?? '确定'.tr,
|
|
style: TextStyle(color: AppColors.mainColor)),
|
|
onPressed: Get.back,
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
// 授权管理员调用是否删除数据
|
|
void showDeleteAdministratorIsHaveAllDataDialog(String contentStr,
|
|
BlockIsHaveAllDataCallback blockIsHaveAllDataCallback) {
|
|
bool selet = false;
|
|
showDialog(
|
|
context: Get.context!,
|
|
builder: (BuildContext context) {
|
|
return CupertinoAlertDialog(
|
|
title: Text('提示'.tr),
|
|
content: SizedBox(
|
|
// height: 100.h,
|
|
child: ShowDeleteAdministratorIsHaveAllDataWidget(
|
|
contentStr: contentStr,
|
|
blockIsHaveAllDataCallback: (bool a) {
|
|
selet = a;
|
|
},
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
CupertinoDialogAction(
|
|
child: Text('取消'.tr),
|
|
onPressed: Get.back,
|
|
),
|
|
CupertinoDialogAction(
|
|
child: Text('确定'.tr),
|
|
onPressed: () {
|
|
Get.back();
|
|
blockIsHaveAllDataCallback(selet);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
// 有取消和确定按钮
|
|
void showIosTipWithContentDialog(String contentStr, Function sureClick) {
|
|
showCupertinoDialog(
|
|
context: Get.context!,
|
|
builder: (BuildContext context) {
|
|
return CupertinoAlertDialog(
|
|
content: Text(contentStr.tr),
|
|
actions: <Widget>[
|
|
CupertinoDialogAction(
|
|
child:
|
|
Text('取消'.tr, style: TextStyle(color: AppColors.mainColor)),
|
|
onPressed: Get.back,
|
|
),
|
|
CupertinoDialogAction(
|
|
child:
|
|
Text('确定'.tr, style: TextStyle(color: AppColors.mainColor)),
|
|
onPressed: () {
|
|
Get.back();
|
|
sureClick();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
TextEditingController getController = TextEditingController();
|
|
void showTFViewAlertDialog(TextEditingController controller, String title,
|
|
String tipTitle, Function sureClick,
|
|
{List<TextInputFormatter>? inputFormatters, bool? isShowSuffixIcon}) {
|
|
// 点击删除 开始扫描
|
|
getController = controller;
|
|
showDialog(
|
|
context: Get.context!,
|
|
builder: (BuildContext context) {
|
|
return ShowTFView(
|
|
title: title,
|
|
tipTitle: tipTitle,
|
|
inputFormatters: inputFormatters,
|
|
controller: controller,
|
|
isShowSuffixIcon: isShowSuffixIcon ?? false,
|
|
sureClick: () {
|
|
if (controller.text.isEmpty) {
|
|
EasyLoading.showToast(tipTitle, duration: 2000.milliseconds);
|
|
return;
|
|
}
|
|
sureClick();
|
|
},
|
|
cancelClick: () {
|
|
// 取消的时候停止扫描
|
|
Get.back();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
void resetGetController() {
|
|
getController.text = '';
|
|
}
|
|
|
|
// 只有一个确定按钮
|
|
void showSureBtnTipsAlert(
|
|
{required String tipsText, required String sureText}) {
|
|
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,
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
//输入框的弹窗
|
|
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(); // 关闭弹窗
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|