From bc85731b62a7e74cec85d30b2ddc9561a052dbbf Mon Sep 17 00:00:00 2001 From: arturplaczek Date: Tue, 26 Apr 2022 13:34:51 +0200 Subject: [PATCH] chore: rename BallCountDisplay to RoundCountDisplay --- ..._display.dart => round_count_display.dart} | 25 ++++++++++++------- ...est.dart => round_count_display_test.dart} | 24 +++++++++--------- 2 files changed, 28 insertions(+), 21 deletions(-) rename lib/game/view/widgets/{ball_count_display.dart => round_count_display.dart} (62%) rename test/game/view/widgets/{ball_count_display_test.dart => round_count_display_test.dart} (79%) diff --git a/lib/game/view/widgets/ball_count_display.dart b/lib/game/view/widgets/round_count_display.dart similarity index 62% rename from lib/game/view/widgets/ball_count_display.dart rename to lib/game/view/widgets/round_count_display.dart index 590420be..44a939af 100644 --- a/lib/game/view/widgets/ball_count_display.dart +++ b/lib/game/view/widgets/round_count_display.dart @@ -1,13 +1,15 @@ -// ignore_for_file: public_member_api_docs - import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pinball/game/game.dart'; import 'package:pinball/l10n/l10n.dart'; import 'package:pinball/theme/theme.dart'; -class BallCountDisplay extends StatelessWidget { - const BallCountDisplay({Key? key}) : super(key: key); +/// {@template round_count_display} +/// [Widget] that displays the count of rounds. +/// {@endtemplate} +class RoundCountDisplay extends StatelessWidget { + /// {@macro round_count_display} + const RoundCountDisplay({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -25,9 +27,9 @@ class BallCountDisplay extends StatelessWidget { const SizedBox(width: 8), Row( children: [ - BallIndicator(isActive: balls >= 1), - BallIndicator(isActive: balls >= 2), - BallIndicator(isActive: balls >= 3), + RoundIndicator(isActive: balls >= 1), + RoundIndicator(isActive: balls >= 2), + RoundIndicator(isActive: balls >= 3), ], ), ], @@ -35,13 +37,18 @@ class BallCountDisplay extends StatelessWidget { } } +/// {@template round_indicator} +/// [Widget] that displays the round indicator. +/// {@endtemplate} @visibleForTesting -class BallIndicator extends StatelessWidget { - const BallIndicator({ +class RoundIndicator extends StatelessWidget { + /// {@macro round_indicator} + const RoundIndicator({ Key? key, required this.isActive, }) : super(key: key); + /// A value that describes whether the indicator is active. final bool isActive; @override diff --git a/test/game/view/widgets/ball_count_display_test.dart b/test/game/view/widgets/round_count_display_test.dart similarity index 79% rename from test/game/view/widgets/ball_count_display_test.dart rename to test/game/view/widgets/round_count_display_test.dart index a55e7b4e..df1a60aa 100644 --- a/test/game/view/widgets/ball_count_display_test.dart +++ b/test/game/view/widgets/round_count_display_test.dart @@ -7,7 +7,7 @@ import 'package:pinball/theme/app_colors.dart'; import '../../../helpers/helpers.dart'; void main() { - group('ScoreBalls renders', () { + group('RoundCountDisplay renders', () { late GameBloc gameBloc; const initialState = GameState( score: 0, @@ -27,12 +27,12 @@ void main() { testWidgets('three active balls', (tester) async { await tester.pumpApp( - const BallCountDisplay(), + const RoundCountDisplay(), gameBloc: gameBloc, ); await tester.pump(); - expect(find.byType(BallIndicator), findsNWidgets(3)); + expect(find.byType(RoundIndicator), findsNWidgets(3)); }); testWidgets('two active balls', (tester) async { @@ -46,27 +46,27 @@ void main() { ); await tester.pumpApp( - const BallCountDisplay(), + const RoundCountDisplay(), gameBloc: gameBloc, ); await tester.pump(); expect( find.byWidgetPredicate( - (widget) => widget is BallIndicator && widget.isActive, + (widget) => widget is RoundIndicator && widget.isActive, ), findsNWidgets(2), ); expect( find.byWidgetPredicate( - (widget) => widget is BallIndicator && !widget.isActive, + (widget) => widget is RoundIndicator && !widget.isActive, ), findsOneWidget, ); }); - testWidgets('one active balls', (tester) async { + testWidgets('one active ball', (tester) async { final state = initialState.copyWith( balls: 1, ); @@ -77,21 +77,21 @@ void main() { ); await tester.pumpApp( - const BallCountDisplay(), + const RoundCountDisplay(), gameBloc: gameBloc, ); await tester.pump(); expect( find.byWidgetPredicate( - (widget) => widget is BallIndicator && widget.isActive, + (widget) => widget is RoundIndicator && widget.isActive, ), findsOneWidget, ); expect( find.byWidgetPredicate( - (widget) => widget is BallIndicator && !widget.isActive, + (widget) => widget is RoundIndicator && !widget.isActive, ), findsNWidgets(2), ); @@ -101,7 +101,7 @@ void main() { testWidgets('active score ball is displaying with proper color', (tester) async { await tester.pumpApp( - const BallIndicator(isActive: true), + const RoundIndicator(isActive: true), ); await tester.pump(); @@ -116,7 +116,7 @@ void main() { testWidgets('inactive score ball is displaying with proper color', (tester) async { await tester.pumpApp( - const BallIndicator(isActive: false), + const RoundIndicator(isActive: false), ); await tester.pump();