diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index c78575c5f..3a012e08d 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4499,5 +4499,6 @@ "messageNotInTargetLang": "Message not in target language", "other": "Other", "botModeValidation": "Please select a chat mode", - "clickBestOption": "Choose the best options to translate your message!" + "clickBestOption": "Choose the best options to translate your message!", + "unlockedLanguageTools": "You’ve unlocked the language tools for this message. Try them out by clicking below!" } \ No newline at end of file diff --git a/lib/pangea/enum/instructions_enum.dart b/lib/pangea/enum/instructions_enum.dart index 3c04f5abf..be04baffd 100644 --- a/lib/pangea/enum/instructions_enum.dart +++ b/lib/pangea/enum/instructions_enum.dart @@ -17,6 +17,7 @@ enum InstructionsEnum { clickAgainToDeselect, missingVoice, clickBestOption, + unlockedLanguageTools, } extension InstructionsEnumExtension on InstructionsEnum { @@ -37,6 +38,7 @@ extension InstructionsEnumExtension on InstructionsEnum { case InstructionsEnum.l1Translation: case InstructionsEnum.translationChoices: case InstructionsEnum.clickBestOption: + case InstructionsEnum.unlockedLanguageTools: ErrorHandler.logError( e: Exception("No title for this instruction"), m: 'InstructionsEnumExtension.title', @@ -73,6 +75,8 @@ extension InstructionsEnumExtension on InstructionsEnum { return l10n.voiceNotAvailable; case InstructionsEnum.clickBestOption: return l10n.clickBestOption; + case InstructionsEnum.unlockedLanguageTools: + return l10n.unlockedLanguageTools; } } @@ -100,6 +104,8 @@ extension InstructionsEnumExtension on InstructionsEnum { return instructionSettings.showedMissingVoice; case InstructionsEnum.clickBestOption: return instructionSettings.showedClickBestOption; + case InstructionsEnum.unlockedLanguageTools: + return instructionSettings.showedUnlockedLanguageTools; } } } diff --git a/lib/pangea/models/user_model.dart b/lib/pangea/models/user_model.dart index daa41d862..97a5f814a 100644 --- a/lib/pangea/models/user_model.dart +++ b/lib/pangea/models/user_model.dart @@ -187,6 +187,7 @@ class UserInstructions { bool showedTooltipInstructions; bool showedMissingVoice; bool showedClickBestOption; + bool showedUnlockedLanguageTools; bool showedSpeechToTextTooltip; bool showedL1TranslationTooltip; @@ -204,6 +205,7 @@ class UserInstructions { this.showedClickAgainToDeselect = false, this.showedMissingVoice = false, this.showedClickBestOption = false, + this.showedUnlockedLanguageTools = false, }); factory UserInstructions.fromJson(Map json) => @@ -227,6 +229,8 @@ class UserInstructions { json[InstructionsEnum.missingVoice.toString()] ?? false, showedClickBestOption: json[InstructionsEnum.clickBestOption.toString()] ?? false, + showedUnlockedLanguageTools: + json[InstructionsEnum.unlockedLanguageTools.toString()] ?? false, ); Map toJson() { @@ -246,6 +250,8 @@ class UserInstructions { showedClickAgainToDeselect; data[InstructionsEnum.missingVoice.toString()] = showedMissingVoice; data[InstructionsEnum.clickBestOption.toString()] = showedClickBestOption; + data[InstructionsEnum.unlockedLanguageTools.toString()] = + showedUnlockedLanguageTools; return data; } diff --git a/lib/pangea/utils/instructions.dart b/lib/pangea/utils/instructions.dart index 99c2e8adc..f606291df 100644 --- a/lib/pangea/utils/instructions.dart +++ b/lib/pangea/utils/instructions.dart @@ -62,6 +62,9 @@ class InstructionsController { case InstructionsEnum.clickBestOption: profile.instructionSettings.showedClickBestOption = value; break; + case InstructionsEnum.unlockedLanguageTools: + profile.instructionSettings.showedUnlockedLanguageTools = value; + break; } return profile; }); diff --git a/lib/pangea/widgets/practice_activity/no_more_practice_card.dart b/lib/pangea/widgets/practice_activity/no_more_practice_card.dart index 12a087d97..3877038d8 100644 --- a/lib/pangea/widgets/practice_activity/no_more_practice_card.dart +++ b/lib/pangea/widgets/practice_activity/no_more_practice_card.dart @@ -1,5 +1,6 @@ import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/pangea/utils/bot_style.dart'; +import 'package:fluffychat/pangea/enum/instructions_enum.dart'; +import 'package:fluffychat/pangea/utils/inline_tooltip.dart'; import 'package:flutter/material.dart'; class StarAnimationWidget extends StatefulWidget { @@ -66,9 +67,12 @@ class _StarAnimationWidgetState extends State } class GamifiedTextWidget extends StatelessWidget { - final String userMessage; + final VoidCallback onCloseTooltip; - const GamifiedTextWidget({super.key, required this.userMessage}); + const GamifiedTextWidget({ + required this.onCloseTooltip, + super.key, + }); @override Widget build(BuildContext context) { @@ -79,11 +83,9 @@ class GamifiedTextWidget extends StatelessWidget { child: Column( children: [ const StarAnimationWidget(), - const SizedBox(height: 10), - Text( - userMessage, - style: BotStyle.text(context), - textAlign: TextAlign.center, + InlineTooltip( + instructionsEnum: InstructionsEnum.unlockedLanguageTools, + onClose: onCloseTooltip, ), ], ), diff --git a/lib/pangea/widgets/practice_activity/practice_activity_card.dart b/lib/pangea/widgets/practice_activity/practice_activity_card.dart index 453059a5b..3531155eb 100644 --- a/lib/pangea/widgets/practice_activity/practice_activity_card.dart +++ b/lib/pangea/widgets/practice_activity/practice_activity_card.dart @@ -23,7 +23,6 @@ import 'package:fluffychat/pangea/widgets/practice_activity/no_more_practice_car import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/l10n.dart'; /// The wrapper for practice activity content. /// Handles the activities associated with a message, @@ -382,11 +381,13 @@ class PracticeActivityCardState extends State { } } + void _closeTooltip() => setState(() {}); + @override Widget build(BuildContext context) { if (!fetchingActivity && currentActivity == null) { return GamifiedTextWidget( - userMessage: L10n.of(context)!.noActivitiesFound, + onCloseTooltip: _closeTooltip, ); }