From cf1f79147a601d007ec7d45d07160e17f82a8790 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 25 Oct 2024 09:20:50 -0400 Subject: [PATCH 1/6] don't allow users to edit the input bar during IT --- lib/pages/chat/chat.dart | 2 +- lib/pages/chat/chat_input_row.dart | 1 + lib/pages/chat/input_bar.dart | 2 ++ lib/pangea/choreographer/controllers/choreographer.dart | 9 +++++---- 4 files changed, 9 insertions(+), 5 deletions(-) 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..9d1691620 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -261,7 +261,7 @@ class Choreographer { // debugger(when: kDebugMode); } - await (choreoMode == ChoreoMode.it && !itController.isTranslationDone + await (isRunningIT ? itController.getTranslationData(_useCustomInput) : igc.getIGCTextData( onlyTokensAndLanguageDetection: onlyTokensAndLanguageDetection, @@ -418,7 +418,7 @@ class Choreographer { setState(); } - giveInputFocus() { + void giveInputFocus() { Future.delayed(Duration.zero, () { chatController.inputFocus.requestFocus(); }); @@ -478,6 +478,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 +508,6 @@ class Choreographer { } } - bool get showIsError => !itController.isOpen && errorService.isError; - LayerLinkAndKey get itBarLinkAndKey => MatrixState.pAnyState.layerLinkAndKey(itBarTransformTargetKey); From 49588b91cfe4fbaf88b4e927fa179b618956566c Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 25 Oct 2024 09:44:18 -0400 Subject: [PATCH 2/6] don't allow send + make send button red while running IT --- .../controllers/choreographer.dart | 22 ++++++++++++++++--- .../controllers/igc_controller.dart | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 9d1691620..3d39a308b 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; } @@ -571,7 +571,7 @@ class Choreographer { return AssistanceState.noMessage; } - if (igc.igcTextData?.matches.isNotEmpty ?? false) { + if ((igc.igcTextData?.matches.isNotEmpty ?? false) || isRunningIT) { return AssistanceState.fetched; } @@ -585,4 +585,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..2b66dbd5d 100644 --- a/lib/pangea/choreographer/controllers/igc_controller.dart +++ b/lib/pangea/choreographer/controllers/igc_controller.dart @@ -202,8 +202,8 @@ class IgcController { } return !((choreographer.itEnabled && - igcTextData!.matches.any((match) => match.isOutOfTargetMatch)) || + igcTextData!.matches.any((match) => match.isITStart)) || (choreographer.igcEnabled && - igcTextData!.matches.any((match) => !match.isOutOfTargetMatch))); + igcTextData!.matches.any((match) => !match.isITStart))); } } From f4c0637f83d69f335e722a2456b42eaad4973ab5 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 25 Oct 2024 09:49:53 -0400 Subject: [PATCH 3/6] only reset IT source text if the user hasn't gone through any IT steps --- lib/pangea/choreographer/controllers/it_controller.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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(); } From 01f07c558426a201891bf74a48e2c10dbab1b99e Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 25 Oct 2024 09:51:39 -0400 Subject: [PATCH 4/6] move canSend function from igcController to choreographer --- .../choreographer/controllers/igc_controller.dart | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/pangea/choreographer/controllers/igc_controller.dart b/lib/pangea/choreographer/controllers/igc_controller.dart index 2b66dbd5d..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.isITStart)) || - (choreographer.igcEnabled && - igcTextData!.matches.any((match) => !match.isITStart))); - } } From 380689cf03d39e48510372598f1d02d785355e38 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 25 Oct 2024 10:04:59 -0400 Subject: [PATCH 5/6] if running language assistance after going through IT, clear the itController --- lib/pangea/choreographer/controllers/choreographer.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 3d39a308b..f3e48a8b6 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -255,10 +255,13 @@ 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 (isRunningIT From 4c3fccd55f960538f534f1d5a2a7a6f1003c2893 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 25 Oct 2024 10:08:13 -0400 Subject: [PATCH 6/6] bump version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"