Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/src/model/analysis/analysis_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class AnalysisPreferences extends _$AnalysisPreferences {
);
}

Future<void> toggleAnnotations() {
return _save(
state.copyWith(
showAnnotations: !state.showAnnotations,
),
);
}

Future<void> togglePgnComments() {
return _save(
state.copyWith(
Expand Down Expand Up @@ -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')
Expand All @@ -102,6 +111,7 @@ class AnalysisPrefState with _$AnalysisPrefState {
enableLocalEvaluation: true,
showEvaluationGauge: true,
showBestMoveArrow: true,
showAnnotations: true,
showPgnComments: true,
numEvalLines: 2,
numEngineCores: defaultEngineCores,
Expand Down
20 changes: 12 additions & 8 deletions lib/src/view/analysis/analysis_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions lib/src/view/analysis/analysis_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 21 additions & 3 deletions lib/src/view/analysis/tree_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,16 @@ class _InlineTreeViewState extends ConsumerState<AnalysisTreeView> {
analysisPreferencesProvider.select((value) => value.showPgnComments),
);

final shouldShowAnnotations = ref.watch(
analysisPreferencesProvider.select((value) => value.showAnnotations),
);

final List<Widget> moveWidgets = _buildTreeWidget(
widget.pgn,
widget.options,
parent: root,
nodes: root.children,
shouldShowAnnotations: shouldShowAnnotations,
shouldShowComments: shouldShowComments,
inMainline: true,
startMainline: true,
Expand Down Expand Up @@ -176,6 +181,7 @@ class _InlineTreeViewState extends ConsumerState<AnalysisTreeView> {
required bool inMainline,
required bool startMainline,
required bool startSideline,
required bool shouldShowAnnotations,
required bool shouldShowComments,
required UciPath initialPath,
}) {
Expand All @@ -196,6 +202,7 @@ class _InlineTreeViewState extends ConsumerState<AnalysisTreeView> {
branch: firstChild,
isCurrentMove: currentMove,
key: currentMove ? currentMoveKey : null,
shouldShowAnnotations: shouldShowAnnotations,
shouldShowComments: shouldShowComments,
isSideline: !inMainline,
startMainline: startMainline,
Expand All @@ -220,6 +227,7 @@ class _InlineTreeViewState extends ConsumerState<AnalysisTreeView> {
options,
parent: parent,
nodes: [nodes[i]].lockUnsafe,
shouldShowAnnotations: shouldShowAnnotations,
shouldShowComments: shouldShowComments,
inMainline: false,
startMainline: false,
Expand All @@ -236,6 +244,7 @@ class _InlineTreeViewState extends ConsumerState<AnalysisTreeView> {
options,
parent: parent,
nodes: [nodes[i]].lockUnsafe,
shouldShowAnnotations: shouldShowAnnotations,
shouldShowComments: shouldShowComments,
inMainline: false,
startMainline: false,
Expand All @@ -253,6 +262,7 @@ class _InlineTreeViewState extends ConsumerState<AnalysisTreeView> {
options,
parent: firstChild,
nodes: firstChild.children,
shouldShowAnnotations: shouldShowAnnotations,
shouldShowComments: shouldShowComments,
inMainline: inMainline,
startMainline: false,
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -411,15 +425,19 @@ class InlineMove extends ConsumerWidget {
context,
1,
isLichessGameAnalysis: options.isLichessGameAnalysis,
nag: branch.nags?.firstOrNull,
nag: shouldShowAnnotations
? branch.nags?.firstOrNull
: null,
),
)
: textStyle.copyWith(
color: _textColor(
context,
0.9,
isLichessGameAnalysis: options.isLichessGameAnalysis,
nag: branch.nags?.firstOrNull,
nag: shouldShowAnnotations
? branch.nags?.firstOrNull
: null,
),
),
),
Expand Down