Skip to content

Commit

Permalink
Animated version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimima committed Nov 13, 2024
1 parent d5b88bc commit eec9d65
Showing 1 changed file with 61 additions and 19 deletions.
80 changes: 61 additions & 19 deletions lib/src/view/game/game_result_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class _GameEndDialogState extends ConsumerState<GameResultDialog> {
final session = ref.watch(authSessionProvider);
final currentGameAnalysis = ref.watch(currentAnalysisProvider);

final ValueNotifier<bool> animationFinished = ValueNotifier(false);

final content = Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
Expand All @@ -122,6 +124,33 @@ class _GameEndDialogState extends ConsumerState<GameResultDialog> {
padding: const EdgeInsets.only(bottom: 16.0),
child: PlayerSummary(game: gameState.game),
),
AnimatedContainer(
duration: const Duration(milliseconds: 400),
onEnd: () {
animationFinished.value = true;
},
height: gameState.game.opponent?.offeringRematch ?? false
? 50
: 0,
child: ValueListenableBuilder<bool>(
valueListenable: animationFinished,
builder: (context, value, child) {
return Visibility(
maintainAnimation: true,
maintainSize: true,
maintainState: true,
visible: animationFinished.value,
child: const Padding(
padding: EdgeInsets.only(bottom: 16.0),
child: Text(
'Your opponent has offered a rematch',
textAlign: TextAlign.center,
),
),
);
},
),
),
if (gameState.game.me?.offeringRematch == true)
SecondaryButton(
semanticsLabel: context.l10n.cancelRematchOffer,
Expand All @@ -134,25 +163,38 @@ class _GameEndDialogState extends ConsumerState<GameResultDialog> {
),
)
else if (gameState.game.opponent?.offeringRematch == true)
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Text("Rematch offered"),
FatButton(
semanticsLabel: context.l10n.rematch,
child: const Text('Accept rematch'),
onPressed: () {
ref.read(ctrlProvider.notifier).proposeOrAcceptRematch();
},
),
SecondaryButton(
semanticsLabel: context.l10n.rematch,
child: const Text('Decline'),
onPressed: () {
ref.read(ctrlProvider.notifier).declineRematch();
},
),
],
ValueListenableBuilder(
valueListenable: animationFinished,
builder: (BuildContext context, value, Widget? child) {
return Visibility(
maintainAnimation: true,
maintainSize: true,
maintainState: true,
visible: animationFinished.value,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Text("Rematch offered"),
FatButton(
semanticsLabel: context.l10n.rematch,
child: const Text('Accept rematch'),
onPressed: () {
ref
.read(ctrlProvider.notifier)
.proposeOrAcceptRematch();
},
),
SecondaryButton(
semanticsLabel: context.l10n.rematch,
child: const Text('Decline'),
onPressed: () {
ref.read(ctrlProvider.notifier).declineRematch();
},
),
],
),
);
},
)
else if (gameState.canOfferRematch)
SecondaryButton(
Expand Down

0 comments on commit eec9d65

Please sign in to comment.