From 24df171167897fca18179695fc80666118f440e6 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 13 Nov 2024 15:34:58 -0500 Subject: [PATCH] added new IT instruction tooltip --- assets/l10n/intl_en.arb | 3 +- lib/pangea/choreographer/widgets/it_bar.dart | 38 ++++++++++++++------ lib/pangea/enum/instructions_enum.dart | 6 ++++ lib/pangea/models/user_model.dart | 5 +++ lib/pangea/utils/instructions.dart | 3 ++ 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 9674f45fc..c78575c5f 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4498,5 +4498,6 @@ "selectBotChatMode": "Select chat mode", "messageNotInTargetLang": "Message not in target language", "other": "Other", - "botModeValidation": "Please select a chat mode" + "botModeValidation": "Please select a chat mode", + "clickBestOption": "Choose the best options to translate your message!" } \ No newline at end of file diff --git a/lib/pangea/choreographer/widgets/it_bar.dart b/lib/pangea/choreographer/widgets/it_bar.dart index ff7ae8d31..6b6af84d8 100644 --- a/lib/pangea/choreographer/widgets/it_bar.dart +++ b/lib/pangea/choreographer/widgets/it_bar.dart @@ -35,6 +35,8 @@ class ITBarState extends State { ITController get itController => widget.choreographer.itController; StreamSubscription? _choreoSub; + bool showedClickInstruction = false; + @override void initState() { // Rebuild the widget each time there's an update from choreo. @@ -44,6 +46,26 @@ class ITBarState extends State { super.initState(); } + bool get showITInstructionsTooltip { + final toggledOff = InstructionsEnum.clickBestOption.toggledOff(); + if (!toggledOff) { + setState(() => showedClickInstruction = true); + } + return !toggledOff; + } + + bool get showTranslationsChoicesTooltip { + return !showedClickInstruction && + !showITInstructionsTooltip && + !itController.choreographer.isFetching && + !itController.isLoading && + !itController.isEditingSourceText && + !itController.isTranslationDone && + itController.currentITStep != null && + itController.currentITStep!.continuances.isNotEmpty && + !itController.showChoiceFeedback; + } + @override void dispose() { _choreoSub?.cancel(); @@ -117,6 +139,12 @@ class ITBarState extends State { // const SizedBox(height: 40.0), OriginalText(controller: itController), const SizedBox(height: 7.0), + if (showITInstructionsTooltip) + InlineTooltip( + instructionsEnum: + InstructionsEnum.clickBestOption, + onClose: () => setState(() {}), + ), if (showTranslationsChoicesTooltip) InlineTooltip( instructionsEnum: @@ -169,16 +197,6 @@ class ITBarState extends State { ), ); } - - bool get showTranslationsChoicesTooltip { - return !itController.choreographer.isFetching && - !itController.isLoading && - !itController.isEditingSourceText && - !itController.isTranslationDone && - itController.currentITStep != null && - itController.currentITStep!.continuances.isNotEmpty && - !itController.showChoiceFeedback; - } } class ChoiceFeedbackText extends StatelessWidget { diff --git a/lib/pangea/enum/instructions_enum.dart b/lib/pangea/enum/instructions_enum.dart index 64bad0fb3..3c04f5abf 100644 --- a/lib/pangea/enum/instructions_enum.dart +++ b/lib/pangea/enum/instructions_enum.dart @@ -16,6 +16,7 @@ enum InstructionsEnum { translationChoices, clickAgainToDeselect, missingVoice, + clickBestOption, } extension InstructionsEnumExtension on InstructionsEnum { @@ -35,6 +36,7 @@ extension InstructionsEnumExtension on InstructionsEnum { case InstructionsEnum.speechToText: case InstructionsEnum.l1Translation: case InstructionsEnum.translationChoices: + case InstructionsEnum.clickBestOption: ErrorHandler.logError( e: Exception("No title for this instruction"), m: 'InstructionsEnumExtension.title', @@ -69,6 +71,8 @@ extension InstructionsEnumExtension on InstructionsEnum { : l10n.tooltipInstructionsBrowserBody; case InstructionsEnum.missingVoice: return l10n.voiceNotAvailable; + case InstructionsEnum.clickBestOption: + return l10n.clickBestOption; } } @@ -94,6 +98,8 @@ extension InstructionsEnumExtension on InstructionsEnum { return instructionSettings.showedClickAgainToDeselect; case InstructionsEnum.missingVoice: return instructionSettings.showedMissingVoice; + case InstructionsEnum.clickBestOption: + return instructionSettings.showedClickBestOption; } } } diff --git a/lib/pangea/models/user_model.dart b/lib/pangea/models/user_model.dart index ba55330f3..daa41d862 100644 --- a/lib/pangea/models/user_model.dart +++ b/lib/pangea/models/user_model.dart @@ -186,6 +186,7 @@ class UserInstructions { bool showedBlurMeansTranslate; bool showedTooltipInstructions; bool showedMissingVoice; + bool showedClickBestOption; bool showedSpeechToTextTooltip; bool showedL1TranslationTooltip; @@ -202,6 +203,7 @@ class UserInstructions { this.showedTranslationChoicesTooltip = false, this.showedClickAgainToDeselect = false, this.showedMissingVoice = false, + this.showedClickBestOption = false, }); factory UserInstructions.fromJson(Map json) => @@ -223,6 +225,8 @@ class UserInstructions { json[InstructionsEnum.clickAgainToDeselect.toString()] ?? false, showedMissingVoice: json[InstructionsEnum.missingVoice.toString()] ?? false, + showedClickBestOption: + json[InstructionsEnum.clickBestOption.toString()] ?? false, ); Map toJson() { @@ -241,6 +245,7 @@ class UserInstructions { data[InstructionsEnum.clickAgainToDeselect.toString()] = showedClickAgainToDeselect; data[InstructionsEnum.missingVoice.toString()] = showedMissingVoice; + data[InstructionsEnum.clickBestOption.toString()] = showedClickBestOption; return data; } diff --git a/lib/pangea/utils/instructions.dart b/lib/pangea/utils/instructions.dart index a4e8ef151..99c2e8adc 100644 --- a/lib/pangea/utils/instructions.dart +++ b/lib/pangea/utils/instructions.dart @@ -59,6 +59,9 @@ class InstructionsController { case InstructionsEnum.missingVoice: profile.instructionSettings.showedMissingVoice = value; break; + case InstructionsEnum.clickBestOption: + profile.instructionSettings.showedClickBestOption = value; + break; } return profile; });