fix: apply code review

pull/206/head
arturplaczek 3 years ago
parent 8a9c6eb59a
commit 6389d489f9

Before

Width:  |  Height:  |  Size: 306 KiB

After

Width:  |  Height:  |  Size: 306 KiB

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 171 KiB

Before

Width:  |  Height:  |  Size: 222 KiB

After

Width:  |  Height:  |  Size: 222 KiB

@ -114,10 +114,12 @@ class PinballGameLoadedView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final leftMargin = MediaQuery.of(context).size.width * 0.3;
final isPlaying = context.select( final isPlaying = context.select(
(StartGameBloc bloc) => bloc.state.status == StartGameStatus.play, (StartGameBloc bloc) => bloc.state.status == StartGameStatus.play,
); );
final widthInRatio = MediaQuery.of(context).size.height * 9 / 16;
final screenWidth = MediaQuery.of(context).size.width;
final leftMargin = (screenWidth / 2) - (widthInRatio / 1.8);
return Stack( return Stack(
children: [ children: [

@ -5,7 +5,7 @@ import 'package:pinball/gen/assets.gen.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
/// {@template bonus_animation} /// {@template bonus_animation}
/// [Widget] that displays the animation. /// [Widget] that displays bonus animations.
/// {@endtemplate} /// {@endtemplate}
class BonusAnimation extends StatefulWidget { class BonusAnimation extends StatefulWidget {
/// {@macro bonus_animation} /// {@macro bonus_animation}
@ -42,7 +42,7 @@ class BonusAnimation extends StatefulWidget {
Key? key, Key? key,
VoidCallback? onCompleted, VoidCallback? onCompleted,
}) : this._( }) : this._(
Assets.images.bonusAnimation.dino.keyName, Assets.images.bonusAnimation.dinoChomp.keyName,
onCompleted: onCompleted, onCompleted: onCompleted,
key: key, key: key,
); );
@ -52,7 +52,7 @@ class BonusAnimation extends StatefulWidget {
Key? key, Key? key,
VoidCallback? onCompleted, VoidCallback? onCompleted,
}) : this._( }) : this._(
Assets.images.bonusAnimation.android.keyName, Assets.images.bonusAnimation.androidSpaceship.keyName,
onCompleted: onCompleted, onCompleted: onCompleted,
key: key, key: key,
); );
@ -62,7 +62,7 @@ class BonusAnimation extends StatefulWidget {
Key? key, Key? key,
VoidCallback? onCompleted, VoidCallback? onCompleted,
}) : this._( }) : this._(
Assets.images.bonusAnimation.google.keyName, Assets.images.bonusAnimation.googleWord.keyName,
onCompleted: onCompleted, onCompleted: onCompleted,
key: key, key: key,
); );
@ -77,9 +77,9 @@ class BonusAnimation extends StatefulWidget {
return [ return [
Flame.images.load(Assets.images.bonusAnimation.dashNest.keyName), Flame.images.load(Assets.images.bonusAnimation.dashNest.keyName),
Flame.images.load(Assets.images.bonusAnimation.sparkyTurboCharge.keyName), Flame.images.load(Assets.images.bonusAnimation.sparkyTurboCharge.keyName),
Flame.images.load(Assets.images.bonusAnimation.dino.keyName), Flame.images.load(Assets.images.bonusAnimation.dinoChomp.keyName),
Flame.images.load(Assets.images.bonusAnimation.android.keyName), Flame.images.load(Assets.images.bonusAnimation.androidSpaceship.keyName),
Flame.images.load(Assets.images.bonusAnimation.google.keyName), Flame.images.load(Assets.images.bonusAnimation.googleWord.keyName),
]; ];
} }

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pinball/game/game.dart'; import 'package:pinball/game/game.dart';
import 'package:pinball/gen/gen.dart'; import 'package:pinball/gen/gen.dart';
import 'package:pinball/theme/app_colors.dart';
/// {@template game_hud} /// {@template game_hud}
/// Overlay on the [PinballGame]. /// Overlay on the [PinballGame].
@ -64,18 +65,29 @@ class _ScoreViewDecoration extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ClipRRect( const radius = BorderRadius.all(Radius.circular(12));
borderRadius: const BorderRadius.all(Radius.circular(12)), const boardWidth = 5.0;
child: DecoratedBox(
decoration: BoxDecoration( return DecoratedBox(
image: DecorationImage( decoration: BoxDecoration(
fit: BoxFit.cover, borderRadius: radius,
image: AssetImage( border: Border.all(
Assets.images.score.miniScoreBackground.path, color: AppColors.white,
), width: boardWidth,
),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(
Assets.images.score.miniScoreBackground.path,
), ),
), ),
child: child, ),
child: Padding(
padding: const EdgeInsets.all(boardWidth - 1),
child: ClipRRect(
borderRadius: radius,
child: child,
),
), ),
); );
} }

@ -5,7 +5,7 @@ import 'package:pinball/l10n/l10n.dart';
import 'package:pinball/theme/theme.dart'; import 'package:pinball/theme/theme.dart';
/// {@template round_count_display} /// {@template round_count_display}
/// [Widget] that displays the count of rounds. /// Colored square indicating if a round is available.
/// {@endtemplate} /// {@endtemplate}
class RoundCountDisplay extends StatelessWidget { class RoundCountDisplay extends StatelessWidget {
/// {@macro round_count_display} /// {@macro round_count_display}
@ -14,6 +14,8 @@ class RoundCountDisplay extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final l10n = context.l10n; final l10n = context.l10n;
// TODO(arturplaczek): refactor when GameState handle balls and rounds and
// select state.rounds property instead of state.ball
final balls = context.select((GameBloc bloc) => bloc.state.balls); final balls = context.select((GameBloc bloc) => bloc.state.balls);
return Row( return Row(

@ -20,21 +20,21 @@ class $AssetsImagesGen {
class $AssetsImagesBonusAnimationGen { class $AssetsImagesBonusAnimationGen {
const $AssetsImagesBonusAnimationGen(); const $AssetsImagesBonusAnimationGen();
/// File path: assets/images/bonus_animation/android.png /// File path: assets/images/bonus_animation/android_spaceship.png
AssetGenImage get android => AssetGenImage get androidSpaceship => const AssetGenImage(
const AssetGenImage('assets/images/bonus_animation/android.png'); 'assets/images/bonus_animation/android_spaceship.png');
/// File path: assets/images/bonus_animation/dash_nest.png /// File path: assets/images/bonus_animation/dash_nest.png
AssetGenImage get dashNest => AssetGenImage get dashNest =>
const AssetGenImage('assets/images/bonus_animation/dash_nest.png'); const AssetGenImage('assets/images/bonus_animation/dash_nest.png');
/// File path: assets/images/bonus_animation/dino.png /// File path: assets/images/bonus_animation/dino_chomp.png
AssetGenImage get dino => AssetGenImage get dinoChomp =>
const AssetGenImage('assets/images/bonus_animation/dino.png'); const AssetGenImage('assets/images/bonus_animation/dino_chomp.png');
/// File path: assets/images/bonus_animation/google.png /// File path: assets/images/bonus_animation/google_word.png
AssetGenImage get google => AssetGenImage get googleWord =>
const AssetGenImage('assets/images/bonus_animation/google.png'); const AssetGenImage('assets/images/bonus_animation/google_word.png');
/// File path: assets/images/bonus_animation/sparky_turbo_charge.png /// File path: assets/images/bonus_animation/sparky_turbo_charge.png
AssetGenImage get sparkyTurboCharge => const AssetGenImage( AssetGenImage get sparkyTurboCharge => const AssetGenImage(

@ -25,7 +25,7 @@ void main() {
); );
}); });
testWidgets('three active balls', (tester) async { testWidgets('three active round indicator', (tester) async {
await tester.pumpApp( await tester.pumpApp(
const RoundCountDisplay(), const RoundCountDisplay(),
gameBloc: gameBloc, gameBloc: gameBloc,
@ -35,7 +35,7 @@ void main() {
expect(find.byType(RoundIndicator), findsNWidgets(3)); expect(find.byType(RoundIndicator), findsNWidgets(3));
}); });
testWidgets('two active balls', (tester) async { testWidgets('two active round indicator', (tester) async {
final state = initialState.copyWith( final state = initialState.copyWith(
balls: 2, balls: 2,
); );
@ -66,7 +66,7 @@ void main() {
); );
}); });
testWidgets('one active ball', (tester) async { testWidgets('one active round indicator', (tester) async {
final state = initialState.copyWith( final state = initialState.copyWith(
balls: 1, balls: 1,
); );
@ -98,7 +98,7 @@ void main() {
}); });
}); });
testWidgets('active score ball is displaying with proper color', testWidgets('active round indicator is displaying with proper color',
(tester) async { (tester) async {
await tester.pumpApp( await tester.pumpApp(
const RoundIndicator(isActive: true), const RoundIndicator(isActive: true),
@ -113,7 +113,7 @@ void main() {
); );
}); });
testWidgets('inactive score ball is displaying with proper color', testWidgets('inactive round indicator is displaying with proper color',
(tester) async { (tester) async {
await tester.pumpApp( await tester.pumpApp(
const RoundIndicator(isActive: false), const RoundIndicator(isActive: false),

Loading…
Cancel
Save