Implemented default mode selection
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import 'package:cabo_counter/core/constants.dart';
|
import 'package:cabo_counter/core/constants.dart';
|
||||||
import 'package:cabo_counter/core/custom_theme.dart';
|
import 'package:cabo_counter/core/custom_theme.dart';
|
||||||
import 'package:cabo_counter/l10n/generated/app_localizations.dart';
|
import 'package:cabo_counter/l10n/generated/app_localizations.dart';
|
||||||
|
import 'package:cabo_counter/presentation/views/mode_selection_view.dart';
|
||||||
import 'package:cabo_counter/presentation/widgets/custom_form_row.dart';
|
import 'package:cabo_counter/presentation/widgets/custom_form_row.dart';
|
||||||
import 'package:cabo_counter/presentation/widgets/custom_stepper.dart';
|
import 'package:cabo_counter/presentation/widgets/custom_stepper.dart';
|
||||||
import 'package:cabo_counter/services/config_service.dart';
|
import 'package:cabo_counter/services/config_service.dart';
|
||||||
@@ -20,6 +21,7 @@ class SettingsView extends StatefulWidget {
|
|||||||
class _SettingsViewState extends State<SettingsView> {
|
class _SettingsViewState extends State<SettingsView> {
|
||||||
UniqueKey _stepperKey1 = UniqueKey();
|
UniqueKey _stepperKey1 = UniqueKey();
|
||||||
UniqueKey _stepperKey2 = UniqueKey();
|
UniqueKey _stepperKey2 = UniqueKey();
|
||||||
|
int defaultMode = ConfigService.gameMode;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -84,6 +86,56 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
CustomFormRow(
|
||||||
|
prefixText: AppLocalizations.of(context).standard_mode,
|
||||||
|
prefixIcon: CupertinoIcons.airplane,
|
||||||
|
suffixWidget: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
defaultMode == -1
|
||||||
|
? AppLocalizations.of(context)
|
||||||
|
.no_mode_selected
|
||||||
|
: (defaultMode == 1
|
||||||
|
? '${ConfigService.pointLimit} ${AppLocalizations.of(context).points}'
|
||||||
|
: AppLocalizations.of(context).unlimited),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
const CupertinoListTileChevron()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
final selectedMode = await Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => ModeSelectionMenu(
|
||||||
|
pointLimit: ConfigService.pointLimit,
|
||||||
|
showDeselection: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
print('Selected mode: $selectedMode');
|
||||||
|
|
||||||
|
switch (selectedMode) {
|
||||||
|
case GameMode.pointLimit:
|
||||||
|
setState(() {
|
||||||
|
defaultMode = 1;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case GameMode.unlimited:
|
||||||
|
setState(() {
|
||||||
|
defaultMode = 0;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case GameMode.none:
|
||||||
|
default:
|
||||||
|
setState(() {
|
||||||
|
defaultMode = -1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ConfigService.setGameMode(defaultMode);
|
||||||
|
},
|
||||||
|
),
|
||||||
CustomFormRow(
|
CustomFormRow(
|
||||||
prefixText:
|
prefixText:
|
||||||
AppLocalizations.of(context).reset_to_default,
|
AppLocalizations.of(context).reset_to_default,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: cabo_counter
|
|||||||
description: "Mobile app for the card game Cabo"
|
description: "Mobile app for the card game Cabo"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.4.9+537
|
version: 0.4.9+539
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.5.4
|
sdk: ^3.5.4
|
||||||
|
|||||||
Reference in New Issue
Block a user