From 799c849570685334cdcb82279b694c96e7b2bf7f Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Fri, 9 Jan 2026 21:55:58 +0100 Subject: [PATCH 1/9] wrap every view that uses a snackbar in ScaffoldMessenger --- .../group_view/create_group_view.dart | 114 ++++---- .../create_match/create_match_view.dart | 254 +++++++++--------- .../views/main_menu/settings_view.dart | 196 +++++++------- 3 files changed, 285 insertions(+), 279 deletions(-) diff --git a/lib/presentation/views/main_menu/group_view/create_group_view.dart b/lib/presentation/views/main_menu/group_view/create_group_view.dart index f92df0f..8192c6b 100644 --- a/lib/presentation/views/main_menu/group_view/create_group_view.dart +++ b/lib/presentation/views/main_menu/group_view/create_group_view.dart @@ -44,66 +44,68 @@ class _CreateGroupViewState extends State { @override Widget build(BuildContext context) { final loc = AppLocalizations.of(context); - return Scaffold( - backgroundColor: CustomTheme.backgroundColor, - appBar: AppBar(title: Text(loc.create_new_group)), - body: SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - margin: CustomTheme.standardMargin, - child: TextInputField( - controller: _groupNameController, - hintText: loc.group_name, + return ScaffoldMessenger( + child: Scaffold( + backgroundColor: CustomTheme.backgroundColor, + appBar: AppBar(title: Text(loc.create_new_group)), + body: SafeArea( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: CustomTheme.standardMargin, + child: TextInputField( + controller: _groupNameController, + hintText: loc.group_name, + ), ), - ), - Expanded( - child: PlayerSelection( - onChanged: (value) { - setState(() { - selectedPlayers = [...value]; - }); - }, + Expanded( + child: PlayerSelection( + onChanged: (value) { + setState(() { + selectedPlayers = [...value]; + }); + }, + ), ), - ), - CustomWidthButton( - text: loc.create_group, - sizeRelativeToWidth: 0.95, - buttonType: ButtonType.primary, - onPressed: - (_groupNameController.text.isEmpty || - (selectedPlayers.length < 2)) - ? null - : () async { - bool success = await db.groupDao.addGroup( - group: Group( - name: _groupNameController.text.trim(), - members: selectedPlayers, - ), - ); - if (!context.mounted) return; - if (success) { - Navigator.pop(context); - } else { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - backgroundColor: CustomTheme.boxColor, - content: Center( - child: Text( - AppLocalizations.of( - context, - ).error_creating_group, - style: const TextStyle(color: Colors.white), - ), - ), + CustomWidthButton( + text: loc.create_group, + sizeRelativeToWidth: 0.95, + buttonType: ButtonType.primary, + onPressed: + (_groupNameController.text.isEmpty || + (selectedPlayers.length < 2)) + ? null + : () async { + bool success = await db.groupDao.addGroup( + group: Group( + name: _groupNameController.text.trim(), + members: selectedPlayers, ), ); - } - }, - ), - const SizedBox(height: 20), - ], + if (!context.mounted) return; + if (success) { + Navigator.pop(context); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: CustomTheme.boxColor, + content: Center( + child: Text( + AppLocalizations.of( + context, + ).error_creating_group, + style: const TextStyle(color: Colors.white), + ), + ), + ), + ); + } + }, + ), + const SizedBox(height: 20), + ], + ), ), ), ); diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index dc6690b..518fd24 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -119,140 +119,142 @@ class _CreateMatchViewState extends State { @override Widget build(BuildContext context) { final loc = AppLocalizations.of(context); - return Scaffold( - backgroundColor: CustomTheme.backgroundColor, - appBar: AppBar(title: Text(loc.create_new_match)), - body: SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - margin: CustomTheme.tileMargin, - child: TextInputField( - controller: _matchNameController, - hintText: hintText ?? '', + return ScaffoldMessenger( + child: Scaffold( + backgroundColor: CustomTheme.backgroundColor, + appBar: AppBar(title: Text(loc.create_new_match)), + body: SafeArea( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: CustomTheme.tileMargin, + child: TextInputField( + controller: _matchNameController, + hintText: hintText ?? '', + ), ), - ), - ChooseTile( - title: loc.game, - trailingText: selectedGameIndex == -1 - ? loc.none - : games[selectedGameIndex].$1, - onPressed: () async { - selectedGameIndex = await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => ChooseGameView( - games: games, - initialGameIndex: selectedGameIndex, + ChooseTile( + title: loc.game, + trailingText: selectedGameIndex == -1 + ? loc.none + : games[selectedGameIndex].$1, + onPressed: () async { + selectedGameIndex = await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => ChooseGameView( + games: games, + initialGameIndex: selectedGameIndex, + ), ), - ), - ); - setState(() { - if (selectedGameIndex != -1) { - hintText = games[selectedGameIndex].$1; - selectedRuleset = games[selectedGameIndex].$3; - selectedRulesetIndex = _rulesets.indexWhere( - (r) => r.$1 == selectedRuleset, - ); - } else { - hintText = loc.match_name; - selectedRuleset = null; - } - }); - }, - ), - ChooseTile( - title: loc.ruleset, - trailingText: selectedRuleset == null - ? loc.none - : translateRulesetToString(selectedRuleset!, context), - onPressed: () async { - selectedRuleset = await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => ChooseRulesetView( - rulesets: _rulesets, - initialRulesetIndex: selectedRulesetIndex, - ), - ), - ); - if (!mounted) return; - selectedRulesetIndex = _rulesets.indexWhere( - (r) => r.$1 == selectedRuleset, - ); - selectedGameIndex = -1; - setState(() {}); - }, - ), - ChooseTile( - title: loc.group, - trailingText: selectedGroup == null - ? loc.none_group - : selectedGroup!.name, - onPressed: () async { - selectedGroup = await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => ChooseGroupView( - groups: groupsList, - initialGroupId: selectedGroupId, - ), - ), - ); - selectedGroupId = selectedGroup?.id ?? ''; - if (selectedGroup != null) { - filteredPlayerList = playerList - .where( - (p) => !selectedGroup!.members.any((m) => m.id == p.id), - ) - .toList(); - } else { - filteredPlayerList = List.from(playerList); - } - setState(() {}); - }, - ), - Expanded( - child: PlayerSelection( - key: ValueKey(selectedGroup?.id ?? 'no_group'), - initialSelectedPlayers: selectedPlayers ?? [], - availablePlayers: filteredPlayerList, - onChanged: (value) { + ); setState(() { - selectedPlayers = value; + if (selectedGameIndex != -1) { + hintText = games[selectedGameIndex].$1; + selectedRuleset = games[selectedGameIndex].$3; + selectedRulesetIndex = _rulesets.indexWhere( + (r) => r.$1 == selectedRuleset, + ); + } else { + hintText = loc.match_name; + selectedRuleset = null; + } }); }, ), - ), - CustomWidthButton( - text: loc.create_match, - sizeRelativeToWidth: 0.95, - buttonType: ButtonType.primary, - onPressed: _enableCreateGameButton() - ? () async { - Match match = Match( - name: _matchNameController.text.isEmpty - ? (hintText ?? '') - : _matchNameController.text.trim(), - createdAt: DateTime.now(), - group: selectedGroup, - players: selectedPlayers, - ); - await db.matchDao.addMatch(match: match); - if (context.mounted) { - Navigator.pushReplacement( - context, - CupertinoPageRoute( - fullscreenDialog: true, - builder: (context) => MatchResultView( - match: match, - onWinnerChanged: widget.onWinnerChanged, - ), - ), + ChooseTile( + title: loc.ruleset, + trailingText: selectedRuleset == null + ? loc.none + : translateRulesetToString(selectedRuleset!, context), + onPressed: () async { + selectedRuleset = await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => ChooseRulesetView( + rulesets: _rulesets, + initialRulesetIndex: selectedRulesetIndex, + ), + ), + ); + if (!mounted) return; + selectedRulesetIndex = _rulesets.indexWhere( + (r) => r.$1 == selectedRuleset, + ); + selectedGameIndex = -1; + setState(() {}); + }, + ), + ChooseTile( + title: loc.group, + trailingText: selectedGroup == null + ? loc.none_group + : selectedGroup!.name, + onPressed: () async { + selectedGroup = await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => ChooseGroupView( + groups: groupsList, + initialGroupId: selectedGroupId, + ), + ), + ); + selectedGroupId = selectedGroup?.id ?? ''; + if (selectedGroup != null) { + filteredPlayerList = playerList + .where( + (p) => !selectedGroup!.members.any((m) => m.id == p.id), + ) + .toList(); + } else { + filteredPlayerList = List.from(playerList); + } + setState(() {}); + }, + ), + Expanded( + child: PlayerSelection( + key: ValueKey(selectedGroup?.id ?? 'no_group'), + initialSelectedPlayers: selectedPlayers ?? [], + availablePlayers: filteredPlayerList, + onChanged: (value) { + setState(() { + selectedPlayers = value; + }); + }, + ), + ), + CustomWidthButton( + text: loc.create_match, + sizeRelativeToWidth: 0.95, + buttonType: ButtonType.primary, + onPressed: _enableCreateGameButton() + ? () async { + Match match = Match( + name: _matchNameController.text.isEmpty + ? (hintText ?? '') + : _matchNameController.text.trim(), + createdAt: DateTime.now(), + group: selectedGroup, + players: selectedPlayers, ); + await db.matchDao.addMatch(match: match); + if (context.mounted) { + Navigator.pushReplacement( + context, + CupertinoPageRoute( + fullscreenDialog: true, + builder: (context) => MatchResultView( + match: match, + onWinnerChanged: widget.onWinnerChanged, + ), + ), + ); + } } - } - : null, - ), - ], + : null, + ), + ], + ), ), ), ); diff --git a/lib/presentation/views/main_menu/settings_view.dart b/lib/presentation/views/main_menu/settings_view.dart index 374c463..c5fcfa2 100644 --- a/lib/presentation/views/main_menu/settings_view.dart +++ b/lib/presentation/views/main_menu/settings_view.dart @@ -21,105 +21,107 @@ class _SettingsViewState extends State { @override Widget build(BuildContext context) { final loc = AppLocalizations.of(context); - return Scaffold( - appBar: AppBar(backgroundColor: CustomTheme.backgroundColor), - backgroundColor: CustomTheme.backgroundColor, - body: LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) => - SingleChildScrollView( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(24, 0, 24, 10), - child: Text( - textAlign: TextAlign.start, - loc.menu, - style: const TextStyle( - fontSize: 28, - fontWeight: FontWeight.bold, - ), - ), - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 24, - vertical: 10, - ), - child: Text( - textAlign: TextAlign.start, - loc.settings, - style: const TextStyle( - fontSize: 22, - fontWeight: FontWeight.bold, - ), - ), - ), - SettingsListTile( - title: loc.export_data, - icon: Icons.upload_rounded, - suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), - onPressed: () async { - final String json = - await DataTransferService.getAppDataAsJson(context); - final result = await DataTransferService.exportData( - json, - 'game_tracker-data', - ); - if (!context.mounted) return; - showExportSnackBar(context: context, result: result); - }, - ), - SettingsListTile( - title: loc.import_data, - icon: Icons.download_rounded, - suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), - onPressed: () async { - final result = await DataTransferService.importData( - context, - ); - if (!context.mounted) return; - showImportSnackBar(context: context, result: result); - }, - ), - SettingsListTile( - title: loc.delete_all_data, - icon: Icons.delete_rounded, - suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), - onPressed: () { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text(loc.delete_all_data), - content: Text(loc.this_cannot_be_undone), - actions: [ - TextButton( - onPressed: () => Navigator.of(context).pop(false), - child: Text(loc.cancel), - ), - TextButton( - onPressed: () => Navigator.of(context).pop(true), - child: Text(loc.delete), - ), - ], + return ScaffoldMessenger( + child: Scaffold( + appBar: AppBar(backgroundColor: CustomTheme.backgroundColor), + backgroundColor: CustomTheme.backgroundColor, + body: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) => + SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(24, 0, 24, 10), + child: Text( + textAlign: TextAlign.start, + loc.menu, + style: const TextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, ), - ).then((confirmed) { - if (confirmed == true && context.mounted) { - DataTransferService.deleteAllData(context); - showSnackbar( - context: context, - message: AppLocalizations.of( - context, - ).data_successfully_deleted, - ); - } - }); - }, - ), - ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 24, + vertical: 10, + ), + child: Text( + textAlign: TextAlign.start, + loc.settings, + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + ), + ), + ), + SettingsListTile( + title: loc.export_data, + icon: Icons.upload_rounded, + suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), + onPressed: () async { + final String json = + await DataTransferService.getAppDataAsJson(context); + final result = await DataTransferService.exportData( + json, + 'game_tracker-data', + ); + if (!context.mounted) return; + showExportSnackBar(context: context, result: result); + }, + ), + SettingsListTile( + title: loc.import_data, + icon: Icons.download_rounded, + suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), + onPressed: () async { + final result = await DataTransferService.importData( + context, + ); + if (!context.mounted) return; + showImportSnackBar(context: context, result: result); + }, + ), + SettingsListTile( + title: loc.delete_all_data, + icon: Icons.delete_rounded, + suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), + onPressed: () { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(loc.delete_all_data), + content: Text(loc.this_cannot_be_undone), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(false), + child: Text(loc.cancel), + ), + TextButton( + onPressed: () => Navigator.of(context).pop(true), + child: Text(loc.delete), + ), + ], + ), + ).then((confirmed) { + if (confirmed == true && context.mounted) { + DataTransferService.deleteAllData(context); + showSnackbar( + context: context, + message: AppLocalizations.of( + context, + ).data_successfully_deleted, + ); + } + }); + }, + ), + ], + ), ), - ), + ), ), ); } From a4ef9705f950042bd4a73d0b6df4f15327314424 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Fri, 9 Jan 2026 22:22:26 +0100 Subject: [PATCH 2/9] made PageRoutes adapt to os, default to MaterialPageRoute --- .../main_menu/custom_navigation_bar.dart | 5 +++- .../main_menu/group_view/groups_view.dart | 9 +++++++- .../create_match/create_match_view.dart | 23 ++++++++++++++++--- .../main_menu/match_view/match_view.dart | 5 +++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/lib/presentation/views/main_menu/custom_navigation_bar.dart b/lib/presentation/views/main_menu/custom_navigation_bar.dart index a8b18c8..17eeb41 100644 --- a/lib/presentation/views/main_menu/custom_navigation_bar.dart +++ b/lib/presentation/views/main_menu/custom_navigation_bar.dart @@ -1,3 +1,6 @@ +import 'dart:io'; + +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/l10n/generated/app_localizations.dart'; @@ -56,7 +59,7 @@ class _CustomNavigationBarState extends State onPressed: () async { await Navigator.push( context, - MaterialPageRoute(builder: (_) => const SettingsView()), + Platform.isIOS ? CupertinoPageRoute(builder: (_) => const SettingsView()) : MaterialPageRoute(builder: (_) => const SettingsView()), ); setState(() { tabKeyCount++; diff --git a/lib/presentation/views/main_menu/group_view/groups_view.dart b/lib/presentation/views/main_menu/group_view/groups_view.dart index 57d05a4..d19028f 100644 --- a/lib/presentation/views/main_menu/group_view/groups_view.dart +++ b/lib/presentation/views/main_menu/group_view/groups_view.dart @@ -1,3 +1,6 @@ +import 'dart:io'; + +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:game_tracker/core/constants.dart'; import 'package:game_tracker/core/custom_theme.dart'; @@ -85,7 +88,11 @@ class _GroupsViewState extends State { onPressed: () async { await Navigator.push( context, - MaterialPageRoute( + Platform.isIOS ? CupertinoPageRoute( + builder: (context) { + return const CreateGroupView(); + }, + ) : MaterialPageRoute( builder: (context) { return const CreateGroupView(); }, diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index dc6690b..cff066d 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:game_tracker/core/custom_theme.dart'; @@ -140,7 +142,12 @@ class _CreateMatchViewState extends State { : games[selectedGameIndex].$1, onPressed: () async { selectedGameIndex = await Navigator.of(context).push( - MaterialPageRoute( + Platform.isIOS ? CupertinoPageRoute( + builder: (context) => ChooseGameView( + games: games, + initialGameIndex: selectedGameIndex, + ), + ) : MaterialPageRoute( builder: (context) => ChooseGameView( games: games, initialGameIndex: selectedGameIndex, @@ -168,7 +175,12 @@ class _CreateMatchViewState extends State { : translateRulesetToString(selectedRuleset!, context), onPressed: () async { selectedRuleset = await Navigator.of(context).push( - MaterialPageRoute( + Platform.isIOS ? CupertinoPageRoute( + builder: (context) => ChooseRulesetView( + rulesets: _rulesets, + initialRulesetIndex: selectedRulesetIndex, + ), + ) : MaterialPageRoute( builder: (context) => ChooseRulesetView( rulesets: _rulesets, initialRulesetIndex: selectedRulesetIndex, @@ -190,7 +202,12 @@ class _CreateMatchViewState extends State { : selectedGroup!.name, onPressed: () async { selectedGroup = await Navigator.of(context).push( - MaterialPageRoute( + Platform.isIOS ? CupertinoPageRoute( + builder: (context) => ChooseGroupView( + groups: groupsList, + initialGroupId: selectedGroupId, + ), + ): MaterialPageRoute( builder: (context) => ChooseGroupView( groups: groupsList, initialGroupId: selectedGroupId, diff --git a/lib/presentation/views/main_menu/match_view/match_view.dart b/lib/presentation/views/main_menu/match_view/match_view.dart index 45b957f..55d35c6 100644 --- a/lib/presentation/views/main_menu/match_view/match_view.dart +++ b/lib/presentation/views/main_menu/match_view/match_view.dart @@ -1,4 +1,5 @@ import 'dart:core' hide Match; +import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -105,7 +106,9 @@ class _MatchViewState extends State { onPressed: () async { Navigator.push( context, - MaterialPageRoute( + Platform.isIOS ? CupertinoPageRoute( + builder: (context) => + CreateMatchView(onWinnerChanged: loadGames)) : MaterialPageRoute( builder: (context) => CreateMatchView(onWinnerChanged: loadGames), ), From db3e8215fa48308b8a892309d53e6e7f890e91c3 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sat, 10 Jan 2026 13:42:09 +0100 Subject: [PATCH 3/9] Added ios swipe back gesture --- lib/main.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 1dee10b..8889755 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -44,6 +44,9 @@ class GameTracker extends StatelessWidget { seedColor: CustomTheme.primaryColor, brightness: Brightness.dark, ).copyWith(surface: CustomTheme.backgroundColor), + pageTransitionsTheme: const PageTransitionsTheme( + builders: {TargetPlatform.iOS: CupertinoPageTransitionsBuilder()}, + ), ), home: const CustomNavigationBar(), ); From 66b90aac25871ac5afea2b7db3c91f2f7ddf283d Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sat, 10 Jan 2026 14:09:08 +0100 Subject: [PATCH 4/9] Fixed issue with android page transition --- lib/main.dart | 5 ++++- pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 8889755..8fdd4e4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -45,7 +45,10 @@ class GameTracker extends StatelessWidget { brightness: Brightness.dark, ).copyWith(surface: CustomTheme.backgroundColor), pageTransitionsTheme: const PageTransitionsTheme( - builders: {TargetPlatform.iOS: CupertinoPageTransitionsBuilder()}, + builders: { + TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), + TargetPlatform.android: FadeForwardsPageTransitionsBuilder(), + }, ), ), home: const CustomNavigationBar(), diff --git a/pubspec.yaml b/pubspec.yaml index e79ca17..4944deb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: game_tracker description: "Game Tracking App for Card Games" publish_to: 'none' -version: 0.0.1+21 +version: 0.0.1+33 environment: sdk: ^3.8.1 From 6faafe9fab327d4e4cfd782dbec8954cc31441a0 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sat, 10 Jan 2026 14:16:16 +0100 Subject: [PATCH 5/9] Changed android page transition to Android U transition --- lib/main.dart | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 8fdd4e4..2f64e2e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -47,7 +47,7 @@ class GameTracker extends StatelessWidget { pageTransitionsTheme: const PageTransitionsTheme( builders: { TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), - TargetPlatform.android: FadeForwardsPageTransitionsBuilder(), + TargetPlatform.android: PredictiveBackPageTransitionsBuilder(), }, ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 4944deb..26253fd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: game_tracker description: "Game Tracking App for Card Games" publish_to: 'none' -version: 0.0.1+33 +version: 0.0.1+37 environment: sdk: ^3.8.1 From d67972624e25227ce6fd7a64cb9fad7b3bfac1d4 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Sat, 10 Jan 2026 14:44:33 +0100 Subject: [PATCH 6/9] replaced ternary operator solution with custom adaptive_page_route.dart --- lib/core/adaptive_page_route.dart | 19 ++++++++++++++ lib/main.dart | 3 ++- .../main_menu/custom_navigation_bar.dart | 5 ++-- .../main_menu/group_view/groups_view.dart | 9 ++----- .../create_match/create_match_view.dart | 26 ++++--------------- .../main_menu/match_view/match_view.dart | 12 +++------ 6 files changed, 34 insertions(+), 40 deletions(-) create mode 100644 lib/core/adaptive_page_route.dart diff --git a/lib/core/adaptive_page_route.dart b/lib/core/adaptive_page_route.dart new file mode 100644 index 0000000..631f000 --- /dev/null +++ b/lib/core/adaptive_page_route.dart @@ -0,0 +1,19 @@ +import 'dart:io'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +Route AdaptivePageRoute({ + required Widget Function(BuildContext) builder, + bool fullscreenDialog = false, +}) { + if (Platform.isIOS) { + return CupertinoPageRoute( + builder: builder, + fullscreenDialog: fullscreenDialog, + ); + } + return MaterialPageRoute( + builder: builder, + fullscreenDialog: fullscreenDialog, + ); +} diff --git a/lib/main.dart b/lib/main.dart index 8889755..9b9683d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -45,7 +45,8 @@ class GameTracker extends StatelessWidget { brightness: Brightness.dark, ).copyWith(surface: CustomTheme.backgroundColor), pageTransitionsTheme: const PageTransitionsTheme( - builders: {TargetPlatform.iOS: CupertinoPageTransitionsBuilder()}, + builders: {TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), TargetPlatform.android: PredictiveBackPageTransitionsBuilder() + }, ), ), home: const CustomNavigationBar(), diff --git a/lib/presentation/views/main_menu/custom_navigation_bar.dart b/lib/presentation/views/main_menu/custom_navigation_bar.dart index 17eeb41..4850e5a 100644 --- a/lib/presentation/views/main_menu/custom_navigation_bar.dart +++ b/lib/presentation/views/main_menu/custom_navigation_bar.dart @@ -1,7 +1,6 @@ -import 'dart:io'; - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/l10n/generated/app_localizations.dart'; import 'package:game_tracker/presentation/views/main_menu/group_view/groups_view.dart'; @@ -59,7 +58,7 @@ class _CustomNavigationBarState extends State onPressed: () async { await Navigator.push( context, - Platform.isIOS ? CupertinoPageRoute(builder: (_) => const SettingsView()) : MaterialPageRoute(builder: (_) => const SettingsView()), + AdaptivePageRoute(builder: (_) => const SettingsView()), ); setState(() { tabKeyCount++; diff --git a/lib/presentation/views/main_menu/group_view/groups_view.dart b/lib/presentation/views/main_menu/group_view/groups_view.dart index d19028f..ce9f697 100644 --- a/lib/presentation/views/main_menu/group_view/groups_view.dart +++ b/lib/presentation/views/main_menu/group_view/groups_view.dart @@ -1,7 +1,6 @@ -import 'dart:io'; - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/constants.dart'; import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/data/db/database.dart'; @@ -88,11 +87,7 @@ class _GroupsViewState extends State { onPressed: () async { await Navigator.push( context, - Platform.isIOS ? CupertinoPageRoute( - builder: (context) { - return const CreateGroupView(); - }, - ) : MaterialPageRoute( + AdaptivePageRoute( builder: (context) { return const CreateGroupView(); }, diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index cff066d..77fe6b9 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -1,7 +1,6 @@ -import 'dart:io'; - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/data/db/database.dart'; @@ -142,12 +141,7 @@ class _CreateMatchViewState extends State { : games[selectedGameIndex].$1, onPressed: () async { selectedGameIndex = await Navigator.of(context).push( - Platform.isIOS ? CupertinoPageRoute( - builder: (context) => ChooseGameView( - games: games, - initialGameIndex: selectedGameIndex, - ), - ) : MaterialPageRoute( + AdaptivePageRoute( builder: (context) => ChooseGameView( games: games, initialGameIndex: selectedGameIndex, @@ -175,12 +169,7 @@ class _CreateMatchViewState extends State { : translateRulesetToString(selectedRuleset!, context), onPressed: () async { selectedRuleset = await Navigator.of(context).push( - Platform.isIOS ? CupertinoPageRoute( - builder: (context) => ChooseRulesetView( - rulesets: _rulesets, - initialRulesetIndex: selectedRulesetIndex, - ), - ) : MaterialPageRoute( + AdaptivePageRoute( builder: (context) => ChooseRulesetView( rulesets: _rulesets, initialRulesetIndex: selectedRulesetIndex, @@ -202,12 +191,7 @@ class _CreateMatchViewState extends State { : selectedGroup!.name, onPressed: () async { selectedGroup = await Navigator.of(context).push( - Platform.isIOS ? CupertinoPageRoute( - builder: (context) => ChooseGroupView( - groups: groupsList, - initialGroupId: selectedGroupId, - ), - ): MaterialPageRoute( + AdaptivePageRoute( builder: (context) => ChooseGroupView( groups: groupsList, initialGroupId: selectedGroupId, @@ -257,7 +241,7 @@ class _CreateMatchViewState extends State { if (context.mounted) { Navigator.pushReplacement( context, - CupertinoPageRoute( + AdaptivePageRoute( fullscreenDialog: true, builder: (context) => MatchResultView( match: match, diff --git a/lib/presentation/views/main_menu/match_view/match_view.dart b/lib/presentation/views/main_menu/match_view/match_view.dart index 55d35c6..6797ffc 100644 --- a/lib/presentation/views/main_menu/match_view/match_view.dart +++ b/lib/presentation/views/main_menu/match_view/match_view.dart @@ -1,8 +1,7 @@ import 'dart:core' hide Match; -import 'dart:io'; - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/constants.dart'; import 'package:game_tracker/core/custom_theme.dart'; import 'package:game_tracker/data/db/database.dart'; @@ -83,7 +82,7 @@ class _MatchViewState extends State { onTap: () async { Navigator.push( context, - CupertinoPageRoute( + AdaptivePageRoute( fullscreenDialog: true, builder: (context) => MatchResultView( match: matches[index], @@ -106,12 +105,9 @@ class _MatchViewState extends State { onPressed: () async { Navigator.push( context, - Platform.isIOS ? CupertinoPageRoute( + AdaptivePageRoute( builder: (context) => - CreateMatchView(onWinnerChanged: loadGames)) : MaterialPageRoute( - builder: (context) => - CreateMatchView(onWinnerChanged: loadGames), - ), + CreateMatchView(onWinnerChanged: loadGames)) ); }, ), From 97ca62b083760766c588f80c766073cebee31c10 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Sat, 10 Jan 2026 14:52:59 +0100 Subject: [PATCH 7/9] refactor: rename AdaptivePageRoute to adaptivePageRoute for lowerCamelCase --- lib/core/adaptive_page_route.dart | 2 +- .../views/main_menu/custom_navigation_bar.dart | 3 +-- .../views/main_menu/group_view/groups_view.dart | 3 +-- .../match_view/create_match/create_match_view.dart | 9 ++++----- .../views/main_menu/match_view/match_view.dart | 5 ++--- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/core/adaptive_page_route.dart b/lib/core/adaptive_page_route.dart index 631f000..ba68557 100644 --- a/lib/core/adaptive_page_route.dart +++ b/lib/core/adaptive_page_route.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -Route AdaptivePageRoute({ +Route adaptivePageRoute({ required Widget Function(BuildContext) builder, bool fullscreenDialog = false, }) { diff --git a/lib/presentation/views/main_menu/custom_navigation_bar.dart b/lib/presentation/views/main_menu/custom_navigation_bar.dart index 4850e5a..0693189 100644 --- a/lib/presentation/views/main_menu/custom_navigation_bar.dart +++ b/lib/presentation/views/main_menu/custom_navigation_bar.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/custom_theme.dart'; @@ -58,7 +57,7 @@ class _CustomNavigationBarState extends State onPressed: () async { await Navigator.push( context, - AdaptivePageRoute(builder: (_) => const SettingsView()), + adaptivePageRoute(builder: (_) => const SettingsView()), ); setState(() { tabKeyCount++; diff --git a/lib/presentation/views/main_menu/group_view/groups_view.dart b/lib/presentation/views/main_menu/group_view/groups_view.dart index ce9f697..239aa23 100644 --- a/lib/presentation/views/main_menu/group_view/groups_view.dart +++ b/lib/presentation/views/main_menu/group_view/groups_view.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/constants.dart'; @@ -87,7 +86,7 @@ class _GroupsViewState extends State { onPressed: () async { await Navigator.push( context, - AdaptivePageRoute( + adaptivePageRoute( builder: (context) { return const CreateGroupView(); }, diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index 77fe6b9..281928e 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/custom_theme.dart'; @@ -141,7 +140,7 @@ class _CreateMatchViewState extends State { : games[selectedGameIndex].$1, onPressed: () async { selectedGameIndex = await Navigator.of(context).push( - AdaptivePageRoute( + adaptivePageRoute( builder: (context) => ChooseGameView( games: games, initialGameIndex: selectedGameIndex, @@ -169,7 +168,7 @@ class _CreateMatchViewState extends State { : translateRulesetToString(selectedRuleset!, context), onPressed: () async { selectedRuleset = await Navigator.of(context).push( - AdaptivePageRoute( + adaptivePageRoute( builder: (context) => ChooseRulesetView( rulesets: _rulesets, initialRulesetIndex: selectedRulesetIndex, @@ -191,7 +190,7 @@ class _CreateMatchViewState extends State { : selectedGroup!.name, onPressed: () async { selectedGroup = await Navigator.of(context).push( - AdaptivePageRoute( + adaptivePageRoute( builder: (context) => ChooseGroupView( groups: groupsList, initialGroupId: selectedGroupId, @@ -241,7 +240,7 @@ class _CreateMatchViewState extends State { if (context.mounted) { Navigator.pushReplacement( context, - AdaptivePageRoute( + adaptivePageRoute( fullscreenDialog: true, builder: (context) => MatchResultView( match: match, diff --git a/lib/presentation/views/main_menu/match_view/match_view.dart b/lib/presentation/views/main_menu/match_view/match_view.dart index 6797ffc..1781302 100644 --- a/lib/presentation/views/main_menu/match_view/match_view.dart +++ b/lib/presentation/views/main_menu/match_view/match_view.dart @@ -1,5 +1,4 @@ import 'dart:core' hide Match; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/constants.dart'; @@ -82,7 +81,7 @@ class _MatchViewState extends State { onTap: () async { Navigator.push( context, - AdaptivePageRoute( + adaptivePageRoute( fullscreenDialog: true, builder: (context) => MatchResultView( match: matches[index], @@ -105,7 +104,7 @@ class _MatchViewState extends State { onPressed: () async { Navigator.push( context, - AdaptivePageRoute( + adaptivePageRoute( builder: (context) => CreateMatchView(onWinnerChanged: loadGames)) ); From 54ec865f04298ee0dfa3652dd5ab8f81c95405b7 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Sat, 10 Jan 2026 15:00:33 +0100 Subject: [PATCH 8/9] fix merge issues --- .../match_view/create_match/create_match_view.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index 134906e..9740b92 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -142,7 +142,7 @@ class _CreateMatchViewState extends State { : games[selectedGameIndex].$1, onPressed: () async { selectedGameIndex = await Navigator.of(context).push( - MaterialPageRoute( + adaptivePageRoute( builder: (context) => ChooseGameView( games: games, initialGameIndex: selectedGameIndex, @@ -170,7 +170,7 @@ class _CreateMatchViewState extends State { : translateRulesetToString(selectedRuleset!, context), onPressed: () async { selectedRuleset = await Navigator.of(context).push( - MaterialPageRoute( + adaptivePageRoute( builder: (context) => ChooseRulesetView( rulesets: _rulesets, initialRulesetIndex: selectedRulesetIndex, @@ -192,7 +192,7 @@ class _CreateMatchViewState extends State { : selectedGroup!.name, onPressed: () async { selectedGroup = await Navigator.of(context).push( - MaterialPageRoute( + adaptivePageRoute( builder: (context) => ChooseGroupView( groups: groupsList, initialGroupId: selectedGroupId, @@ -242,7 +242,7 @@ class _CreateMatchViewState extends State { if (context.mounted) { Navigator.pushReplacement( context, - CupertinoPageRoute( + adaptivePageRoute( fullscreenDialog: true, builder: (context) => MatchResultView( match: match, From 9eb9c0eb7f4493f546cd74b37ec8c2ff8f400e30 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Sat, 10 Jan 2026 15:02:01 +0100 Subject: [PATCH 9/9] remove unneccessary import --- .../main_menu/match_view/create_match/create_match_view.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index 9740b92..b9885a4 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/custom_theme.dart';