flutter: Add code for developer mode

This commit is contained in:
Calcitem 2021-04-09 01:20:35 +08:00
parent e2c443830a
commit 080b7da46d
4 changed files with 23 additions and 15 deletions

View File

@ -662,6 +662,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
],
),
onPressed: () {
if (Config.developerMode) return;
Game.instance.regret(steps: 2);
setState(() {});
},

View File

@ -69,6 +69,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
restoreFactoryDefaultSettings() async {
confirm() async {
Navigator.of(context).pop();
if (Config.developerMode) return;
final profile = await Settings.instance();
await profile.restore();
exit(0);
@ -189,19 +190,6 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
],
),
SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).forDevelopers, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.developerMode,
onChanged: setDeveloperMode,
titleString: S.of(context).developerMode,
),
],
),
SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).restore, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
@ -214,6 +202,19 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
ListItemDivider(),
],
),
SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).forDevelopers, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.developerMode,
onChanged: setDeveloperMode,
titleString: S.of(context).developerMode,
),
],
),
];
}

View File

@ -23,6 +23,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:sanmill/generated/l10n.dart';
import 'package:sanmill/style/app_theme.dart';
import 'package:sanmill/common/config.dart';
enum DrawerIndex {
humanVsAi,
@ -181,6 +182,10 @@ class _HomeDrawerState extends State<HomeDrawer> {
color: AppTheme.exitIconColor,
),
onTap: () async {
if (Config.developerMode) {
return;
}
await SystemChannels.platform.invokeMethod<void>('SystemNavigator.pop');
},
);

View File

@ -19,6 +19,7 @@
import 'package:flutter/material.dart';
import 'package:sanmill/engine/engine.dart';
import 'package:sanmill/mill/game.dart';
import 'package:sanmill/common/config.dart';
import 'package:sanmill/style/app_theme.dart';
import 'package:sanmill/widgets/about_page.dart';
import 'package:sanmill/widgets/drawer_user_controller.dart';
@ -104,11 +105,11 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
setState(() {
screenView = PersonalizationSettingsPage();
});
} else if (drawerIndex == DrawerIndex.Help) {
} else if (drawerIndex == DrawerIndex.Help && !Config.developerMode) {
setState(() {
screenView = HelpScreen();
});
} else if (drawerIndex == DrawerIndex.About) {
} else if (drawerIndex == DrawerIndex.About && !Config.developerMode) {
setState(() {
screenView = AboutPage();
});