From 9af29d1d0c854908b316f69902d4bdbc2b754c52 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 30 Oct 2024 15:06:37 -0400 Subject: [PATCH 1/4] start language assistance on enter --- lib/pages/chat/chat_input_row.dart | 10 +++++----- .../choreographer/controllers/choreographer.dart | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/pages/chat/chat_input_row.dart b/lib/pages/chat/chat_input_row.dart index 57360d25d..b135f9b58 100644 --- a/lib/pages/chat/chat_input_row.dart +++ b/lib/pages/chat/chat_input_row.dart @@ -1,5 +1,4 @@ import 'package:animations/animations.dart'; -import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/pangea/choreographer/widgets/send_button.dart'; import 'package:fluffychat/pangea/constants/language_constants.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -299,11 +298,12 @@ class ChatInputRow extends StatelessWidget { maxLines: 8, autofocus: !PlatformInfos.isMobile, keyboardType: TextInputType.multiline, - textInputAction: AppConfig.sendOnEnter == true && - PlatformInfos.isMobile - ? TextInputAction.send - : null, // #Pangea + // textInputAction: AppConfig.sendOnEnter == true && + // PlatformInfos.isMobile + // ? TextInputAction.send + // : null, + textInputAction: TextInputAction.send, // onSubmitted: controller.onInputBarSubmitted, onSubmitted: (String value) => controller.onInputBarSubmitted(value, context), diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 6f65ea836..578ffc127 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -68,7 +68,12 @@ class Choreographer { } void send(BuildContext context) { - if (!canSendMessage) return; + if (!canSendMessage) { + if (igc.igcTextData != null) { + igc.showFirstMatch(context); + } + return; + } if (pangeaController.subscriptionController.subscriptionStatus == SubscriptionStatus.showPaywall) { From 61aed51d15033e1a4642efdfff48602d956ac72f Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 30 Oct 2024 15:11:26 -0400 Subject: [PATCH 2/4] always show the choreographer send button --- lib/pages/chat/chat_input_row.dart | 56 +++++++++---------- .../choreographer/widgets/send_button.dart | 6 +- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/pages/chat/chat_input_row.dart b/lib/pages/chat/chat_input_row.dart index b135f9b58..340784455 100644 --- a/lib/pages/chat/chat_input_row.dart +++ b/lib/pages/chat/chat_input_row.dart @@ -336,36 +336,36 @@ class ChatInputRow extends StatelessWidget { height: height, width: height, alignment: Alignment.center, - child: PlatformInfos.platformCanRecord && - controller.sendController.text.isEmpty - ? FloatingActionButton.small( - tooltip: L10n.of(context)!.voiceMessage, - onPressed: controller.voiceMessageAction, - elevation: 0, - heroTag: null, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(height), - ), - backgroundColor: theme.colorScheme.primary, - foregroundColor: theme.colorScheme.onPrimary, - child: const Icon(Icons.mic_none_outlined), - ) - : + child: // #Pangea + // PlatformInfos.platformCanRecord && + // controller.sendController.text.isEmpty + // ? FloatingActionButton.small( + // tooltip: L10n.of(context)!.voiceMessage, + // onPressed: controller.voiceMessageAction, + // elevation: 0, + // heroTag: null, + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(height), + // ), + // backgroundColor: theme.colorScheme.primary, + // foregroundColor: theme.colorScheme.onPrimary, + // child: const Icon(Icons.mic_none_outlined), + // ) + // : FloatingActionButton.small( + // tooltip: L10n.of(context)!.send, + // onPressed: controller.send, + // elevation: 0, + // heroTag: null, + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(height), + // ), + // backgroundColor: + // theme.colorScheme.onPrimaryContainer, + // foregroundColor: theme.colorScheme.onPrimary, + // child: const Icon(Icons.send_outlined), + // ), ChoreographerSendButton(controller: controller), - // FloatingActionButton.small( - // tooltip: L10n.of(context)!.send, - // onPressed: controller.send, - // elevation: 0, - // heroTag: null, - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(height), - // ), - // backgroundColor: - // theme.colorScheme.onPrimaryContainer, - // foregroundColor: theme.colorScheme.onPrimary, - // child: const Icon(Icons.send_outlined), - // ), // Pangea# ), ], diff --git a/lib/pangea/choreographer/widgets/send_button.dart b/lib/pangea/choreographer/widgets/send_button.dart index 6fba75395..159a70ea1 100644 --- a/lib/pangea/choreographer/widgets/send_button.dart +++ b/lib/pangea/choreographer/widgets/send_button.dart @@ -58,8 +58,10 @@ class ChoreographerSendButtonState extends State { onPressed: () { widget.controller.choreographer.canSendMessage ? widget.controller.choreographer.send(context) - : widget.controller.choreographer.igc - .showFirstMatch(context); + : !widget.controller.choreographer.isRunningIT + ? widget.controller.choreographer.igc + .showFirstMatch(context) + : null; }, tooltip: L10n.of(context)!.send, ), From 2c75090a06cd8eee65d462536a7365b611f24299 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 30 Oct 2024 15:12:40 -0400 Subject: [PATCH 3/4] removed freeze-analytics comments --- lib/pangea/widgets/chat/missing_voice_button.dart | 2 -- .../widgets/practice_activity/multiple_choice_activity.dart | 2 -- lib/pangea/widgets/practice_activity/word_audio_button.dart | 1 - 3 files changed, 5 deletions(-) diff --git a/lib/pangea/widgets/chat/missing_voice_button.dart b/lib/pangea/widgets/chat/missing_voice_button.dart index b1f12c626..e1f8b74fb 100644 --- a/lib/pangea/widgets/chat/missing_voice_button.dart +++ b/lib/pangea/widgets/chat/missing_voice_button.dart @@ -49,8 +49,6 @@ class MissingVoiceButton extends StatelessWidget { ), TextButton( onPressed: () => launchTTSSettings, - // commenting out as suspecting this is causing an issue - // #freeze-activity style: const ButtonStyle( tapTargetSize: MaterialTapTargetSize.shrinkWrap, ), diff --git a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart index e76021000..e48a7bb5b 100644 --- a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart +++ b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart @@ -70,7 +70,6 @@ class MultipleChoiceActivityState extends State { return; } - // #freeze-activity MatrixState.pangeaController.myAnalytics.setState( AnalyticsStream( // note - this maybe should be the activity event id @@ -112,7 +111,6 @@ class MultipleChoiceActivityState extends State { ), ), const SizedBox(height: 8), - // #freeze-activity if (practiceActivity.activityType == ActivityTypeEnum.wordFocusListening) WordAudioButton( diff --git a/lib/pangea/widgets/practice_activity/word_audio_button.dart b/lib/pangea/widgets/practice_activity/word_audio_button.dart index 2f56299c8..591228e18 100644 --- a/lib/pangea/widgets/practice_activity/word_audio_button.dart +++ b/lib/pangea/widgets/practice_activity/word_audio_button.dart @@ -55,7 +55,6 @@ class WordAudioButtonState extends State { } }, // Disable button if language isn't supported ), - // #freeze-activity widget.ttsController.missingVoiceButton, ], ); From 66e7eb79fa65f342e3e580d4fd8e62019240da31 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 30 Oct 2024 16:56:50 -0400 Subject: [PATCH 4/4] don't run languageAssistance after dismissing IT --- lib/pangea/choreographer/controllers/choreographer.dart | 9 ++++++--- lib/pangea/choreographer/controllers/it_controller.dart | 6 ++++++ lib/pangea/choreographer/widgets/send_button.dart | 7 +------ lib/pangea/enum/edit_type.dart | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 578ffc127..04e10ae0d 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -89,7 +89,7 @@ class Choreographer { return; } - if (!igc.hasRelevantIGCTextData) { + if (!igc.hasRelevantIGCTextData && !itController.dismissed) { getLanguageHelp().then((value) => _sendWithIGC(context)); } else { _sendWithIGC(context); @@ -206,7 +206,8 @@ class Choreographer { return; } - if (_textController.editType == EditType.igc) { + if (_textController.editType == EditType.igc || + _textController.editType == EditType.itDismissed) { _lastChecked = _textController.text; _textController.editType = EditType.keyboard; return; @@ -608,7 +609,9 @@ class Choreographer { if (isFetching) return false; // they're supposed to run IGC but haven't yet, don't let them send - if (isAutoIGCEnabled && igc.igcTextData == null) return false; + if (igc.igcTextData == null) { + return itController.dismissed; + } // if they have relevant matches, don't let them send final hasITMatches = diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index e30f30b3d..08450605a 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -4,6 +4,7 @@ import 'dart:developer'; import 'package:fluffychat/pangea/choreographer/controllers/error_service.dart'; import 'package:fluffychat/pangea/constants/choreo_constants.dart'; import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart'; +import 'package:fluffychat/pangea/enum/edit_type.dart'; import 'package:fluffychat/pangea/models/pangea_token_model.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart'; import 'package:flutter/foundation.dart'; @@ -25,6 +26,7 @@ class ITController { bool _willOpen = false; bool _isEditingSourceText = false; bool showChoiceFeedback = false; + bool dismissed = false; ITStartData? _itStartData; String? sourceText; @@ -41,6 +43,7 @@ class ITController { _willOpen = false; showChoiceFeedback = false; _isEditingSourceText = false; + dismissed = false; _itStartData = null; sourceText = null; @@ -70,9 +73,11 @@ class ITController { void closeIT() { // if the user hasn't gone through any IT steps, reset the text if (completedITSteps.isEmpty && sourceText != null) { + choreographer.textController.editType = EditType.itDismissed; choreographer.textController.text = sourceText!; } clear(); + dismissed = true; } /// if IGC isn't positive that text is full L1 then translate to L1 @@ -200,6 +205,7 @@ class ITController { final ITResponseModel res = await _customInputTranslation(currentText + nextText); + if (sourceText == null) return; nextITStep = CurrentITStep( sourceText: sourceText!, diff --git a/lib/pangea/choreographer/widgets/send_button.dart b/lib/pangea/choreographer/widgets/send_button.dart index 159a70ea1..f5e358a31 100644 --- a/lib/pangea/choreographer/widgets/send_button.dart +++ b/lib/pangea/choreographer/widgets/send_button.dart @@ -56,12 +56,7 @@ class ChoreographerSendButtonState extends State { color: widget.controller.choreographer.assistanceState .stateColor(context), onPressed: () { - widget.controller.choreographer.canSendMessage - ? widget.controller.choreographer.send(context) - : !widget.controller.choreographer.isRunningIT - ? widget.controller.choreographer.igc - .showFirstMatch(context) - : null; + widget.controller.choreographer.send(context); }, tooltip: L10n.of(context)!.send, ), diff --git a/lib/pangea/enum/edit_type.dart b/lib/pangea/enum/edit_type.dart index 5d0a43932..775c376f8 100644 --- a/lib/pangea/enum/edit_type.dart +++ b/lib/pangea/enum/edit_type.dart @@ -5,4 +5,5 @@ enum EditType { alternativeTranslation, itGold, itStart, + itDismissed, }