Merge pull request #84 from flixcoo/enhance/56-disruptive-animation

Implemented openRoundView method
This commit is contained in:
2025-07-08 21:54:25 +02:00
committed by GitHub
3 changed files with 29 additions and 27 deletions

View File

@@ -105,17 +105,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
: const Text('\u{23F3}', : const Text('\u{23F3}',
style: TextStyle(fontSize: 22)), style: TextStyle(fontSize: 22)),
onTap: () async { onTap: () async {
// ignore: unused_local_variable _openRoundView(index + 1);
final val = await Navigator.of(context,
rootNavigator: true)
.push(
CupertinoPageRoute(
fullscreenDialog: true,
builder: (context) => RoundView(
gameSession: gameSession,
roundNumber: index + 1),
),
);
}, },
)); ));
}, },
@@ -362,4 +352,25 @@ class _ActiveGameViewState extends State<ActiveGameView> {
}); });
} }
} }
/// 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);
});
}
}
} }

View File

@@ -76,10 +76,8 @@ class _RoundViewState extends State<RoundView> {
middle: Text(AppLocalizations.of(context).results), middle: Text(AppLocalizations.of(context).results),
leading: CupertinoButton( leading: CupertinoButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: () => { onPressed: () =>
LocalStorageService.saveGameSessions(), {LocalStorageService.saveGameSessions(), Navigator.pop(context)},
Navigator.pop(context, widget.gameSession)
},
child: Text(AppLocalizations.of(context).cancel), child: Text(AppLocalizations.of(context).cancel),
), ),
), ),
@@ -290,7 +288,7 @@ class _RoundViewState extends State<RoundView> {
? () { ? () {
_finishRound(); _finishRound();
LocalStorageService.saveGameSessions(); LocalStorageService.saveGameSessions();
Navigator.pop(context, widget.gameSession); Navigator.pop(context);
} }
: null, : null,
child: Text(AppLocalizations.of(context).done), child: Text(AppLocalizations.of(context).done),
@@ -301,17 +299,10 @@ class _RoundViewState extends State<RoundView> {
_finishRound(); _finishRound();
LocalStorageService.saveGameSessions(); LocalStorageService.saveGameSessions();
if (widget.gameSession.isGameFinished == true) { if (widget.gameSession.isGameFinished == true) {
Navigator.pop(context, widget.gameSession); Navigator.pop(context);
} else { } else {
Navigator.of(context, rootNavigator: true) Navigator.pop(
.pushReplacement( context, widget.roundNumber + 1);
CupertinoPageRoute(
builder: (context) => RoundView(
gameSession: widget.gameSession,
roundNumber: widget.roundNumber + 1,
),
),
);
} }
} }
: null, : null,

View File

@@ -2,7 +2,7 @@ name: cabo_counter
description: "Mobile app for the card game Cabo" description: "Mobile app for the card game Cabo"
publish_to: 'none' publish_to: 'none'
version: 0.3.8+327 version: 0.3.9+331
environment: environment:
sdk: ^3.5.4 sdk: ^3.5.4