showPermissionConfirmDialog static method
Future<bool?>
showPermissionConfirmDialog(
- BuildContext context,
- dynamic value, [
- TUITheme? theme,
- bool isShowPermissionPage = true,
Implementation
static Future<bool?> showPermissionConfirmDialog(BuildContext context, value,
[TUITheme? theme, bool isShowPermissionPage = true]) async {
final platformUtils = PlatformUtils();
// 第一次直接走系统文案
if (!await checkPermissionSetBefore(value)) {
await setLocalPermission(value);
if (platformUtils.isAndroid && isShowPermissionPage) {
showPermissionRequestInfoDialog(context, value);
}
return true;
}
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String appName = packageInfo.appName;
final option2 = _names(context)[value];
final permissionText = _permissionText(context, appName, value);
void closeDialog() {
Navigator.of(context).pop(false);
}
void getPermission() async {
Navigator.of(context).pop(false);
openAppSettings();
}
return showDialog<bool>(
context: context,
builder: (context) {
return platformUtils.isIOS
? CupertinoAlertDialog(
title: Text("“$appName”" +
TIM_t_para(" 想访问您的{{option2}}", " 想访问您的$option2")(
option2: option2)),
content: Text(permissionText),
actions: <Widget>[
CupertinoDialogAction(
child: Text(TIM_t("以后再说")),
onPressed: closeDialog, // 关闭对话框
),
CupertinoDialogAction(
child: Text(TIM_t("去开启")),
onPressed: getPermission,
),
],
)
: AlertDialog(
content: Text(permissionText),
actions: <Widget>[
const Divider(),
SizedBox(
height: 48,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: TextButton(
child: Text(TIM_t("以后再说"),
style: TextStyle(
color: theme?.black ?? Colors.black,
)),
onPressed: closeDialog, // 关闭对话框
),
),
const VerticalDivider(),
Expanded(
child: TextButton(
child: Text(TIM_t("去开启"),
style: TextStyle(
color: theme?.black ?? Colors.black,
)),
onPressed: getPermission,
),
)
],
),
)
],
);
},
);
}