diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 8c5954014..661c781f4 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -5014,5 +5014,6 @@ "getStartedFriendsButton": "Invite a friend", "groupChat": "Group Chat", "directMessage": "Direct Message", - "newDirectMessage": "New direct message" + "newDirectMessage": "New direct message", + "speakingExercisesTooltip": "Speaking practice" } \ No newline at end of file diff --git a/lib/pangea/analytics_misc/learning_skills_enum.dart b/lib/pangea/analytics_misc/learning_skills_enum.dart index ca01e155a..60fad7847 100644 --- a/lib/pangea/analytics_misc/learning_skills_enum.dart +++ b/lib/pangea/analytics_misc/learning_skills_enum.dart @@ -7,7 +7,7 @@ import 'package:fluffychat/l10n/l10n.dart'; enum LearningSkillsEnum { writing(isVisible: true, icon: Symbols.edit_square), reading(isVisible: true, icon: Symbols.two_pager), - speaking(isVisible: false), + speaking(isVisible: true, icon: Icons.mic_outlined), hearing(isVisible: true, icon: Icons.volume_up), other(isVisible: false); @@ -27,6 +27,8 @@ enum LearningSkillsEnum { return L10n.of(context).readingExercisesTooltip; case LearningSkillsEnum.hearing: return L10n.of(context).listeningExercisesTooltip; + case LearningSkillsEnum.speaking: + return L10n.of(context).speakingExercisesTooltip; default: return ""; } diff --git a/lib/pangea/toolbar/models/speech_to_text_models.dart b/lib/pangea/toolbar/models/speech_to_text_models.dart index 1b7b676af..4b00929a0 100644 --- a/lib/pangea/toolbar/models/speech_to_text_models.dart +++ b/lib/pangea/toolbar/models/speech_to_text_models.dart @@ -245,6 +245,7 @@ class SpeechToTextModel { ); for (final sstToken in transcript.sttTokens) { final token = sstToken.token; + if (!token.lemma.saveVocab) continue; constructs.addAll( token.allUses( ConstructUseTypeEnum.pvm, diff --git a/lib/pangea/toolbar/widgets/overlay_message.dart b/lib/pangea/toolbar/widgets/overlay_message.dart index 91a528738..7717303ae 100644 --- a/lib/pangea/toolbar/widgets/overlay_message.dart +++ b/lib/pangea/toolbar/widgets/overlay_message.dart @@ -142,6 +142,86 @@ class OverlayMessage extends StatelessWidget { final showSpeechTranslation = overlayController.showSpeechTranslation && overlayController.speechTranslation != null; + final transcription = showTranscription + ? Container( + width: messageWidth, + constraints: const BoxConstraints( + maxHeight: AppConfig.audioTranscriptionMaxHeight, + ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: overlayController.transcriptionError != null + ? Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.error_outline, + color: Theme.of(context).colorScheme.error, + ), + const SizedBox(width: 8), + Text( + L10n.of(context).oopsSomethingWentWrong, + style: AppConfig.messageTextStyle( + event, + textColor, + ).copyWith(fontStyle: FontStyle.italic), + ), + ], + ) + : overlayController.transcription != null + ? SingleChildScrollView( + child: Text( + overlayController.transcription!.transcript.text, + style: AppConfig.messageTextStyle( + event, + textColor, + ).copyWith( + fontStyle: FontStyle.italic, + ), + ), + ) + : Row( + mainAxisSize: MainAxisSize.min, + children: [ + CircularProgressIndicator.adaptive( + backgroundColor: textColor, + ), + ], + ), + ), + ) + : const SizedBox(); + + final translation = showTranslation || showSpeechTranslation + ? Container( + width: messageWidth, + constraints: const BoxConstraints( + maxHeight: AppConfig.audioTranscriptionMaxHeight, + ), + child: Padding( + padding: const EdgeInsets.fromLTRB( + 12.0, + 20.0, + 12.0, + 12.0, + ), + child: SingleChildScrollView( + child: Text( + showTranslation + ? overlayController.translation! + : overlayController.speechTranslation!, + style: AppConfig.messageTextStyle( + event, + textColor, + ).copyWith( + fontStyle: FontStyle.italic, + ), + ), + ), + ), + ) + : const SizedBox(); + final content = Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular( @@ -159,6 +239,8 @@ class OverlayMessage extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ + if (readingAssistanceMode == ReadingAssistanceMode.transitionMode) + transcription, if (event.relationshipType == RelationshipTypes.reply) FutureBuilder( future: event.getReplyEvent( @@ -257,6 +339,8 @@ class OverlayMessage extends StatelessWidget { ], ), ), + if (readingAssistanceMode == ReadingAssistanceMode.transitionMode) + translation, ], ), ), @@ -273,48 +357,8 @@ class OverlayMessage extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (showTranscription) - Container( - width: messageWidth, - constraints: const BoxConstraints( - maxHeight: AppConfig.audioTranscriptionMaxHeight, - ), - child: Padding( - padding: const EdgeInsets.all(12.0), - child: overlayController.transcriptionError != null - ? Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.error_outline, - color: Theme.of(context).colorScheme.error, - ), - const SizedBox(width: 8), - Text( - L10n.of(context).oopsSomethingWentWrong, - style: AppConfig.messageTextStyle( - event, - textColor, - ).copyWith(fontStyle: FontStyle.italic), - ), - ], - ) - : overlayController.transcription != null - ? SingleChildScrollView( - child: Text( - overlayController - .transcription!.transcript.text, - style: AppConfig.messageTextStyle( - event, - textColor, - ).copyWith( - fontStyle: FontStyle.italic, - ), - ), - ) - : const LinearProgressIndicator(), - ), - ), + if (readingAssistanceMode != ReadingAssistanceMode.transitionMode) + transcription, sizeAnimation != null ? AnimatedBuilder( animation: sizeAnimation!, @@ -327,34 +371,8 @@ class OverlayMessage extends StatelessWidget { }, ) : content, - if (showTranslation || showSpeechTranslation) - Container( - width: messageWidth, - constraints: const BoxConstraints( - maxHeight: AppConfig.audioTranscriptionMaxHeight, - ), - child: Padding( - padding: const EdgeInsets.fromLTRB( - 12.0, - 20.0, - 12.0, - 12.0, - ), - child: SingleChildScrollView( - child: Text( - showTranslation - ? overlayController.translation! - : overlayController.speechTranslation!, - style: AppConfig.messageTextStyle( - event, - textColor, - ).copyWith( - fontStyle: FontStyle.italic, - ), - ), - ), - ), - ), + if (readingAssistanceMode != ReadingAssistanceMode.transitionMode) + translation, ], ), ),