diff --git a/lib/views/active_game_view.dart b/lib/views/active_game_view.dart index 68dfeeb..5945a3e 100644 --- a/lib/views/active_game_view.dart +++ b/lib/views/active_game_view.dart @@ -105,17 +105,7 @@ class _ActiveGameViewState extends State { : const Text('\u{23F3}', style: TextStyle(fontSize: 22)), onTap: () async { - // ignore: unused_local_variable - final val = await Navigator.of(context, - rootNavigator: true) - .push( - CupertinoPageRoute( - fullscreenDialog: true, - builder: (context) => RoundView( - gameSession: gameSession, - roundNumber: index + 1), - ), - ); + _openRoundView(index + 1); }, )); }, @@ -362,4 +352,25 @@ class _ActiveGameViewState extends State { }); } } + + /// Recursively opens the RoundView for the specified round number. + /// It starts with the given [roundNumber] and continues to open the next round + /// until the user navigates back or the round number is invalid. + void _openRoundView(int roundNumber) async { + final val = await Navigator.of(context, rootNavigator: true).push( + CupertinoPageRoute( + fullscreenDialog: true, + builder: (context) => RoundView( + gameSession: gameSession, + roundNumber: roundNumber, + ), + ), + ); + if (val != null && val >= 0) { + WidgetsBinding.instance.addPostFrameCallback((_) async { + await Future.delayed(const Duration(milliseconds: 600)); + _openRoundView(val); + }); + } + } } diff --git a/lib/views/round_view.dart b/lib/views/round_view.dart index c40db1b..beb6577 100644 --- a/lib/views/round_view.dart +++ b/lib/views/round_view.dart @@ -290,7 +290,7 @@ class _RoundViewState extends State { ? () { _finishRound(); LocalStorageService.saveGameSessions(); - Navigator.pop(context, widget.gameSession); + Navigator.pop(context, -1); } : null, child: Text(AppLocalizations.of(context).done), @@ -301,17 +301,10 @@ class _RoundViewState extends State { _finishRound(); LocalStorageService.saveGameSessions(); if (widget.gameSession.isGameFinished == true) { - Navigator.pop(context, widget.gameSession); + Navigator.pop(context, -1); } else { - Navigator.of(context, rootNavigator: true) - .pushReplacement( - CupertinoPageRoute( - builder: (context) => RoundView( - gameSession: widget.gameSession, - roundNumber: widget.roundNumber + 1, - ), - ), - ); + Navigator.pop( + context, widget.roundNumber + 1); } } : null, diff --git a/pubspec.yaml b/pubspec.yaml index 7ac98ec..006a846 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.3.8+327 +version: 0.3.9+330 environment: sdk: ^3.5.4