From fadc99564ff6ea2a05c31b863ee224c833ac0853 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Wed, 23 Jul 2025 11:26:09 +0200 Subject: [PATCH 1/2] Fixed bug with playing confetti on cancel button --- lib/presentation/views/active_game_view.dart | 2 ++ lib/presentation/views/round_view.dart | 2 +- pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/presentation/views/active_game_view.dart b/lib/presentation/views/active_game_view.dart index ff9e066..d428f1c 100644 --- a/lib/presentation/views/active_game_view.dart +++ b/lib/presentation/views/active_game_view.dart @@ -453,6 +453,8 @@ class _ActiveGameViewState extends State { ), ); + if (round == -1) return; + if (widget.gameSession.isGameFinished && context.mounted) { _playFinishAnimation(context); } diff --git a/lib/presentation/views/round_view.dart b/lib/presentation/views/round_view.dart index d2a9da5..45249b4 100644 --- a/lib/presentation/views/round_view.dart +++ b/lib/presentation/views/round_view.dart @@ -80,7 +80,7 @@ class _RoundViewState extends State { padding: EdgeInsets.zero, onPressed: () => { LocalStorageService.saveGameSessions(), - Navigator.pop(context) + Navigator.pop(context, -1) }, child: Text(AppLocalizations.of(context).cancel), ), diff --git a/pubspec.yaml b/pubspec.yaml index 2ea3c92..367411f 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.5.3+594 +version: 0.5.3+595 environment: sdk: ^3.5.4 From 237af7e3dc8abeb72e558a5e4cdc1e53749926f2 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Wed, 23 Jul 2025 11:33:57 +0200 Subject: [PATCH 2/2] Added constant and updated docs --- lib/presentation/views/active_game_view.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/presentation/views/active_game_view.dart b/lib/presentation/views/active_game_view.dart index d428f1c..b05daba 100644 --- a/lib/presentation/views/active_game_view.dart +++ b/lib/presentation/views/active_game_view.dart @@ -24,11 +24,19 @@ class ActiveGameView extends StatefulWidget { } class _ActiveGameViewState extends State { + /// Constant value to represent a press on the cancel button in round view. + static const int kRoundCancelled = -1; + final confettiController = ConfettiController( duration: const Duration(seconds: 10), ); + late final GameSession gameSession; + + /// A list of the ranks for each player corresponding to their index in sortedPlayerIndices late List denseRanks; + + /// A list of player indices sorted by their scores in ascending order. late List sortedPlayerIndices; @override @@ -453,7 +461,8 @@ class _ActiveGameViewState extends State { ), ); - if (round == -1) return; + // If the user presses the cancel button + if (round == kRoundCancelled) return; if (widget.gameSession.isGameFinished && context.mounted) { _playFinishAnimation(context);