refactor: move user score to gameover dialog

pull/98/head
RuiAlonso 4 years ago
parent 81396d337f
commit d2534c89eb

@ -70,7 +70,10 @@ class _PinballGameViewState extends State<PinballGameView> {
showDialog<void>( showDialog<void>(
context: context, context: context,
builder: (_) { builder: (_) {
return const GameOverDialog(); return GameOverDialog(
score: state.score,
theme: widget.theme.characterTheme,
);
}, },
); );
} }

@ -1,21 +1,38 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pinball/game/game.dart'; import 'package:pinball/game/game.dart';
import 'package:pinball_theme/pinball_theme.dart';
/// {@template game_over_dialog} /// {@template game_over_dialog}
/// [Dialog] displayed when the [PinballGame] is over. /// [Dialog] displayed when the [PinballGame] is over.
/// {@endtemplate} /// {@endtemplate}
class GameOverDialog extends StatelessWidget { class GameOverDialog extends StatelessWidget {
/// {@macro game_over_dialog} /// {@macro game_over_dialog}
const GameOverDialog({Key? key}) : super(key: key); const GameOverDialog({Key? key, required this.score, required this.theme})
: super(key: key);
final int score;
final CharacterTheme theme;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const Dialog( return Dialog(
child: SizedBox( child: SizedBox(
width: 200, width: 200,
height: 200, height: 200,
child: Center( child: Center(
child: Text('Game Over'), child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('Game Over'),
Text('Congratulations! your score is $score'),
TextButton(
onPressed: () {
//TODO: navigate to LeadersboardPage
},
child: const Text('Add User'),
),
],
),
), ),
), ),
); );

Loading…
Cancel
Save