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": {
"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": {
"description": "Pick "

View File

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

View File

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