diff --git a/api/packages/crossword_repository/lib/src/crossword_repository.dart b/api/packages/crossword_repository/lib/src/crossword_repository.dart index 3326992b9..f9c1f226d 100644 --- a/api/packages/crossword_repository/lib/src/crossword_repository.dart +++ b/api/packages/crossword_repository/lib/src/crossword_repository.dart @@ -15,8 +15,8 @@ class CrosswordRepository { final DbClient _dbClient; - static const _sectionsCollection = 'boardChunks'; - static const _answersCollection = 'answers'; + static const _sectionsCollection = 'boardChunks2'; + static const _answersCollection = 'answers2'; static const _boardInfoCollection = 'boardInfo'; /// Fetches all sections from the board. diff --git a/api/packages/crossword_repository/test/src/crossword_repository_test.dart b/api/packages/crossword_repository/test/src/crossword_repository_test.dart index 4f56cb447..6871d152f 100644 --- a/api/packages/crossword_repository/test/src/crossword_repository_test.dart +++ b/api/packages/crossword_repository/test/src/crossword_repository_test.dart @@ -16,8 +16,8 @@ void main() { group('CrosswordRepository', () { late DbClient dbClient; - const sectionsCollection = 'boardChunks'; - const answersCollection = 'answers'; + const sectionsCollection = 'boardChunks2'; + const answersCollection = 'answers2'; setUpAll(() { registerFallbackValue(_MockDbEntityRecord()); diff --git a/api/packages/hint_repository/lib/src/hint_repository.dart b/api/packages/hint_repository/lib/src/hint_repository.dart index c4a0be050..f2a484ed2 100644 --- a/api/packages/hint_repository/lib/src/hint_repository.dart +++ b/api/packages/hint_repository/lib/src/hint_repository.dart @@ -16,7 +16,7 @@ class HintRepository { final DbClient _dbClient; final GenerativeModelWrapper _generativeModel; - static const _answersCollection = 'answers'; + static const _answersCollection = 'answers2'; static const _hintsCollection = 'hints'; static const _boardInfoCollection = 'boardInfo'; diff --git a/lib/crossword/game/crossword_game.dart b/lib/crossword/game/crossword_game.dart index c360abee9..bda16846e 100644 --- a/lib/crossword/game/crossword_game.dart +++ b/lib/crossword/game/crossword_game.dart @@ -206,11 +206,6 @@ class CrosswordGame extends FlameGame _updateVisibleSections(); } - @override - Color backgroundColor() { - return const Color(0xFF212123); - } - bool get isMobile { return defaultTargetPlatform == TargetPlatform.android || defaultTargetPlatform == TargetPlatform.iOS; diff --git a/lib/crossword/view/crossword_page.dart b/lib/crossword/view/crossword_page.dart index 1bc88dfe5..8358c74cf 100644 --- a/lib/crossword/view/crossword_page.dart +++ b/lib/crossword/view/crossword_page.dart @@ -1,9 +1,9 @@ import 'package:api_client/api_client.dart'; -import 'package:flame/game.dart' hide Route; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:io_crossword/bottom_bar/view/bottom_bar.dart'; import 'package:io_crossword/crossword/crossword.dart'; +import 'package:io_crossword/crossword2/crossword2.dart'; import 'package:io_crossword/drawer/drawer.dart'; import 'package:io_crossword/l10n/l10n.dart'; import 'package:io_crossword/music/music.dart'; @@ -81,76 +81,21 @@ class CrosswordView extends StatelessWidget { } } -class LoadedBoardView extends StatefulWidget { +@visibleForTesting +class LoadedBoardView extends StatelessWidget { @visibleForTesting const LoadedBoardView({super.key}); - @visibleForTesting - static const zoomInKey = Key('game_zoomIn'); - - @visibleForTesting - static const zoomOutKey = Key('game_zoomOut'); - - @override - State createState() => LoadedBoardViewState(); -} - -@visibleForTesting -class LoadedBoardViewState extends State { - late final CrosswordGame game; - - @override - void initState() { - super.initState(); - game = CrosswordGame( - crosswordBloc: context.read(), - wordSelectionBloc: context.read(), - playerBloc: context.read(), - ); - } - @override Widget build(BuildContext context) { final layout = IoLayout.of(context); return Stack( children: [ - GameWidget(game: game), + const Crossword2View(), const WordSelectionPage(), if (layout == IoLayoutData.large) const BottomBar(), - _ZoomControls(game: game), ], ); } } - -class _ZoomControls extends StatelessWidget { - const _ZoomControls({ - required this.game, - }); - - final CrosswordGame game; - - @override - Widget build(BuildContext context) { - return Positioned( - left: 16, - bottom: 16, - child: Column( - children: [ - ElevatedButton( - key: LoadedBoardView.zoomInKey, - onPressed: game.zoomIn, - child: const Icon(Icons.zoom_in), - ), - const SizedBox(height: 16), - ElevatedButton( - key: LoadedBoardView.zoomOutKey, - onPressed: game.zoomOut, - child: const Icon(Icons.zoom_out), - ), - ], - ), - ); - } -} diff --git a/packages/board_generator/lib/src/crossword_repository.dart b/packages/board_generator/lib/src/crossword_repository.dart index 0e516ae61..3b0677e54 100644 --- a/packages/board_generator/lib/src/crossword_repository.dart +++ b/packages/board_generator/lib/src/crossword_repository.dart @@ -21,7 +21,7 @@ class CrosswordRepository { } Future _addAnswers(List answers) async { - final answersCollection = firestore.collection('answers'); + final answersCollection = firestore.collection('answers2'); for (final answer in answers) { await answersCollection.doc(answer.id).set(answer.toJson()); } @@ -38,7 +38,7 @@ class CrosswordRepository { /// Adds a list of sections to the database. Future _addSections(List sections) async { for (final section in sections) { - await firestore.collection('boardChunks').add(section.toJson()); + await firestore.collection('boardChunks2').add(section.toJson()); } } diff --git a/packages/crossword_repository/lib/src/crossword_repository.dart b/packages/crossword_repository/lib/src/crossword_repository.dart index 73e612de8..b33b1717c 100644 --- a/packages/crossword_repository/lib/src/crossword_repository.dart +++ b/packages/crossword_repository/lib/src/crossword_repository.dart @@ -13,7 +13,7 @@ class CrosswordRepository { required this.db, Random? rng, }) : _rng = rng ?? Random() { - sectionCollection = db.collection('boardChunks'); + sectionCollection = db.collection('boardChunks2'); } /// The [FirebaseFirestore] instance. diff --git a/packages/crossword_repository/test/src/crossword_repository_test.dart b/packages/crossword_repository/test/src/crossword_repository_test.dart index 81262e0d6..9618fe56f 100644 --- a/packages/crossword_repository/test/src/crossword_repository_test.dart +++ b/packages/crossword_repository/test/src/crossword_repository_test.dart @@ -29,7 +29,7 @@ void main() { ], borderWords: const [], ); - const sectionsCollection = 'boardChunks'; + const sectionsCollection = 'boardChunks2'; late FirebaseFirestore firebaseFirestore; late CrosswordRepository crosswordRepository; diff --git a/test/crossword/view/crossword_page_test.dart b/test/crossword/view/crossword_page_test.dart index 68e24ce02..1600a7407 100644 --- a/test/crossword/view/crossword_page_test.dart +++ b/test/crossword/view/crossword_page_test.dart @@ -3,12 +3,11 @@ import 'package:bloc_test/bloc_test.dart'; import 'package:flame/cache.dart'; import 'package:flame/flame.dart'; -import 'package:flame/game.dart'; import 'package:flutter/material.dart' hide Axis; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:game_domain/game_domain.dart'; import 'package:io_crossword/crossword/crossword.dart'; +import 'package:io_crossword/crossword2/crossword2.dart'; import 'package:io_crossword/drawer/drawer.dart'; import 'package:io_crossword/music/widget/mute_button.dart'; import 'package:io_crossword/player/player.dart'; @@ -28,11 +27,6 @@ class _MockWordSelectionBloc extends MockBloc implements WordSelectionBloc {} -class _FakeBoardSection extends Fake implements BoardSection { - @override - List get words => []; -} - void main() { group('$CrosswordPage', () { testWidgets('renders $CrosswordView', (tester) async { @@ -49,6 +43,12 @@ void main() { setUp(() { Flame.images = Images(prefix: ''); crosswordBloc = _MockCrosswordBloc(); + when(() => crosswordBloc.state).thenReturn( + CrosswordState( + status: CrosswordStatus.success, + sectionSize: 40, + ), + ); }); testWidgets('renders $IoAppBar', (tester) async { @@ -108,38 +108,19 @@ void main() { expect(find.byType(ErrorView), findsOneWidget); }); - testWidgets('renders game with ${CrosswordStatus.success}', (tester) async { - when(() => crosswordBloc.state).thenReturn( - CrosswordState( - status: CrosswordStatus.success, - sectionSize: 40, - sections: { - (0, 0): _FakeBoardSection(), - }, - ), - ); - + testWidgets('renders $Crossword2View with ${CrosswordStatus.success}', + (tester) async { await tester.pumpSubject( - CrosswordView(), crosswordBloc: crosswordBloc, + CrosswordView(), ); - expect(find.byType(GameWidget), findsOneWidget); + expect(find.byType(Crossword2View), findsOneWidget); }); testWidgets( 'renders $WordSelectionPage when loaded', (tester) async { - when(() => crosswordBloc.state).thenReturn( - CrosswordState( - status: CrosswordStatus.success, - sectionSize: 40, - sections: { - (0, 0): _FakeBoardSection(), - }, - ), - ); - await tester.pumpSubject( CrosswordView(), crosswordBloc: crosswordBloc,