added tooltip toggle status to matrix profile to prevent showing again after it's been dismissed
This commit is contained in:
parent
104750732b
commit
5c7a1f554b
3 changed files with 65 additions and 3 deletions
|
|
@ -72,4 +72,17 @@ extension InlineInstructionsExtension on InlineInstructions {
|
|||
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 showedTooltipInstructions;
|
||||
|
||||
bool showedSpeechToTextTooltip;
|
||||
bool showedL1TranslationTooltip;
|
||||
bool showedTranslationChoicesTooltip;
|
||||
|
||||
UserInstructions({
|
||||
this.showedItInstructions = false,
|
||||
this.showedClickMessage = false,
|
||||
this.showedBlurMeansTranslate = false,
|
||||
this.showedTooltipInstructions = false,
|
||||
this.showedSpeechToTextTooltip = false,
|
||||
this.showedL1TranslationTooltip = false,
|
||||
this.showedTranslationChoicesTooltip = false,
|
||||
});
|
||||
|
||||
factory UserInstructions.fromJson(Map<String, dynamic> json) =>
|
||||
|
|
@ -203,6 +210,12 @@ class UserInstructions {
|
|||
json[InstructionsEnum.blurMeansTranslate.toString()] ?? false,
|
||||
showedTooltipInstructions:
|
||||
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() {
|
||||
|
|
@ -213,6 +226,12 @@ class UserInstructions {
|
|||
showedBlurMeansTranslate;
|
||||
data[InstructionsEnum.tooltipInstructions.toString()] =
|
||||
showedTooltipInstructions;
|
||||
data[InlineInstructions.l1Translation.toString()] =
|
||||
showedL1TranslationTooltip;
|
||||
data[InlineInstructions.translationChoices.toString()] =
|
||||
showedTranslationChoicesTooltip;
|
||||
data[InlineInstructions.speechToText.toString()] =
|
||||
showedSpeechToTextTooltip;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
@ -238,6 +257,21 @@ class UserInstructions {
|
|||
?.content[InstructionsEnum.tooltipInstructions.toString()]
|
||||
as bool?) ??
|
||||
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 = {};
|
||||
|
||||
/// Returns true if the user requested this popup not be shown again
|
||||
bool? toggledOff(String key) => InstructionsEnum.values
|
||||
.firstWhereOrNull((value) => value.toString() == key)
|
||||
?.toggledOff;
|
||||
bool? toggledOff(String key) {
|
||||
final bool? instruction = InstructionsEnum.values
|
||||
.firstWhereOrNull((value) => value.toString() == key)
|
||||
?.toggledOff;
|
||||
final bool? tooltip = InlineInstructions.values
|
||||
.firstWhereOrNull((value) => value.toString() == key)
|
||||
?.toggledOff;
|
||||
return instruction ?? tooltip;
|
||||
}
|
||||
|
||||
InstructionsController(PangeaController pangeaController) {
|
||||
_pangeaController = pangeaController;
|
||||
|
|
@ -58,6 +64,15 @@ class InstructionsController {
|
|||
if (key == InstructionsEnum.tooltipInstructions.toString()) {
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue