Merge pull request #999 from pangeachat/967-give-a-message-about-what-it-is-before-the-message-about-clicking-and-holding-for-a-hint

added new IT instruction tooltip
pull/1490/head
ggurdin 1 year ago committed by GitHub
commit d0eb98d141
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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!"
}

@ -35,6 +35,8 @@ class ITBarState extends State<ITBar> {
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<ITBar> {
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<ITBar> {
// 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<ITBar> {
),
);
}
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 {

@ -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;
}
}
}

@ -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<String, dynamic> 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<String, dynamic> toJson() {
@ -241,6 +245,7 @@ class UserInstructions {
data[InstructionsEnum.clickAgainToDeselect.toString()] =
showedClickAgainToDeselect;
data[InstructionsEnum.missingVoice.toString()] = showedMissingVoice;
data[InstructionsEnum.clickBestOption.toString()] = showedClickBestOption;
return data;
}

@ -59,6 +59,9 @@ class InstructionsController {
case InstructionsEnum.missingVoice:
profile.instructionSettings.showedMissingVoice = value;
break;
case InstructionsEnum.clickBestOption:
profile.instructionSettings.showedClickBestOption = value;
break;
}
return profile;
});

Loading…
Cancel
Save