diff --git a/lib/game/view/widgets/play_button_overlay.dart b/lib/game/view/widgets/play_button_overlay.dart deleted file mode 100644 index 21493ca2..00000000 --- a/lib/game/view/widgets/play_button_overlay.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:pinball/l10n/l10n.dart'; -import 'package:pinball/start_game/start_game.dart'; - -/// {@template play_button_overlay} -/// [Widget] that renders the button responsible to starting the game -/// {@endtemplate} -class PlayButtonOverlay extends StatelessWidget { - /// {@macro play_button_overlay} - const PlayButtonOverlay({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final l10n = context.l10n; - - return Center( - child: ElevatedButton( - onPressed: () { - context.read().add(const PlayTapped()); - }, - child: Text(l10n.play), - ), - ); - } -} diff --git a/lib/select_character/view/character_selection_page.dart b/lib/select_character/view/character_selection_page.dart deleted file mode 100644 index 80a184ab..00000000 --- a/lib/select_character/view/character_selection_page.dart +++ /dev/null @@ -1,130 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:pinball/l10n/l10n.dart'; -import 'package:pinball/select_character/select_character.dart'; -import 'package:pinball/start_game/start_game.dart'; -import 'package:pinball_theme/pinball_theme.dart'; -import 'package:pinball_ui/pinball_ui.dart'; - -class CharacterSelectionDialog extends StatelessWidget { - const CharacterSelectionDialog({Key? key}) : super(key: key); - - static Route route() { - return MaterialPageRoute( - builder: (_) => const CharacterSelectionDialog(), - ); - } - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (_) => CharacterThemeCubit(), - child: const CharacterSelectionView(), - ); - } -} - -class CharacterSelectionView extends StatelessWidget { - const CharacterSelectionView({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final l10n = context.l10n; - - return PixelatedDecoration( - header: Text( - l10n.characterSelectionTitle, - style: Theme.of(context).textTheme.headline3, - ), - body: SingleChildScrollView( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const _CharacterSelectionGridView(), - const SizedBox(height: 20), - TextButton( - onPressed: () { - Navigator.of(context).pop(); - context.read().add(const CharacterSelected()); - }, - child: Text(l10n.start), - ), - ], - ), - ), - ); - } -} - -class _CharacterSelectionGridView extends StatelessWidget { - const _CharacterSelectionGridView({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(20), - child: GridView.count( - shrinkWrap: true, - crossAxisCount: 2, - mainAxisSpacing: 20, - crossAxisSpacing: 20, - children: const [ - CharacterImageButton( - DashTheme(), - key: Key('characterSelectionPage_dashButton'), - ), - CharacterImageButton( - SparkyTheme(), - key: Key('characterSelectionPage_sparkyButton'), - ), - CharacterImageButton( - AndroidTheme(), - key: Key('characterSelectionPage_androidButton'), - ), - CharacterImageButton( - DinoTheme(), - key: Key('characterSelectionPage_dinoButton'), - ), - ], - ), - ); - } -} - -// TODO(allisonryan0002): remove visibility when adding final UI. -@visibleForTesting -class CharacterImageButton extends StatelessWidget { - const CharacterImageButton( - this.characterTheme, { - Key? key, - }) : super(key: key); - - final CharacterTheme characterTheme; - - @override - Widget build(BuildContext context) { - final currentCharacterTheme = - context.select( - (cubit) => cubit.state.characterTheme, - ); - - return GestureDetector( - onTap: () => - context.read().characterSelected(characterTheme), - child: DecoratedBox( - decoration: BoxDecoration( - color: (currentCharacterTheme == characterTheme) - ? Colors.blue.withOpacity(0.5) - : null, - borderRadius: BorderRadius.circular(6), - ), - child: Padding( - padding: const EdgeInsets.all(8), - child: characterTheme.icon.image(), - ), - ), - ); - } -} diff --git a/lib/select_character/view/view.dart b/lib/select_character/view/view.dart deleted file mode 100644 index 1af489b5..00000000 --- a/lib/select_character/view/view.dart +++ /dev/null @@ -1 +0,0 @@ -export 'character_selection_page.dart'; diff --git a/packages/pinball_theme/assets/images/pinball_button.png b/packages/pinball_theme/assets/images/pinball_button.png deleted file mode 100644 index 62373b85..00000000 Binary files a/packages/pinball_theme/assets/images/pinball_button.png and /dev/null differ diff --git a/packages/pinball_theme/assets/images/select_character_background.png b/packages/pinball_theme/assets/images/select_character_background.png deleted file mode 100644 index 69120148..00000000 Binary files a/packages/pinball_theme/assets/images/select_character_background.png and /dev/null differ diff --git a/packages/pinball_theme/lib/src/generated/assets.gen.dart b/packages/pinball_theme/lib/src/generated/assets.gen.dart index 3feeecce..a25075ff 100644 --- a/packages/pinball_theme/lib/src/generated/assets.gen.dart +++ b/packages/pinball_theme/lib/src/generated/assets.gen.dart @@ -13,15 +13,6 @@ class $AssetsImagesGen { $AssetsImagesAndroidGen get android => const $AssetsImagesAndroidGen(); $AssetsImagesDashGen get dash => const $AssetsImagesDashGen(); $AssetsImagesDinoGen get dino => const $AssetsImagesDinoGen(); - - /// File path: assets/images/pinball_button.png - AssetGenImage get pinballButton => - const AssetGenImage('assets/images/pinball_button.png'); - - /// File path: assets/images/select_character_background.png - AssetGenImage get selectCharacterBackground => - const AssetGenImage('assets/images/select_character_background.png'); - $AssetsImagesSparkyGen get sparky => const $AssetsImagesSparkyGen(); } @@ -36,10 +27,6 @@ class $AssetsImagesAndroidGen { AssetGenImage get background => const AssetGenImage('assets/images/android/background.png'); - /// File path: assets/images/android/character.png - AssetGenImage get character => - const AssetGenImage('assets/images/android/character.png'); - /// File path: assets/images/android/icon.png AssetGenImage get icon => const AssetGenImage('assets/images/android/icon.png'); @@ -60,10 +47,6 @@ class $AssetsImagesDashGen { AssetGenImage get background => const AssetGenImage('assets/images/dash/background.png'); - /// File path: assets/images/dash/character.png - AssetGenImage get character => - const AssetGenImage('assets/images/dash/character.png'); - /// File path: assets/images/dash/icon.png AssetGenImage get icon => const AssetGenImage('assets/images/dash/icon.png'); @@ -83,10 +66,6 @@ class $AssetsImagesDinoGen { AssetGenImage get background => const AssetGenImage('assets/images/dino/background.png'); - /// File path: assets/images/dino/character.png - AssetGenImage get character => - const AssetGenImage('assets/images/dino/character.png'); - /// File path: assets/images/dino/icon.png AssetGenImage get icon => const AssetGenImage('assets/images/dino/icon.png'); @@ -106,10 +85,6 @@ class $AssetsImagesSparkyGen { AssetGenImage get background => const AssetGenImage('assets/images/sparky/background.png'); - /// File path: assets/images/sparky/character.png - AssetGenImage get character => - const AssetGenImage('assets/images/sparky/character.png'); - /// File path: assets/images/sparky/icon.png AssetGenImage get icon => const AssetGenImage('assets/images/sparky/icon.png'); diff --git a/test/game/view/widgets/play_button_overlay_test.dart b/test/game/view/widgets/play_button_overlay_test.dart deleted file mode 100644 index a4d53617..00000000 --- a/test/game/view/widgets/play_button_overlay_test.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:bloc_test/bloc_test.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:mocktail/mocktail.dart'; -import 'package:pinball/game/game.dart'; -import 'package:pinball/start_game/bloc/start_game_bloc.dart'; - -import '../../../helpers/helpers.dart'; - -void main() { - group('PlayButtonOverlay', () { - late StartGameBloc startGameBloc; - - setUp(() { - startGameBloc = MockStartGameBloc(); - - whenListen( - startGameBloc, - Stream.value(const StartGameState.initial()), - initialState: const StartGameState.initial(), - ); - }); - - testWidgets('renders correctly', (tester) async { - await tester.pumpApp(const PlayButtonOverlay()); - - expect(find.text('Play'), findsOneWidget); - }); - - testWidgets('adds PlayTapped event to StartGameBloc when taped', - (tester) async { - await tester.pumpApp( - const PlayButtonOverlay(), - startGameBloc: startGameBloc, - ); - - await tester.tap(find.text('Play')); - await tester.pump(); - - verify(() => startGameBloc.add(const PlayTapped())).called(1); - }); - }); -} diff --git a/test/select_character/view/character_selection_page_test.dart b/test/select_character/view/character_selection_page_test.dart deleted file mode 100644 index 5cd22f54..00000000 --- a/test/select_character/view/character_selection_page_test.dart +++ /dev/null @@ -1,119 +0,0 @@ -// ignore_for_file: prefer_const_constructors - -import 'package:bloc_test/bloc_test.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockingjay/mockingjay.dart'; -import 'package:pinball/select_character/select_character.dart'; -import 'package:pinball/start_game/start_game.dart'; -import 'package:pinball_theme/pinball_theme.dart'; - -import '../../helpers/helpers.dart'; - -void main() { - late CharacterThemeCubit characterThemeCubit; - late StartGameBloc startGameBloc; - - setUp(() { - characterThemeCubit = MockCharacterThemeCubit(); - startGameBloc = MockStartGameBloc(); - - whenListen( - characterThemeCubit, - const Stream.empty(), - initialState: const CharacterThemeState.initial(), - ); - }); - - group('CharacterSelectionPage', () { - testWidgets('renders CharacterSelectionView', (tester) async { - await tester.pumpApp( - CharacterSelectionDialog(), - characterThemeCubit: characterThemeCubit, - ); - expect(find.byType(CharacterSelectionView), findsOneWidget); - }); - - testWidgets('route returns a valid navigation route', (tester) async { - await tester.pumpApp( - Scaffold( - body: Builder( - builder: (context) { - return ElevatedButton( - onPressed: () { - Navigator.of(context) - .push(CharacterSelectionDialog.route()); - }, - child: Text('Tap me'), - ); - }, - ), - ), - characterThemeCubit: characterThemeCubit, - ); - - await tester.tap(find.text('Tap me')); - await tester.pumpAndSettle(); - - expect(find.byType(CharacterSelectionDialog), findsOneWidget); - }); - }); - - group('CharacterSelectionView', () { - testWidgets('renders correctly', (tester) async { - const titleText = 'Choose your character!'; - await tester.pumpApp( - CharacterSelectionView(), - characterThemeCubit: characterThemeCubit, - ); - - expect(find.text(titleText), findsOneWidget); - expect(find.byType(CharacterImageButton), findsNWidgets(4)); - expect(find.byType(TextButton), findsOneWidget); - }); - - testWidgets('calls characterSelected when a character image is tapped', - (tester) async { - const sparkyButtonKey = Key('characterSelectionPage_sparkyButton'); - - await tester.pumpApp( - CharacterSelectionView(), - characterThemeCubit: characterThemeCubit, - ); - - await tester.tap(find.byKey(sparkyButtonKey)); - - verify(() => characterThemeCubit.characterSelected(SparkyTheme())) - .called(1); - }); - - testWidgets('adds CharacterSelected event when start is tapped', - (tester) async { - whenListen( - startGameBloc, - Stream.value(const StartGameState.initial()), - initialState: const StartGameState.initial(), - ); - - await tester.pumpApp( - CharacterSelectionView(), - characterThemeCubit: characterThemeCubit, - startGameBloc: startGameBloc, - ); - await tester.ensureVisible(find.byType(TextButton)); - await tester.tap(find.byType(TextButton)); - await tester.pumpAndSettle(); - - verify(() => startGameBloc.add(CharacterSelected())).called(1); - }); - }); - - testWidgets('CharacterImageButton renders correctly', (tester) async { - await tester.pumpApp( - CharacterImageButton(DashTheme()), - characterThemeCubit: characterThemeCubit, - ); - - expect(find.byType(Image), findsOneWidget); - }); -}