added tooltip toggle status to matrix profile to prevent showing again after it's been dismissed

pull/1384/head
ggurdin 1 year ago
parent 104750732b
commit 5c7a1f554b
No known key found for this signature in database
GPG Key ID: A01CB41737CBB478

@ -72,4 +72,17 @@ extension InlineInstructionsExtension on InlineInstructions {
return L10n.of(context)!.translationChoicesBody; return L10n.of(context)!.translationChoicesBody;
} }
} }
bool get toggledOff {
final instructionSettings =
MatrixState.pangeaController.userController.profile.instructionSettings;
switch (this) {
case InlineInstructions.speechToText:
return instructionSettings.showedSpeechToTextTooltip;
case InlineInstructions.l1Translation:
return instructionSettings.showedL1TranslationTooltip;
case InlineInstructions.translationChoices:
return instructionSettings.showedTranslationChoicesTooltip;
}
}
} }

@ -186,11 +186,18 @@ class UserInstructions {
bool showedBlurMeansTranslate; bool showedBlurMeansTranslate;
bool showedTooltipInstructions; bool showedTooltipInstructions;
bool showedSpeechToTextTooltip;
bool showedL1TranslationTooltip;
bool showedTranslationChoicesTooltip;
UserInstructions({ UserInstructions({
this.showedItInstructions = false, this.showedItInstructions = false,
this.showedClickMessage = false, this.showedClickMessage = false,
this.showedBlurMeansTranslate = false, this.showedBlurMeansTranslate = false,
this.showedTooltipInstructions = false, this.showedTooltipInstructions = false,
this.showedSpeechToTextTooltip = false,
this.showedL1TranslationTooltip = false,
this.showedTranslationChoicesTooltip = false,
}); });
factory UserInstructions.fromJson(Map<String, dynamic> json) => factory UserInstructions.fromJson(Map<String, dynamic> json) =>
@ -203,6 +210,12 @@ class UserInstructions {
json[InstructionsEnum.blurMeansTranslate.toString()] ?? false, json[InstructionsEnum.blurMeansTranslate.toString()] ?? false,
showedTooltipInstructions: showedTooltipInstructions:
json[InstructionsEnum.tooltipInstructions.toString()] ?? false, json[InstructionsEnum.tooltipInstructions.toString()] ?? false,
showedL1TranslationTooltip:
json[InlineInstructions.l1Translation.toString()] ?? false,
showedTranslationChoicesTooltip:
json[InlineInstructions.translationChoices.toString()] ?? false,
showedSpeechToTextTooltip:
json[InlineInstructions.speechToText.toString()] ?? false,
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -213,6 +226,12 @@ class UserInstructions {
showedBlurMeansTranslate; showedBlurMeansTranslate;
data[InstructionsEnum.tooltipInstructions.toString()] = data[InstructionsEnum.tooltipInstructions.toString()] =
showedTooltipInstructions; showedTooltipInstructions;
data[InlineInstructions.l1Translation.toString()] =
showedL1TranslationTooltip;
data[InlineInstructions.translationChoices.toString()] =
showedTranslationChoicesTooltip;
data[InlineInstructions.speechToText.toString()] =
showedSpeechToTextTooltip;
return data; return data;
} }
@ -238,6 +257,21 @@ class UserInstructions {
?.content[InstructionsEnum.tooltipInstructions.toString()] ?.content[InstructionsEnum.tooltipInstructions.toString()]
as bool?) ?? as bool?) ??
false, false,
showedL1TranslationTooltip:
(accountData[InlineInstructions.l1Translation.toString()]
?.content[InlineInstructions.l1Translation.toString()]
as bool?) ??
false,
showedTranslationChoicesTooltip: (accountData[
InlineInstructions.translationChoices.toString()]
?.content[InlineInstructions.translationChoices.toString()]
as bool?) ??
false,
showedSpeechToTextTooltip:
(accountData[InlineInstructions.speechToText.toString()]
?.content[InlineInstructions.speechToText.toString()]
as bool?) ??
false,
); );
} }
} }

@ -25,9 +25,15 @@ class InstructionsController {
final Map<String, bool> _instructionsShown = {}; final Map<String, bool> _instructionsShown = {};
/// Returns true if the user requested this popup not be shown again /// Returns true if the user requested this popup not be shown again
bool? toggledOff(String key) => InstructionsEnum.values bool? toggledOff(String key) {
.firstWhereOrNull((value) => value.toString() == key) final bool? instruction = InstructionsEnum.values
?.toggledOff; .firstWhereOrNull((value) => value.toString() == key)
?.toggledOff;
final bool? tooltip = InlineInstructions.values
.firstWhereOrNull((value) => value.toString() == key)
?.toggledOff;
return instruction ?? tooltip;
}
InstructionsController(PangeaController pangeaController) { InstructionsController(PangeaController pangeaController) {
_pangeaController = pangeaController; _pangeaController = pangeaController;
@ -58,6 +64,15 @@ class InstructionsController {
if (key == InstructionsEnum.tooltipInstructions.toString()) { if (key == InstructionsEnum.tooltipInstructions.toString()) {
profile.instructionSettings.showedTooltipInstructions = value; profile.instructionSettings.showedTooltipInstructions = value;
} }
if (key == InlineInstructions.speechToText.toString()) {
profile.instructionSettings.showedSpeechToTextTooltip = value;
}
if (key == InlineInstructions.l1Translation.toString()) {
profile.instructionSettings.showedL1TranslationTooltip = value;
}
if (key == InlineInstructions.translationChoices.toString()) {
profile.instructionSettings.showedTranslationChoicesTooltip = value;
}
return profile; return profile;
}); });
} }

Loading…
Cancel
Save