diff --git a/lib/src/model/analysis/analysis_preferences.dart b/lib/src/model/analysis/analysis_preferences.dart index 45d615baef..4cfc0e1daa 100644 --- a/lib/src/model/analysis/analysis_preferences.dart +++ b/lib/src/model/analysis/analysis_preferences.dart @@ -40,6 +40,14 @@ class AnalysisPreferences extends _$AnalysisPreferences { ); } + Future toggleAnnotations() { + return _save( + state.copyWith( + showAnnotations: !state.showAnnotations, + ), + ); + } + Future togglePgnComments() { return _save( state.copyWith( @@ -92,6 +100,7 @@ class AnalysisPrefState with _$AnalysisPrefState { required bool enableLocalEvaluation, required bool showEvaluationGauge, required bool showBestMoveArrow, + required bool showAnnotations, required bool showPgnComments, @Assert('numEvalLines >= 1 && numEvalLines <= 3') required int numEvalLines, @Assert('numEngineCores >= 1 && numEngineCores <= maxEngineCores') @@ -102,6 +111,7 @@ class AnalysisPrefState with _$AnalysisPrefState { enableLocalEvaluation: true, showEvaluationGauge: true, showBestMoveArrow: true, + showAnnotations: true, showPgnComments: true, numEvalLines: 2, numEngineCores: defaultEngineCores, diff --git a/lib/src/view/analysis/analysis_screen.dart b/lib/src/view/analysis/analysis_screen.dart index 4efbd17ece..ce5e60232b 100644 --- a/lib/src/view/analysis/analysis_screen.dart +++ b/lib/src/view/analysis/analysis_screen.dart @@ -450,6 +450,9 @@ class _BoardState extends ConsumerState<_Board> { (value) => value.showBestMoveArrow, ), ); + final showAnnotationsOnBoard = ref.watch( + analysisPreferencesProvider.select((value) => value.showAnnotations), + ); final evalBestMoves = ref.watch( engineEvaluationProvider.select((s) => s.eval?.bestMoves), @@ -485,14 +488,15 @@ class _BoardState extends ConsumerState<_Board> { sideToMove: analysisState.position.turn.cg, validMoves: analysisState.validMoves, shapes: userShapes.union(bestMoveShapes), - annotations: sanMove != null && annotation != null - ? altCastles.containsKey(sanMove.move.uci) - ? IMap({ - Move.fromUci(altCastles[sanMove.move.uci]!)!.cg.to: - annotation, - }) - : IMap({sanMove.move.cg.to: annotation}) - : null, + annotations: + showAnnotationsOnBoard && sanMove != null && annotation != null + ? altCastles.containsKey(sanMove.move.uci) + ? IMap({ + Move.fromUci(altCastles[sanMove.move.uci]!)!.cg.to: + annotation, + }) + : IMap({sanMove.move.cg.to: annotation}) + : null, ), settings: cg.BoardSettings( pieceAssets: boardPrefs.pieceSet.assets, diff --git a/lib/src/view/analysis/analysis_settings.dart b/lib/src/view/analysis/analysis_settings.dart index bb66b90928..33a8ea3749 100644 --- a/lib/src/view/analysis/analysis_settings.dart +++ b/lib/src/view/analysis/analysis_settings.dart @@ -126,6 +126,13 @@ class AnalysisSettings extends ConsumerWidget { .read(analysisPreferencesProvider.notifier) .toggleShowEvaluationGauge(), ), + SwitchSettingTile( + title: Text(context.l10n.toggleGlyphAnnotations), + value: prefs.showAnnotations, + onChanged: (_) => ref + .read(analysisPreferencesProvider.notifier) + .toggleAnnotations(), + ), SwitchSettingTile( title: Text(context.l10n.mobileShowComments), value: prefs.showPgnComments, diff --git a/lib/src/view/analysis/tree_view.dart b/lib/src/view/analysis/tree_view.dart index 324f22ba4d..0a2571cd5f 100644 --- a/lib/src/view/analysis/tree_view.dart +++ b/lib/src/view/analysis/tree_view.dart @@ -114,11 +114,16 @@ class _InlineTreeViewState extends ConsumerState { analysisPreferencesProvider.select((value) => value.showPgnComments), ); + final shouldShowAnnotations = ref.watch( + analysisPreferencesProvider.select((value) => value.showAnnotations), + ); + final List moveWidgets = _buildTreeWidget( widget.pgn, widget.options, parent: root, nodes: root.children, + shouldShowAnnotations: shouldShowAnnotations, shouldShowComments: shouldShowComments, inMainline: true, startMainline: true, @@ -176,6 +181,7 @@ class _InlineTreeViewState extends ConsumerState { required bool inMainline, required bool startMainline, required bool startSideline, + required bool shouldShowAnnotations, required bool shouldShowComments, required UciPath initialPath, }) { @@ -196,6 +202,7 @@ class _InlineTreeViewState extends ConsumerState { branch: firstChild, isCurrentMove: currentMove, key: currentMove ? currentMoveKey : null, + shouldShowAnnotations: shouldShowAnnotations, shouldShowComments: shouldShowComments, isSideline: !inMainline, startMainline: startMainline, @@ -220,6 +227,7 @@ class _InlineTreeViewState extends ConsumerState { options, parent: parent, nodes: [nodes[i]].lockUnsafe, + shouldShowAnnotations: shouldShowAnnotations, shouldShowComments: shouldShowComments, inMainline: false, startMainline: false, @@ -236,6 +244,7 @@ class _InlineTreeViewState extends ConsumerState { options, parent: parent, nodes: [nodes[i]].lockUnsafe, + shouldShowAnnotations: shouldShowAnnotations, shouldShowComments: shouldShowComments, inMainline: false, startMainline: false, @@ -253,6 +262,7 @@ class _InlineTreeViewState extends ConsumerState { options, parent: firstChild, nodes: firstChild.children, + shouldShowAnnotations: shouldShowAnnotations, shouldShowComments: shouldShowComments, inMainline: inMainline, startMainline: false, @@ -289,6 +299,7 @@ class InlineMove extends ConsumerWidget { required this.path, required this.parent, required this.branch, + required this.shouldShowAnnotations, required this.shouldShowComments, required this.isCurrentMove, required this.isSideline, @@ -303,6 +314,7 @@ class InlineMove extends ConsumerWidget { final UciPath path; final ViewNode parent; final ViewBranch branch; + final bool shouldShowAnnotations; final bool shouldShowComments; final bool isCurrentMove; final bool isSideline; @@ -349,7 +361,9 @@ class InlineMove extends ConsumerWidget { : null); final moveWithNag = move.san + - (branch.nags != null ? moveAnnotationChar(branch.nags!) : ''); + (branch.nags != null && shouldShowAnnotations + ? moveAnnotationChar(branch.nags!) + : ''); return Row( mainAxisSize: MainAxisSize.min, @@ -411,7 +425,9 @@ class InlineMove extends ConsumerWidget { context, 1, isLichessGameAnalysis: options.isLichessGameAnalysis, - nag: branch.nags?.firstOrNull, + nag: shouldShowAnnotations + ? branch.nags?.firstOrNull + : null, ), ) : textStyle.copyWith( @@ -419,7 +435,9 @@ class InlineMove extends ConsumerWidget { context, 0.9, isLichessGameAnalysis: options.isLichessGameAnalysis, - nag: branch.nags?.firstOrNull, + nag: shouldShowAnnotations + ? branch.nags?.firstOrNull + : null, ), ), ),