flutter: non-Android: Prompt exit App manually when restoring default settings

(cherry picked from commit 6c1e6a33a9)
This commit is contained in:
Calcitem 2021-05-13 23:08:27 +08:00
parent 0797f5986d
commit bcd03c59f7
3 changed files with 20 additions and 5 deletions

View File

@ -608,6 +608,10 @@
"@exitApp": { "@exitApp": {
"description": "The App will exit." "description": "The App will exit."
}, },
"exitAppManually": "You have to close immediately and reopen App to take effect.",
"@exitAppManually": {
"description": "You have to close immediately and reopen App to take effect."
},
"pick": "Pick", "pick": "Pick",
"@pick": { "@pick": {
"description": "Pick " "description": "Pick "

View File

@ -152,6 +152,7 @@
"restore": "重置", "restore": "重置",
"restoreDefaultSettings": "恢复默认设置", "restoreDefaultSettings": "恢复默认设置",
"exitApp": "App 将退出。", "exitApp": "App 将退出。",
"exitAppManually": "您需要立即退出并重新打开本程序才能使默认配置生效。",
"pick": "选择", "pick": "选择",
"hint": "提示", "hint": "提示",
"player": "玩家", "player": "玩家",

View File

@ -171,12 +171,24 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
restoreFactoryDefaultSettings() async { restoreFactoryDefaultSettings() async {
confirm() async { confirm() async {
Navigator.of(context).pop(); Navigator.of(context).pop();
if (Platform.isAndroid) {
_startTimer(); _startTimer();
showCountdownDialog(context); showCountdownDialog(context);
} else {
_restore();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(S.of(context).exitAppManually)));
}
} }
cancel() => Navigator.of(context).pop(); cancel() => Navigator.of(context).pop();
var prompt = "";
if (Platform.isAndroid) {
prompt = S.of(context).exitApp;
}
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -184,9 +196,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
title: Text(S.of(context).restore, title: Text(S.of(context).restore,
style: TextStyle(color: AppTheme.dialogTitleColor)), style: TextStyle(color: AppTheme.dialogTitleColor)),
content: SingleChildScrollView( content: SingleChildScrollView(
child: Text(S.of(context).restoreDefaultSettings + child: Text(S.of(context).restoreDefaultSettings + "?\n" + prompt),
"?\n" +
S.of(context).exitApp),
), ),
actions: <Widget>[ actions: <Widget>[
TextButton(child: Text(S.of(context).ok), onPressed: confirm), TextButton(child: Text(S.of(context).ok), onPressed: confirm),