diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index cb1c86f5e..ebfd384bc 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -1419,7 +1419,7 @@ class ChatController extends State void onSelectMessage(Event event) { // #Pangea - if (choreographer.itController.isOpen) { + if (choreographer.itController.willOpen) { return; } // Pangea# diff --git a/lib/pages/chat/chat_input_row.dart b/lib/pages/chat/chat_input_row.dart index cc931ef12..57360d25d 100644 --- a/lib/pages/chat/chat_input_row.dart +++ b/lib/pages/chat/chat_input_row.dart @@ -321,6 +321,7 @@ class ChatInputRow extends StatelessWidget { // #Pangea // hintText: L10n.of(context)!.writeAMessage, hintText: hintText(), + disabledBorder: InputBorder.none, // Pangea# hintMaxLines: 1, border: InputBorder.none, diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index c0939f278..347d68786 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -478,6 +478,8 @@ class InputBar extends StatelessWidget { // builder: (context, controller, focusNode) => TextField( builder: (context, _, focusNode) => TextField( enableSuggestions: false, + readOnly: + controller != null && controller!.choreographer.isRunningIT, // Pangea# controller: controller, focusNode: focusNode, diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index df254d49c..f3e48a8b6 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -68,7 +68,7 @@ class Choreographer { } void send(BuildContext context) { - if (isFetching) return; + if (!canSendMessage) return; if (pangeaController.subscriptionController.subscriptionStatus == SubscriptionStatus.showPaywall) { @@ -92,7 +92,7 @@ class Choreographer { } Future _sendWithIGC(BuildContext context) async { - if (!igc.canSendMessage) { + if (!canSendMessage) { igc.showFirstMatch(context); return; } @@ -255,13 +255,16 @@ class Choreographer { } startLoading(); + + // if getting language assistance after finishing IT, + // reset the itController if (choreoMode == ChoreoMode.it && itController.isTranslationDone && !onlyTokensAndLanguageDetection) { - // debugger(when: kDebugMode); + itController.clear(); } - await (choreoMode == ChoreoMode.it && !itController.isTranslationDone + await (isRunningIT ? itController.getTranslationData(_useCustomInput) : igc.getIGCTextData( onlyTokensAndLanguageDetection: onlyTokensAndLanguageDetection, @@ -418,7 +421,7 @@ class Choreographer { setState(); } - giveInputFocus() { + void giveInputFocus() { Future.delayed(Duration.zero, () { chatController.inputFocus.requestFocus(); }); @@ -478,6 +481,9 @@ class Choreographer { bool get _noChange => _lastChecked != null && _lastChecked == _textController.text; + bool get isRunningIT => + choreoMode == ChoreoMode.it && !itController.isTranslationDone; + void startLoading() { _lastChecked = _textController.text; isFetching = true; @@ -505,8 +511,6 @@ class Choreographer { } } - bool get showIsError => !itController.isOpen && errorService.isError; - LayerLinkAndKey get itBarLinkAndKey => MatrixState.pAnyState.layerLinkAndKey(itBarTransformTargetKey); @@ -570,7 +574,7 @@ class Choreographer { return AssistanceState.noMessage; } - if (igc.igcTextData?.matches.isNotEmpty ?? false) { + if ((igc.igcTextData?.matches.isNotEmpty ?? false) || isRunningIT) { return AssistanceState.fetched; } @@ -584,4 +588,20 @@ class Choreographer { return AssistanceState.complete; } + + bool get canSendMessage { + if (isFetching) return false; + if (errorService.isError) return true; + if (itEnabled && isRunningIT) return false; + + final hasITMatches = + igc.igcTextData!.matches.any((match) => match.isITStart); + final hasIGCMatches = + igc.igcTextData!.matches.any((match) => !match.isITStart); + + if ((itEnabled && hasITMatches) || (igcEnabled && hasIGCMatches)) { + return false; + } + return true; + } } diff --git a/lib/pangea/choreographer/controllers/igc_controller.dart b/lib/pangea/choreographer/controllers/igc_controller.dart index 1acb37332..ed770cca4 100644 --- a/lib/pangea/choreographer/controllers/igc_controller.dart +++ b/lib/pangea/choreographer/controllers/igc_controller.dart @@ -192,18 +192,4 @@ class IgcController { // Not sure why this is here // MatrixState.pAnyState.closeOverlay(); } - - bool get canSendMessage { - if (choreographer.isFetching) return false; - if (igcTextData == null || - choreographer.errorService.isError || - igcTextData!.matches.isEmpty) { - return true; - } - - return !((choreographer.itEnabled && - igcTextData!.matches.any((match) => match.isOutOfTargetMatch)) || - (choreographer.igcEnabled && - igcTextData!.matches.any((match) => !match.isOutOfTargetMatch))); - } } diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index b618386f8..e30f30b3d 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -68,9 +68,10 @@ class ITController { } void closeIT() { - //if they close it before completing, just put their text back - //PTODO - explore using last itStep - choreographer.textController.text = sourceText ?? ""; + // if the user hasn't gone through any IT steps, reset the text + if (completedITSteps.isEmpty && sourceText != null) { + choreographer.textController.text = sourceText!; + } clear(); } diff --git a/pubspec.yaml b/pubspec.yaml index 2ae643555..e24350240 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 1.22.7+3557 +version: 1.22.8+3558 environment: sdk: ">=3.0.0 <4.0.0"