From efa355f1c1fe8979ce4d89a3ef05fc4618e55045 Mon Sep 17 00:00:00 2001 From: Vincent Velociter Date: Fri, 10 Jan 2025 09:52:47 +0800 Subject: [PATCH] Disallow editor when engine is not allowed Fixes #1350 --- lib/src/view/analysis/analysis_screen.dart | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/src/view/analysis/analysis_screen.dart b/lib/src/view/analysis/analysis_screen.dart index 9be60c3b76..56730d3317 100644 --- a/lib/src/view/analysis/analysis_screen.dart +++ b/lib/src/view/analysis/analysis_screen.dart @@ -276,21 +276,23 @@ class _BottomBar extends ConsumerWidget { ref.read(analysisControllerProvider(options).notifier).userPrevious(); Future _showAnalysisMenu(BuildContext context, WidgetRef ref) { + final analysisState = ref.read(analysisControllerProvider(options)).requireValue; return showAdaptiveActionSheet( context: context, actions: [ - BottomSheetAction( - makeLabel: (context) => Text(context.l10n.boardEditor), - onPressed: (context) { - final analysisState = ref.read(analysisControllerProvider(options)).requireValue; - final boardFen = analysisState.position.fen; - pushPlatformRoute( - context, - title: context.l10n.boardEditor, - builder: (_) => BoardEditorScreen(initialFen: boardFen), - ); - }, - ), + // board editor can be used to quickly analyze a position, so engine must be allowed to access + if (analysisState.isComputerAnalysisAllowed) + BottomSheetAction( + makeLabel: (context) => Text(context.l10n.boardEditor), + onPressed: (context) { + final boardFen = analysisState.position.fen; + pushPlatformRoute( + context, + title: context.l10n.boardEditor, + builder: (_) => BoardEditorScreen(initialFen: boardFen), + ); + }, + ), BottomSheetAction( makeLabel: (context) => Text(context.l10n.mobileShareGamePGN), onPressed: (_) {