remove unused code

This commit is contained in:
Leptopoda-GitHub 2021-11-24 09:03:21 +01:00 committed by Nikolas Rimikis
parent c9e6892322
commit fcd8eae98f
4 changed files with 20 additions and 55 deletions

View File

@ -430,9 +430,9 @@
"@difficulty": {
"description": "Difficulty"
},
"playSounds": "Sound effects",
"@playSounds": {
"description": "Sound effects"
"gameSettings": "Game settings",
"@gameSettings": {
"description": "Settings to change the behaviour of the game."
},
"playSoundsInTheGame": "Play sounds in the game",
"@playSoundsInTheGame": {

View File

@ -52,7 +52,8 @@ class Preferences {
this.considerMobility = true,
@Deprecated("we won't export the developer settings anymore. People should use the EnvironmentConfig.devMode")
this.developerMode = false,
this.experimentsEnabled = false,
@Deprecated("use [EnvironmentConfig.devMode] instead")
this.experimentsEnabled = false,
});
@HiveField(0)
@ -98,6 +99,7 @@ class Preferences {
)
final bool developerMode;
@HiveField(19)
@Deprecated("use [EnvironmentConfig.devMode] instead")
final bool experimentsEnabled;
/// encodes a Json style map into a [Preferences] object

View File

@ -23,7 +23,6 @@ import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart' show Box;
import 'package:sanmill/generated/intl/l10n.dart';
import 'package:sanmill/models/preferences.dart';
import 'package:sanmill/screens/env_page.dart';
import 'package:sanmill/services/environment_config.dart';
import 'package:sanmill/services/storage/storage.dart';
import 'package:sanmill/shared/custom_drawer/custom_drawer.dart';
@ -141,13 +140,6 @@ class GameSettingsPage extends StatelessWidget {
debugPrint("$_tag screenReaderSupport: $value");
}
void _setExperimentsEnabled(Preferences _preferences, bool value) {
LocalDatabaseService.preferences =
_preferences.copyWith(experimentsEnabled: value);
debugPrint("$_tag experimentsEnabled: $value");
}
Column _buildPrefs(BuildContext context, Box<Preferences> prefBox, _) {
final Preferences _preferences = prefBox.get(
LocalDatabaseService.preferencesKey,
@ -156,9 +148,14 @@ class GameSettingsPage extends StatelessWidget {
final _widowsSettings = [
const CustomSpacer(),
Text(S.of(context).playSounds, style: AppTheme.settingsHeaderStyle),
Text(S.of(context).gameSettings, style: AppTheme.settingsHeaderStyle),
SettingsCard(
children: <Widget>[
SettingsSwitchListTile(
value: _preferences.isAutoRestart,
onChanged: (val) => _setIsAutoRestart(_preferences, val),
titleString: S.of(context).isAutoRestart,
),
SettingsSwitchListTile(
value: _preferences.toneEnabled,
onChanged: (val) => _setTone(_preferences, val),
@ -173,39 +170,6 @@ class GameSettingsPage extends StatelessWidget {
),
];
final _developerSettings = [
const CustomSpacer(),
Text(S.of(context).forDevelopers, style: AppTheme.settingsHeaderStyle),
SettingsCard(
children: <Widget>[
SettingsSwitchListTile(
value: EnvironmentConfig.devMode,
onChanged: (_) {},
titleString: S.of(context).developerMode,
),
SettingsSwitchListTile(
value: _preferences.experimentsEnabled,
onChanged: (val) => _setExperimentsEnabled(_preferences, val),
titleString: S.of(context).experiments,
),
SettingsSwitchListTile(
value: _preferences.isAutoRestart,
onChanged: (val) => _setIsAutoRestart(_preferences, val),
titleString: S.of(context).isAutoRestart,
),
SettingsListTile(
titleString: S.of(context).environmentVariables,
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const EnvironmentVariablesPage(),
),
),
),
],
),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -289,7 +253,6 @@ class GameSettingsPage extends StatelessWidget {
),
],
),
if (EnvironmentConfig.devMode) ..._developerSettings,
],
);
}

View File

@ -20,6 +20,7 @@ import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart' show Box;
import 'package:sanmill/generated/intl/l10n.dart';
import 'package:sanmill/models/rules.dart';
import 'package:sanmill/services/environment_config.dart';
import 'package:sanmill/services/storage/storage.dart';
import 'package:sanmill/shared/custom_drawer/custom_drawer.dart';
import 'package:sanmill/shared/custom_spacer.dart';
@ -269,21 +270,20 @@ class RuleSettingsPage extends StatelessWidget {
Text(S.of(context).moving, style: AppTheme.settingsHeaderStyle),
SettingsCard(
children: <Widget>[
if (LocalDatabaseService.preferences.experimentsEnabled)
if (EnvironmentConfig.devMode)
SettingsSwitchListTile(
value: _rules.mayMoveInPlacingPhase,
onChanged: (val) =>
_setMayMoveInPlacingPhase(context, _rules, val),
titleString: S.of(context).mayMoveInPlacingPhase,
subtitleString: S.of(context).mayMoveInPlacingPhase_Detail,
)
else
SettingsSwitchListTile(
value: _rules.isDefenderMoveFirst,
onChanged: (val) => _setIsDefenderMoveFirst(_rules, val),
titleString: S.of(context).isDefenderMoveFirst,
subtitleString: S.of(context).isDefenderMoveFirst_Detail,
),
SettingsSwitchListTile(
value: _rules.isDefenderMoveFirst,
onChanged: (val) => _setIsDefenderMoveFirst(_rules, val),
titleString: S.of(context).isDefenderMoveFirst,
subtitleString: S.of(context).isDefenderMoveFirst_Detail,
),
SettingsSwitchListTile(
value: _rules.isLoseButNotChangeSideWhenNoWay,
onChanged: (val) =>