replace no more practice activities text with tooltip telling user to use language tools

pull/1490/head
ggurdin 1 year ago
parent d0eb98d141
commit cf571c6a92
No known key found for this signature in database
GPG Key ID: A01CB41737CBB478

@ -4499,5 +4499,6 @@
"messageNotInTargetLang": "Message not in target language", "messageNotInTargetLang": "Message not in target language",
"other": "Other", "other": "Other",
"botModeValidation": "Please select a chat mode", "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": "Youve unlocked the language tools for this message. Try them out by clicking below!"
} }

@ -17,6 +17,7 @@ enum InstructionsEnum {
clickAgainToDeselect, clickAgainToDeselect,
missingVoice, missingVoice,
clickBestOption, clickBestOption,
unlockedLanguageTools,
} }
extension InstructionsEnumExtension on InstructionsEnum { extension InstructionsEnumExtension on InstructionsEnum {
@ -37,6 +38,7 @@ extension InstructionsEnumExtension on InstructionsEnum {
case InstructionsEnum.l1Translation: case InstructionsEnum.l1Translation:
case InstructionsEnum.translationChoices: case InstructionsEnum.translationChoices:
case InstructionsEnum.clickBestOption: case InstructionsEnum.clickBestOption:
case InstructionsEnum.unlockedLanguageTools:
ErrorHandler.logError( ErrorHandler.logError(
e: Exception("No title for this instruction"), e: Exception("No title for this instruction"),
m: 'InstructionsEnumExtension.title', m: 'InstructionsEnumExtension.title',
@ -73,6 +75,8 @@ extension InstructionsEnumExtension on InstructionsEnum {
return l10n.voiceNotAvailable; return l10n.voiceNotAvailable;
case InstructionsEnum.clickBestOption: case InstructionsEnum.clickBestOption:
return l10n.clickBestOption; return l10n.clickBestOption;
case InstructionsEnum.unlockedLanguageTools:
return l10n.unlockedLanguageTools;
} }
} }
@ -100,6 +104,8 @@ extension InstructionsEnumExtension on InstructionsEnum {
return instructionSettings.showedMissingVoice; return instructionSettings.showedMissingVoice;
case InstructionsEnum.clickBestOption: case InstructionsEnum.clickBestOption:
return instructionSettings.showedClickBestOption; return instructionSettings.showedClickBestOption;
case InstructionsEnum.unlockedLanguageTools:
return instructionSettings.showedUnlockedLanguageTools;
} }
} }
} }

@ -187,6 +187,7 @@ class UserInstructions {
bool showedTooltipInstructions; bool showedTooltipInstructions;
bool showedMissingVoice; bool showedMissingVoice;
bool showedClickBestOption; bool showedClickBestOption;
bool showedUnlockedLanguageTools;
bool showedSpeechToTextTooltip; bool showedSpeechToTextTooltip;
bool showedL1TranslationTooltip; bool showedL1TranslationTooltip;
@ -204,6 +205,7 @@ class UserInstructions {
this.showedClickAgainToDeselect = false, this.showedClickAgainToDeselect = false,
this.showedMissingVoice = false, this.showedMissingVoice = false,
this.showedClickBestOption = false, this.showedClickBestOption = false,
this.showedUnlockedLanguageTools = false,
}); });
factory UserInstructions.fromJson(Map<String, dynamic> json) => factory UserInstructions.fromJson(Map<String, dynamic> json) =>
@ -227,6 +229,8 @@ class UserInstructions {
json[InstructionsEnum.missingVoice.toString()] ?? false, json[InstructionsEnum.missingVoice.toString()] ?? false,
showedClickBestOption: showedClickBestOption:
json[InstructionsEnum.clickBestOption.toString()] ?? false, json[InstructionsEnum.clickBestOption.toString()] ?? false,
showedUnlockedLanguageTools:
json[InstructionsEnum.unlockedLanguageTools.toString()] ?? false,
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -246,6 +250,8 @@ class UserInstructions {
showedClickAgainToDeselect; showedClickAgainToDeselect;
data[InstructionsEnum.missingVoice.toString()] = showedMissingVoice; data[InstructionsEnum.missingVoice.toString()] = showedMissingVoice;
data[InstructionsEnum.clickBestOption.toString()] = showedClickBestOption; data[InstructionsEnum.clickBestOption.toString()] = showedClickBestOption;
data[InstructionsEnum.unlockedLanguageTools.toString()] =
showedUnlockedLanguageTools;
return data; return data;
} }

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

@ -1,5 +1,6 @@
import 'package:fluffychat/config/app_config.dart'; 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'; import 'package:flutter/material.dart';
class StarAnimationWidget extends StatefulWidget { class StarAnimationWidget extends StatefulWidget {
@ -66,9 +67,12 @@ class _StarAnimationWidgetState extends State<StarAnimationWidget>
} }
class GamifiedTextWidget extends StatelessWidget { 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -79,11 +83,9 @@ class GamifiedTextWidget extends StatelessWidget {
child: Column( child: Column(
children: [ children: [
const StarAnimationWidget(), const StarAnimationWidget(),
const SizedBox(height: 10), InlineTooltip(
Text( instructionsEnum: InstructionsEnum.unlockedLanguageTools,
userMessage, onClose: onCloseTooltip,
style: BotStyle.text(context),
textAlign: TextAlign.center,
), ),
], ],
), ),

@ -23,7 +23,6 @@ import 'package:fluffychat/pangea/widgets/practice_activity/no_more_practice_car
import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
/// The wrapper for practice activity content. /// The wrapper for practice activity content.
/// Handles the activities associated with a message, /// Handles the activities associated with a message,
@ -382,11 +381,13 @@ class PracticeActivityCardState extends State<PracticeActivityCard> {
} }
} }
void _closeTooltip() => setState(() {});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!fetchingActivity && currentActivity == null) { if (!fetchingActivity && currentActivity == null) {
return GamifiedTextWidget( return GamifiedTextWidget(
userMessage: L10n.of(context)!.noActivitiesFound, onCloseTooltip: _closeTooltip,
); );
} }

Loading…
Cancel
Save