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": { "@difficulty": {
"description": "Difficulty" "description": "Difficulty"
}, },
"playSounds": "Sound effects", "gameSettings": "Game settings",
"@playSounds": { "@gameSettings": {
"description": "Sound effects" "description": "Settings to change the behaviour of the game."
}, },
"playSoundsInTheGame": "Play sounds in the game", "playSoundsInTheGame": "Play sounds in the game",
"@playSoundsInTheGame": { "@playSoundsInTheGame": {

View File

@ -52,7 +52,8 @@ class Preferences {
this.considerMobility = true, this.considerMobility = true,
@Deprecated("we won't export the developer settings anymore. People should use the EnvironmentConfig.devMode") @Deprecated("we won't export the developer settings anymore. People should use the EnvironmentConfig.devMode")
this.developerMode = false, this.developerMode = false,
this.experimentsEnabled = false, @Deprecated("use [EnvironmentConfig.devMode] instead")
this.experimentsEnabled = false,
}); });
@HiveField(0) @HiveField(0)
@ -98,6 +99,7 @@ class Preferences {
) )
final bool developerMode; final bool developerMode;
@HiveField(19) @HiveField(19)
@Deprecated("use [EnvironmentConfig.devMode] instead")
final bool experimentsEnabled; final bool experimentsEnabled;
/// encodes a Json style map into a [Preferences] object /// 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:hive_flutter/hive_flutter.dart' show Box;
import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/generated/intl/l10n.dart';
import 'package:sanmill/models/preferences.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/environment_config.dart';
import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/services/storage/storage.dart';
import 'package:sanmill/shared/custom_drawer/custom_drawer.dart'; import 'package:sanmill/shared/custom_drawer/custom_drawer.dart';
@ -141,13 +140,6 @@ class GameSettingsPage extends StatelessWidget {
debugPrint("$_tag screenReaderSupport: $value"); 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, _) { Column _buildPrefs(BuildContext context, Box<Preferences> prefBox, _) {
final Preferences _preferences = prefBox.get( final Preferences _preferences = prefBox.get(
LocalDatabaseService.preferencesKey, LocalDatabaseService.preferencesKey,
@ -156,9 +148,14 @@ class GameSettingsPage extends StatelessWidget {
final _widowsSettings = [ final _widowsSettings = [
const CustomSpacer(), const CustomSpacer(),
Text(S.of(context).playSounds, style: AppTheme.settingsHeaderStyle), Text(S.of(context).gameSettings, style: AppTheme.settingsHeaderStyle),
SettingsCard( SettingsCard(
children: <Widget>[ children: <Widget>[
SettingsSwitchListTile(
value: _preferences.isAutoRestart,
onChanged: (val) => _setIsAutoRestart(_preferences, val),
titleString: S.of(context).isAutoRestart,
),
SettingsSwitchListTile( SettingsSwitchListTile(
value: _preferences.toneEnabled, value: _preferences.toneEnabled,
onChanged: (val) => _setTone(_preferences, val), 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( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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:hive_flutter/hive_flutter.dart' show Box;
import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/generated/intl/l10n.dart';
import 'package:sanmill/models/rules.dart'; import 'package:sanmill/models/rules.dart';
import 'package:sanmill/services/environment_config.dart';
import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/services/storage/storage.dart';
import 'package:sanmill/shared/custom_drawer/custom_drawer.dart'; import 'package:sanmill/shared/custom_drawer/custom_drawer.dart';
import 'package:sanmill/shared/custom_spacer.dart'; import 'package:sanmill/shared/custom_spacer.dart';
@ -269,21 +270,20 @@ class RuleSettingsPage extends StatelessWidget {
Text(S.of(context).moving, style: AppTheme.settingsHeaderStyle), Text(S.of(context).moving, style: AppTheme.settingsHeaderStyle),
SettingsCard( SettingsCard(
children: <Widget>[ children: <Widget>[
if (LocalDatabaseService.preferences.experimentsEnabled) if (EnvironmentConfig.devMode)
SettingsSwitchListTile( SettingsSwitchListTile(
value: _rules.mayMoveInPlacingPhase, value: _rules.mayMoveInPlacingPhase,
onChanged: (val) => onChanged: (val) =>
_setMayMoveInPlacingPhase(context, _rules, val), _setMayMoveInPlacingPhase(context, _rules, val),
titleString: S.of(context).mayMoveInPlacingPhase, titleString: S.of(context).mayMoveInPlacingPhase,
subtitleString: S.of(context).mayMoveInPlacingPhase_Detail, 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( SettingsSwitchListTile(
value: _rules.isLoseButNotChangeSideWhenNoWay, value: _rules.isLoseButNotChangeSideWhenNoWay,
onChanged: (val) => onChanged: (val) =>