Skip to content

Commit

Permalink
Restore CupertinoAlertDialog on game screen
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Feb 4, 2025
1 parent 9916ed5 commit f789267
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions lib/src/view/game/game_result_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,10 @@ class GameResultDialog extends ConsumerStatefulWidget {
final void Function(PlayableGame game) onNewOpponentCallback;

@override
ConsumerState<GameResultDialog> createState() => _GameEndDialogState();
ConsumerState<GameResultDialog> createState() => _GameResultDialogState();
}

Widget _adaptiveDialog(BuildContext context, Widget content) {
final screenWidth = MediaQuery.of(context).size.width;
final paddedContent = Padding(padding: const EdgeInsets.all(16.0), child: content);
return Dialog(
child: SizedBox(
width: min(screenWidth, kMaterialPopupMenuMaxWidth),
child:
Theme.of(context).platform == TargetPlatform.iOS
? CupertinoPopupSurface(child: paddedContent)
: paddedContent,
),
);
}

class _GameEndDialogState extends ConsumerState<GameResultDialog> {
class _GameResultDialogState extends ConsumerState<GameResultDialog> {
late Timer _buttonActivationTimer;
bool _activateButtons = false;

Expand Down Expand Up @@ -332,3 +318,15 @@ class GameResult extends StatelessWidget {
);
}
}

Widget _adaptiveDialog(BuildContext context, Widget content) {
final screenWidth = MediaQuery.of(context).size.width;
final paddedContent = Padding(padding: const EdgeInsets.all(16.0), child: content);
final sizedContent = SizedBox(
width: min(screenWidth, kMaterialPopupMenuMaxWidth),
child: paddedContent,
);
return Theme.of(context).platform == TargetPlatform.iOS
? CupertinoAlertDialog(content: sizedContent)
: Dialog(child: sizedContent);
}

0 comments on commit f789267

Please sign in to comment.