fix: apply self review

pull/254/head
arturplaczek 3 years ago
parent 82122cf54b
commit 2ed170e841

@ -77,9 +77,7 @@ class _FlipperControls extends StatelessWidget {
const SizedBox(height: 10), const SizedBox(height: 10),
Column( Column(
children: [ children: [
Row( Wrap(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: const [ children: const [
KeyIndicator.fromIcon(keyIcon: Icons.keyboard_arrow_left), KeyIndicator.fromIcon(keyIcon: Icons.keyboard_arrow_left),
rowSpacing, rowSpacing,

@ -28,7 +28,7 @@ class StartGameListener extends StatelessWidget {
_onSelectCharacter(context); _onSelectCharacter(context);
break; break;
case StartGameStatus.howToPlay: case StartGameStatus.howToPlay:
_handleHowToPlay(context); _onHowToPlay(context);
break; break;
case StartGameStatus.play: case StartGameStatus.play:
_game.gameFlowController.start(); _game.gameFlowController.start();
@ -41,43 +41,43 @@ class StartGameListener extends StatelessWidget {
); );
} }
void _onSelectCharacter( void _onSelectCharacter(BuildContext context) {
BuildContext context, _showPinballDialog(
) {
showDialog<void>(
context: context, context: context,
builder: (_) {
// TODO(arturplaczek): remove that when PR with PinballLayout will be
// merged
final height = MediaQuery.of(context).size.height * 0.5;
return Center(
child: SizedBox(
height: height,
width: height * 1.2,
child: const CharacterSelectionDialog(), child: const CharacterSelectionDialog(),
),
);
},
barrierDismissible: false, barrierDismissible: false,
); );
} }
} }
Future<void> _handleHowToPlay( Future<void> _onHowToPlay(BuildContext context) async {
BuildContext context, _showPinballDialog(
) async { context: context,
final startGameBloc = context.read<StartGameBloc>(); child: HowToPlayDialog(
onDismissCallback: () {
context.read<StartGameBloc>().add(const HowToPlayFinished());
},
),
);
}
void _showPinballDialog({
required BuildContext context,
required Widget child,
bool barrierDismissible = true,
}) {
final gameWidgetWidth = MediaQuery.of(context).size.height * 9 / 16;
await showDialog<void>( showDialog<void>(
context: context, context: context,
barrierColor: AppColors.transparent, barrierColor: AppColors.transparent,
barrierDismissible: barrierDismissible,
builder: (_) { builder: (_) {
return Center( return Center(
child: HowToPlayDialog( child: SizedBox(
onDismissCallback: () { height: gameWidgetWidth,
startGameBloc.add(const HowToPlayFinished()); width: gameWidgetWidth,
}, child: child,
), ),
); );
}, },

@ -198,12 +198,11 @@ void main() {
find.byWidgetPredicate((w) => w is GameWidget<PinballGame>), find.byWidgetPredicate((w) => w is GameWidget<PinballGame>),
findsOneWidget, findsOneWidget,
); );
// TODO(arturplaczek): add Visibility to GameHud based on StartGameBloc
// status expect(
// expect( find.byType(GameHud),
// find.byType(GameHud), findsNothing,
// findsNothing, );
// );
}); });
testWidgets('renders a hud on play state', (tester) async { testWidgets('renders a hud on play state', (tester) async {

@ -137,7 +137,7 @@ void main() {
); );
testWidgets( testWidgets(
'calls HowToPlayFinished event after HowToPlayDialog is closed', 'adds HowToPlayFinished event after closing HowToPlayDialog',
(tester) async { (tester) async {
whenListen( whenListen(
startGameBloc, startGameBloc,

Loading…
Cancel
Save