flutter: Add code for developer mode
This commit is contained in:
parent
e2c443830a
commit
080b7da46d
|
@ -662,6 +662,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
if (Config.developerMode) return;
|
||||||
Game.instance.regret(steps: 2);
|
Game.instance.regret(steps: 2);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
|
|
|
@ -69,6 +69,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
|
||||||
restoreFactoryDefaultSettings() async {
|
restoreFactoryDefaultSettings() async {
|
||||||
confirm() async {
|
confirm() async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
if (Config.developerMode) return;
|
||||||
final profile = await Settings.instance();
|
final profile = await Settings.instance();
|
||||||
await profile.restore();
|
await profile.restore();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -189,19 +190,6 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: AppTheme.sizedBoxHeight),
|
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),
|
Text(S.of(context).restore, style: AppTheme.settingsHeaderStyle),
|
||||||
SettingsCard(
|
SettingsCard(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -214,6 +202,19 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
|
||||||
ListItemDivider(),
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:sanmill/generated/l10n.dart';
|
import 'package:sanmill/generated/l10n.dart';
|
||||||
import 'package:sanmill/style/app_theme.dart';
|
import 'package:sanmill/style/app_theme.dart';
|
||||||
|
import 'package:sanmill/common/config.dart';
|
||||||
|
|
||||||
enum DrawerIndex {
|
enum DrawerIndex {
|
||||||
humanVsAi,
|
humanVsAi,
|
||||||
|
@ -181,6 +182,10 @@ class _HomeDrawerState extends State<HomeDrawer> {
|
||||||
color: AppTheme.exitIconColor,
|
color: AppTheme.exitIconColor,
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
if (Config.developerMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await SystemChannels.platform.invokeMethod<void>('SystemNavigator.pop');
|
await SystemChannels.platform.invokeMethod<void>('SystemNavigator.pop');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:sanmill/engine/engine.dart';
|
import 'package:sanmill/engine/engine.dart';
|
||||||
import 'package:sanmill/mill/game.dart';
|
import 'package:sanmill/mill/game.dart';
|
||||||
|
import 'package:sanmill/common/config.dart';
|
||||||
import 'package:sanmill/style/app_theme.dart';
|
import 'package:sanmill/style/app_theme.dart';
|
||||||
import 'package:sanmill/widgets/about_page.dart';
|
import 'package:sanmill/widgets/about_page.dart';
|
||||||
import 'package:sanmill/widgets/drawer_user_controller.dart';
|
import 'package:sanmill/widgets/drawer_user_controller.dart';
|
||||||
|
@ -104,11 +105,11 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
||||||
setState(() {
|
setState(() {
|
||||||
screenView = PersonalizationSettingsPage();
|
screenView = PersonalizationSettingsPage();
|
||||||
});
|
});
|
||||||
} else if (drawerIndex == DrawerIndex.Help) {
|
} else if (drawerIndex == DrawerIndex.Help && !Config.developerMode) {
|
||||||
setState(() {
|
setState(() {
|
||||||
screenView = HelpScreen();
|
screenView = HelpScreen();
|
||||||
});
|
});
|
||||||
} else if (drawerIndex == DrawerIndex.About) {
|
} else if (drawerIndex == DrawerIndex.About && !Config.developerMode) {
|
||||||
setState(() {
|
setState(() {
|
||||||
screenView = AboutPage();
|
screenView = AboutPage();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue