diff --git a/lib/src/view/coordinate_training/coordinate_training_screen.dart b/lib/src/view/coordinate_training/coordinate_training_screen.dart index f4d8e65b44..c0391cf227 100644 --- a/lib/src/view/coordinate_training/coordinate_training_screen.dart +++ b/lib/src/view/coordinate_training/coordinate_training_screen.dart @@ -431,9 +431,9 @@ class _TrainingBoardState extends ConsumerState<_TrainingBoard> { Stack( alignment: Alignment.center, children: [ - ChessboardEditor( + Chessboard.fixed( size: widget.boardSize, - pieces: readFen(trainingPrefs.showPieces ? kInitialFEN : kEmptyFEN), + fen: trainingPrefs.showPieces ? kInitialFEN : kEmptyFEN, squareHighlights: widget.squareHighlights, orientation: widget.orientation, settings: boardPrefs.toBoardSettings().copyWith( @@ -444,8 +444,7 @@ class _TrainingBoardState extends ConsumerState<_TrainingBoard> { : BorderRadius.zero, boxShadow: widget.isTablet ? boardShadows : const [], ), - pointerMode: EditorPointerMode.edit, - onEditedSquare: (square) { + onTappedSquare: (square) { if (trainingState.trainingActive && trainingPrefs.mode == TrainingMode.findSquare) { widget.onGuess(square); } diff --git a/pubspec.yaml b/pubspec.yaml index 94160d5a69..63382017db 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: async: ^2.10.0 auto_size_text: ^3.0.0 cached_network_image: ^3.2.2 - chessground: ^6.2.3 + chessground: ^6.3.0 clock: ^1.1.1 collection: ^1.17.0 connectivity_plus: ^6.0.2 diff --git a/test/view/coordinate_training/coordinate_training_screen_test.dart b/test/view/coordinate_training/coordinate_training_screen_test.dart index 687a2b9829..77d548c917 100644 --- a/test/view/coordinate_training/coordinate_training_screen_test.dart +++ b/test/view/coordinate_training/coordinate_training_screen_test.dart @@ -3,10 +3,12 @@ import 'package:dartchess/dartchess.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:lichess_mobile/src/model/common/game.dart'; import 'package:lichess_mobile/src/model/coordinate_training/coordinate_training_controller.dart'; import 'package:lichess_mobile/src/model/coordinate_training/coordinate_training_preferences.dart'; import 'package:lichess_mobile/src/view/coordinate_training/coordinate_training_screen.dart'; +import '../../test_helpers.dart'; import '../../test_provider_scope.dart'; void main() { @@ -18,13 +20,11 @@ void main() { await tester.tap(find.text('Start Training')); await tester.pumpAndSettle(); - final container = ProviderScope.containerOf(tester.element(find.byType(ChessboardEditor))); + final container = ProviderScope.containerOf(tester.element(find.byType(Chessboard))); final controllerProvider = coordinateTrainingControllerProvider; final trainingPrefsNotifier = container.read(coordinateTrainingPreferencesProvider.notifier); trainingPrefsNotifier.setMode(TrainingMode.findSquare); - // This way all squares can be found via find.byKey(ValueKey('${square.name}-empty')) - trainingPrefsNotifier.setShowPieces(false); await tester.pumpAndSettle(); expect(container.read(controllerProvider).score, 0); @@ -41,24 +41,22 @@ void main() { final app = await makeTestProviderScopeApp(tester, home: const CoordinateTrainingScreen()); await tester.pumpWidget(app); + final container = ProviderScope.containerOf(tester.element(find.byType(Chessboard))); + final trainingPrefsNotifier = container.read(coordinateTrainingPreferencesProvider.notifier); + trainingPrefsNotifier.setMode(TrainingMode.findSquare); + trainingPrefsNotifier.setSideChoice(SideChoice.white); + await tester.tap(find.text('Start Training')); await tester.pumpAndSettle(); - final container = ProviderScope.containerOf(tester.element(find.byType(ChessboardEditor))); final controllerProvider = coordinateTrainingControllerProvider; - final trainingPrefsNotifier = container.read(coordinateTrainingPreferencesProvider.notifier); - trainingPrefsNotifier.setMode(TrainingMode.findSquare); - // This way all squares can be found via find.byKey(ValueKey('${square.name}-empty')) - trainingPrefsNotifier.setShowPieces(false); - await tester.pumpAndSettle(); - final currentCoord = container.read(controllerProvider).currentCoord; final nextCoord = container.read(controllerProvider).nextCoord; final wrongCoord = Square.values[(currentCoord! + 1) % Square.values.length]; - await tester.tap(find.byKey(ValueKey('${wrongCoord.name}-empty'))); + await tester.tapAt(squareOffset(wrongCoord, tester.getRect(find.byType(Chessboard)))); await tester.pump(); expect(container.read(controllerProvider).score, 0); @@ -76,22 +74,21 @@ void main() { final app = await makeTestProviderScopeApp(tester, home: const CoordinateTrainingScreen()); await tester.pumpWidget(app); - await tester.tap(find.text('Start Training')); - await tester.pumpAndSettle(); + final container = ProviderScope.containerOf(tester.element(find.byType(Chessboard))); + final trainingPrefsNotifier = container.read(coordinateTrainingPreferencesProvider.notifier); + trainingPrefsNotifier.setMode(TrainingMode.findSquare); + trainingPrefsNotifier.setSideChoice(SideChoice.white); - final container = ProviderScope.containerOf(tester.element(find.byType(ChessboardEditor))); final controllerProvider = coordinateTrainingControllerProvider; - final trainingPrefsNotifier = container.read(coordinateTrainingPreferencesProvider.notifier); - trainingPrefsNotifier.setMode(TrainingMode.findSquare); - // This way all squares can be found via find.byKey(ValueKey('${square.name}-empty')) - trainingPrefsNotifier.setShowPieces(false); + await tester.tap(find.text('Start Training')); await tester.pumpAndSettle(); final currentCoord = container.read(controllerProvider).currentCoord; final nextCoord = container.read(controllerProvider).nextCoord; - await tester.tap(find.byKey(ValueKey('${currentCoord!.name}-empty'))); + await tester.tapAt(squareOffset(currentCoord!, tester.getRect(find.byType(Chessboard)))); + await tester.pump(); expect(find.byKey(ValueKey('${currentCoord.name}-highlight')), findsOneWidget);