app-starlock/star_lock/lib/tools/showCupertinoAlert.dart
Daisy eca37e7588 1,密码钥匙重置接口增加
2,新增删除账号入口及安全验证页面
3,新增删除账号接口调试
4,新增刷新库
5,部分页面状态刷新重构
2023-09-28 18:22:35 +08:00

57 lines
1.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dart:async';
import 'package:flutter/cupertino.dart';
//封装一个适合我们项目的,结果返回一个 future
//颜色等受系统默认的值影响这里面就不填写属性了primaryColor 更新会影响到所有的默认效果
Future<bool> showCupertinoAlert({
BuildContext? context, //如果没设置全局需要传递自己的context
String title = '',
String message = '',
confirmText = '确定',
cancelText = '取消',
isShowCancel = true,
isDestructiveConfirm = false,
isDestructiveCancel = false,
}) {
// context = context ?? DialogConfig.context;
final completer = Completer<bool>();
final actions = <CupertinoDialogAction>[
CupertinoDialogAction(
isDestructiveAction: isDestructiveConfirm,
onPressed: () {
completer.complete(true);
Navigator.of(context!).pop();
},
child: Text(confirmText),
),
];
if (isShowCancel) {
actions.insert(
0,
CupertinoDialogAction(
isDestructiveAction: isDestructiveCancel,
onPressed: () {
completer.complete(false);
Navigator.of(context!).pop();
},
child: Text(
cancelText,
),
),
);
}
// showCupertinoModalPopup<void>(
// context: context,
// barrierDismissible: false,
// builder: (BuildContext context) => CupertinoAlertDialog(
// title: Text(title),
// content: Padding(
// padding: const EdgeInsets.only(top: 10),
// child: Text(message),
// ),
// actions: actions,
// ),
// );
return completer.future;
}