From c03b891c44ec3f79e442fbb3a820b4af6ed1d4c0 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sun, 8 Jun 2025 18:37:30 +0200 Subject: [PATCH 1/5] Added button state update in round view --- lib/views/round_view.dart | 13 +++++++++++++ pubspec.yaml | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/views/round_view.dart b/lib/views/round_view.dart index 48bc4b9..77a36c5 100644 --- a/lib/views/round_view.dart +++ b/lib/views/round_view.dart @@ -58,6 +58,11 @@ class _RoundViewState extends State { _kamikazePlayerIndex = gameSession.roundList[widget.roundNumber - 1].kamikazePlayerIndex; } + + for (var controller in _scoreControllerList) { + controller.addListener(_updateButtonState); + } + super.initState(); } @@ -337,6 +342,7 @@ class _RoundViewState extends State { /// Round Inputs are valid if every player has a score or /// kamikaze is selected for a player bool _areRoundInputsValid() { + print('Überprüfe, ob die Eingaben für die Runde gültig sind'); if (_areTextFieldsEmpty() && _kamikazePlayerIndex == null) return false; return true; } @@ -387,11 +393,18 @@ class _RoundViewState extends State { } } + void _updateButtonState() { + setState(() {}); // Erzwingt UI-Update + } + @override void dispose() { for (final controller in _scoreControllerList) { controller.dispose(); } + for (var controller in _scoreControllerList) { + controller.removeListener(_updateButtonState); + } for (final focusNode in _focusNodeList) { focusNode.dispose(); } diff --git a/pubspec.yaml b/pubspec.yaml index 9661bec..85cf31a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: cabo_counter description: "Mobile app for the card game Cabo" publish_to: 'none' -version: 0.1.6+145 +version: 0.1.6+146 environment: sdk: ^3.5.4 From 1f03c0fbce0f0a0d1755e2d83572ce5cdb47c1cb Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sun, 8 Jun 2025 18:39:30 +0200 Subject: [PATCH 2/5] Moved setState to onChanged Callback in text field --- lib/views/round_view.dart | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/views/round_view.dart b/lib/views/round_view.dart index 77a36c5..59e6196 100644 --- a/lib/views/round_view.dart +++ b/lib/views/round_view.dart @@ -59,10 +59,6 @@ class _RoundViewState extends State { gameSession.roundList[widget.roundNumber - 1].kamikazePlayerIndex; } - for (var controller in _scoreControllerList) { - controller.addListener(_updateButtonState); - } - super.initState(); } @@ -220,6 +216,7 @@ class _RoundViewState extends State { textAlign: TextAlign.center, onSubmitted: (_) => _focusNextTextfield(index), + onChanged: (_) => setState(() {}), ), ), const SizedBox(width: 50), @@ -393,18 +390,11 @@ class _RoundViewState extends State { } } - void _updateButtonState() { - setState(() {}); // Erzwingt UI-Update - } - @override void dispose() { for (final controller in _scoreControllerList) { controller.dispose(); } - for (var controller in _scoreControllerList) { - controller.removeListener(_updateButtonState); - } for (final focusNode in _focusNodeList) { focusNode.dispose(); } From 845528e36249502cb4b8e29fb99cdfbd72d4a957 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sun, 8 Jun 2025 19:11:57 +0200 Subject: [PATCH 3/5] Fixed state update bug --- lib/main.dart | 4 +- lib/services/config_service.dart | 4 +- lib/services/local_storage_service.dart | 12 +- lib/utility/globals.dart | 26 ++- lib/views/create_game_view.dart | 10 +- lib/views/main_menu_view.dart | 266 +++++++++++++----------- lib/views/settings_view.dart | 10 +- pubspec.yaml | 2 +- 8 files changed, 178 insertions(+), 156 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index edd7d3c..26ff4eb 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,8 +8,8 @@ import 'package:flutter/cupertino.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await ConfigService.initConfig(); - Globals.pointLimit = await ConfigService.getPointLimit(); - Globals.caboPenalty = await ConfigService.getCaboPenalty(); + globals.pointLimit = await ConfigService.getPointLimit(); + globals.caboPenalty = await ConfigService.getCaboPenalty(); runApp(const App()); } diff --git a/lib/services/config_service.dart b/lib/services/config_service.dart index 1c8275a..a4336e0 100644 --- a/lib/services/config_service.dart +++ b/lib/services/config_service.dart @@ -48,8 +48,8 @@ class ConfigService { /// Resets the configuration to default values. static Future resetConfig() async { - Globals.pointLimit = _defaultPointLimit; - Globals.caboPenalty = _defaultCaboPenalty; + globals.pointLimit = _defaultPointLimit; + globals.caboPenalty = _defaultCaboPenalty; final prefs = await SharedPreferences.getInstance(); await prefs.setInt(_keyPointLimit, _defaultPointLimit); await prefs.setInt(_keyCaboPenalty, _defaultCaboPenalty); diff --git a/lib/services/local_storage_service.dart b/lib/services/local_storage_service.dart index a68f3e4..5ca438e 100644 --- a/lib/services/local_storage_service.dart +++ b/lib/services/local_storage_service.dart @@ -19,7 +19,7 @@ class LocalStorageService { /// Writes the game session list to a JSON file and returns it as string. static String getJsonFile() { final jsonFile = - Globals.gameList.map((session) => session.toJson()).toList(); + globals.gameList.map((session) => session.toJson()).toList(); return json.encode(jsonFile); } @@ -63,14 +63,14 @@ class LocalStorageService { if (!await validateJsonSchema(jsonString)) { logger.w('Die Datei konnte nicht validiert werden'); - Globals.gameList = []; + globals.gameList = []; return false; } logger.d('Die gefundene Datei hat Inhalt'); logger.d('Die gefundene Datei wurde erfolgreich validiert'); final jsonList = json.decode(jsonString) as List; - Globals.gameList = jsonList + globals.gameList = jsonList .map((jsonItem) => GameSession.fromJson(jsonItem as Map)) .toList(); @@ -80,7 +80,7 @@ class LocalStorageService { } catch (e) { logger.e('Fehler beim Laden der Spieldaten:\n$e', error: 'JSON nicht geladen'); - Globals.gameList = []; + globals.gameList = []; return false; } } @@ -125,7 +125,7 @@ class LocalStorageService { return false; } final jsonData = json.decode(jsonString) as List; - Globals.gameList = jsonData + globals.gameList = jsonData .map((jsonItem) => GameSession.fromJson(jsonItem as Map)) .toList(); @@ -172,7 +172,7 @@ class LocalStorageService { static Future deleteAllGames() async { try { - Globals.gameList.clear(); + globals.gameList.clear(); await saveGameSessions(); logger.i('Alle Runden wurden erfolgreich gelöscht.'); return true; diff --git a/lib/utility/globals.dart b/lib/utility/globals.dart index 89d8559..7b4d7e0 100644 --- a/lib/utility/globals.dart +++ b/lib/utility/globals.dart @@ -1,17 +1,25 @@ import 'package:cabo_counter/data/game_session.dart'; +import 'package:cabo_counter/services/local_storage_service.dart'; +import 'package:flutter/foundation.dart'; -class Globals { - /// The [gameList] contains all active game sessions. - static List gameList = []; +class Globals extends ChangeNotifier { + List gameList = []; + int pointLimit = 100; + int caboPenalty = 5; + String appDevPhase = 'Alpha'; - static void addGameSession(GameSession session) { + void addGameSession(GameSession session) { gameList.add(session); gameList.sort((a, b) => b.createdAt.compareTo(a.createdAt)); + notifyListeners(); // Wichtig! + LocalStorageService.saveGameSessions(); } - static int pointLimit = 100; - - static int caboPenalty = 5; - - static String appDevPhase = 'Alpha'; + void removeGameSession(int index) { + gameList.removeAt(index); + notifyListeners(); // Wichtig! + LocalStorageService.saveGameSessions(); + } } + +final globals = Globals(); // Globale Instanz diff --git a/lib/views/create_game_view.dart b/lib/views/create_game_view.dart index 7bbeefa..aa0d40f 100644 --- a/lib/views/create_game_view.dart +++ b/lib/views/create_game_view.dart @@ -81,7 +81,7 @@ class _CreateGameState extends State { context, CupertinoPageRoute( builder: (context) => ModeSelectionMenu( - pointLimit: Globals.pointLimit, + pointLimit: globals.pointLimit, ), ), ); @@ -285,13 +285,11 @@ class _CreateGameState extends State { createdAt: DateTime.now(), gameTitle: _gameTitleTextController.text, players: players, - pointLimit: Globals.pointLimit, - caboPenalty: Globals.caboPenalty, + pointLimit: globals.pointLimit, + caboPenalty: globals.caboPenalty, isPointsLimitEnabled: selectedMode!, ); - setState(() { - Globals.addGameSession(gameSession); - }); + globals.addGameSession(gameSession); LocalStorageService.saveGameSessions(); if (context.mounted) { Navigator.pushReplacement( diff --git a/lib/views/main_menu_view.dart b/lib/views/main_menu_view.dart index fabd02d..9572c82 100644 --- a/lib/views/main_menu_view.dart +++ b/lib/views/main_menu_view.dart @@ -26,6 +26,11 @@ class _MainMenuViewState extends State { _isLoading = false; }); }); + globals.addListener(_updateView); + } + + void _updateView() { + if (mounted) setState(() {}); } @override @@ -33,132 +38,143 @@ class _MainMenuViewState extends State { print('MainMenuView build'); LocalStorageService.loadGameSessions(); - return CupertinoPageScaffold( - resizeToAvoidBottomInset: false, - navigationBar: CupertinoNavigationBar( - leading: IconButton( - onPressed: () { - Navigator.push( - context, - CupertinoPageRoute( - builder: (context) => const SettingsView(), - ), - ); - }, - icon: const Icon(CupertinoIcons.settings, size: 30)), - middle: const Text('Cabo Counter'), - trailing: IconButton( - onPressed: () => { - Navigator.push( - context, - CupertinoPageRoute( - builder: (context) => const CreateGame(), - ), - ) - }, - icon: const Icon(CupertinoIcons.add)), - ), - child: CupertinoPageScaffold( - child: SafeArea( - child: _isLoading - ? const Center(child: CupertinoActivityIndicator()) - : Globals.gameList.isEmpty - ? Column( - mainAxisAlignment: - MainAxisAlignment.center, // Oben ausrichten - children: [ - const SizedBox(height: 30), // Abstand von oben - Center( - child: GestureDetector( - onTap: () => setState(() {}), - child: Icon( - CupertinoIcons.plus, - size: 60, - color: CustomTheme.primaryColor, + return ListenableBuilder( + listenable: globals, + builder: (context, _) { + return CupertinoPageScaffold( + resizeToAvoidBottomInset: false, + navigationBar: CupertinoNavigationBar( + leading: IconButton( + onPressed: () { + Navigator.push( + context, + CupertinoPageRoute( + builder: (context) => const SettingsView(), + ), + ); + }, + icon: const Icon(CupertinoIcons.settings, size: 30)), + middle: const Text('Cabo Counter'), + trailing: IconButton( + onPressed: () => { + Navigator.push( + context, + CupertinoPageRoute( + builder: (context) => const CreateGame(), ), - )), - const SizedBox(height: 10), // Abstand von oben - const Padding( - padding: EdgeInsets.symmetric(horizontal: 70), - child: Text( - 'Ganz schön leer hier...\nFüge über den Button oben rechts eine neue Runde hinzu.', - textAlign: TextAlign.center, - style: TextStyle(fontSize: 16), - ), - ), - ], - ) - : ListView.builder( - itemCount: Globals.gameList.length, - itemBuilder: (context, index) { - final session = Globals.gameList[index]; - return Dismissible( - key: Key(session.gameTitle), - background: Container( - color: CupertinoColors.destructiveRed, - alignment: Alignment.centerLeft, - padding: const EdgeInsets.only(left: 20.0), - child: const Icon( - CupertinoIcons.delete, - color: CupertinoColors.white, - ), - ), - direction: DismissDirection.startToEnd, - confirmDismiss: (direction) async { - final String gameTitle = - Globals.gameList[index].gameTitle; - return await _showDeleteGamePopup(gameTitle); - }, - onDismissed: (direction) { - _deleteSpecificGame(index); - }, - dismissThresholds: const { - DismissDirection.startToEnd: 0.6 - }, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10.0), - child: CupertinoListTile( - title: Text(session.gameTitle), - subtitle: session.isGameFinished == true - ? Text( - '\u{1F947} ${session.winner}', - style: const TextStyle(fontSize: 14), - ) - : Text( - 'Modus: ${_translateGameMode(session.isPointsLimitEnabled)}', - style: const TextStyle(fontSize: 14), - ), - trailing: Row( - children: [ - Text('${session.roundNumber}'), - const SizedBox(width: 3), - const Icon(CupertinoIcons - .arrow_2_circlepath_circle_fill), - const SizedBox(width: 15), - Text('${session.players.length}'), - const SizedBox(width: 3), - const Icon(CupertinoIcons.person_2_fill), - ], - ), - onTap: () async { - //ignore: unused_local_variable - final val = await Navigator.push( - context, - CupertinoPageRoute( - builder: (context) => ActiveGameView( - gameSession: Globals.gameList[index]), - ), - ); - setState(() {}); - }, - ), - ), - ); + ) }, - ), - ), - ), - ); + icon: const Icon(CupertinoIcons.add)), + ), + child: CupertinoPageScaffold( + child: SafeArea( + child: _isLoading + ? const Center(child: CupertinoActivityIndicator()) + : globals.gameList.isEmpty + ? Column( + mainAxisAlignment: + MainAxisAlignment.center, // Oben ausrichten + children: [ + const SizedBox(height: 30), // Abstand von oben + Center( + child: GestureDetector( + onTap: () => setState(() {}), + child: Icon( + CupertinoIcons.plus, + size: 60, + color: CustomTheme.primaryColor, + ), + )), + const SizedBox(height: 10), // Abstand von oben + const Padding( + padding: EdgeInsets.symmetric(horizontal: 70), + child: Text( + 'Ganz schön leer hier...\nFüge über den Button oben rechts eine neue Runde hinzu.', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 16), + ), + ), + ], + ) + : ListView.builder( + itemCount: globals.gameList.length, + itemBuilder: (context, index) { + final session = globals.gameList[index]; + return Dismissible( + key: Key(session.gameTitle), + background: Container( + color: CupertinoColors.destructiveRed, + alignment: Alignment.centerLeft, + padding: const EdgeInsets.only(left: 20.0), + child: const Icon( + CupertinoIcons.delete, + color: CupertinoColors.white, + ), + ), + direction: DismissDirection.startToEnd, + confirmDismiss: (direction) async { + final String gameTitle = + globals.gameList[index].gameTitle; + return await _showDeleteGamePopup(gameTitle); + }, + onDismissed: (direction) { + _deleteSpecificGame(index); + }, + dismissThresholds: const { + DismissDirection.startToEnd: 0.6 + }, + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 10.0), + child: CupertinoListTile( + backgroundColorActivated: + CustomTheme.backgroundColor, + title: Text(session.gameTitle), + subtitle: session.isGameFinished == true + ? Text( + '\u{1F947} ${session.winner}', + style: + const TextStyle(fontSize: 14), + ) + : Text( + 'Modus: ${_translateGameMode(session.isPointsLimitEnabled)}', + style: + const TextStyle(fontSize: 14), + ), + trailing: Row( + children: [ + Text('${session.roundNumber}'), + const SizedBox(width: 3), + const Icon(CupertinoIcons + .arrow_2_circlepath_circle_fill), + const SizedBox(width: 15), + Text('${session.players.length}'), + const SizedBox(width: 3), + const Icon( + CupertinoIcons.person_2_fill), + ], + ), + onTap: () async { + //ignore: unused_local_variable + final val = await Navigator.push( + context, + CupertinoPageRoute( + builder: (context) => ActiveGameView( + gameSession: + globals.gameList[index]), + ), + ); + setState(() {}); + }, + ), + ), + ); + }, + ), + ), + ), + ); + }); } /// Translates the game mode boolean into the corresponding String. @@ -204,7 +220,7 @@ class _MainMenuViewState extends State { /// This function takes an [index] as parameter and removes the game session at /// that index from the global game list, void _deleteSpecificGame(int index) { - Globals.gameList.removeAt(index); + globals.gameList.removeAt(index); LocalStorageService.saveGameSessions(); } } diff --git a/lib/views/settings_view.dart b/lib/views/settings_view.dart index 8f0dcf4..36c7099 100644 --- a/lib/views/settings_view.dart +++ b/lib/views/settings_view.dart @@ -50,14 +50,14 @@ class _SettingsViewState extends State { subtitle: const Text('... für falsches Cabo sagen'), trailing: Stepper( key: _stepperKey1, - initialValue: Globals.caboPenalty, + initialValue: globals.caboPenalty, minValue: 0, maxValue: 50, step: 1, onChanged: (newCaboPenalty) { setState(() { ConfigService.setCaboPenalty(newCaboPenalty); - Globals.caboPenalty = newCaboPenalty; + globals.caboPenalty = newCaboPenalty; }); }, ), @@ -70,14 +70,14 @@ class _SettingsViewState extends State { subtitle: const Text('... hier ist Schluss'), trailing: Stepper( key: _stepperKey2, - initialValue: Globals.pointLimit, + initialValue: globals.pointLimit, minValue: 30, maxValue: 1000, step: 10, onChanged: (newPointLimit) { setState(() { ConfigService.setPointLimit(newPointLimit); - Globals.pointLimit = newPointLimit; + globals.pointLimit = newPointLimit; }); }, ), @@ -201,7 +201,7 @@ class _SettingsViewState extends State { builder: (context, snapshot) { if (snapshot.hasData) { return Text( - '${Globals.appDevPhase} ${snapshot.data!.version} ' + '${globals.appDevPhase} ${snapshot.data!.version} ' '(Build ${snapshot.data!.buildNumber})', textAlign: TextAlign.center, ); diff --git a/pubspec.yaml b/pubspec.yaml index 85cf31a..990882b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: cabo_counter description: "Mobile app for the card game Cabo" publish_to: 'none' -version: 0.1.6+146 +version: 0.1.6+148 environment: sdk: ^3.5.4 From 28aa3261fb19d31d70f45a8d94df415651197d1d Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sun, 8 Jun 2025 19:24:01 +0200 Subject: [PATCH 4/5] Refactoring & comments --- lib/data/game_manager.dart | 30 +++++++++++++++++++++++++ lib/main.dart | 4 ++-- lib/services/config_service.dart | 4 ++-- lib/services/local_storage_service.dart | 2 +- lib/utility/globals.dart | 28 ++++------------------- lib/views/create_game_view.dart | 7 +++--- lib/views/main_menu_view.dart | 2 +- lib/views/settings_view.dart | 10 ++++----- 8 files changed, 49 insertions(+), 38 deletions(-) create mode 100644 lib/data/game_manager.dart diff --git a/lib/data/game_manager.dart b/lib/data/game_manager.dart new file mode 100644 index 0000000..578b03b --- /dev/null +++ b/lib/data/game_manager.dart @@ -0,0 +1,30 @@ +import 'package:cabo_counter/data/game_session.dart'; +import 'package:cabo_counter/services/local_storage_service.dart'; +import 'package:flutter/foundation.dart'; + +class GameManager extends ChangeNotifier { + List gameList = []; + + /// Adds a new game session to the list and sorts it by creation date. + /// Takes a [GameSession] object as input. It then adds the session to the `gameList`, + /// sorts the list in descending order based on the creation date, and notifies listeners of the change. + /// It also saves the updated game sessions to local storage. + void addGameSession(GameSession session) { + gameList.add(session); + gameList.sort((a, b) => b.createdAt.compareTo(a.createdAt)); + notifyListeners(); + LocalStorageService.saveGameSessions(); + } + + /// Removes a game session from the list and sorts it by creation date. + /// Takes a [index] as input. It then removes the session at the specified index from the `gameList`, + /// sorts the list in descending order based on the creation date, and notifies listeners of the change. + /// It also saves the updated game sessions to local storage. + void removeGameSession(int index) { + gameList.removeAt(index); + notifyListeners(); + LocalStorageService.saveGameSessions(); + } +} + +final globals = GameManager(); diff --git a/lib/main.dart b/lib/main.dart index 26ff4eb..edd7d3c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,8 +8,8 @@ import 'package:flutter/cupertino.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await ConfigService.initConfig(); - globals.pointLimit = await ConfigService.getPointLimit(); - globals.caboPenalty = await ConfigService.getCaboPenalty(); + Globals.pointLimit = await ConfigService.getPointLimit(); + Globals.caboPenalty = await ConfigService.getCaboPenalty(); runApp(const App()); } diff --git a/lib/services/config_service.dart b/lib/services/config_service.dart index a4336e0..1c8275a 100644 --- a/lib/services/config_service.dart +++ b/lib/services/config_service.dart @@ -48,8 +48,8 @@ class ConfigService { /// Resets the configuration to default values. static Future resetConfig() async { - globals.pointLimit = _defaultPointLimit; - globals.caboPenalty = _defaultCaboPenalty; + Globals.pointLimit = _defaultPointLimit; + Globals.caboPenalty = _defaultCaboPenalty; final prefs = await SharedPreferences.getInstance(); await prefs.setInt(_keyPointLimit, _defaultPointLimit); await prefs.setInt(_keyCaboPenalty, _defaultCaboPenalty); diff --git a/lib/services/local_storage_service.dart b/lib/services/local_storage_service.dart index 5ca438e..a6d005c 100644 --- a/lib/services/local_storage_service.dart +++ b/lib/services/local_storage_service.dart @@ -1,8 +1,8 @@ import 'dart:convert'; import 'dart:io'; +import 'package:cabo_counter/data/game_manager.dart'; import 'package:cabo_counter/data/game_session.dart'; -import 'package:cabo_counter/utility/globals.dart'; import 'package:file_picker/file_picker.dart'; import 'package:file_saver/file_saver.dart'; import 'package:flutter/services.dart'; diff --git a/lib/utility/globals.dart b/lib/utility/globals.dart index 7b4d7e0..4244f07 100644 --- a/lib/utility/globals.dart +++ b/lib/utility/globals.dart @@ -1,25 +1,5 @@ -import 'package:cabo_counter/data/game_session.dart'; -import 'package:cabo_counter/services/local_storage_service.dart'; -import 'package:flutter/foundation.dart'; - -class Globals extends ChangeNotifier { - List gameList = []; - int pointLimit = 100; - int caboPenalty = 5; - String appDevPhase = 'Alpha'; - - void addGameSession(GameSession session) { - gameList.add(session); - gameList.sort((a, b) => b.createdAt.compareTo(a.createdAt)); - notifyListeners(); // Wichtig! - LocalStorageService.saveGameSessions(); - } - - void removeGameSession(int index) { - gameList.removeAt(index); - notifyListeners(); // Wichtig! - LocalStorageService.saveGameSessions(); - } +class Globals { + static int pointLimit = 100; + static int caboPenalty = 5; + static String appDevPhase = 'Alpha'; } - -final globals = Globals(); // Globale Instanz diff --git a/lib/views/create_game_view.dart b/lib/views/create_game_view.dart index aa0d40f..92ce4f0 100644 --- a/lib/views/create_game_view.dart +++ b/lib/views/create_game_view.dart @@ -1,3 +1,4 @@ +import 'package:cabo_counter/data/game_manager.dart'; import 'package:cabo_counter/data/game_session.dart'; import 'package:cabo_counter/services/local_storage_service.dart'; import 'package:cabo_counter/utility/custom_theme.dart'; @@ -81,7 +82,7 @@ class _CreateGameState extends State { context, CupertinoPageRoute( builder: (context) => ModeSelectionMenu( - pointLimit: globals.pointLimit, + pointLimit: Globals.pointLimit, ), ), ); @@ -285,8 +286,8 @@ class _CreateGameState extends State { createdAt: DateTime.now(), gameTitle: _gameTitleTextController.text, players: players, - pointLimit: globals.pointLimit, - caboPenalty: globals.caboPenalty, + pointLimit: Globals.pointLimit, + caboPenalty: Globals.caboPenalty, isPointsLimitEnabled: selectedMode!, ); globals.addGameSession(gameSession); diff --git a/lib/views/main_menu_view.dart b/lib/views/main_menu_view.dart index 9572c82..0420a4c 100644 --- a/lib/views/main_menu_view.dart +++ b/lib/views/main_menu_view.dart @@ -1,6 +1,6 @@ +import 'package:cabo_counter/data/game_manager.dart'; import 'package:cabo_counter/services/local_storage_service.dart'; import 'package:cabo_counter/utility/custom_theme.dart'; -import 'package:cabo_counter/utility/globals.dart'; import 'package:cabo_counter/views/active_game_view.dart'; import 'package:cabo_counter/views/create_game_view.dart'; import 'package:cabo_counter/views/settings_view.dart'; diff --git a/lib/views/settings_view.dart b/lib/views/settings_view.dart index 36c7099..8f0dcf4 100644 --- a/lib/views/settings_view.dart +++ b/lib/views/settings_view.dart @@ -50,14 +50,14 @@ class _SettingsViewState extends State { subtitle: const Text('... für falsches Cabo sagen'), trailing: Stepper( key: _stepperKey1, - initialValue: globals.caboPenalty, + initialValue: Globals.caboPenalty, minValue: 0, maxValue: 50, step: 1, onChanged: (newCaboPenalty) { setState(() { ConfigService.setCaboPenalty(newCaboPenalty); - globals.caboPenalty = newCaboPenalty; + Globals.caboPenalty = newCaboPenalty; }); }, ), @@ -70,14 +70,14 @@ class _SettingsViewState extends State { subtitle: const Text('... hier ist Schluss'), trailing: Stepper( key: _stepperKey2, - initialValue: globals.pointLimit, + initialValue: Globals.pointLimit, minValue: 30, maxValue: 1000, step: 10, onChanged: (newPointLimit) { setState(() { ConfigService.setPointLimit(newPointLimit); - globals.pointLimit = newPointLimit; + Globals.pointLimit = newPointLimit; }); }, ), @@ -201,7 +201,7 @@ class _SettingsViewState extends State { builder: (context, snapshot) { if (snapshot.hasData) { return Text( - '${globals.appDevPhase} ${snapshot.data!.version} ' + '${Globals.appDevPhase} ${snapshot.data!.version} ' '(Build ${snapshot.data!.buildNumber})', textAlign: TextAlign.center, ); From cadf606871d955511c1528b754cf2c1068c656df Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sun, 8 Jun 2025 19:26:00 +0200 Subject: [PATCH 5/5] Removed print --- lib/views/round_view.dart | 1 - pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/views/round_view.dart b/lib/views/round_view.dart index 59e6196..6cd6695 100644 --- a/lib/views/round_view.dart +++ b/lib/views/round_view.dart @@ -339,7 +339,6 @@ class _RoundViewState extends State { /// Round Inputs are valid if every player has a score or /// kamikaze is selected for a player bool _areRoundInputsValid() { - print('Überprüfe, ob die Eingaben für die Runde gültig sind'); if (_areTextFieldsEmpty() && _kamikazePlayerIndex == null) return false; return true; } diff --git a/pubspec.yaml b/pubspec.yaml index 990882b..1b9467e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: cabo_counter description: "Mobile app for the card game Cabo" publish_to: 'none' -version: 0.1.6+148 +version: 0.1.6+149 environment: sdk: ^3.5.4