From d11902b3d8113a3472f86a456377edf6c6988920 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sat, 3 May 2025 00:53:34 +0200 Subject: [PATCH] Changed folder name --- .../local_storage_service.dart | 0 lib/views/create_game_view.dart | 22 +++++++++++++------ lib/views/information_view.dart | 2 +- lib/views/main_menu_view.dart | 2 +- lib/views/round_view.dart | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) rename lib/{utility => services}/local_storage_service.dart (100%) diff --git a/lib/utility/local_storage_service.dart b/lib/services/local_storage_service.dart similarity index 100% rename from lib/utility/local_storage_service.dart rename to lib/services/local_storage_service.dart diff --git a/lib/views/create_game_view.dart b/lib/views/create_game_view.dart index 4c3e49f..2bff053 100644 --- a/lib/views/create_game_view.dart +++ b/lib/views/create_game_view.dart @@ -1,7 +1,8 @@ import 'package:cabo_counter/data/game_session.dart'; +import 'package:cabo_counter/services/config_service.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/utility/local_storage_service.dart'; import 'package:cabo_counter/views/active_game_view.dart'; import 'package:cabo_counter/views/mode_selection_view.dart'; import 'package:flutter/cupertino.dart'; @@ -206,7 +207,7 @@ class _CreateGameState extends State { ), ], ), - onPressed: () { + onPressed: () async { if (_gameTitleTextController.text == '') { showCupertinoDialog( context: context, @@ -282,17 +283,24 @@ class _CreateGameState extends State { players.add(controller.text); } GameSession gameSession = GameSession( + createdAt: DateTime.now(), gameTitle: _gameTitleTextController.text, players: players, + pointLimit: await ConfigService.getPointLimit(), + caboPenalty: await ConfigService.getCaboPenalty(), isPointsLimitEnabled: selectedMode!, ); Globals.addGameSession(gameSession); LocalStorageService.saveGameSessions(); - Navigator.pushReplacement( - context, - CupertinoPageRoute( - builder: (context) => - ActiveGameView(gameSession: gameSession))); + if (context.mounted) { + Navigator.pushReplacement( + context, + CupertinoPageRoute( + builder: (context) => + ActiveGameView(gameSession: gameSession))); + } else { + print('Context is not mounted'); + } }, ), ), diff --git a/lib/views/information_view.dart b/lib/views/information_view.dart index cac3a61..3f22c03 100644 --- a/lib/views/information_view.dart +++ b/lib/views/information_view.dart @@ -1,4 +1,4 @@ -import 'package:cabo_counter/utility/local_storage_service.dart'; +import 'package:cabo_counter/services/local_storage_service.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/views/main_menu_view.dart b/lib/views/main_menu_view.dart index 2b5afd1..490f209 100644 --- a/lib/views/main_menu_view.dart +++ b/lib/views/main_menu_view.dart @@ -1,6 +1,6 @@ +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/utility/local_storage_service.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/round_view.dart b/lib/views/round_view.dart index 7e5ea96..fe68ce7 100644 --- a/lib/views/round_view.dart +++ b/lib/views/round_view.dart @@ -1,6 +1,6 @@ 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'; -import 'package:cabo_counter/utility/local_storage_service.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';