From 40c4045f865204f87f95896e62de47cf7cca879b Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Fri, 7 Jun 2024 22:17:48 -0400 Subject: [PATCH 01/30] fixes for exiting IT and editing original message --- .../controllers/it_controller.dart | 23 ++++++++++++++----- lib/pangea/choreographer/widgets/it_bar.dart | 7 +++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index 6d5f8e347..91899a71a 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -61,11 +61,9 @@ class ITController { } void closeIT() { - //if they close it before choosing anything, just put their text back + //if they close it before completing, just put their text back //PTODO - explore using last itStep - if (choreographer.currentText.isEmpty) { - choreographer.textController.text = sourceText ?? ""; - } + choreographer.textController.text = sourceText ?? ""; clear(); } @@ -217,8 +215,20 @@ class ITController { Future onEditSourceTextSubmit(String newSourceText) async { try { - sourceText = newSourceText; + + _isOpen = true; _isEditingSourceText = false; + _itStartData = ITStartData(newSourceText, choreographer.l1LangCode); + completedITSteps = []; + currentITStep = null; + nextITStep = null; + goldRouteTracker = GoldRouteTracker.defaultTracker; + payLoadIds = []; + + _setSourceText(); + getTranslationData(false); + + /*sourceText = newSourceText; final String currentText = choreographer.currentText; choreographer.startLoading(); @@ -241,7 +251,7 @@ class ITController { storedGoldContinuances: goldRouteTracker.continuances, ); - _addPayloadId(responses[1]); + _addPayloadId(responses[1]);*/ } catch (err, stack) { debugger(when: kDebugMode); if (err is! http.Response) { @@ -252,6 +262,7 @@ class ITController { ); } finally { choreographer.stopLoading(); + choreographer.textController.text = ""; } } diff --git a/lib/pangea/choreographer/widgets/it_bar.dart b/lib/pangea/choreographer/widgets/it_bar.dart index 4e26cba58..013c7238b 100644 --- a/lib/pangea/choreographer/widgets/it_bar.dart +++ b/lib/pangea/choreographer/widgets/it_bar.dart @@ -184,7 +184,12 @@ class OriginalText extends StatelessWidget { ), ), ), - if (!controller.isEditingSourceText && controller.sourceText != null) + if ( + !controller.isEditingSourceText + && controller.sourceText != null + && controller.completedITSteps.length + < controller.goldRouteTracker.continuances.length + ) IconButton( onPressed: () => controller.setIsEditingSourceText(true), icon: const Icon(Icons.edit_outlined), From f7753a0477ddf3303c9e10071396fe93475df82c Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Sat, 8 Jun 2024 22:55:36 -0400 Subject: [PATCH 02/30] ITController Animates in --- .../controllers/it_controller.dart | 5 + lib/pangea/choreographer/widgets/it_bar.dart | 165 ++++++++++-------- 2 files changed, 95 insertions(+), 75 deletions(-) diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index 91899a71a..f29bb59b2 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -21,6 +21,7 @@ class ITController { Choreographer choreographer; bool _isOpen = false; + bool _willOpen = false; bool _isEditingSourceText = false; bool showChoiceFeedback = false; @@ -36,6 +37,7 @@ class ITController { void clear() { _isOpen = false; + _willOpen = false; showChoiceFeedback = false; _isEditingSourceText = false; @@ -54,6 +56,7 @@ class ITController { } Future initializeIT(ITStartData itStartData) async { + _willOpen = true; Future.delayed(const Duration(microseconds: 100), () { _isOpen = true; }); @@ -347,6 +350,8 @@ class ITController { bool get isOpen => _isOpen; + bool get willOpen => _willOpen; + String get targetLangCode => choreographer.l2LangCode!; String get sourceLangCode => choreographer.l1LangCode!; diff --git a/lib/pangea/choreographer/widgets/it_bar.dart b/lib/pangea/choreographer/widgets/it_bar.dart index 013c7238b..068d99166 100644 --- a/lib/pangea/choreographer/widgets/it_bar.dart +++ b/lib/pangea/choreographer/widgets/it_bar.dart @@ -7,6 +7,7 @@ import 'package:fluffychat/pangea/choreographer/widgets/it_feedback_card.dart'; import 'package:fluffychat/pangea/choreographer/widgets/translation_finished_flow.dart'; import 'package:fluffychat/pangea/constants/choreo_constants.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -21,93 +22,107 @@ class ITBar extends StatelessWidget { final Choreographer choreographer; const ITBar({super.key, required this.choreographer}); - ITController get controller => choreographer.itController; + ITController get itController => choreographer.itController; @override Widget build(BuildContext context) { - if (!controller.isOpen) return const SizedBox(); - return CompositedTransformTarget( - link: choreographer.itBarLinkAndKey.link, - child: Container( - key: choreographer.itBarLinkAndKey.key, - decoration: BoxDecoration( - color: Theme.of(context).brightness == Brightness.light - ? Colors.white - : Colors.black, - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(AppConfig.borderRadius), - topRight: Radius.circular(AppConfig.borderRadius), - ), - ), - width: double.infinity, - padding: const EdgeInsets.fromLTRB(0, 3, 3, 3), - child: Stack( - children: [ - SingleChildScrollView( - child: Column( + return AnimatedSize( + duration: itController.willOpen + ? const Duration(milliseconds: 2000) + : const Duration(milliseconds: 500), + curve: Curves.fastOutSlowIn, + clipBehavior: Clip.none, + child: !itController.willOpen + ? const SizedBox() + : CompositedTransformTarget( + link: choreographer.itBarLinkAndKey.link, + child: AnimatedOpacity( + duration: itController.willOpen + ? const Duration(milliseconds: 2000) + : const Duration(milliseconds: 500), + opacity: itController.willOpen ? 1.0 : 0.0, + child: Container( + key: choreographer.itBarLinkAndKey.key, + decoration: BoxDecoration( + color: Theme.of(context).brightness == Brightness.light + ? Colors.white + : Colors.black, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(AppConfig.borderRadius), + topRight: Radius.circular(AppConfig.borderRadius), + ), + ), + width: double.infinity, + padding: const EdgeInsets.fromLTRB(0, 3, 3, 3), + child: Stack( children: [ - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // // Row( - // // mainAxisAlignment: MainAxisAlignment.start, - // // crossAxisAlignment: CrossAxisAlignment.start, - // // children: [ - // // CounterDisplay( - // // correct: controller.correctChoices, - // // custom: controller.customChoices, - // // incorrect: controller.incorrectChoices, - // // yellow: controller.wildcardChoices, - // // ), - // // CompositedTransformTarget( - // // link: choreographer.itBotLayerLinkAndKey.link, - // // child: ITBotButton( - // // key: choreographer.itBotLayerLinkAndKey.key, - // // choreographer: choreographer, - // // ), - // // ), - // // ], - // // ), - // ITCloseButton(choreographer: choreographer), - // ], - // ), - // const SizedBox(height: 40.0), - OriginalText(controller: controller), - const SizedBox(height: 7.0), - IntrinsicHeight( - child: Container( - constraints: const BoxConstraints(minHeight: 80), - width: double.infinity, - padding: const EdgeInsets.symmetric(horizontal: 4.0), - child: Center( - child: controller.choreographer.errorService.isError - ? ITError( - error: controller + SingleChildScrollView( + child: Column( + children: [ + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // // Row( + // // mainAxisAlignment: MainAxisAlignment.start, + // // crossAxisAlignment: CrossAxisAlignment.start, + // // children: [ + // // CounterDisplay( + // // correct: controller.correctChoices, + // // custom: controller.customChoices, + // // incorrect: controller.incorrectChoices, + // // yellow: controller.wildcardChoices, + // // ), + // // CompositedTransformTarget( + // // link: choreographer.itBotLayerLinkAndKey.link, + // // child: ITBotButton( + // // key: choreographer.itBotLayerLinkAndKey.key, + // // choreographer: choreographer, + // // ), + // // ), + // // ], + // // ), + // ITCloseButton(choreographer: choreographer), + // ], + // ), + // const SizedBox(height: 40.0), + OriginalText(controller: itController), + const SizedBox(height: 7.0), + IntrinsicHeight( + child: Container( + constraints: const BoxConstraints(minHeight: 80), + width: double.infinity, + padding: const EdgeInsets.symmetric(horizontal: 4.0), + child: Center( + child: itController.choreographer.errorService.isError + ? ITError( + error: itController .choreographer.errorService.error!, - controller: controller, + controller: itController, ) - : controller.showChoiceFeedback - ? ChoiceFeedbackText(controller: controller) - : controller.isTranslationDone - ? TranslationFeedback( - controller: controller, - ) - : ITChoices(controller: controller), - ), + : itController.showChoiceFeedback + ? ChoiceFeedbackText(controller: itController) + : itController.isTranslationDone + ? TranslationFeedback( + controller: itController, + ) + : ITChoices(controller: itController), + ), + ), + ), + ], ), ), + Positioned( + top: 0.0, + right: 0.0, + child: ITCloseButton(choreographer: choreographer), + ), ], ), ), - Positioned( - top: 0.0, - right: 0.0, - child: ITCloseButton(choreographer: choreographer), - ), - ], - ), + ), ), ); } From 5a5f18bd84cdbf8ed2e636d1d1c1e3fc664a4a42 Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:21:35 -0400 Subject: [PATCH 03/30] Auto Play Interactive Translator --- assets/l10n/intl_en.arb | 12 ++- assets/l10n/intl_es.arb | 13 ++- .../controllers/choreographer.dart | 5 + .../controllers/igc_controller.dart | 5 + lib/pangea/controllers/user_controller.dart | 9 ++ lib/pangea/models/class_model.dart | 5 + lib/pangea/models/user_model.dart | 3 + .../widgets/igc/pangea_text_controller.dart | 27 ++++-- needed-translations.txt | 94 +++++++++++++++++++ 9 files changed, 162 insertions(+), 11 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index fe2a3da03..7fceca29b 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2514,6 +2514,16 @@ "type": "text", "placeholders": {} }, + "interactiveTranslatorAutoPlaySliderHeader": "Auto Play Interactive Translator", + "@interactiveTranslatorAutoPlaySliderHeader": { + "type": "text", + "placeholders": {} + }, + "interactiveTranslatorAutoPlayDesc": "Launches the interactive translator without asking.", + "@interactiveTranslatorAutoPlayDesc": { + "type": "text", + "placeholders": {} + }, "notYetSet": "Not yet set", "@notYetSet": { "type": "text", @@ -3964,4 +3974,4 @@ "roomDataMissing": "Some data may be missing from rooms in which you are not a member.", "updatePhoneOS": "You may need to update your device's OS version.", "wordsPerMinute": "Words per minute" -} \ No newline at end of file +} diff --git a/assets/l10n/intl_es.arb b/assets/l10n/intl_es.arb index d463699be..3d652ac2a 100644 --- a/assets/l10n/intl_es.arb +++ b/assets/l10n/intl_es.arb @@ -3099,6 +3099,17 @@ "type": "text", "placeholders": {} }, + "interactiveTranslatorAutoPlaySliderHeader": "Traductora interactiva de reproducción automática", + "interactiveTranslatorAutoPlay": "Traductora interactiva de reproducción automática", + "@interactiveTranslatorAutoPlay": { + "type": "text", + "placeholders": {} + }, + "interactiveTranslatorAutoPlayDesc": "Inicia el traductor interactivo sin preguntar.", + "@interactiveTranslatorAutoPlayDesc": { + "type": "text", + "placeholders": {} + }, "grammarAssistance": "Asistencia gramatical", "@grammarAssistance": { "type": "text", @@ -4652,4 +4663,4 @@ "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reacción al envío del aviso de debate", "studentAnalyticsNotAvailable": "Datos de los estudiantes no disponibles actualmente", "roomDataMissing": "Es posible que falten algunos datos de las salas de las que no es miembro." -} \ No newline at end of file +} diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 3a26676c6..529ba95b4 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -513,6 +513,11 @@ class Choreographer { chatController.room, ); + bool get itAutoPlayEnabled => pangeaController.permissionsController.isToolEnabled( + ToolSetting.itAutoPlay, + chatController.room, + ); + bool get definitionsEnabled => pangeaController.permissionsController.isToolEnabled( ToolSetting.definitions, diff --git a/lib/pangea/choreographer/controllers/igc_controller.dart b/lib/pangea/choreographer/controllers/igc_controller.dart index 73694e257..6638afa3b 100644 --- a/lib/pangea/choreographer/controllers/igc_controller.dart +++ b/lib/pangea/choreographer/controllers/igc_controller.dart @@ -191,6 +191,11 @@ class IgcController { const int firstMatchIndex = 0; final PangeaMatch match = igcTextData!.matches[firstMatchIndex]; + if (match.isITStart && choreographer.itAutoPlayEnabled && igcTextData != null) { + choreographer.onITStart(igcTextData!.matches[firstMatchIndex]); + return; + } + OverlayUtil.showPositionedCard( context: context, cardToShow: SpanCard( diff --git a/lib/pangea/controllers/user_controller.dart b/lib/pangea/controllers/user_controller.dart index d3a17d365..0e336fdf6 100644 --- a/lib/pangea/controllers/user_controller.dart +++ b/lib/pangea/controllers/user_controller.dart @@ -126,6 +126,7 @@ class UserController extends BaseController { final bool? trial = migratedProfileInfo(MatrixProfile.activatedFreeTrial); final bool? interactiveTranslator = migratedProfileInfo(MatrixProfile.interactiveTranslator); + final bool? itAutoPlay = migratedProfileInfo(MatrixProfile.itAutoPlay); final bool? interactiveGrammar = migratedProfileInfo(MatrixProfile.interactiveGrammar); final bool? immersionMode = @@ -144,6 +145,7 @@ class UserController extends BaseController { autoPlayMessages: autoPlay, activatedFreeTrial: trial, interactiveTranslator: interactiveTranslator, + itAutoPlay: itAutoPlay, interactiveGrammar: interactiveGrammar, immersionMode: immersionMode, definitions: definitions, @@ -225,6 +227,7 @@ class UserController extends BaseController { bool? autoPlayMessages, bool? activatedFreeTrial, bool? interactiveTranslator, + bool? itAutoPlay, bool? interactiveGrammar, bool? immersionMode, bool? definitions, @@ -262,6 +265,12 @@ class UserController extends BaseController { interactiveTranslator, ); } + if (itAutoPlay != null) { + await _pangeaController.pStoreService.save( + MatrixProfile.itAutoPlay.title, + itAutoPlay, + ); + } if (interactiveGrammar != null) { await _pangeaController.pStoreService.save( MatrixProfile.interactiveGrammar.title, diff --git a/lib/pangea/models/class_model.dart b/lib/pangea/models/class_model.dart index 1f588980c..cf0cadedb 100644 --- a/lib/pangea/models/class_model.dart +++ b/lib/pangea/models/class_model.dart @@ -295,6 +295,7 @@ class PangeaRoomRules { enum ToolSetting { interactiveTranslator, + itAutoPlay, interactiveGrammar, immersionMode, definitions, @@ -306,6 +307,8 @@ extension SettingCopy on ToolSetting { switch (this) { case ToolSetting.interactiveTranslator: return L10n.of(context)!.interactiveTranslatorSliderHeader; + case ToolSetting.itAutoPlay: + return L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader; case ToolSetting.interactiveGrammar: return L10n.of(context)!.interactiveGrammarSliderHeader; case ToolSetting.immersionMode: @@ -324,6 +327,8 @@ extension SettingCopy on ToolSetting { return L10n.of(context)!.itToggleDescription; case ToolSetting.interactiveGrammar: return L10n.of(context)!.igcToggleDescription; + case ToolSetting.itAutoPlay: + return L10n.of(context)!.interactiveTranslatorAutoPlayDesc; case ToolSetting.immersionMode: return L10n.of(context)!.toggleImmersionModeDesc; case ToolSetting.definitions: diff --git a/lib/pangea/models/user_model.dart b/lib/pangea/models/user_model.dart index 2169c6f70..396bcaccb 100644 --- a/lib/pangea/models/user_model.dart +++ b/lib/pangea/models/user_model.dart @@ -56,6 +56,7 @@ enum MatrixProfile { autoPlayMessages, activatedFreeTrial, interactiveTranslator, + itAutoPlay, interactiveGrammar, immersionMode, definitions, @@ -81,6 +82,8 @@ extension MatrixProfileExtension on MatrixProfile { return PLocalKey.activatedTrialKey; case MatrixProfile.interactiveTranslator: return ToolSetting.interactiveTranslator.toString(); + case MatrixProfile.itAutoPlay: + return ToolSetting.itAutoPlay.toString(); case MatrixProfile.interactiveGrammar: return ToolSetting.interactiveGrammar.toString(); case MatrixProfile.immersionMode: diff --git a/lib/pangea/widgets/igc/pangea_text_controller.dart b/lib/pangea/widgets/igc/pangea_text_controller.dart index a40e2cc15..30551463b 100644 --- a/lib/pangea/widgets/igc/pangea_text_controller.dart +++ b/lib/pangea/widgets/igc/pangea_text_controller.dart @@ -96,15 +96,24 @@ class PangeaTextController extends TextEditingController { : null; if (cardToShow != null) { - OverlayUtil.showPositionedCard( - context: context, - cardSize: matchIndex != -1 && - choreographer.igc.igcTextData!.matches[matchIndex].isITStart - ? const Size(350, 220) - : const Size(350, 400), - cardToShow: cardToShow, - transformTargetId: choreographer.inputTransformTargetKey, - ); + if ( + choreographer.itAutoPlayEnabled && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart + ) { + choreographer.onITStart( + choreographer.igc.igcTextData!.matches[matchIndex], + ); + } else { + OverlayUtil.showPositionedCard( + context: context, + cardSize: matchIndex != -1 && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart + ? const Size(350, 220) + : const Size(350, 400), + cardToShow: cardToShow, + transformTargetId: choreographer.inputTransformTargetKey, + ); + } } } diff --git a/needed-translations.txt b/needed-translations.txt index bb967d011..2bf77fe82 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -51,6 +51,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -1430,6 +1432,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -2340,6 +2344,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -3240,6 +3246,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -4140,6 +4148,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -5040,6 +5050,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -5935,6 +5947,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -6787,6 +6801,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -7687,6 +7703,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -8579,6 +8597,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -9422,6 +9442,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -10273,6 +10295,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -11173,6 +11197,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -12073,6 +12099,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -12973,6 +13001,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -13865,6 +13895,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -14716,6 +14748,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -15616,6 +15650,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -16513,6 +16549,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -17403,6 +17441,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -18817,6 +18857,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -19727,6 +19769,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -20627,6 +20671,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -21523,6 +21569,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -22412,6 +22460,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -23312,6 +23362,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -24212,6 +24264,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -25112,6 +25166,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -26012,6 +26068,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -26912,6 +26970,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -27812,6 +27872,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -28712,6 +28774,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -29608,6 +29672,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -30481,6 +30547,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -31381,6 +31449,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -32273,6 +32343,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -33124,6 +33196,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -34024,6 +34098,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -34924,6 +35000,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -35820,6 +35898,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -36689,6 +36769,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -37589,6 +37671,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -38485,6 +38569,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -39366,6 +39452,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -40217,6 +40305,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -41109,6 +41199,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -41960,6 +42052,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", From 831080198131b53e06e92c883bef9e62cf3c8a2a Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:21:35 -0400 Subject: [PATCH 04/30] Auto Play Interactive Translator --- assets/l10n/intl_en.arb | 12 ++- assets/l10n/intl_es.arb | 13 ++- .../controllers/choreographer.dart | 5 + .../controllers/igc_controller.dart | 20 +++- lib/pangea/choreographer/widgets/it_bar.dart | 18 +++- lib/pangea/controllers/user_controller.dart | 9 ++ lib/pangea/models/class_model.dart | 5 + lib/pangea/models/user_model.dart | 3 + .../widgets/igc/pangea_text_controller.dart | 37 +++++--- lib/pangea/widgets/igc/span_card.dart | 44 +++++++++ needed-translations.txt | 94 +++++++++++++++++++ 11 files changed, 241 insertions(+), 19 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index fe2a3da03..7fceca29b 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2514,6 +2514,16 @@ "type": "text", "placeholders": {} }, + "interactiveTranslatorAutoPlaySliderHeader": "Auto Play Interactive Translator", + "@interactiveTranslatorAutoPlaySliderHeader": { + "type": "text", + "placeholders": {} + }, + "interactiveTranslatorAutoPlayDesc": "Launches the interactive translator without asking.", + "@interactiveTranslatorAutoPlayDesc": { + "type": "text", + "placeholders": {} + }, "notYetSet": "Not yet set", "@notYetSet": { "type": "text", @@ -3964,4 +3974,4 @@ "roomDataMissing": "Some data may be missing from rooms in which you are not a member.", "updatePhoneOS": "You may need to update your device's OS version.", "wordsPerMinute": "Words per minute" -} \ No newline at end of file +} diff --git a/assets/l10n/intl_es.arb b/assets/l10n/intl_es.arb index d463699be..3d652ac2a 100644 --- a/assets/l10n/intl_es.arb +++ b/assets/l10n/intl_es.arb @@ -3099,6 +3099,17 @@ "type": "text", "placeholders": {} }, + "interactiveTranslatorAutoPlaySliderHeader": "Traductora interactiva de reproducción automática", + "interactiveTranslatorAutoPlay": "Traductora interactiva de reproducción automática", + "@interactiveTranslatorAutoPlay": { + "type": "text", + "placeholders": {} + }, + "interactiveTranslatorAutoPlayDesc": "Inicia el traductor interactivo sin preguntar.", + "@interactiveTranslatorAutoPlayDesc": { + "type": "text", + "placeholders": {} + }, "grammarAssistance": "Asistencia gramatical", "@grammarAssistance": { "type": "text", @@ -4652,4 +4663,4 @@ "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reacción al envío del aviso de debate", "studentAnalyticsNotAvailable": "Datos de los estudiantes no disponibles actualmente", "roomDataMissing": "Es posible que falten algunos datos de las salas de las que no es miembro." -} \ No newline at end of file +} diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 3a26676c6..529ba95b4 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -513,6 +513,11 @@ class Choreographer { chatController.room, ); + bool get itAutoPlayEnabled => pangeaController.permissionsController.isToolEnabled( + ToolSetting.itAutoPlay, + chatController.room, + ); + bool get definitionsEnabled => pangeaController.permissionsController.isToolEnabled( ToolSetting.definitions, diff --git a/lib/pangea/choreographer/controllers/igc_controller.dart b/lib/pangea/choreographer/controllers/igc_controller.dart index 73694e257..07a0ac2a2 100644 --- a/lib/pangea/choreographer/controllers/igc_controller.dart +++ b/lib/pangea/choreographer/controllers/igc_controller.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart'; import 'package:fluffychat/pangea/choreographer/controllers/error_service.dart'; +import 'package:fluffychat/pangea/models/class_model.dart'; import 'package:fluffychat/pangea/models/igc_text_data_model.dart'; import 'package:fluffychat/pangea/models/pangea_match_model.dart'; import 'package:fluffychat/pangea/models/span_data.dart'; @@ -29,6 +30,8 @@ class IgcController { IgcController(this.choreographer); + bool turnOnAutoPlay = false; + Future getIGCTextData({required bool tokensOnly}) async { try { if (choreographer.currentText.isEmpty) return clear(); @@ -191,6 +194,15 @@ class IgcController { const int firstMatchIndex = 0; final PangeaMatch match = igcTextData!.matches[firstMatchIndex]; + if ( + match.isITStart && + choreographer.itAutoPlayEnabled && + igcTextData != null + ) { + choreographer.onITStart(igcTextData!.matches[firstMatchIndex]); + return; + } + OverlayUtil.showPositionedCard( context: context, cardToShow: SpanCard( @@ -203,6 +215,12 @@ class IgcController { ), onITStart: () { if (choreographer.itEnabled && igcTextData != null) { + if (turnOnAutoPlay) { + choreographer.pangeaController.pStoreService.save( + ToolSetting.itAutoPlay.toString(), + true, + ); + } choreographer.onITStart(igcTextData!.matches[firstMatchIndex]); } }, @@ -210,7 +228,7 @@ class IgcController { ), roomId: choreographer.roomId, ), - cardSize: match.isITStart ? const Size(350, 220) : const Size(350, 400), + cardSize: match.isITStart ? const Size(350, 260) : const Size(350, 400), transformTargetId: choreographer.inputTransformTargetKey, ); } diff --git a/lib/pangea/choreographer/widgets/it_bar.dart b/lib/pangea/choreographer/widgets/it_bar.dart index 068d99166..2ba630900 100644 --- a/lib/pangea/choreographer/widgets/it_bar.dart +++ b/lib/pangea/choreographer/widgets/it_bar.dart @@ -202,12 +202,20 @@ class OriginalText extends StatelessWidget { if ( !controller.isEditingSourceText && controller.sourceText != null - && controller.completedITSteps.length - < controller.goldRouteTracker.continuances.length ) - IconButton( - onPressed: () => controller.setIsEditingSourceText(true), - icon: const Icon(Icons.edit_outlined), + AnimatedOpacity( + duration: const Duration(milliseconds: 500), + opacity: controller.nextITStep != null + ? 1.0 + : 0.0, + child: IconButton( + onPressed: () => { + if (controller.nextITStep != null) { + controller.setIsEditingSourceText(true), + }, + }, + icon: const Icon(Icons.edit_outlined), + ), ), ], ), diff --git a/lib/pangea/controllers/user_controller.dart b/lib/pangea/controllers/user_controller.dart index d3a17d365..0e336fdf6 100644 --- a/lib/pangea/controllers/user_controller.dart +++ b/lib/pangea/controllers/user_controller.dart @@ -126,6 +126,7 @@ class UserController extends BaseController { final bool? trial = migratedProfileInfo(MatrixProfile.activatedFreeTrial); final bool? interactiveTranslator = migratedProfileInfo(MatrixProfile.interactiveTranslator); + final bool? itAutoPlay = migratedProfileInfo(MatrixProfile.itAutoPlay); final bool? interactiveGrammar = migratedProfileInfo(MatrixProfile.interactiveGrammar); final bool? immersionMode = @@ -144,6 +145,7 @@ class UserController extends BaseController { autoPlayMessages: autoPlay, activatedFreeTrial: trial, interactiveTranslator: interactiveTranslator, + itAutoPlay: itAutoPlay, interactiveGrammar: interactiveGrammar, immersionMode: immersionMode, definitions: definitions, @@ -225,6 +227,7 @@ class UserController extends BaseController { bool? autoPlayMessages, bool? activatedFreeTrial, bool? interactiveTranslator, + bool? itAutoPlay, bool? interactiveGrammar, bool? immersionMode, bool? definitions, @@ -262,6 +265,12 @@ class UserController extends BaseController { interactiveTranslator, ); } + if (itAutoPlay != null) { + await _pangeaController.pStoreService.save( + MatrixProfile.itAutoPlay.title, + itAutoPlay, + ); + } if (interactiveGrammar != null) { await _pangeaController.pStoreService.save( MatrixProfile.interactiveGrammar.title, diff --git a/lib/pangea/models/class_model.dart b/lib/pangea/models/class_model.dart index 1f588980c..cf0cadedb 100644 --- a/lib/pangea/models/class_model.dart +++ b/lib/pangea/models/class_model.dart @@ -295,6 +295,7 @@ class PangeaRoomRules { enum ToolSetting { interactiveTranslator, + itAutoPlay, interactiveGrammar, immersionMode, definitions, @@ -306,6 +307,8 @@ extension SettingCopy on ToolSetting { switch (this) { case ToolSetting.interactiveTranslator: return L10n.of(context)!.interactiveTranslatorSliderHeader; + case ToolSetting.itAutoPlay: + return L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader; case ToolSetting.interactiveGrammar: return L10n.of(context)!.interactiveGrammarSliderHeader; case ToolSetting.immersionMode: @@ -324,6 +327,8 @@ extension SettingCopy on ToolSetting { return L10n.of(context)!.itToggleDescription; case ToolSetting.interactiveGrammar: return L10n.of(context)!.igcToggleDescription; + case ToolSetting.itAutoPlay: + return L10n.of(context)!.interactiveTranslatorAutoPlayDesc; case ToolSetting.immersionMode: return L10n.of(context)!.toggleImmersionModeDesc; case ToolSetting.definitions: diff --git a/lib/pangea/models/user_model.dart b/lib/pangea/models/user_model.dart index 2169c6f70..396bcaccb 100644 --- a/lib/pangea/models/user_model.dart +++ b/lib/pangea/models/user_model.dart @@ -56,6 +56,7 @@ enum MatrixProfile { autoPlayMessages, activatedFreeTrial, interactiveTranslator, + itAutoPlay, interactiveGrammar, immersionMode, definitions, @@ -81,6 +82,8 @@ extension MatrixProfileExtension on MatrixProfile { return PLocalKey.activatedTrialKey; case MatrixProfile.interactiveTranslator: return ToolSetting.interactiveTranslator.toString(); + case MatrixProfile.itAutoPlay: + return ToolSetting.itAutoPlay.toString(); case MatrixProfile.interactiveGrammar: return ToolSetting.interactiveGrammar.toString(); case MatrixProfile.immersionMode: diff --git a/lib/pangea/widgets/igc/pangea_text_controller.dart b/lib/pangea/widgets/igc/pangea_text_controller.dart index a40e2cc15..c476ccca0 100644 --- a/lib/pangea/widgets/igc/pangea_text_controller.dart +++ b/lib/pangea/widgets/igc/pangea_text_controller.dart @@ -82,9 +82,15 @@ class PangeaTextController extends TextEditingController { debugPrint("onSentenceRewrite $tokenIndex $sentenceRewrite"); }), onIgnore: () => choreographer.onIgnoreMatch( - cursorOffset: selection.baseOffset, - ), + cursorOffset: selection.baseOffset, + ), onITStart: () { + if (choreographer.igc.turnOnAutoPlay) { + choreographer.pangeaController.pStoreService.save( + 'ToolSetting.itAutoPlay', + true, + ); + } choreographer.onITStart( choreographer.igc.igcTextData!.matches[matchIndex], ); @@ -96,15 +102,24 @@ class PangeaTextController extends TextEditingController { : null; if (cardToShow != null) { - OverlayUtil.showPositionedCard( - context: context, - cardSize: matchIndex != -1 && - choreographer.igc.igcTextData!.matches[matchIndex].isITStart - ? const Size(350, 220) - : const Size(350, 400), - cardToShow: cardToShow, - transformTargetId: choreographer.inputTransformTargetKey, - ); + if ( + choreographer.itAutoPlayEnabled && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart + ) { + choreographer.onITStart( + choreographer.igc.igcTextData!.matches[matchIndex], + ); + } else { + OverlayUtil.showPositionedCard( + context: context, + cardSize: matchIndex != -1 && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart + ? const Size(350, 260) + : const Size(350, 400), + cardToShow: cardToShow, + transformTargetId: choreographer.inputTransformTargetKey, + ); + } } } diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index fd44383a0..52901bfa2 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -281,6 +281,13 @@ class WordMatchContent extends StatelessWidget { ), ], ), + if (controller.widget.scm.pangeaMatch!.isITStart) + DontShowSwitchListTile( + value: controller.widget.scm.choreographer.igc.turnOnAutoPlay, + onChanged: ((value) { + controller.widget.scm.choreographer.igc.turnOnAutoPlay = value; + }), + ), ], ); } on Exception catch (e) { @@ -419,3 +426,40 @@ class StartITButton extends StatelessWidget { ); } } + +class DontShowSwitchListTile extends StatefulWidget { + final bool value; + final ValueChanged onChanged; + + const DontShowSwitchListTile({ + super.key, + required this.value, + required this.onChanged, + }); + + @override + DontShowSwitchListTileState createState() => DontShowSwitchListTileState(); +} + +class DontShowSwitchListTileState extends State { + bool switchValue = false; + + @override + void initState() { + super.initState(); + switchValue = widget.value; + } + + @override + Widget build(BuildContext context) { + return SwitchListTile.adaptive( + activeColor: AppConfig.activeToggleColor, + title: Text(L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader), + value: switchValue, + onChanged: (value) => { + widget.onChanged(value), + setState(() => switchValue = value), + }, + ); + } +} diff --git a/needed-translations.txt b/needed-translations.txt index bb967d011..2bf77fe82 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -51,6 +51,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -1430,6 +1432,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -2340,6 +2344,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -3240,6 +3246,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -4140,6 +4148,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -5040,6 +5050,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -5935,6 +5947,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -6787,6 +6801,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -7687,6 +7703,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -8579,6 +8597,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -9422,6 +9442,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -10273,6 +10295,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -11173,6 +11197,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -12073,6 +12099,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -12973,6 +13001,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -13865,6 +13895,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -14716,6 +14748,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -15616,6 +15650,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -16513,6 +16549,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -17403,6 +17441,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -18817,6 +18857,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -19727,6 +19769,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -20627,6 +20671,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -21523,6 +21569,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -22412,6 +22460,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -23312,6 +23362,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -24212,6 +24264,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -25112,6 +25166,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -26012,6 +26068,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -26912,6 +26970,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -27812,6 +27872,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -28712,6 +28774,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -29608,6 +29672,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -30481,6 +30547,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -31381,6 +31449,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -32273,6 +32343,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -33124,6 +33196,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -34024,6 +34098,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -34924,6 +35000,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -35820,6 +35898,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -36689,6 +36769,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -37589,6 +37671,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -38485,6 +38569,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -39366,6 +39452,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -40217,6 +40305,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -41109,6 +41199,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", @@ -41960,6 +42052,8 @@ "interactiveTranslatorNotAllowedDesc", "interactiveTranslatorAllowedDesc", "interactiveTranslatorRequiredDesc", + "interactiveTranslatorAutoPlaySliderHeader", + "interactiveTranslatorAutoPlayDesc", "notYetSet", "multiLingualClass", "classAnalytics", From 94f87a5312af33e67e47cbf7e8b7c640fe96ff24 Mon Sep 17 00:00:00 2001 From: William Jordan-Cooley Date: Fri, 14 Jun 2024 08:38:10 -0400 Subject: [PATCH 05/30] copy edits --- assets/l10n/intl_en.arb | 14 ++++++++------ assets/l10n/intl_es.arb | 8 ++++---- lib/pangea/enum/span_data_type.dart | 7 +++++-- lib/pangea/utils/match_copy.dart | 18 +++++++++++------- lib/pangea/widgets/igc/span_card.dart | 7 ++++--- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 7fceca29b..6974d82f0 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2514,7 +2514,7 @@ "type": "text", "placeholders": {} }, - "interactiveTranslatorAutoPlaySliderHeader": "Auto Play Interactive Translator", + "interactiveTranslatorAutoPlaySliderHeader": "Autoplay translation", "@interactiveTranslatorAutoPlaySliderHeader": { "type": "text", "placeholders": {} @@ -2884,21 +2884,23 @@ "type": "text", "placeholders": {} }, - "helpMeTranslate": "Help me translate!", + "helpMeTranslate": "Yes!", "@helpMeTranslate": { "type": "text", "placeholders": {} }, - "needsItShortMessage": "Try interactive translation!", + "needsItShortMessage": "Out of target", "needsIGCShortMessage": "Try interactive grammar assistance!", "@needsItShortMessage": { "type": "text", "placeholders": {} }, - "needsItMessage": "This message has too many words in your base language.", + "needsItMessage": "Wait, that's not {targetLanguage}! Do you need help translating?", "@needsItMessage": { "type": "text", - "placeholders": {} + "placeholders": { + "targetLanguage": {} + } }, "needsIgcMessage": "This message has a grammar error.", "tokenTranslationTitle": "A word is in your base language.", @@ -3974,4 +3976,4 @@ "roomDataMissing": "Some data may be missing from rooms in which you are not a member.", "updatePhoneOS": "You may need to update your device's OS version.", "wordsPerMinute": "Words per minute" -} +} \ No newline at end of file diff --git a/assets/l10n/intl_es.arb b/assets/l10n/intl_es.arb index 3d652ac2a..819caeea0 100644 --- a/assets/l10n/intl_es.arb +++ b/assets/l10n/intl_es.arb @@ -3099,7 +3099,7 @@ "type": "text", "placeholders": {} }, - "interactiveTranslatorAutoPlaySliderHeader": "Traductora interactiva de reproducción automática", + "interactiveTranslatorAutoPlaySliderHeader": "Traducción de reproducción automática", "interactiveTranslatorAutoPlay": "Traductora interactiva de reproducción automática", "@interactiveTranslatorAutoPlay": { "type": "text", @@ -3172,10 +3172,10 @@ "translationSeemsFinished": "La traducción parece estar terminada.", "needsItShortMessage": "¡Pruebe la traducción interactiva!", "needsIGCShortMessage": "¡Pruebe el corrector gramatical interactivo!", - "needsItMessage": "Este mensaje tiene demasiadas palabras en su idioma base.", + "needsItMessage": "Espera, ¡ese no es {targetLanguage}! ¿Necesitas ayuda para traducir?", "needsIgcMessage": "Este mensaje tiene un error gramatical.", "tokenTranslationTitle": "Una palabra está en su idioma base.", - "helpMeTranslate": "¡Ayúdeme a traducir!", + "helpMeTranslate": "¡Sí!", "setToPublicSettingsTitle": "¿Quiere encontrar un compañero de conversación?", "setToPublicSettingsDesc": "Antes de que pueda buscar un compañero de conversación, debe configurar la visibilidad de su perfil como pública.", "publicProfileTitle": "Perfil público", @@ -4663,4 +4663,4 @@ "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reacción al envío del aviso de debate", "studentAnalyticsNotAvailable": "Datos de los estudiantes no disponibles actualmente", "roomDataMissing": "Es posible que falten algunos datos de las salas de las que no es miembro." -} +} \ No newline at end of file diff --git a/lib/pangea/enum/span_data_type.dart b/lib/pangea/enum/span_data_type.dart index 5e4fdf8cb..949aac26b 100644 --- a/lib/pangea/enum/span_data_type.dart +++ b/lib/pangea/enum/span_data_type.dart @@ -1,5 +1,5 @@ +import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/material.dart'; - import 'package:flutter_gen/gen_l10n/l10n.dart'; enum SpanDataTypeEnum { @@ -32,7 +32,10 @@ extension SpanDataTypeEnumExt on SpanDataTypeEnum { case SpanDataTypeEnum.correction: return L10n.of(context)!.correctionDefaultPrompt; case SpanDataTypeEnum.itStart: - return L10n.of(context)!.needsItMessage; + return L10n.of(context)!.needsItMessage( + MatrixState.pangeaController.languageController.userL2?.displayName ?? + "target language", + ); } } } diff --git a/lib/pangea/utils/match_copy.dart b/lib/pangea/utils/match_copy.dart index 28080f9b5..86d784356 100644 --- a/lib/pangea/utils/match_copy.dart +++ b/lib/pangea/utils/match_copy.dart @@ -1,13 +1,13 @@ import 'dart:developer'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; - import 'package:fluffychat/pangea/enum/span_data_type.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart'; +import 'package:fluffychat/widgets/matrix.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; + import '../constants/match_rule_ids.dart'; import '../models/pangea_match_model.dart'; @@ -96,7 +96,11 @@ class MatchCopy { switch (afterColon) { case MatchRuleIds.interactiveTranslation: title = l10n.needsItShortMessage; - description = l10n.needsItMessage; + description = l10n.needsItMessage( + MatrixState + .pangeaController.languageController.userL2?.displayName ?? + "target language", + ); break; case MatchRuleIds.tokenNeedsTranslation: title = l10n.tokenTranslationTitle; diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index 52901bfa2..9b9fbb4ec 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -162,6 +162,7 @@ class WordMatchContent extends StatelessWidget { try { return Column( children: [ + // if (!controller.widget.scm.pangeaMatch!.isITStart) CardHeader( text: controller.error?.toString() ?? matchCopy.title, botExpression: controller.error == null @@ -222,7 +223,7 @@ class WordMatchContent extends StatelessWidget { opacity: 0.8, child: TextButton( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( AppConfig.primaryColor.withOpacity(0.1), ), ), @@ -249,7 +250,7 @@ class WordMatchContent extends StatelessWidget { ? onReplaceSelected : null, style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( (controller.selectedChoice != null ? controller.selectedChoice!.color : AppConfig.primaryColor) @@ -272,7 +273,7 @@ class WordMatchContent extends StatelessWidget { ); }, style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( (AppConfig.primaryColor).withOpacity(0.1), ), ), From 89e726b9636073614306d65d127ea0314142bbfd Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:42:15 -0400 Subject: [PATCH 06/30] Added New Bot with Animations --- assets/pangea/bot_faces/pangea_bot.riv | Bin 0 -> 10794 bytes .../controllers/it_controller.dart | 24 ------ lib/pangea/controllers/user_controller.dart | 2 +- lib/pangea/widgets/common/bot_face_svg.dart | 78 +++++++++++++++--- pubspec.yaml | 3 +- 5 files changed, 68 insertions(+), 39 deletions(-) create mode 100644 assets/pangea/bot_faces/pangea_bot.riv diff --git a/assets/pangea/bot_faces/pangea_bot.riv b/assets/pangea/bot_faces/pangea_bot.riv new file mode 100644 index 0000000000000000000000000000000000000000..b6956e547eeb1962304f8ad5aeec12c435307b3e GIT binary patch literal 10794 zcmdUVdw5LO*Z(<_nMlJNK~m=gagDfCg@_=MbIwFkX$j@bOsHxuq6mq`rL?{pcY=z# zC2?=vDlTykW#-I8Y2DSOl-8|^ep6L#Df-I0);{~pOn&-%-sk<}eV+IAJZD>b?ax|k z@3r>Yw@kleTVf67yR{uE+53JB{;SWhH5le;LI4)`{SFx_S;iP3=Z($CP0t&`7>s_F z+_5Ic%rGA$a9A(~6C3p8{vELn769-Ez}VbTCWDzN%5`#loW;WUnf%N>D_2>#w8Bys zV>B6qzx_;-La<=!njD7kw6wH*f||W|g@uc}xT532Cy*A`A1JWm2tU^SHL zgDP8ez{0I@*F|0CYABZv>aQ`S(66EChzhEPa{HiqF1u*q)N$Lf_w}lwDtu6PlMY+B z(Tlet>g8&v!#=2hlRGS2{?A(wB~(Lw>4QprdfLKWpA_U`f=mq=lc^D3mS>cNq`i+- zy{2LfJ@~7S95@}c2cJyj>sSxY5+ZSLQoga+;ZBObIK_0d{B7_>558sa!Q6Rk1)y0W@%p=bJI>|G3hJRS7h+dxJ|+APBT zzwc;mx57`!!o+)pII0+aN=Uv7k?5n?DmlYa-E_#K$Dp zaSOM?pJDHkcthzimk^U|a+4agS%iRBs44_cMC;1pP~o)@MDHSJpTSXS0=S9Paeub+gWY2 z+QMHLi*Ru4LbTt9?-0<^BAh%iM{9$c8{5!x$30{0ZDyYDRJq8v%h7XoVlkC384%$X zy6(P&^E#D(*l(jtNbNcZwWji4kAELVHK!?RP32QQZEg{omTlIMB?DSngp>^8V`$45 zBcq&#{Ff87Skk&`S^()5hQuzy8F<3m8|Xs@=|d);Q5feI&YirE_)NaX+;c9WesMkY zb0$A%K|@&>d>}<@+t9#_v*)H(yLLL=B0OJQ3%#DnL(PqH7O-+{O*7=t%SF-kDvv$)>VSFvmujJF5N?H!pEA=5Y@6 z(%+QJuln`0Q)oS?wy3oDbNM0bw1_a#HfV_?*;%2rL=Z>ca5^C?KUNjX<<}(Z;gJQB zt!2*@2ko7j577|KuY4v6CB>KH6_@izr}gyHpG8~gTU$l@pMCpkh)1nPibA-5vZU00 z^DWW(b*DR`t!uZss{QE65}dQA4B=H(Rk&V{GM^f@b{`isdU`ahW#fX+Hrp^6oONmNXMQf^Kt7HrQ z;;hr2|Ls!j)d&2B2J2nI-royd%8uk`4(q(_Rg!J}hSriDDS`-o^{`7gkX$Y)$Maa# zD%W6TTVdq)lkVEd=&Phx~4N8 z?@TZsFDlswYeX4-^jS3iyfxWVZj&0I^Z2HJ-5S|fn64vcTZWm0e0Ma7ojWW$)&H3lUWNzua zhAP-7V9ipq+bYLgkZ^UG%M!QGWBK!k21&xg>@%V=gzuzUyUL1e`!Fe5wg2>f2lNO) z9^C#-6(0Ps%xUX6G|OqP`%8Bm<~dIqfo`>Gkc(6ER^wbPMBOISLYAMhWVkGBI#M5_ z1J!GN-jZQS2tc(^J-&9m6V~tLk}|G&iqkr1%vRBsHzh=}ztJ^;N{kuS*d-{p0%c{u zdy(;0v1xb7w$B)^+E*U3d39Bp7XvoJyqy z1|jIAi({VeM@OyHg0PC^--`>Eg+U9x5tTnW?sZyME?X+u+?7{EJ5t~+fGkaDAPO`7 zT~k)N+<7@(gS@*|RDB@V`UJUzPZNJ~D#tF|6Rq`@{w>-5dVQ1A&aC>IYI%NMk-%Gj zstU?#T2P;+rLO6sA$;GyeN{{y)3=5;`F>l)roYASh;NqmAjH+2ncdg3O3KN_^+Z znwtHFzdOvEHWhW?c(rwm6Vv7;tqJp{3}R%e<>G=@eB*>c?SQ#`WH5|k#B3*oY^N5o zT`XT7_GLWm=y9SF_g9W+^>?SEi=kl=|A#8vTK`P6ZCE?rVSjr3K5f|j)yq!d&a*kH zVr+Cuw5|>BnFmtdb?W+fa%N?-ftZ?Ra4t z7Tju4!A&@I34O5NcN&%ye~#1es%IL)n4}JN7}KI1I1LYK`Fe=u|LULa5;B6|q#VE zLCgGQ_Z`Cfjy_JM?ew!wYt3Geul-l3qCIf)D>&HiJ<|&Y%k(=Sb7?V0aIiO=>eu!CeJnT6qCL$%=m}I;{K}Gz3eC=9IdoA3QmC z4RWr26SXPRr&Mfq`wc;E{@L^k@p{gk#GE_HR?E4v7pB2QwQ~j6<)_;?4bHIU_Zmf3 z1V?nZD}~%^xgQhny2mpw$}XykuHeq3|BSNdSaZbLwiUq#l6%M@y9Lz_9=G|Jg?n?p1+kaeY8Rkeo*ABP4jx!; z;lleSA?#{(*pEK2*z4;p+)L|TL)f+Iu-iVct0^}eoc+W;H_U>YEQID3%dZKobir}* zpkzzy+}dd$wY3yurZvby&l`6oWyNNg>t8ic(032X81USaZT{%^3=5aHtQD%eqh-)t zmY=4!bHV8$3(t*EEh#>#3Ufyu#G@iqZ#+FAL)Ag67bZMbVbw48wh~!9NdmZ6ObZvZ zu6BXppL`6rnq2JW0y;ED!w)pWzp?!HE#|r4_(ZN|P>miuSr&q~Z9>&h{g((=wX@Ag zx1efhyHFN3|F(d(mWMqdt!Nlpq3VJ&QW{45j*kPIXKjqqlhM#DLpR#)&iZLX&?uaSq6TwZMa+L_WD6LbPKA1?fP1TvYt*_eZ5weMYx<2jH;nEcw2@W zmLmaG-=i5|Fd8lCW3up#BeJ%G%Wny1H9ymQsHWV7{k_&a2iW@d__OztGv!o~-P_PtTJaM1(E$zBIt!ia-MB*ne9n`%wwCQ7zk$Iy6t5$qEh zVgDuhqTWsKswxufEA77J|!ZD$$b?X<;V7;s4Rr{Sj9kC+- zSrb};kRnN$xj#y>hHjoO+s<#=?68mi1g@3@a(~iF8MU}t%0BacrRQ6d;hH}r*AY;t@lqyNw#t2uZZ?*n_;o?HvweWn*(5i z*BvV>pT~Aktt~R%l5BTAcEsCD2d_Z$0IAqB39jW^-jWsmMzmzTZJsLG5_5_j_RG6S z4*@b~?H-E|l=`-+lwNBoSvP;!ShoG{3~<`-ol&Tk8=+(I7#)%_}Wc$V8A4*WnhbbZs-ea+Tndi#9J$O zWJ1BS0gIJmNji!qOPYlin2_?}as>w{{O2MDMh_m)L~1h@Td~-Q#eOUfVsXS%oI&aw78kL&jKx(fu3>Qpiw9Ud!D6NXijT12+5$}wS3A=|CSpZ^4wS0QQ#Vrv7oW)Bw1rU2T}Cqjglf)`uLeyHVymflo- zZ2-@J=PQqT^0XY5fc$_((=1Hm7=L-lkdawKy6$FUS-oe~x)O@LYUpr-?NzLo-c4vc z90*aLVMoH5@E&X`xeJA(fz;H>s^?620*p%Mw)1kkd%16TxdXl2;a=_pFLxGL)fF#A zn%Z0M!^fU!d?6}Z^BwUVy4Sex&>G-5X6f1Z;1nKZGe1~z25<3B9M#UJ%i+%KrU~y2+fTGaz*DoNKOKB_0=*2EJMpJ z&wr0J4khWMA4edB_CgP|$68d`&F;{Q*80v|fKq6!-RuoWqP2Gxv_N?r9L1tFiY-P9 z6ilp9G_`i(e{D2JK{Oz1p!dJ@nbrj=+C)9#cf|#RCGjCN$rs`*J!US5*#wXDfzKOy zr7L`-2^|_8L~INl`h^~YBtnNq*C7oI<82^x;}}z7&e*IxFoM3*x=8-g6PDl)y(OgH zTgQr&3g|8JDOnH5*LFRz09Vk_VF@^^0vFCo04|RB>ABHJHUW~wzae=$15XKI34y>L z^X(@{qB=@y>IeYU}pd)x_p{o+LZAMbJF7-KRlmt8Lz z$!dwq3v@q$*W8G`22Uk1Y0D%aBfVT0vd-=4ZT;>rX=bn%1E~9Vb*hqVY=X&-wZ$`hr$wIr_#yE zgd~8eG;ApMjSqcEqY37!5C1t072>D+dG*ZJXp+vAKJ-H$%p)KE6Cb+D2Q!U^1oa>H zq0eeG>CXiZ-@Do2_(7xv^k}oOFK#us0To4F!RX;+KeDq4>VyR#>CD|Fu|VRyr&tL{ zxo8(+F$E~LKT(N^0DO`I6#gkXgz6^wKn1oSpK2$$LGk6tr}{~rQ2cS=gKA6{_>W`? zl_)_sQwt<(sKh$tQwt=6D83B&)B?#Sim%XAV^V@ zHzA)|AUQ|zUudc^^}qtjIx10sVWJjD22zQ|$fp)aHd6c=#)&=%z(`Zq5^1WNM4Aea zNK@@3(iFcBBC6{rk*4^6h%}WTk){?%q^SgnG_^n?P4U|?(sTqQ(iHy>k){$P($oTp zG?gHcrWQz~DSjhHnpz-{ruct|G?gHcrWQz~sRW5MwLl_G@vAY?)B=e##nVXR4FPwq zztNfWRxl5T{Za2sJctmN5q{&Cz}Ip|4r!7&DtByF*9qQR0cv{g<3wTqgeU7Pun?f*<@l}yXHuQ3vd%1Ytpx7ucx0{zMd$}<4bZj3l z*XrdC@^Ul1T)cMBKEUBw*N_J!Io)U{794qF7}k}G8L`xl=tjDe!-(`v5kZlI-f;oG zg_lcr2|U8!{X#!fl6Acnz)qf+hs!AVK;KNzhjfdv6OydaxP1|>&l0VzMI5xyj0dOc z3k2TeXujhSkS-4`y;w|gx;S+7V&keW4PFa$rlAEoG0_5@XJ~;=OSC|-t%0PI5-m`y zWCPctiOwfhd`)1ALMV zg!E)H0m(2wV1^Czl4Ep$_k@NMm!8m?0!hzekbgP}=Y9Pw2KlFxaLD&Pi=h^J7DFxc zP=#73iCQR$S}2KHh?vj3ewl22sAa*iKk(Fr`7|%n&j}=I*|Tv4?l*AZ(7EwmZjzVV z+slQuK*z!Y;Jf>2#<2G%IuAp&aOX+tVf-?l8Y}6z3%h{3ALZiiN4aQ>a#OrqG}iRo zSExZV=9%sPo$%=II(0xBdDjU`fMv|*i6;TH>B~8S{7wzP)f_>T9H|4~Dw8;2_*fXX zfv#b&-~bj~$i!T)fCl|~^AfVOqdh8Rt{=xUICx3tl6z(o`1M0rLIdPRvbgfM1@d~; zuZKXB{$7&65*xV6WgdMMU5la(z6`DQp5+BK;DXU*2ufa4&&fo`)PvtjCTHg6z;8Lm zX7x_b95y^Bi|JCp)+9G@{E5fdET(G#TccO{#H_p~9TX09 zh2IIBsm&xUXBl`+#6QXd&sdEI^1!RHiY-hbIIQ`tV(-@QNWl*>fya94`NX0h^Pf5# BTiyTw literal 0 HcmV?d00001 diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index f29bb59b2..ba14aa095 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -231,30 +231,6 @@ class ITController { _setSourceText(); getTranslationData(false); - /*sourceText = newSourceText; - final String currentText = choreographer.currentText; - - choreographer.startLoading(); - - final List responses = await Future.wait([ - _customInputTranslation(""), - _customInputTranslation(choreographer.currentText), - ]); - if (responses[0].goldContinuances != null && - responses[0].goldContinuances!.isNotEmpty) { - goldRouteTracker = GoldRouteTracker( - responses[0].goldContinuances!, - sourceText!, - ); - } - currentITStep = CurrentITStep( - sourceText: sourceText!, - currentText: currentText, - responseModel: responses[1], - storedGoldContinuances: goldRouteTracker.continuances, - ); - - _addPayloadId(responses[1]);*/ } catch (err, stack) { debugger(when: kDebugMode); if (err is! http.Response) { diff --git a/lib/pangea/controllers/user_controller.dart b/lib/pangea/controllers/user_controller.dart index 0e336fdf6..c6a1b3409 100644 --- a/lib/pangea/controllers/user_controller.dart +++ b/lib/pangea/controllers/user_controller.dart @@ -142,7 +142,7 @@ class UserController extends BaseController { await updateMatrixProfile( dateOfBirth: dob, - autoPlayMessages: autoPlay, + autoPlayMessages: autoPlay ?? false, activatedFreeTrial: trial, interactiveTranslator: interactiveTranslator, itAutoPlay: itAutoPlay, diff --git a/lib/pangea/widgets/common/bot_face_svg.dart b/lib/pangea/widgets/common/bot_face_svg.dart index 718f10c90..b856596dd 100644 --- a/lib/pangea/widgets/common/bot_face_svg.dart +++ b/lib/pangea/widgets/common/bot_face_svg.dart @@ -1,8 +1,13 @@ import 'package:flutter/material.dart'; +import 'package:rive/rive.dart'; enum BotExpression { surprised, right, addled, left, down, shocked } -class BotFace extends StatelessWidget { +class BotFace extends StatefulWidget { + final double width; + final Color? forceColor; + final BotExpression expression; + const BotFace({ super.key, required this.width, @@ -10,21 +15,68 @@ class BotFace extends StatelessWidget { this.forceColor, }); - final double width; - final Color? forceColor; - final BotExpression expression; + @override + BotFaceState createState() => BotFaceState(); +} + +class BotFaceState extends State { + Artboard? _artboard; + SMINumber? _input; + + @override + void initState() { + super.initState(); + _loadRiveFile(); + } + + double mapExpressionToInput(BotExpression expression) { + switch (expression) { + case BotExpression.surprised: + return 1.0; + case BotExpression.right: + return 2.0; + case BotExpression.shocked: + return 3.0; + case BotExpression.addled: + return 4.0; + default: + return 0.0; + } + } + + Future _loadRiveFile() async { + final riveFile = await RiveFile.asset('assets/pangea/bot_faces/pangea_bot.riv'); + + final artboard = riveFile.mainArtboard; + final controller = StateMachineController + .fromArtboard(artboard, 'BotIconStateMachine'); + + if (controller != null) { + artboard.addController(controller); + _input = controller.findInput("Enter State") as SMINumber?; + controller.setInputValue( + 890, // this should be the id of the input + mapExpressionToInput(widget.expression), + ); + } + + setState(() { + _artboard = artboard; + }); + } @override Widget build(BuildContext context) { - return Image.asset( - 'assets/pangea/bot_faces/${expression.toString().split('.').last}.png', - // 'assets/pangea/bot_faces/surprised.png', - width: width, - height: width, - // color: forceColor ?? - // (Theme.of(context).brightness == Brightness.light - // ? Theme.of(context).colorScheme.primary - // : Theme.of(context).colorScheme.primary), + + return SizedBox( + width: widget.width, + height: widget.width, + child: _artboard != null + ? Rive( + artboard: _artboard!, + fit: BoxFit.cover, + ) + : Container(), ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 0c3b2faac..e8d93c8d1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -124,6 +124,7 @@ dependencies: sentry_flutter: ^8.2.0 shimmer: ^3.0.0 syncfusion_flutter_xlsio: ^25.1.40 + rive: 0.11.11 # Pangea# dev_dependencies: @@ -212,4 +213,4 @@ dependency_overrides: keyboard_shortcuts: git: url: https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git - ref: null-safety \ No newline at end of file + ref: null-safety From 5c0763f0a9fd00eaed7dafef565519cb560a211d Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:14:37 -0400 Subject: [PATCH 07/30] Finished Bot Animations and other fixes --- assets/pangea/bot_faces/pangea_bot.riv | Bin 10794 -> 10789 bytes .../controllers/igc_controller.dart | 9 ---- .../choreographer/widgets/it_bar_buttons.dart | 2 +- .../widgets/it_feedback_card.dart | 2 +- lib/pangea/controllers/user_controller.dart | 2 +- lib/pangea/utils/instructions.dart | 2 +- lib/pangea/widgets/common/bot_face_svg.dart | 32 +++++++++----- .../conversation_bot_settings.dart | 2 +- .../widgets/igc/pangea_text_controller.dart | 6 --- lib/pangea/widgets/igc/span_card.dart | 40 ++++++++++++------ lib/pangea/widgets/new_group/vocab_list.dart | 6 +-- 11 files changed, 57 insertions(+), 46 deletions(-) diff --git a/assets/pangea/bot_faces/pangea_bot.riv b/assets/pangea/bot_faces/pangea_bot.riv index b6956e547eeb1962304f8ad5aeec12c435307b3e..177b9b28fe53aa22a9bb986fbdd7a3e62dd71a09 100644 GIT binary patch delta 178 zcmZ1#vNUAFEwRma#B^9UbIE*T+svdK%)B{V&5^mD%QdegwJ5kGu_TqjvWt=3C$TcM zNWqZ7j=^y{Bg;I-34RQ2vl$scJhpj^7x=-vxj=yidyp7AiWq|fNQ`kF;|q4UItQ>A l(>%r<;&8DB2L{`zKr?KoiZL<*H32!y4E7+31w^ni0051&D{KG& delta 186 zcmZ1)vMOZ5Eip#x%{Rq#S(&UEH?zrnV*}BDl!BQ-w7;4ob3M0fUP)?^LU2i9Nh*V7 z7bCk*VkMAo$l$ getIGCTextData({required bool tokensOnly}) async { try { if (choreographer.currentText.isEmpty) return clear(); @@ -215,12 +212,6 @@ class IgcController { ), onITStart: () { if (choreographer.itEnabled && igcTextData != null) { - if (turnOnAutoPlay) { - choreographer.pangeaController.pStoreService.save( - ToolSetting.itAutoPlay.toString(), - true, - ); - } choreographer.onITStart(igcTextData!.matches[firstMatchIndex]); } }, diff --git a/lib/pangea/choreographer/widgets/it_bar_buttons.dart b/lib/pangea/choreographer/widgets/it_bar_buttons.dart index 815020d17..786c17c07 100644 --- a/lib/pangea/choreographer/widgets/it_bar_buttons.dart +++ b/lib/pangea/choreographer/widgets/it_bar_buttons.dart @@ -45,7 +45,7 @@ class ITBotButton extends StatelessWidget { ); return IconButton( - icon: const BotFace(width: 40.0, expression: BotExpression.right), + icon: const BotFace(width: 40.0, expression: BotExpression.idle), onPressed: () => choreographer.pangeaController.instructions.show( context, InstructionsEnum.itInstructions, diff --git a/lib/pangea/choreographer/widgets/it_feedback_card.dart b/lib/pangea/choreographer/widgets/it_feedback_card.dart index 072d24e1a..5424310a8 100644 --- a/lib/pangea/choreographer/widgets/it_feedback_card.dart +++ b/lib/pangea/choreographer/widgets/it_feedback_card.dart @@ -129,7 +129,7 @@ class ITFeedbackCardView extends StatelessWidget { children: [ CardHeader( text: controller.widget.req.chosenContinuance, - botExpression: BotExpression.down, + botExpression: BotExpression.nonGold, ), Text( controller.widget.choiceFeedback, diff --git a/lib/pangea/controllers/user_controller.dart b/lib/pangea/controllers/user_controller.dart index c6a1b3409..0e336fdf6 100644 --- a/lib/pangea/controllers/user_controller.dart +++ b/lib/pangea/controllers/user_controller.dart @@ -142,7 +142,7 @@ class UserController extends BaseController { await updateMatrixProfile( dateOfBirth: dob, - autoPlayMessages: autoPlay ?? false, + autoPlayMessages: autoPlay, activatedFreeTrial: trial, interactiveTranslator: interactiveTranslator, itAutoPlay: itAutoPlay, diff --git a/lib/pangea/utils/instructions.dart b/lib/pangea/utils/instructions.dart index f1fa8b59f..7d3711ae6 100644 --- a/lib/pangea/utils/instructions.dart +++ b/lib/pangea/utils/instructions.dart @@ -73,7 +73,7 @@ class InstructionsController { children: [ CardHeader( text: key.title(context), - botExpression: BotExpression.surprised, + botExpression: BotExpression.idle, onClose: () => {_instructionsClosed[key] = true}, ), const SizedBox(height: 10.0), diff --git a/lib/pangea/widgets/common/bot_face_svg.dart b/lib/pangea/widgets/common/bot_face_svg.dart index b856596dd..f387b4bc3 100644 --- a/lib/pangea/widgets/common/bot_face_svg.dart +++ b/lib/pangea/widgets/common/bot_face_svg.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; -enum BotExpression { surprised, right, addled, left, down, shocked } +enum BotExpression { gold, nonGold, addled, idle, surprised } class BotFace extends StatefulWidget { final double width; @@ -21,7 +21,7 @@ class BotFace extends StatefulWidget { class BotFaceState extends State { Artboard? _artboard; - SMINumber? _input; + StateMachineController? _controller; @override void initState() { @@ -31,11 +31,11 @@ class BotFaceState extends State { double mapExpressionToInput(BotExpression expression) { switch (expression) { - case BotExpression.surprised: + case BotExpression.gold: return 1.0; - case BotExpression.right: + case BotExpression.nonGold: return 2.0; - case BotExpression.shocked: + case BotExpression.surprised: return 3.0; case BotExpression.addled: return 4.0; @@ -48,14 +48,13 @@ class BotFaceState extends State { final riveFile = await RiveFile.asset('assets/pangea/bot_faces/pangea_bot.riv'); final artboard = riveFile.mainArtboard; - final controller = StateMachineController + _controller = StateMachineController .fromArtboard(artboard, 'BotIconStateMachine'); - if (controller != null) { - artboard.addController(controller); - _input = controller.findInput("Enter State") as SMINumber?; - controller.setInputValue( - 890, // this should be the id of the input + if (_controller != null) { + artboard.addController(_controller!); + _controller!.setInputValue( + _controller!.stateMachine.inputs[0].id, mapExpressionToInput(widget.expression), ); } @@ -79,6 +78,17 @@ class BotFaceState extends State { : Container(), ); } + + @override + void didUpdateWidget(BotFace oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.expression != widget.expression) { + _controller!.setInputValue( + _controller!.stateMachine.inputs[0].id, + mapExpressionToInput(widget.expression), + ); + } + } } // extension ParseToString on BotExpressions { diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart index d10fd6980..7e242b706 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart @@ -142,7 +142,7 @@ class ConversationBotSettingsState extends State { Theme.of(context).textTheme.bodyLarge!.color, child: const BotFace( width: 30.0, - expression: BotExpression.right, + expression: BotExpression.idle, ), ), activeColor: AppConfig.activeToggleColor, diff --git a/lib/pangea/widgets/igc/pangea_text_controller.dart b/lib/pangea/widgets/igc/pangea_text_controller.dart index c476ccca0..adecb4f00 100644 --- a/lib/pangea/widgets/igc/pangea_text_controller.dart +++ b/lib/pangea/widgets/igc/pangea_text_controller.dart @@ -85,12 +85,6 @@ class PangeaTextController extends TextEditingController { cursorOffset: selection.baseOffset, ), onITStart: () { - if (choreographer.igc.turnOnAutoPlay) { - choreographer.pangeaController.pStoreService.save( - 'ToolSetting.itAutoPlay', - true, - ); - } choreographer.onITStart( choreographer.igc.igcTextData!.matches[matchIndex], ); diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index 9b9fbb4ec..3d6df9928 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -15,6 +15,7 @@ import '../../../widgets/matrix.dart'; import '../../choreographer/widgets/choice_array.dart'; import '../../controllers/pangea_controller.dart'; import '../../enum/span_choice_type.dart'; +import '../../models/class_model.dart'; import '../../models/span_card_model.dart'; import '../common/bot_face_svg.dart'; import 'card_header.dart'; @@ -49,6 +50,8 @@ class SpanCardState extends State { bool fetchingData = false; int? selectedChoiceIndex; + BotExpression currentExpression = BotExpression.nonGold; + //on initState, get SpanDetails @override void initState() { @@ -121,7 +124,23 @@ class WordMatchContent extends StatelessWidget { .choices?[index] .selected = true; - controller.setState(() => ()); + controller.setState( + () => ( + controller.currentExpression = + controller + .widget + .scm + .choreographer + .igc + .igcTextData + !.matches[controller.widget.scm.matchIndex] + .match + .choices![index] + .isBestCorrection + ? BotExpression.gold + : BotExpression.nonGold + ), + ); // if (controller.widget.scm.pangeaMatch.match.choices![index].type == // SpanChoiceType.distractor) { // await controller.getSpanDetails(); @@ -166,7 +185,7 @@ class WordMatchContent extends StatelessWidget { CardHeader( text: controller.error?.toString() ?? matchCopy.title, botExpression: controller.error == null - ? BotExpression.right + ? controller.currentExpression : BotExpression.addled, ), Expanded( @@ -284,10 +303,7 @@ class WordMatchContent extends StatelessWidget { ), if (controller.widget.scm.pangeaMatch!.isITStart) DontShowSwitchListTile( - value: controller.widget.scm.choreographer.igc.turnOnAutoPlay, - onChanged: ((value) { - controller.widget.scm.choreographer.igc.turnOnAutoPlay = value; - }), + controller: pangeaController, ), ], ); @@ -429,13 +445,11 @@ class StartITButton extends StatelessWidget { } class DontShowSwitchListTile extends StatefulWidget { - final bool value; - final ValueChanged onChanged; + final PangeaController controller; const DontShowSwitchListTile({ super.key, - required this.value, - required this.onChanged, + required this.controller, }); @override @@ -448,7 +462,6 @@ class DontShowSwitchListTileState extends State { @override void initState() { super.initState(); - switchValue = widget.value; } @override @@ -458,7 +471,10 @@ class DontShowSwitchListTileState extends State { title: Text(L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader), value: switchValue, onChanged: (value) => { - widget.onChanged(value), + widget.controller.pStoreService.save( + ToolSetting.itAutoPlay.toString(), + value, + ), setState(() => switchValue = value), }, ); diff --git a/lib/pangea/widgets/new_group/vocab_list.dart b/lib/pangea/widgets/new_group/vocab_list.dart index e6c2675e4..240e99a85 100644 --- a/lib/pangea/widgets/new_group/vocab_list.dart +++ b/lib/pangea/widgets/new_group/vocab_list.dart @@ -271,7 +271,7 @@ class GenerateVocabButtonState extends State { ElevatedButton.icon( icon: const BotFace( width: 50.0, - expression: BotExpression.right, + expression: BotExpression.idle, ), label: Text(L10n.of(context)!.generateVocabulary), onPressed: () async { @@ -464,9 +464,9 @@ class PromptsFieldState extends State { // button to call API ElevatedButton.icon( - icon: const BotFace( + icon: BotFace( width: 50.0, - expression: BotExpression.right, + expression: BotExpression.idle, ), label: Text(L10n.of(context)!.generatePrompts), onPressed: () async { From 929909a000f61175a753b3ac1e6c7efbc0192da1 Mon Sep 17 00:00:00 2001 From: William Jordan-Cooley Date: Tue, 18 Jun 2024 12:10:49 -0400 Subject: [PATCH 08/30] little code cleanup --- .../widgets/igc/pangea_text_controller.dart | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/pangea/widgets/igc/pangea_text_controller.dart b/lib/pangea/widgets/igc/pangea_text_controller.dart index adecb4f00..b91186c22 100644 --- a/lib/pangea/widgets/igc/pangea_text_controller.dart +++ b/lib/pangea/widgets/igc/pangea_text_controller.dart @@ -71,6 +71,16 @@ class PangeaTextController extends TextEditingController { choreographer.igc.igcTextData!.getTopMatchIndexForOffset( selection.baseOffset, ); + + // if autoplay on and it start then just start it + if (matchIndex != -1 && + choreographer.itAutoPlayEnabled && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart) { + return choreographer.onITStart( + choreographer.igc.igcTextData!.matches[matchIndex], + ); + } + final Widget? cardToShow = matchIndex != -1 ? SpanCard( scm: SpanCardModel( @@ -82,8 +92,8 @@ class PangeaTextController extends TextEditingController { debugPrint("onSentenceRewrite $tokenIndex $sentenceRewrite"); }), onIgnore: () => choreographer.onIgnoreMatch( - cursorOffset: selection.baseOffset, - ), + cursorOffset: selection.baseOffset, + ), onITStart: () { choreographer.onITStart( choreographer.igc.igcTextData!.matches[matchIndex], @@ -96,24 +106,15 @@ class PangeaTextController extends TextEditingController { : null; if (cardToShow != null) { - if ( - choreographer.itAutoPlayEnabled && - choreographer.igc.igcTextData!.matches[matchIndex].isITStart - ) { - choreographer.onITStart( - choreographer.igc.igcTextData!.matches[matchIndex], - ); - } else { - OverlayUtil.showPositionedCard( - context: context, - cardSize: matchIndex != -1 && - choreographer.igc.igcTextData!.matches[matchIndex].isITStart - ? const Size(350, 260) - : const Size(350, 400), - cardToShow: cardToShow, - transformTargetId: choreographer.inputTransformTargetKey, - ); - } + OverlayUtil.showPositionedCard( + context: context, + cardSize: matchIndex != -1 && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart + ? const Size(350, 260) + : const Size(350, 400), + cardToShow: cardToShow, + transformTargetId: choreographer.inputTransformTargetKey, + ); } } From 90adf436d31d29fbaa2005da3bbb8532bf7f6f8d Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:29:44 -0400 Subject: [PATCH 09/30] Choice quick click bug fixed 343 --- assets/pangea/bot_faces/pangea_bot.riv | Bin 10789 -> 11187 bytes lib/pages/chat/chat_input_row.dart | 4 - lib/pages/chat/chat_view.dart | 4 + .../choreographer/widgets/choice_array.dart | 97 ++++++++++++++---- lib/pangea/controllers/local_settings.dart | 3 +- lib/pangea/widgets/igc/span_card.dart | 2 +- 6 files changed, 83 insertions(+), 27 deletions(-) diff --git a/assets/pangea/bot_faces/pangea_bot.riv b/assets/pangea/bot_faces/pangea_bot.riv index 177b9b28fe53aa22a9bb986fbdd7a3e62dd71a09..94244a30f977bc7fadbcec98932ba3bff200374d 100644 GIT binary patch delta 533 zcmZ1)vN?RiIk8Yl<6H(QQ(gu+7e=@9zR4Cq4j-6P$GX9ULDIMaE}M1klsQ~>0V9(c zkRt$A%D~WI59A2KIh)Ult!3i#g{zjZb#mHVE*Z?p4zvZtnS4S?l}1*-QPN@7LA4s_ z4LqKl?5Uz+K&nSKo2n%;P2MfWHF>&*7Hxbo`GCglz#c{h1_uWQ%PvNCpTx@4A_YSR zdj{L7Kv5vU3?f)T1Pg;5gX45Yrg@AL{21J31EqmHmU)a9_`$rnKmlMB0mYanU(i&S TV4ughLmVOFz~BHfgpmONzpMoNT46%q(xtH91FJV)Hp=0cOVB$^5D+o72=InI@mm z)Sm3Ab<32&vWt=3C$TcMNWqZ7j=^y{Bg;I-34RQ2vl$scJhpj^7x=-vxj=yidyp9W l? choices; final void Function(int) onPressed; @@ -18,6 +17,7 @@ class ChoicesArray extends StatelessWidget { final int? selectedChoiceIndex; final String originalSpan; final String Function(int) uniqueKeyForLayerLink; + const ChoicesArray({ super.key, required this.isLoading, @@ -29,23 +29,49 @@ class ChoicesArray extends StatelessWidget { this.onLongPress, }); + @override + ChoicesArrayState createState() => ChoicesArrayState(); +} + +class ChoicesArrayState extends State { + bool interactionDisabled = false; + + void disableInteraction() { + WidgetsBinding.instance.addPostFrameCallback((_) { + setState(() { + interactionDisabled = true; + }); + }); + } + + void enableInteractions() { + WidgetsBinding.instance.addPostFrameCallback((_) { + setState(() { + interactionDisabled = false; + }); + }); + } + @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return isLoading && (choices == null || choices!.length <= 1) - ? ItShimmer(originalSpan: originalSpan) + return widget.isLoading && (widget.choices == null || widget.choices!.length <= 1) + ? ItShimmer(originalSpan: widget.originalSpan) : Wrap( alignment: WrapAlignment.center, - children: choices + children: widget.choices ?.asMap() .entries .map( (entry) => ChoiceItem( theme: theme, - onLongPress: onLongPress, - onPressed: onPressed, + onLongPress: widget.onLongPress, + onPressed: widget.onPressed, entry: entry, - isSelected: selectedChoiceIndex == entry.key, + interactionDisabled: interactionDisabled, + enableInteraction: enableInteractions, + disableInteraction: disableInteraction, + isSelected: widget.selectedChoiceIndex == entry.key, ), ) .toList() ?? @@ -74,6 +100,9 @@ class ChoiceItem extends StatelessWidget { required this.onPressed, required this.entry, required this.isSelected, + required this.interactionDisabled, + required this.enableInteraction, + required this.disableInteraction, }); final MapEntry entry; @@ -81,6 +110,9 @@ class ChoiceItem extends StatelessWidget { final void Function(int p1)? onLongPress; final void Function(int p1) onPressed; final bool isSelected; + final bool interactionDisabled; + final VoidCallback enableInteraction; + final VoidCallback disableInteraction; @override Widget build(BuildContext context) { @@ -94,6 +126,8 @@ class ChoiceItem extends StatelessWidget { key: ValueKey(entry.value.text), selected: entry.value.color != null, isGold: entry.value.isGold, + enableInteraction: enableInteraction, + disableInteraction: disableInteraction, child: Container( margin: const EdgeInsets.all(2), padding: EdgeInsets.zero, @@ -128,8 +162,9 @@ class ChoiceItem extends StatelessWidget { ), ), onLongPress: - onLongPress != null ? () => onLongPress!(entry.key) : null, - onPressed: () => onPressed(entry.key), + onLongPress != null && !interactionDisabled + ? () => onLongPress!(entry.key) : null, + onPressed: interactionDisabled ? null : () => onPressed(entry.key), child: Text( entry.value.text, style: BotStyle.text(context), @@ -149,11 +184,15 @@ class ChoiceAnimationWidget extends StatefulWidget { final Widget child; final bool selected; final bool isGold; + final VoidCallback enableInteraction; + final VoidCallback disableInteraction; const ChoiceAnimationWidget({ super.key, required this.child, required this.selected, + required this.enableInteraction, + required this.disableInteraction, this.isGold = false, }); @@ -161,11 +200,13 @@ class ChoiceAnimationWidget extends StatefulWidget { ChoiceAnimationWidgetState createState() => ChoiceAnimationWidgetState(); } +enum AnimationState { ready, forward, reverse, finished } + class ChoiceAnimationWidgetState extends State with SingleTickerProviderStateMixin { late final AnimationController _controller; late final Animation _animation; - bool animationPlayed = false; + AnimationState animationState = AnimationState.ready; @override void initState() { @@ -193,17 +234,29 @@ class ChoiceAnimationWidgetState extends State ), ]).animate(_controller); - if (widget.selected && !animationPlayed) { + widget.enableInteraction(); + + if (widget.selected && animationState == AnimationState.ready) { + widget.disableInteraction(); _controller.forward(); - animationPlayed = true; - setState(() {}); + setState(() { + animationState = AnimationState.forward; + }); } _controller.addStatusListener((status) { - if (status == AnimationStatus.completed) { + if (status == AnimationStatus.completed && + animationState == AnimationState.forward) { _controller.reverse(); - } else if (status == AnimationStatus.dismissed) { - _controller.stop(); - _controller.reset(); + setState(() { + animationState = AnimationState.reverse; + }); + } + if (status == AnimationStatus.dismissed && + animationState == AnimationState.reverse) { + widget.enableInteraction(); + setState(() { + animationState = AnimationState.finished; + }); } }); } @@ -211,10 +264,12 @@ class ChoiceAnimationWidgetState extends State @override void didUpdateWidget(ChoiceAnimationWidget oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.selected && !animationPlayed) { + if (widget.selected && animationState == AnimationState.ready) { + widget.disableInteraction(); _controller.forward(); - animationPlayed = true; - setState(() {}); + setState(() { + animationState = AnimationState.forward; + }); } } diff --git a/lib/pangea/controllers/local_settings.dart b/lib/pangea/controllers/local_settings.dart index 5984a7bf5..d6ae119a5 100644 --- a/lib/pangea/controllers/local_settings.dart +++ b/lib/pangea/controllers/local_settings.dart @@ -9,7 +9,8 @@ class LocalSettings { } bool userLanguageToolSetting(ToolSetting setting) => - _pangeaController.pStoreService.read(setting.toString()) ?? true; + _pangeaController.pStoreService.read(setting.toString()) + ?? setting != ToolSetting.itAutoPlay; // bool get userEnableIT => // _pangeaController.pStoreService.read(ToolSetting.interactiveTranslator.toString()) ?? true; diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index 3d6df9928..75738a687 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -138,7 +138,7 @@ class WordMatchContent extends StatelessWidget { .choices![index] .isBestCorrection ? BotExpression.gold - : BotExpression.nonGold + : BotExpression.surprised ), ); // if (controller.widget.scm.pangeaMatch.match.choices![index].type == From 50dc34bd94166e125a8c41720562722a83db4f05 Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Thu, 20 Jun 2024 22:20:47 -0400 Subject: [PATCH 10/30] itAutoPlay added to setting switches --- lib/pangea/enum/span_data_type.dart | 2 +- lib/pangea/models/class_model.dart | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/pangea/enum/span_data_type.dart b/lib/pangea/enum/span_data_type.dart index 949aac26b..38315fd50 100644 --- a/lib/pangea/enum/span_data_type.dart +++ b/lib/pangea/enum/span_data_type.dart @@ -34,7 +34,7 @@ extension SpanDataTypeEnumExt on SpanDataTypeEnum { case SpanDataTypeEnum.itStart: return L10n.of(context)!.needsItMessage( MatrixState.pangeaController.languageController.userL2?.displayName ?? - "target language", + L10n.of(context)!.targetLanguage, ); } } diff --git a/lib/pangea/models/class_model.dart b/lib/pangea/models/class_model.dart index cf0cadedb..f663af8ce 100644 --- a/lib/pangea/models/class_model.dart +++ b/lib/pangea/models/class_model.dart @@ -120,6 +120,7 @@ class PangeaRoomRules { bool isInviteOnlyStudents; // 0 = forbidden, 1 = allow individual to choose, 2 = require int interactiveTranslator; + int itAutoPlay; int interactiveGrammar; int immersionMode; int definitions; @@ -138,6 +139,7 @@ class PangeaRoomRules { this.isVoiceNotes = true, this.isInviteOnlyStudents = true, this.interactiveTranslator = ClassDefaultValues.languageToolPermissions, + this.itAutoPlay = ClassDefaultValues.languageToolPermissions, this.interactiveGrammar = ClassDefaultValues.languageToolPermissions, this.immersionMode = ClassDefaultValues.languageToolPermissions, this.definitions = ClassDefaultValues.languageToolPermissions, @@ -189,6 +191,9 @@ class PangeaRoomRules { case ToolSetting.interactiveTranslator: interactiveTranslator = value; break; + case ToolSetting.itAutoPlay: + itAutoPlay = value; + break; case ToolSetting.interactiveGrammar: interactiveGrammar = value; break; @@ -227,6 +232,8 @@ class PangeaRoomRules { isInviteOnlyStudents: json['is_invite_only_students'] ?? true, interactiveTranslator: json['interactive_translator'] ?? ClassDefaultValues.languageToolPermissions, + itAutoPlay: json['it_auto_play'] ?? + ClassDefaultValues.languageToolPermissions, interactiveGrammar: json['interactive_grammar'] ?? ClassDefaultValues.languageToolPermissions, immersionMode: json['immersion_mode'] ?? @@ -252,6 +259,7 @@ class PangeaRoomRules { data['is_voice_notes'] = isVoiceNotes; data['is_invite_only_students'] = isInviteOnlyStudents; data['interactive_translator'] = interactiveTranslator; + data['it_auto_play'] = itAutoPlay; data['interactive_grammar'] = interactiveGrammar; data['immersion_mode'] = immersionMode; data['definitions'] = definitions; @@ -263,6 +271,8 @@ class PangeaRoomRules { switch (setting) { case ToolSetting.interactiveTranslator: return interactiveTranslator; + case ToolSetting.itAutoPlay: + return itAutoPlay; case ToolSetting.interactiveGrammar: return interactiveGrammar; case ToolSetting.immersionMode: From dec0c2352375e0804edfd90aff8dedaa9819bc4e Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Fri, 21 Jun 2024 17:16:18 -0400 Subject: [PATCH 11/30] save, not working, freezes when open room detail --- assets/l10n/intl_en.arb | 4 + lib/pangea/constants/model_keys.dart | 8 +- lib/pangea/models/bot_options_model.dart | 70 ++++-- ...sation_bot_custom_system_prompt_input.dart | 73 +++++++ .../conversation_bot_custom_zone.dart | 63 +++++- .../conversation_bot_mode_dynamic_zone.dart | 11 +- .../conversation_bot_mode_select.dart | 2 +- .../conversation_bot_settings.dart | 45 ++-- needed-translations.txt | 200 ++++++++++++++++++ pubspec.lock | 40 ++++ 10 files changed, 459 insertions(+), 57 deletions(-) create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_custom_system_prompt_input.dart diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index c66ef7ac6..2b97c1686 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4022,6 +4022,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Hours between discussion prompts", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Responds on ⏩ reaction", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reaction to send discussion prompt", + "conversationBotCustomZone_title": "Custom Settings", + "conversationBotCustomZone_customSystemPromptLabel": "System prompt", + "conversationBotCustomZone_customSystemPromptPlaceholder": "Set custom system prompt", + "conversationBotCustomZone_customTriggerReactionEnabledLabel": "Responds on ⏩ reaction", "addConversationBotDialogTitleInvite": "Confirm inviting conversation bot", "addConversationBotButtonInvite": "Invite", "addConversationBotDialogInviteConfirmation": "Invite", diff --git a/lib/pangea/constants/model_keys.dart b/lib/pangea/constants/model_keys.dart index 0cd14e5a4..dca53288d 100644 --- a/lib/pangea/constants/model_keys.dart +++ b/lib/pangea/constants/model_keys.dart @@ -102,14 +102,14 @@ class ModelKey { static const String custom = "custom"; static const String discussionTopic = "discussion_topic"; static const String discussionKeywords = "discussion_keywords"; - static const String discussionTriggerScheduleEnabled = - "discussion_trigger_schedule_enabled"; - static const String discussionTriggerScheduleHourInterval = - "discussion_trigger_schedule_hour_interval"; static const String discussionTriggerReactionEnabled = "discussion_trigger_reaction_enabled"; static const String discussionTriggerReactionKey = "discussion_trigger_reaction_key"; + static const String customSystemPrompt = "custom_system_prompt"; + static const String customTriggerReactionEnabled = + "custom_trigger_reaction_enabled"; + static const String customTriggerReactionKey = "custom_trigger_reaction_key"; static const String prevEventId = "prev_event_id"; static const String prevLastUpdated = "prev_last_updated"; diff --git a/lib/pangea/models/bot_options_model.dart b/lib/pangea/models/bot_options_model.dart index 00eaddc1b..0e1019e62 100644 --- a/lib/pangea/models/bot_options_model.dart +++ b/lib/pangea/models/bot_options_model.dart @@ -16,41 +16,62 @@ class BotOptionsModel { String? custom; String? discussionTopic; String? discussionKeywords; - bool? discussionTriggerScheduleEnabled; - int? discussionTriggerScheduleHourInterval; - bool? discussionTriggerReactionEnabled; - String? discussionTriggerReactionKey; + bool discussionTriggerReactionEnabled; + String discussionTriggerReactionKey; + String? customSystemPrompt; + bool customTriggerReactionEnabled; + String customTriggerReactionKey; BotOptionsModel({ + //////////////////////////////////////////////////////////////////////////// + // General Bot Options + //////////////////////////////////////////////////////////////////////////// this.languageLevel, this.topic = "General Conversation", this.keywords = const [], this.safetyModeration = true, this.mode = "discussion", - this.custom = "", + + //////////////////////////////////////////////////////////////////////////// + // Discussion Mode Options + //////////////////////////////////////////////////////////////////////////// this.discussionTopic, this.discussionKeywords, - this.discussionTriggerScheduleEnabled, - this.discussionTriggerScheduleHourInterval, this.discussionTriggerReactionEnabled = true, - this.discussionTriggerReactionKey, + this.discussionTriggerReactionKey = "⏩", + + //////////////////////////////////////////////////////////////////////////// + // Custom Mode Options + //////////////////////////////////////////////////////////////////////////// + this.customSystemPrompt, + this.customTriggerReactionEnabled = true, + this.customTriggerReactionKey = "⏩", }); factory BotOptionsModel.fromJson(json) { return BotOptionsModel( + ////////////////////////////////////////////////////////////////////////// + // General Bot Options + ////////////////////////////////////////////////////////////////////////// languageLevel: json[ModelKey.languageLevel], safetyModeration: json[ModelKey.safetyModeration] ?? true, mode: json[ModelKey.mode] ?? "discussion", - custom: json[ModelKey.custom], + + ////////////////////////////////////////////////////////////////////////// + // Discussion Mode Options + ////////////////////////////////////////////////////////////////////////// discussionTopic: json[ModelKey.discussionTopic], discussionKeywords: json[ModelKey.discussionKeywords], - discussionTriggerScheduleEnabled: - json[ModelKey.discussionTriggerScheduleEnabled], - discussionTriggerScheduleHourInterval: - json[ModelKey.discussionTriggerScheduleHourInterval], discussionTriggerReactionEnabled: json[ModelKey.discussionTriggerReactionEnabled], discussionTriggerReactionKey: json[ModelKey.discussionTriggerReactionKey], + + ////////////////////////////////////////////////////////////////////////// + // Custom Mode Options + ////////////////////////////////////////////////////////////////////////// + customSystemPrompt: json[ModelKey.customSystemPrompt], + customTriggerReactionEnabled: json[ModelKey.customTriggerReactionEnabled], + customTriggerReactionKey: json[ModelKey.customTriggerReactionKey], ); } @@ -64,14 +85,14 @@ class BotOptionsModel { data[ModelKey.custom] = custom; data[ModelKey.discussionTopic] = discussionTopic; data[ModelKey.discussionKeywords] = discussionKeywords; - data[ModelKey.discussionTriggerScheduleEnabled] = - discussionTriggerScheduleEnabled; - data[ModelKey.discussionTriggerScheduleHourInterval] = - discussionTriggerScheduleHourInterval; data[ModelKey.discussionTriggerReactionEnabled] = discussionTriggerReactionEnabled; data[ModelKey.discussionTriggerReactionKey] = discussionTriggerReactionKey; + data[ModelKey.customSystemPrompt] = customSystemPrompt; + data[ModelKey.customTriggerReactionEnabled] = + customTriggerReactionEnabled; + data[ModelKey.customTriggerReactionKey] = customTriggerReactionKey; return data; } catch (e, s) { debugger(when: kDebugMode); @@ -101,18 +122,21 @@ class BotOptionsModel { case ModelKey.discussionKeywords: discussionKeywords = value; break; - case ModelKey.discussionTriggerScheduleEnabled: - discussionTriggerScheduleEnabled = value; - break; - case ModelKey.discussionTriggerScheduleHourInterval: - discussionTriggerScheduleHourInterval = value; - break; case ModelKey.discussionTriggerReactionEnabled: discussionTriggerReactionEnabled = value; break; case ModelKey.discussionTriggerReactionKey: discussionTriggerReactionKey = value; break; + case ModelKey.customSystemPrompt: + customSystemPrompt = value; + break; + case ModelKey.customTriggerReactionEnabled: + customTriggerReactionEnabled = value; + break; + case ModelKey.customTriggerReactionKey: + customTriggerReactionKey = value; + break; default: throw Exception('Invalid key for bot options - $key'); } diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_custom_system_prompt_input.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_system_prompt_input.dart new file mode 100644 index 000000000..55ec1493d --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_system_prompt_input.dart @@ -0,0 +1,73 @@ +import 'package:fluffychat/pangea/models/bot_options_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; + +class ConversationBotCustomSystemPromptInput extends StatelessWidget { + final BotOptionsModel initialBotOptions; + // call this to update propagate changes to parents + final void Function(BotOptionsModel) onChanged; + + const ConversationBotCustomSystemPromptInput({ + super.key, + required this.initialBotOptions, + required this.onChanged, + }); + + @override + Widget build(BuildContext context) { + String customSystemPrompt = initialBotOptions.customSystemPrompt ?? ""; + + final TextEditingController textFieldController = + TextEditingController(text: customSystemPrompt); + + void setBotCustomSystemPromptAction() async { + showDialog( + context: context, + useRootNavigator: false, + builder: (BuildContext context) => AlertDialog( + title: Text( + L10n.of(context)!.conversationBotCustomZone_customSystemPromptLabel, + ), + content: TextField( + minLines: 1, + maxLines: 10, + maxLength: 1000, + controller: textFieldController, + onChanged: (value) { + customSystemPrompt = value; + }, + ), + actions: [ + TextButton( + child: Text(L10n.of(context)!.cancel), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text(L10n.of(context)!.ok), + onPressed: () { + if (customSystemPrompt == "") return; + if (customSystemPrompt != + initialBotOptions.customSystemPrompt) { + initialBotOptions.customSystemPrompt = customSystemPrompt; + onChanged.call(initialBotOptions); + Navigator.of(context).pop(); + } + }, + ), + ], + ), + ); + } + + return ListTile( + onTap: setBotCustomSystemPromptAction, + title: Text( + initialBotOptions.customSystemPrompt ?? + L10n.of(context)! + .conversationBotCustomZone_customSystemPromptPlaceholder, + ), + ); + } +} diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart index 5fe8880ea..46f87237c 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart @@ -1,15 +1,74 @@ +import 'package:fluffychat/pangea/models/bot_options_model.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_custom_system_prompt_input.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; class ConversationBotCustomZone extends StatelessWidget { + final BotOptionsModel initialBotOptions; + // call this to update propagate changes to parents + final void Function(BotOptionsModel) onChanged; + const ConversationBotCustomZone({ super.key, + required this.initialBotOptions, + required this.onChanged, }); @override Widget build(BuildContext context) { - return const Column( + return Column( children: [ - Text('Custom Zone'), + const SizedBox(height: 12), + Text( + L10n.of(context)!.conversationBotCustomZone_title, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + const Divider( + color: Colors.grey, + thickness: 1, + ), + const SizedBox(height: 12), + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.fromLTRB(12, 0, 0, 0), + child: Text( + L10n.of(context)! + .conversationBotCustomZone_customSystemPromptLabel, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8), + child: ConversationBotCustomSystemPromptInput( + initialBotOptions: initialBotOptions, + onChanged: onChanged, + ), + ), + const SizedBox(height: 12), + CheckboxListTile( + title: Text( + L10n.of(context)! + .conversationBotCustomZone_customTriggerReactionEnabledLabel, + ), + enabled: false, + value: initialBotOptions.customTriggerReactionEnabled, + onChanged: (value) { + initialBotOptions.customTriggerReactionEnabled = value ?? false; + initialBotOptions.customTriggerReactionKey = + "⏩"; // hard code this for now + onChanged.call(initialBotOptions); + }, + // make this input disabled always + ), + const SizedBox(height: 12), ], ); } diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart index b0c78888f..b15689357 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart @@ -1,7 +1,5 @@ import 'package:fluffychat/pangea/models/bot_options_model.dart'; -import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_conversation_zone.dart'; import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart'; -import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart'; import 'package:flutter/material.dart'; import 'conversation_bot_discussion_zone.dart'; @@ -23,9 +21,12 @@ class ConversationBotModeDynamicZone extends StatelessWidget { initialBotOptions: initialBotOptions, onChanged: onChanged, ), - "custom": const ConversationBotCustomZone(), - "conversation": const ConversationBotConversationZone(), - "text_adventure": const ConversationBotTextAdventureZone(), + "custom": ConversationBotCustomZone( + initialBotOptions: initialBotOptions, + onChanged: onChanged, + ), + // "conversation": const ConversationBotConversationZone(), + // "text_adventure": const ConversationBotTextAdventureZone(), }; return Container( decoration: BoxDecoration( diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart index 9662dec55..ba60f038c 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart @@ -16,7 +16,7 @@ class ConversationBotModeSelect extends StatelessWidget { final Map options = { "discussion": L10n.of(context)!.conversationBotModeSelectOption_discussion, - // "custom": L10n.of(context)!.conversationBotModeSelectOption_custom, + "custom": L10n.of(context)!.conversationBotModeSelectOption_custom, // "conversation": // L10n.of(context)!.conversationBotModeSelectOption_conversation, // "text_adventure": diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart index 6684dcca7..6b57ca3a4 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart @@ -4,6 +4,7 @@ import 'package:fluffychat/pangea/models/bot_options_model.dart'; import 'package:fluffychat/pangea/utils/bot_name.dart'; import 'package:fluffychat/pangea/widgets/common/bot_face_svg.dart'; import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart'; import 'package:fluffychat/pangea/widgets/space/language_level_dropdown.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -226,28 +227,28 @@ class ConversationBotSettingsState extends State { }), ), ), - // Padding( - // padding: const EdgeInsets.fromLTRB(32, 16, 0, 0), - // child: Text( - // L10n.of(context)!.conversationBotModeSelectDescription, - // style: TextStyle( - // color: Theme.of(context).colorScheme.secondary, - // fontWeight: FontWeight.bold, - // fontSize: 16, - // ), - // ), - // ), - // Padding( - // padding: const EdgeInsets.only(left: 16), - // child: ConversationBotModeSelect( - // initialMode: botOptions.mode, - // onChanged: (String? mode) => updateBotOption( - // () { - // botOptions.mode = mode ?? "discussion"; - // }, - // ), - // ), - // ), + Padding( + padding: const EdgeInsets.fromLTRB(32, 16, 0, 0), + child: Text( + L10n.of(context)!.conversationBotModeSelectDescription, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + ), + Padding( + padding: const EdgeInsets.only(left: 16), + child: ConversationBotModeSelect( + initialMode: botOptions.mode, + onChanged: (String? mode) => updateBotOption( + () { + botOptions.mode = mode ?? "discussion"; + }, + ), + ), + ), Padding( padding: const EdgeInsets.fromLTRB(28, 0, 12, 0), child: ConversationBotModeDynamicZone( diff --git a/needed-translations.txt b/needed-translations.txt index 293985cfc..3ce87e091 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -831,6 +831,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -2330,6 +2334,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -3829,6 +3837,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -5332,6 +5344,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -6237,6 +6253,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -7224,6 +7244,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -8098,6 +8122,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -9548,6 +9576,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -10700,6 +10732,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -10773,6 +10809,10 @@ "searchMore", "gallery", "files", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -11621,6 +11661,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -12491,6 +12535,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -13498,6 +13546,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -14471,6 +14523,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -15800,6 +15856,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -16808,6 +16868,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -17945,6 +18009,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -18819,6 +18887,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -20071,6 +20143,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -21567,6 +21643,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -22516,6 +22596,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -23404,6 +23488,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -24891,6 +24979,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -25769,6 +25861,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -27027,6 +27123,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -27954,6 +28054,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -28992,6 +29096,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -30349,6 +30457,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -31223,6 +31335,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -32259,6 +32375,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -33139,6 +33259,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -34339,6 +34463,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -35305,6 +35433,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -36280,6 +36412,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -37761,6 +37897,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -38639,6 +38779,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -39840,6 +39984,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -40850,6 +40998,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -41728,6 +41880,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -42995,6 +43151,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -44394,6 +44554,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -45567,6 +45731,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -46474,6 +46642,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -47974,6 +48146,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -49428,6 +49604,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -50302,6 +50482,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -51205,6 +51389,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -52561,6 +52749,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -53434,6 +53626,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", @@ -54581,6 +54777,10 @@ "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", + "conversationBotCustomZone_title", + "conversationBotCustomZone_customSystemPromptLabel", + "conversationBotCustomZone_customSystemPromptPlaceholder", + "conversationBotCustomZone_customTriggerReactionEnabledLabel", "addConversationBotDialogTitleInvite", "addConversationBotButtonInvite", "addConversationBotDialogInviteConfirmation", diff --git a/pubspec.lock b/pubspec.lock index afe372a2f..655752eda 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -975,6 +975,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + globbing: + dependency: transitive + description: + name: globbing + sha256: "4f89cfaf6fa74c9c1740a96259da06bd45411ede56744e28017cc534a12b6e2d" + url: "https://pub.dev" + source: hosted + version: "1.0.0" go_router: dependency: "direct main" description: @@ -1167,6 +1175,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.8+1" + injector: + dependency: transitive + description: + name: injector + sha256: ed389bed5b48a699d5b9561c985023d0d5cc88dd5ff2237aadcce5a5ab433e4e + url: "https://pub.dev" + source: hosted + version: "3.0.0" integration_test: dependency: "direct dev" description: flutter @@ -1749,6 +1765,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + properties: + dependency: transitive + description: + name: properties + sha256: "333f427dd4ed07bdbe8c75b9ff864a1e70b5d7a8426a2e8bdd457b65ae5ac598" + url: "https://pub.dev" + source: hosted + version: "2.1.1" provider: dependency: "direct main" description: @@ -1949,6 +1973,14 @@ packages: url: "https://pub.dev" source: hosted version: "8.2.0" + sentry_dart_plugin: + dependency: "direct dev" + description: + name: sentry_dart_plugin + sha256: e81fa3e0ffabd04fdcfbfecd6468d4a342f02ab33edca09708c61bcd2be42b7d + url: "https://pub.dev" + source: hosted + version: "1.7.1" sentry_flutter: dependency: "direct main" description: @@ -2234,6 +2266,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0+1" + system_info2: + dependency: transitive + description: + name: system_info2 + sha256: "65206bbef475217008b5827374767550a5420ce70a04d2d7e94d1d2253f3efc9" + url: "https://pub.dev" + source: hosted + version: "4.0.0" tar: dependency: transitive description: From 9c615e7b6604446b320f5789e0c6a9570db52e56 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Tue, 25 Jun 2024 10:21:27 -0400 Subject: [PATCH 12/30] Set max topic height, working on scroll --- .../class_description_button.dart | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart b/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart index 4fdb38604..4f231d1d0 100644 --- a/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart +++ b/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart @@ -26,14 +26,23 @@ class ClassDescriptionButton extends StatelessWidget { foregroundColor: iconColor, child: const Icon(Icons.topic_outlined), ), - subtitle: Text( - room.topic.isEmpty - ? (room.isRoomAdmin - ? (room.isSpace - ? L10n.of(context)!.classDescriptionDesc - : L10n.of(context)!.chatTopicDesc) - : L10n.of(context)!.topicNotSet) - : room.topic, + subtitle: ConstrainedBox( + constraints: const BoxConstraints( + maxHeight: 190, + ), + child: SingleChildScrollView( + // child: NestedScrollView( ??? + controller: ScrollController(), + child: Text( + room.topic.isEmpty + ? (room.isRoomAdmin + ? (room.isSpace + ? L10n.of(context)!.classDescriptionDesc + : L10n.of(context)!.chatTopicDesc) + : L10n.of(context)!.topicNotSet) + : room.topic, + ), + ), ), title: Text( room.isSpace From 2572f277b09c41f849b3322fdebf07fd8734d3a0 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Tue, 25 Jun 2024 11:35:28 -0400 Subject: [PATCH 13/30] Fix scrollbar weirdness --- lib/pages/chat_details/chat_details_view.dart | 1067 +++++++++-------- .../class_description_button.dart | 24 +- 2 files changed, 554 insertions(+), 537 deletions(-) diff --git a/lib/pages/chat_details/chat_details_view.dart b/lib/pages/chat_details/chat_details_view.dart index ca8cb8b04..cf4668637 100644 --- a/lib/pages/chat_details/chat_details_view.dart +++ b/lib/pages/chat_details/chat_details_view.dart @@ -104,380 +104,170 @@ class ChatDetailsView extends StatelessWidget { backgroundColor: Theme.of(context).appBarTheme.backgroundColor, ), body: MaxWidthBody( - child: ListView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: members.length + 1 + (canRequestMoreMembers ? 1 : 0), - itemBuilder: (BuildContext context, int i) => i == 0 - ? Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - children: [ - Padding( - padding: const EdgeInsets.all(32.0), - child: Stack( - children: [ - Material( - elevation: Theme.of(context) - .appBarTheme - .scrolledUnderElevation ?? - 4, - shadowColor: Theme.of(context) - .appBarTheme - .shadowColor, - shape: RoundedRectangleBorder( - side: BorderSide( - color: Theme.of(context).dividerColor, + // #Pangea + child: ScrollConfiguration( + behavior: + ScrollConfiguration.of(context).copyWith(scrollbars: false), + // Pangea# + child: ListView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: members.length + 1 + (canRequestMoreMembers ? 1 : 0), + itemBuilder: (BuildContext context, int i) => i == 0 + ? Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + Padding( + padding: const EdgeInsets.all(32.0), + child: Stack( + children: [ + Material( + elevation: Theme.of(context) + .appBarTheme + .scrolledUnderElevation ?? + 4, + shadowColor: Theme.of(context) + .appBarTheme + .shadowColor, + shape: RoundedRectangleBorder( + side: BorderSide( + color: Theme.of(context).dividerColor, + ), + borderRadius: BorderRadius.circular( + Avatar.defaultSize * 2.5, + ), ), - borderRadius: BorderRadius.circular( - Avatar.defaultSize * 2.5, - ), - ), - child: Hero( - tag: controller - .widget.embeddedCloseButton != - null - ? 'embedded_content_banner' - : 'content_banner', - child: Avatar( - mxContent: room.avatar, - name: displayname, - size: Avatar.defaultSize * 2.5, - ), - ), - ), - if (!room.isDirectChat && - room.canChangeStateEvent( - EventTypes.RoomAvatar, - )) - Positioned( - bottom: 0, - right: 0, - child: FloatingActionButton.small( - onPressed: controller.setAvatarAction, - heroTag: null, - child: const Icon( - Icons.camera_alt_outlined, + child: Hero( + tag: controller.widget + .embeddedCloseButton != + null + ? 'embedded_content_banner' + : 'content_banner', + child: Avatar( + mxContent: room.avatar, + name: displayname, + size: Avatar.defaultSize * 2.5, ), ), ), - ], + if (!room.isDirectChat && + room.canChangeStateEvent( + EventTypes.RoomAvatar, + )) + Positioned( + bottom: 0, + right: 0, + child: FloatingActionButton.small( + onPressed: controller.setAvatarAction, + heroTag: null, + child: const Icon( + Icons.camera_alt_outlined, + ), + ), + ), + ], + ), ), - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TextButton.icon( - onPressed: () => room.isDirectChat - ? null - : room.canChangeStateEvent( - EventTypes.RoomName, - ) - ? controller.setDisplaynameAction() - : FluffyShare.share( - displayname, - context, - copyOnly: true, - ), - icon: Icon( - room.isDirectChat - ? Icons.chat_bubble_outline + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextButton.icon( + onPressed: () => room.isDirectChat + ? null : room.canChangeStateEvent( EventTypes.RoomName, ) - ? Icons.edit_outlined - : Icons.copy_outlined, - size: 16, - ), - style: TextButton.styleFrom( - foregroundColor: Theme.of(context) - .colorScheme - .onSurface, - ), - label: Text( - room.isDirectChat - ? L10n.of(context)!.directChat - : displayname, - maxLines: 1, - overflow: TextOverflow.ellipsis, - // style: const TextStyle(fontSize: 18), - ), - ), - TextButton.icon( - onPressed: () => room.isDirectChat - ? null - : context.push( - '/rooms/${controller.roomId}/details/members', - ), - icon: const Icon( - Icons.group_outlined, - size: 14, - ), - style: TextButton.styleFrom( - foregroundColor: Theme.of(context) - .colorScheme - .secondary, - ), - label: Text( - L10n.of(context)!.countParticipants( - actualMembersCount, + ? controller + .setDisplaynameAction() + : FluffyShare.share( + displayname, + context, + copyOnly: true, + ), + icon: Icon( + room.isDirectChat + ? Icons.chat_bubble_outline + : room.canChangeStateEvent( + EventTypes.RoomName, + ) + ? Icons.edit_outlined + : Icons.copy_outlined, + size: 16, + ), + style: TextButton.styleFrom( + foregroundColor: Theme.of(context) + .colorScheme + .onSurface, + ), + label: Text( + room.isDirectChat + ? L10n.of(context)!.directChat + : displayname, + maxLines: 1, + overflow: TextOverflow.ellipsis, + // style: const TextStyle(fontSize: 18), ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - // style: const TextStyle(fontSize: 12), ), - ), - ], + TextButton.icon( + onPressed: () => room.isDirectChat + ? null + : context.push( + '/rooms/${controller.roomId}/details/members', + ), + icon: const Icon( + Icons.group_outlined, + size: 14, + ), + style: TextButton.styleFrom( + foregroundColor: Theme.of(context) + .colorScheme + .secondary, + ), + label: Text( + L10n.of(context)!.countParticipants( + actualMembersCount, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + // style: const TextStyle(fontSize: 12), + ), + ), + ], + ), ), - ), - ], - ), - Divider( - height: 1, - color: Theme.of(context).dividerColor, - ), - // if (room.canSendEvent('m.room.name')) - if (room.isRoomAdmin) - // #Pangea - ClassNameButton( - room: room, - controller: controller, + ], ), - if (room.canSendEvent('m.room.topic')) - ClassDescriptionButton( - room: room, - controller: controller, + Divider( + height: 1, + color: Theme.of(context).dividerColor, ), - // #Pangea - RoomCapacityButton( - room: room, - controller: controller, - ), - // Pangea# - if ((room.isPangeaClass || room.isExchange) && - room.isRoomAdmin) - ListTile( - title: Text( - L10n.of(context)!.classAnalytics, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: iconColor, - child: const Icon( - Icons.analytics_outlined, - ), - ), - onTap: () => context.go( - '/rooms/analytics/${room.id}', - ), - ), - if (room.classSettings != null && room.isRoomAdmin) - ClassSettings( - roomId: controller.roomId, - startOpen: false, - ), - if (room.pangeaRoomRules != null) - RoomRulesEditor( - roomId: controller.roomId, - startOpen: false, - ), - // if (!room.canChangeStateEvent(EventTypes.RoomTopic)) - // ListTile( - // title: Text( - // L10n.of(context)!.chatDescription, - // style: TextStyle( - // color: Theme.of(context).colorScheme.secondary, - // fontWeight: FontWeight.bold, - // ), - // ), - // ) - // else - // Padding( - // padding: const EdgeInsets.all(16.0), - // child: TextButton.icon( - // onPressed: controller.setTopicAction, - // label: Text(L10n.of(context)!.setChatDescription), - // icon: const Icon(Icons.edit_outlined), - // style: TextButton.styleFrom( - // backgroundColor: Theme.of(context) - // .colorScheme - // .secondaryContainer, - // foregroundColor: Theme.of(context) - // .colorScheme - // .onSecondaryContainer, - // ), - // ), - // ), - // Padding( - // padding: const EdgeInsets.symmetric( - // horizontal: 16.0, - // ), - // child: SelectableLinkify( - // text: room.topic.isEmpty - // ? L10n.of(context)!.noChatDescriptionYet - // : room.topic, - // options: const LinkifyOptions(humanize: false), - // linkStyle: const TextStyle( - // color: Colors.blueAccent, - // decorationColor: Colors.blueAccent, - // ), - // style: TextStyle( - // fontSize: 14, - // fontStyle: room.topic.isEmpty - // ? FontStyle.italic - // : FontStyle.normal, - // color: - // Theme.of(context).textTheme.bodyMedium!.color, - // decorationColor: - // Theme.of(context).textTheme.bodyMedium!.color, - // ), - // onOpen: (url) => - // UrlLauncher(context, url.url).launchUrl(), - // ), - // ), - // const SizedBox(height: 16), - // Divider( - // height: 1, - // color: Theme.of(context).dividerColor, - // ), - // ListTile( - // leading: CircleAvatar( - // backgroundColor: - // Theme.of(context).scaffoldBackgroundColor, - // foregroundColor: iconColor, - // child: const Icon( - // Icons.insert_emoticon_outlined, - // ), - // ), - // title: - // Text(L10n.of(context)!.customEmojisAndStickers), - // subtitle: Text(L10n.of(context)!.setCustomEmotes), - // onTap: controller.goToEmoteSettings, - // trailing: const Icon(Icons.chevron_right_outlined), - // ), - // if (!room.isDirectChat) - // ListTile( - // leading: CircleAvatar( - // backgroundColor: - // Theme.of(context).scaffoldBackgroundColor, - // foregroundColor: iconColor, - // child: const Icon(Icons.shield_outlined), - // ), - // title: Text( - // L10n.of(context)!.accessAndVisibility, - // ), - // subtitle: Text( - // L10n.of(context)!.accessAndVisibilityDescription, - // ), - // onTap: () => context - // .push('/rooms/${room.id}/details/access'), - // trailing: const Icon(Icons.chevron_right_outlined), - // ), - // if (!room.isDirectChat) - if (!room.isDirectChat && - !room.isSpace && - room.isRoomAdmin) - // Pangea# - ListTile( - // #Pangea - // title: Text(L10n.of(context)!.chatPermissions), - title: Text( - L10n.of(context)!.editChatPermissions, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - // Pangea# - subtitle: Text( - L10n.of(context)!.whoCanPerformWhichAction, - ), - leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: iconColor, - child: const Icon( - Icons.edit_attributes_outlined, - ), - ), - // #Pangea - // trailing: const Icon(Icons.chevron_right_outlined), - // Pangea# - onTap: () => context - .push('/rooms/${room.id}/details/permissions'), - ), - Divider( - height: 1, - color: Theme.of(context).dividerColor, - ), - // #Pangea - if (room.canInvite && - !room.isDirectChat && - (!room.isSpace || room.isRoomAdmin)) - ListTile( - title: Text( - room.isSpace - ? L10n.of(context)!.inviteUsersFromPangea - : L10n.of(context)!.inviteStudentByUserName, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: - Theme.of(context).textTheme.bodyLarge!.color, - child: const Icon( - Icons.add, - ), - ), - onTap: () => context.go('/rooms/${room.id}/invite'), - ), - if (room.showClassEditOptions && room.isSpace) - SpaceDetailsToggleAddStudentsTile( - controller: controller, - ), - if (controller.displayAddStudentOptions && - room.showClassEditOptions) - ClassInvitationButtons(roomId: controller.roomId!), - const Divider(height: 1), - if (!room.isSpace && - !room.isDirectChat && - room.canInvite) - ConversationBotSettings( - key: controller.addConversationBotKey, - room: room, - ), - const Divider(height: 1), - if (!room.isPangeaClass && - !room.isDirectChat && - room.isRoomAdmin) - AddToSpaceToggles( - roomId: room.id, - key: controller.addToSpaceKey, - startOpen: false, - mode: room.isExchange - ? AddToClassMode.exchange - : AddToClassMode.chat, - ), - const Divider(height: 1), - if (!room.isDirectChat) + // if (room.canSendEvent('m.room.name')) if (room.isRoomAdmin) + // #Pangea + ClassNameButton( + room: room, + controller: controller, + ), + if (room.canSendEvent('m.room.topic')) + ClassDescriptionButton( + room: room, + controller: controller, + ), + // #Pangea + RoomCapacityButton( + room: room, + controller: controller, + ), + // Pangea# + if ((room.isPangeaClass || room.isExchange) && + room.isRoomAdmin) ListTile( title: Text( - room.isSpace - ? L10n.of(context)!.archiveSpace - : L10n.of(context)!.archive, + L10n.of(context)!.classAnalytics, style: TextStyle( color: Theme.of(context).colorScheme.secondary, @@ -489,199 +279,424 @@ class ChatDetailsView extends StatelessWidget { Theme.of(context).scaffoldBackgroundColor, foregroundColor: iconColor, child: const Icon( - Icons.archive_outlined, + Icons.analytics_outlined, ), ), - onTap: () async { - OkCancelResult confirmed = OkCancelResult.ok; - bool shouldGo = false; - // archiveSpace has its own popup; only show if not space - if (!room.isSpace) { - confirmed = await showOkCancelAlertDialog( - useRootNavigator: false, - context: context, - title: L10n.of(context)!.areYouSure, - okLabel: L10n.of(context)!.ok, - cancelLabel: L10n.of(context)!.cancel, - message: L10n.of(context)! - .archiveRoomDescription, - ); - } - if (confirmed == OkCancelResult.ok) { - if (room.isSpace) { - shouldGo = await room.archiveSpace( - context, - Matrix.of(context).client, - ); - } else { - final success = - await showFutureLoadingDialog( + onTap: () => context.go( + '/rooms/analytics/${room.id}', + ), + ), + if (room.classSettings != null && room.isRoomAdmin) + ClassSettings( + roomId: controller.roomId, + startOpen: false, + ), + if (room.pangeaRoomRules != null) + RoomRulesEditor( + roomId: controller.roomId, + startOpen: false, + ), + // if (!room.canChangeStateEvent(EventTypes.RoomTopic)) + // ListTile( + // title: Text( + // L10n.of(context)!.chatDescription, + // style: TextStyle( + // color: Theme.of(context).colorScheme.secondary, + // fontWeight: FontWeight.bold, + // ), + // ), + // ) + // else + // Padding( + // padding: const EdgeInsets.all(16.0), + // child: TextButton.icon( + // onPressed: controller.setTopicAction, + // label: Text(L10n.of(context)!.setChatDescription), + // icon: const Icon(Icons.edit_outlined), + // style: TextButton.styleFrom( + // backgroundColor: Theme.of(context) + // .colorScheme + // .secondaryContainer, + // foregroundColor: Theme.of(context) + // .colorScheme + // .onSecondaryContainer, + // ), + // ), + // ), + // Padding( + // padding: const EdgeInsets.symmetric( + // horizontal: 16.0, + // ), + // child: SelectableLinkify( + // text: room.topic.isEmpty + // ? L10n.of(context)!.noChatDescriptionYet + // : room.topic, + // options: const LinkifyOptions(humanize: false), + // linkStyle: const TextStyle( + // color: Colors.blueAccent, + // decorationColor: Colors.blueAccent, + // ), + // style: TextStyle( + // fontSize: 14, + // fontStyle: room.topic.isEmpty + // ? FontStyle.italic + // : FontStyle.normal, + // color: + // Theme.of(context).textTheme.bodyMedium!.color, + // decorationColor: + // Theme.of(context).textTheme.bodyMedium!.color, + // ), + // onOpen: (url) => + // UrlLauncher(context, url.url).launchUrl(), + // ), + // ), + // const SizedBox(height: 16), + // Divider( + // height: 1, + // color: Theme.of(context).dividerColor, + // ), + // ListTile( + // leading: CircleAvatar( + // backgroundColor: + // Theme.of(context).scaffoldBackgroundColor, + // foregroundColor: iconColor, + // child: const Icon( + // Icons.insert_emoticon_outlined, + // ), + // ), + // title: + // Text(L10n.of(context)!.customEmojisAndStickers), + // subtitle: Text(L10n.of(context)!.setCustomEmotes), + // onTap: controller.goToEmoteSettings, + // trailing: const Icon(Icons.chevron_right_outlined), + // ), + // if (!room.isDirectChat) + // ListTile( + // leading: CircleAvatar( + // backgroundColor: + // Theme.of(context).scaffoldBackgroundColor, + // foregroundColor: iconColor, + // child: const Icon(Icons.shield_outlined), + // ), + // title: Text( + // L10n.of(context)!.accessAndVisibility, + // ), + // subtitle: Text( + // L10n.of(context)!.accessAndVisibilityDescription, + // ), + // onTap: () => context + // .push('/rooms/${room.id}/details/access'), + // trailing: const Icon(Icons.chevron_right_outlined), + // ), + // if (!room.isDirectChat) + if (!room.isDirectChat && + !room.isSpace && + room.isRoomAdmin) + // Pangea# + ListTile( + // #Pangea + // title: Text(L10n.of(context)!.chatPermissions), + title: Text( + L10n.of(context)!.editChatPermissions, + style: TextStyle( + color: + Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + // Pangea# + subtitle: Text( + L10n.of(context)!.whoCanPerformWhichAction, + ), + leading: CircleAvatar( + backgroundColor: + Theme.of(context).scaffoldBackgroundColor, + foregroundColor: iconColor, + child: const Icon( + Icons.edit_attributes_outlined, + ), + ), + // #Pangea + // trailing: const Icon(Icons.chevron_right_outlined), + // Pangea# + onTap: () => context.push( + '/rooms/${room.id}/details/permissions'), + ), + Divider( + height: 1, + color: Theme.of(context).dividerColor, + ), + // #Pangea + if (room.canInvite && + !room.isDirectChat && + (!room.isSpace || room.isRoomAdmin)) + ListTile( + title: Text( + room.isSpace + ? L10n.of(context)!.inviteUsersFromPangea + : L10n.of(context)!.inviteStudentByUserName, + style: TextStyle( + color: + Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + leading: CircleAvatar( + backgroundColor: + Theme.of(context).scaffoldBackgroundColor, + foregroundColor: Theme.of(context) + .textTheme + .bodyLarge! + .color, + child: const Icon( + Icons.add, + ), + ), + onTap: () => + context.go('/rooms/${room.id}/invite'), + ), + if (room.showClassEditOptions && room.isSpace) + SpaceDetailsToggleAddStudentsTile( + controller: controller, + ), + if (controller.displayAddStudentOptions && + room.showClassEditOptions) + ClassInvitationButtons(roomId: controller.roomId!), + const Divider(height: 1), + if (!room.isSpace && + !room.isDirectChat && + room.canInvite) + ConversationBotSettings( + key: controller.addConversationBotKey, + room: room, + ), + const Divider(height: 1), + if (!room.isPangeaClass && + !room.isDirectChat && + room.isRoomAdmin) + AddToSpaceToggles( + roomId: room.id, + key: controller.addToSpaceKey, + startOpen: false, + mode: room.isExchange + ? AddToClassMode.exchange + : AddToClassMode.chat, + ), + const Divider(height: 1), + if (!room.isDirectChat) + if (room.isRoomAdmin) + ListTile( + title: Text( + room.isSpace + ? L10n.of(context)!.archiveSpace + : L10n.of(context)!.archive, + style: TextStyle( + color: + Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + leading: CircleAvatar( + backgroundColor: + Theme.of(context).scaffoldBackgroundColor, + foregroundColor: iconColor, + child: const Icon( + Icons.archive_outlined, + ), + ), + onTap: () async { + OkCancelResult confirmed = OkCancelResult.ok; + bool shouldGo = false; + // archiveSpace has its own popup; only show if not space + if (!room.isSpace) { + confirmed = await showOkCancelAlertDialog( + useRootNavigator: false, context: context, - future: () async { - await room.archive(); - }, + title: L10n.of(context)!.areYouSure, + okLabel: L10n.of(context)!.ok, + cancelLabel: L10n.of(context)!.cancel, + message: L10n.of(context)! + .archiveRoomDescription, ); - shouldGo = (success.error == null); } - if (shouldGo) { - context.go('/rooms'); - } - } - }, - ), - ListTile( - title: Text( - L10n.of(context)!.leave, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: iconColor, - child: const Icon( - Icons.arrow_forward, - ), - ), - onTap: () async { - OkCancelResult confirmed = OkCancelResult.ok; - bool shouldGo = false; - // If user is only admin, room will be archived - final bool onlyAdmin = await room.isOnlyAdmin(); - // archiveSpace has its own popup; only show if not space - if (!room.isSpace) { - confirmed = await showOkCancelAlertDialog( - useRootNavigator: false, - context: context, - title: L10n.of(context)!.areYouSure, - okLabel: L10n.of(context)!.ok, - cancelLabel: L10n.of(context)!.cancel, - message: onlyAdmin - ? L10n.of(context)!.onlyAdminDescription - : L10n.of(context)!.leaveRoomDescription, - ); - } - if (confirmed == OkCancelResult.ok) { - if (room.isSpace) { - shouldGo = onlyAdmin - ? await room.archiveSpace( - context, - Matrix.of(context).client, - onlyAdmin: true, - ) - : await room.leaveSpace( + if (confirmed == OkCancelResult.ok) { + if (room.isSpace) { + shouldGo = await room.archiveSpace( context, Matrix.of(context).client, ); - } else { - final success = await showFutureLoadingDialog( - context: context, - future: () async { - onlyAdmin - ? await room.archive() - : await room.leave(); - }, - ); - shouldGo = (success.error == null); - } - if (shouldGo) { - context.go('/rooms'); - } - } - }, - ), - if (room.isRoomAdmin && !room.isDirectChat) - SwitchListTile.adaptive( - activeColor: AppConfig.activeToggleColor, + } else { + final success = + await showFutureLoadingDialog( + context: context, + future: () async { + await room.archive(); + }, + ); + shouldGo = (success.error == null); + } + if (shouldGo) { + context.go('/rooms'); + } + } + }, + ), + ListTile( title: Text( - room.isSpace - ? L10n.of(context)!.lockSpace - : L10n.of(context)!.lockChat, + L10n.of(context)!.leave, style: TextStyle( color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), - secondary: CircleAvatar( + leading: CircleAvatar( backgroundColor: Theme.of(context).scaffoldBackgroundColor, foregroundColor: iconColor, - child: Icon( - room.isLocked - ? Icons.lock_outlined - : Icons.no_encryption_outlined, + child: const Icon( + Icons.arrow_forward, ), ), - value: room.isLocked, - onChanged: (value) => showFutureLoadingDialog( - context: context, - future: () => value - ? lockRoom( - room, - Matrix.of(context).client, - ) - : unlockRoom( - room, - Matrix.of(context).client, - ), + onTap: () async { + OkCancelResult confirmed = OkCancelResult.ok; + bool shouldGo = false; + // If user is only admin, room will be archived + final bool onlyAdmin = await room.isOnlyAdmin(); + // archiveSpace has its own popup; only show if not space + if (!room.isSpace) { + confirmed = await showOkCancelAlertDialog( + useRootNavigator: false, + context: context, + title: L10n.of(context)!.areYouSure, + okLabel: L10n.of(context)!.ok, + cancelLabel: L10n.of(context)!.cancel, + message: onlyAdmin + ? L10n.of(context)!.onlyAdminDescription + : L10n.of(context)!.leaveRoomDescription, + ); + } + if (confirmed == OkCancelResult.ok) { + if (room.isSpace) { + shouldGo = onlyAdmin + ? await room.archiveSpace( + context, + Matrix.of(context).client, + onlyAdmin: true, + ) + : await room.leaveSpace( + context, + Matrix.of(context).client, + ); + } else { + final success = await showFutureLoadingDialog( + context: context, + future: () async { + onlyAdmin + ? await room.archive() + : await room.leave(); + }, + ); + shouldGo = (success.error == null); + } + if (shouldGo) { + context.go('/rooms'); + } + } + }, + ), + if (room.isRoomAdmin && !room.isDirectChat) + SwitchListTile.adaptive( + activeColor: AppConfig.activeToggleColor, + title: Text( + room.isSpace + ? L10n.of(context)!.lockSpace + : L10n.of(context)!.lockChat, + style: TextStyle( + color: + Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + secondary: CircleAvatar( + backgroundColor: + Theme.of(context).scaffoldBackgroundColor, + foregroundColor: iconColor, + child: Icon( + room.isLocked + ? Icons.lock_outlined + : Icons.no_encryption_outlined, + ), + ), + value: room.isLocked, + onChanged: (value) => showFutureLoadingDialog( + context: context, + future: () => value + ? lockRoom( + room, + Matrix.of(context).client, + ) + : unlockRoom( + room, + Matrix.of(context).client, + ), + ), + ), + const Divider(height: 1), + // Pangea# + ListTile( + title: Text( + L10n.of(context)!.countParticipants( + actualMembersCount.toString(), + ), + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), ), ), - const Divider(height: 1), - // Pangea# - ListTile( - title: Text( - L10n.of(context)!.countParticipants( - actualMembersCount.toString(), + // #Pangea + // if (!room.isDirectChat && room.canInvite) + // ListTile( + // title: Text(L10n.of(context)!.inviteContact), + // leading: CircleAvatar( + // backgroundColor: Theme.of(context) + // .colorScheme + // .primaryContainer, + // foregroundColor: Theme.of(context) + // .colorScheme + // .onPrimaryContainer, + // radius: Avatar.defaultSize / 2, + // child: const Icon(Icons.add_outlined), + // ), + // trailing: const Icon(Icons.chevron_right_outlined), + // onTap: () => context.go('/rooms/${room.id}/invite'), + // ), + // Pangea# + ], + ) + : i < members.length + 1 + ? ParticipantListItem(members[i - 1]) + : ListTile( + title: Text( + L10n.of(context)!.loadCountMoreParticipants( + (actualMembersCount - members.length) + .toString(), + ), ), - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, + leading: CircleAvatar( + backgroundColor: + Theme.of(context).scaffoldBackgroundColor, + child: const Icon( + Icons.group_outlined, + color: Colors.grey, + ), ), - ), - ), - // #Pangea - // if (!room.isDirectChat && room.canInvite) - // ListTile( - // title: Text(L10n.of(context)!.inviteContact), - // leading: CircleAvatar( - // backgroundColor: Theme.of(context) - // .colorScheme - // .primaryContainer, - // foregroundColor: Theme.of(context) - // .colorScheme - // .onPrimaryContainer, - // radius: Avatar.defaultSize / 2, - // child: const Icon(Icons.add_outlined), - // ), - // trailing: const Icon(Icons.chevron_right_outlined), - // onTap: () => context.go('/rooms/${room.id}/invite'), - // ), - // Pangea# - ], - ) - : i < members.length + 1 - ? ParticipantListItem(members[i - 1]) - : ListTile( - title: Text( - L10n.of(context)!.loadCountMoreParticipants( - (actualMembersCount - members.length).toString(), + onTap: () => context.push( + '/rooms/${controller.roomId!}/details/members', ), + trailing: const Icon(Icons.chevron_right_outlined), ), - leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - child: const Icon( - Icons.group_outlined, - color: Colors.grey, - ), - ), - onTap: () => context.push( - '/rooms/${controller.roomId!}/details/members', - ), - trailing: const Icon(Icons.chevron_right_outlined), - ), + ), ), ), ); diff --git a/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart b/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart index 4f231d1d0..24c934953 100644 --- a/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart +++ b/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart @@ -30,17 +30,19 @@ class ClassDescriptionButton extends StatelessWidget { constraints: const BoxConstraints( maxHeight: 190, ), - child: SingleChildScrollView( - // child: NestedScrollView( ??? - controller: ScrollController(), - child: Text( - room.topic.isEmpty - ? (room.isRoomAdmin - ? (room.isSpace - ? L10n.of(context)!.classDescriptionDesc - : L10n.of(context)!.chatTopicDesc) - : L10n.of(context)!.topicNotSet) - : room.topic, + child: Scrollbar( + child: SingleChildScrollView( + primary: false, + controller: ScrollController(), + child: Text( + room.topic.isEmpty + ? (room.isRoomAdmin + ? (room.isSpace + ? L10n.of(context)!.classDescriptionDesc + : L10n.of(context)!.chatTopicDesc) + : L10n.of(context)!.topicNotSet) + : room.topic, + ), ), ), ), From aab10ff613bd8afbcb93a09d060ab5b3e642e154 Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Tue, 25 Jun 2024 11:52:36 -0400 Subject: [PATCH 14/30] add custom mode and propagate user inputs to state events --- lib/pangea/constants/model_keys.dart | 1 - lib/pangea/models/bot_options_model.dart | 31 +++++++++---------- .../conversation_bot_custom_zone.dart | 5 +-- .../conversation_bot_discussion_zone.dart | 4 +-- .../conversation_bot_settings.dart | 4 ++- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/lib/pangea/constants/model_keys.dart b/lib/pangea/constants/model_keys.dart index dca53288d..502435479 100644 --- a/lib/pangea/constants/model_keys.dart +++ b/lib/pangea/constants/model_keys.dart @@ -99,7 +99,6 @@ class ModelKey { static const String languageLevel = "difficulty"; static const String safetyModeration = "safety_moderation"; static const String mode = "mode"; - static const String custom = "custom"; static const String discussionTopic = "discussion_topic"; static const String discussionKeywords = "discussion_keywords"; static const String discussionTriggerReactionEnabled = diff --git a/lib/pangea/models/bot_options_model.dart b/lib/pangea/models/bot_options_model.dart index 0e1019e62..179461a34 100644 --- a/lib/pangea/models/bot_options_model.dart +++ b/lib/pangea/models/bot_options_model.dart @@ -13,14 +13,13 @@ class BotOptionsModel { List keywords; bool safetyModeration; String mode; - String? custom; String? discussionTopic; String? discussionKeywords; - bool discussionTriggerReactionEnabled; - String discussionTriggerReactionKey; + bool? discussionTriggerReactionEnabled; + String? discussionTriggerReactionKey; String? customSystemPrompt; - bool customTriggerReactionEnabled; - String customTriggerReactionKey; + bool? customTriggerReactionEnabled; + String? customTriggerReactionKey; BotOptionsModel({ //////////////////////////////////////////////////////////////////////////// @@ -63,15 +62,17 @@ class BotOptionsModel { discussionTopic: json[ModelKey.discussionTopic], discussionKeywords: json[ModelKey.discussionKeywords], discussionTriggerReactionEnabled: - json[ModelKey.discussionTriggerReactionEnabled], - discussionTriggerReactionKey: json[ModelKey.discussionTriggerReactionKey], + json[ModelKey.discussionTriggerReactionEnabled] ?? true, + discussionTriggerReactionKey: + json[ModelKey.discussionTriggerReactionKey] ?? "⏩", ////////////////////////////////////////////////////////////////////////// // Custom Mode Options ////////////////////////////////////////////////////////////////////////// customSystemPrompt: json[ModelKey.customSystemPrompt], - customTriggerReactionEnabled: json[ModelKey.customTriggerReactionEnabled], - customTriggerReactionKey: json[ModelKey.customTriggerReactionKey], + customTriggerReactionEnabled: + json[ModelKey.customTriggerReactionEnabled] ?? true, + customTriggerReactionKey: json[ModelKey.customTriggerReactionKey] ?? "⏩", ); } @@ -82,17 +83,16 @@ class BotOptionsModel { data[ModelKey.languageLevel] = languageLevel; data[ModelKey.safetyModeration] = safetyModeration; data[ModelKey.mode] = mode; - data[ModelKey.custom] = custom; data[ModelKey.discussionTopic] = discussionTopic; data[ModelKey.discussionKeywords] = discussionKeywords; data[ModelKey.discussionTriggerReactionEnabled] = - discussionTriggerReactionEnabled; + discussionTriggerReactionEnabled ?? true; data[ModelKey.discussionTriggerReactionKey] = - discussionTriggerReactionKey; + discussionTriggerReactionKey ?? "⏩"; data[ModelKey.customSystemPrompt] = customSystemPrompt; data[ModelKey.customTriggerReactionEnabled] = - customTriggerReactionEnabled; - data[ModelKey.customTriggerReactionKey] = customTriggerReactionKey; + customTriggerReactionEnabled ?? true; + data[ModelKey.customTriggerReactionKey] = customTriggerReactionKey ?? "⏩"; return data; } catch (e, s) { debugger(when: kDebugMode); @@ -113,9 +113,6 @@ class BotOptionsModel { case ModelKey.mode: mode = value; break; - case ModelKey.custom: - custom = value; - break; case ModelKey.discussionTopic: discussionTopic = value; break; diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart index 46f87237c..553de7182 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart @@ -16,6 +16,7 @@ class ConversationBotCustomZone extends StatelessWidget { @override Widget build(BuildContext context) { + print(initialBotOptions.toJson()); return Column( children: [ const SizedBox(height: 12), @@ -59,9 +60,9 @@ class ConversationBotCustomZone extends StatelessWidget { .conversationBotCustomZone_customTriggerReactionEnabledLabel, ), enabled: false, - value: initialBotOptions.customTriggerReactionEnabled, + value: initialBotOptions.customTriggerReactionEnabled ?? true, onChanged: (value) { - initialBotOptions.customTriggerReactionEnabled = value ?? false; + initialBotOptions.customTriggerReactionEnabled = value ?? true; initialBotOptions.customTriggerReactionKey = "⏩"; // hard code this for now onChanged.call(initialBotOptions); diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart index ed642a391..2bb4d7a76 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart @@ -82,9 +82,9 @@ class ConversationBotDiscussionZone extends StatelessWidget { .conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel, ), enabled: false, - value: initialBotOptions.discussionTriggerReactionEnabled ?? false, + value: initialBotOptions.discussionTriggerReactionEnabled ?? true, onChanged: (value) { - initialBotOptions.discussionTriggerReactionEnabled = value ?? false; + initialBotOptions.discussionTriggerReactionEnabled = value ?? true; initialBotOptions.discussionTriggerReactionKey = "⏩"; // hard code this for now onChanged.call(initialBotOptions); diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart index 6b57ca3a4..226b728d7 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart @@ -47,7 +47,9 @@ class ConversationBotSettingsState extends State { void initState() { super.initState(); isOpen = widget.startOpen; - botOptions = widget.room?.botOptions ?? BotOptionsModel(); + botOptions = widget.room?.botOptions != null + ? BotOptionsModel.fromJson(widget.room?.botOptions?.toJson()) + : BotOptionsModel(); widget.room?.isBotRoom.then((bool isBotRoom) { setState(() { addBot = isBotRoom; From 6ecccbbc3e11fcc693fa16573b1dc5965a803b9a Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Tue, 25 Jun 2024 15:02:23 -0400 Subject: [PATCH 15/30] remove excess int files --- assets/l10n/intl_fil 2.arb | 870 ------------------------------------- assets/l10n/intl_ka 2.arb | 744 ------------------------------- needed-translations.txt | 3 - 3 files changed, 1617 deletions(-) delete mode 100644 assets/l10n/intl_fil 2.arb delete mode 100644 assets/l10n/intl_ka 2.arb diff --git a/assets/l10n/intl_fil 2.arb b/assets/l10n/intl_fil 2.arb deleted file mode 100644 index 07ef65218..000000000 --- a/assets/l10n/intl_fil 2.arb +++ /dev/null @@ -1,870 +0,0 @@ -{ - "remove": "Tanggalin", - "@remove": { - "type": "text", - "placeholders": {} - }, - "importNow": "I-import ngayon", - "@importNow": {}, - "importEmojis": "I-import ang mga Emoji", - "@importEmojis": {}, - "importFromZipFile": "Mag-import mula sa .zip file", - "@importFromZipFile": {}, - "exportEmotePack": "I-export ang Emote pack bilang .zip", - "@exportEmotePack": {}, - "accept": "Tanggapin", - "@accept": { - "type": "text", - "placeholders": {} - }, - "account": "Account", - "@account": { - "type": "text", - "placeholders": {} - }, - "addEmail": "Magdagdag ng email", - "@addEmail": { - "type": "text", - "placeholders": {} - }, - "confirmMatrixId": "Paki-kumpirma ang iyong Matrix ID para burahin ang iyong account.", - "@confirmMatrixId": {}, - "addChatDescription": "Magdagdag ng deskripsyon ng chat...", - "@addChatDescription": {}, - "admin": "Admin", - "@admin": { - "type": "text", - "placeholders": {} - }, - "alias": "alyas", - "@alias": { - "type": "text", - "placeholders": {} - }, - "all": "Lahat", - "@all": { - "type": "text", - "placeholders": {} - }, - "allChats": "Lahat ng mga chat", - "@allChats": { - "type": "text", - "placeholders": {} - }, - "commandHint_googly": "Magpadala ng mga googly eye", - "@commandHint_googly": {}, - "commandHint_cuddle": "Magpadala ng yakap", - "@commandHint_cuddle": {}, - "cuddleContent": "Niyakap ka ni {senderName}", - "@cuddleContent": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "hugContent": "Niyakap ka ni {senderName}", - "@hugContent": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "anyoneCanJoin": "Pwede sumali ang anumang tao", - "@anyoneCanJoin": { - "type": "text", - "placeholders": {} - }, - "appLock": "Lock ng app", - "@appLock": { - "type": "text", - "placeholders": {} - }, - "archive": "Archive", - "@archive": { - "type": "text", - "placeholders": {} - }, - "areGuestsAllowedToJoin": "Pwede ba sumali ang mga bisita", - "@areGuestsAllowedToJoin": { - "type": "text", - "placeholders": {} - }, - "areYouSure": "Sigurado ka?", - "@areYouSure": { - "type": "text", - "placeholders": {} - }, - "askVerificationRequest": "Tanggapin ang hiling ng verification mula sa {username}?", - "@askVerificationRequest": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "autoplayImages": "Awtomatikong i-play ang mga gumagalaw na sticker at emote", - "@autoplayImages": { - "type": "text", - "placeholder": {} - }, - "sendTypingNotifications": "Ipadala ang mga typing notification", - "@sendTypingNotifications": {}, - "blockDevice": "I-block ang Device", - "@blockDevice": { - "type": "text", - "placeholders": {} - }, - "blocked": "Na-block", - "@blocked": { - "type": "text", - "placeholders": {} - }, - "changeDeviceName": "Palitan ang pangalan ng device", - "@changeDeviceName": { - "type": "text", - "placeholders": {} - }, - "changedTheChatAvatar": "Pinalitan ni {username} ang avatar ng chat", - "@changedTheChatAvatar": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheGuestAccessRules": "Pinalitan ni {username} ang mga tuntunin sa pag-access ng bisita", - "@changedTheGuestAccessRules": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheHistoryVisibility": "Pinalitan ni {username} ang kakayahan ng pagkikita ng history", - "@changedTheHistoryVisibility": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheHistoryVisibilityTo": "Pinalitan ni {username} ang kakayahan ng pagkikita ng history sa: {rules}", - "@changedTheHistoryVisibilityTo": { - "type": "text", - "placeholders": { - "username": {}, - "rules": {} - } - }, - "changedTheRoomAliases": "Pinalitan ni {username} ang mga alias ng room", - "@changedTheRoomAliases": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changePassword": "Palitan ang password", - "@changePassword": { - "type": "text", - "placeholders": {} - }, - "changeYourAvatar": "Palitan ang iyong avatar", - "@changeYourAvatar": { - "type": "text", - "placeholders": {} - }, - "channelCorruptedDecryptError": "Nasira ang encryption", - "@channelCorruptedDecryptError": { - "type": "text", - "placeholders": {} - }, - "chat": "Chat", - "@chat": { - "type": "text", - "placeholders": {} - }, - "chatBackup": "Pag-backup ng chat", - "@chatBackup": { - "type": "text", - "placeholders": {} - }, - "chatDetails": "Mga detalye ng chat", - "@chatDetails": { - "type": "text", - "placeholders": {} - }, - "chatHasBeenAddedToThisSpace": "Nadagdag ang chat sa space na ito", - "@chatHasBeenAddedToThisSpace": {}, - "chats": "Mga Chat", - "@chats": { - "type": "text", - "placeholders": {} - }, - "chooseAStrongPassword": "Pumili ng malakas na password", - "@chooseAStrongPassword": { - "type": "text", - "placeholders": {} - }, - "clearArchive": "I-clear ang archive", - "@clearArchive": {}, - "close": "Isara", - "@close": { - "type": "text", - "placeholders": {} - }, - "commandHint_markasgroup": "Markahan bilang grupo", - "@commandHint_markasgroup": {}, - "commandHint_ban": "Pagbawalan ang ibinigay na user sa room na ito", - "@commandHint_ban": { - "type": "text", - "description": "Usage hint for the command /ban" - }, - "repeatPassword": "Ulitin ang password", - "@repeatPassword": {}, - "notAnImage": "Hindi isang file na larawan.", - "@notAnImage": {}, - "replace": "Palitan", - "@replace": {}, - "about": "Tungkol sa", - "@about": { - "type": "text", - "placeholders": {} - }, - "acceptedTheInvitation": "👍 Tinanggap ni {username} ang imbitasyon", - "@acceptedTheInvitation": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "activatedEndToEndEncryption": "🔐 Na-activate ni {username} ang end to end encryption", - "@activatedEndToEndEncryption": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "supposedMxid": "Dapat ito ay {mxid}", - "@supposedMxid": { - "type": "text", - "placeholders": { - "mxid": {} - } - }, - "addToSpace": "Idagdag sa space", - "@addToSpace": {}, - "commandHint_hug": "Magpadala ng yakap", - "@commandHint_hug": {}, - "googlyEyesContent": "Nagpadala si {senderName} ng googly eyes", - "@googlyEyesContent": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "answeredTheCall": "Sinagot ni {senderName} ang tawag", - "@answeredTheCall": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "areYouSureYouWantToLogout": "Sigurado kang gusto mong mag-log out?", - "@areYouSureYouWantToLogout": { - "type": "text", - "placeholders": {} - }, - "askSSSSSign": "Para i-sign ang isa pang tao, pakilagay ang iyong secure store passphrase o recovery key.", - "@askSSSSSign": { - "type": "text", - "placeholders": {} - }, - "badServerLoginTypesException": "Ang homeserver ay sinusuportahan ang sumusunod na uri ng login:\n{serverVersions}\nNgunit sinusuportahan lang ng app ang:\n{supportedVersions}", - "@badServerLoginTypesException": { - "type": "text", - "placeholders": { - "serverVersions": {}, - "supportedVersions": {} - } - }, - "sendOnEnter": "Ipadala sa pagpindot ng enter", - "@sendOnEnter": {}, - "badServerVersionsException": "Ang homeserver ay sinusuportahan ang mga Spec bersyon:\n{serverVersions}\nNgunit sinusuportahan lang ng app ang {supportedVersions}", - "@badServerVersionsException": { - "type": "text", - "placeholders": { - "serverVersions": {}, - "supportedVersions": {} - } - }, - "banFromChat": "Pagbawalan sa chat", - "@banFromChat": { - "type": "text", - "placeholders": {} - }, - "banned": "Pinagbawalan", - "@banned": { - "type": "text", - "placeholders": {} - }, - "botMessages": "Mga mensahe ng bot", - "@botMessages": { - "type": "text", - "placeholders": {} - }, - "cancel": "Kanselahin", - "@cancel": { - "type": "text", - "placeholders": {} - }, - "bannedUser": "Pinagbawalan ni {username} si {targetName}", - "@bannedUser": { - "type": "text", - "placeholders": { - "username": {}, - "targetName": {} - } - }, - "cantOpenUri": "Hindi mabuksan ang URI na {uri}", - "@cantOpenUri": { - "type": "text", - "placeholders": { - "uri": {} - } - }, - "changedTheJoinRules": "Pinalitan ni {username} ang mga tuntunin sa pagsali", - "@changedTheJoinRules": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheJoinRulesTo": "Pinalitan ni {username} ang mga tuntunin sa pagsali sa: {joinRules}", - "@changedTheJoinRulesTo": { - "type": "text", - "placeholders": { - "username": {}, - "joinRules": {} - } - }, - "changedTheChatDescriptionTo": "Pinalitan ni {username} ang deskripsyon ng chat sa: '{description}'", - "@changedTheChatDescriptionTo": { - "type": "text", - "placeholders": { - "username": {}, - "description": {} - } - }, - "changedTheProfileAvatar": "Pinalitan ni {username} ang kanilang avatar", - "@changedTheProfileAvatar": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheChatNameTo": "Pinalitan ni {username} ang pangalan ng chat sa: '{chatname}'", - "@changedTheChatNameTo": { - "type": "text", - "placeholders": { - "username": {}, - "chatname": {} - } - }, - "changedTheRoomInvitationLink": "Pinalitan ni {username} ang link ng imbitasyon", - "@changedTheRoomInvitationLink": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changeTheHomeserver": "Palitan ang homeserver", - "@changeTheHomeserver": { - "type": "text", - "placeholders": {} - }, - "changeTheme": "Palitan ang iyong istilio", - "@changeTheme": { - "type": "text", - "placeholders": {} - }, - "changedTheChatPermissions": "Pinalitan ni {username} ang mga pahintulot ng chat", - "@changedTheChatPermissions": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changeTheNameOfTheGroup": "Palitan ng pangalan ng grupo", - "@changeTheNameOfTheGroup": { - "type": "text", - "placeholders": {} - }, - "changedTheDisplaynameTo": "Pinalitan ni {username} ang kanilang displayname sa: '{displayname}'", - "@changedTheDisplaynameTo": { - "type": "text", - "placeholders": { - "username": {}, - "displayname": {} - } - }, - "yourChatBackupHasBeenSetUp": "Na-set up na ang iyong chat backup.", - "@yourChatBackupHasBeenSetUp": {}, - "chatBackupDescription": "Naka-secure ang iyong mga lumang mensahe gamit ng recovery key. Siguraduhing hindi mo ito mawalan.", - "@chatBackupDescription": { - "type": "text", - "placeholders": {} - }, - "commandHint_markasdm": "Markahan bilang direktang mensahe na room para sa ibinigay na Matrix ID", - "@commandHint_markasdm": {}, - "changedTheGuestAccessRulesTo": "Pinalitan ni {username} ang mga tuntunin sa pag-access ng bisita sa: {rules}", - "@changedTheGuestAccessRulesTo": { - "type": "text", - "placeholders": { - "username": {}, - "rules": {} - } - }, - "commandHint_clearcache": "I-clear ang cache", - "@commandHint_clearcache": { - "type": "text", - "description": "Usage hint for the command /clearcache" - }, - "commandHint_discardsession": "Iwaksi ang sesyon", - "@commandHint_discardsession": { - "type": "text", - "description": "Usage hint for the command /discardsession" - }, - "commandHint_create": "Gumawa ng walang lamang group chat\nGumamit ng --no-encryption para i-disable ang encryption", - "@commandHint_create": { - "type": "text", - "description": "Usage hint for the command /create" - }, - "configureChat": "I-configure ang chat", - "@configureChat": { - "type": "text", - "placeholders": {} - }, - "confirm": "Kumpirmahin", - "@confirm": { - "type": "text", - "placeholders": {} - }, - "compareNumbersMatch": "Paki-kumpara ang mga numero", - "@compareNumbersMatch": { - "type": "text", - "placeholders": {} - }, - "copiedToClipboard": "Kinopya sa clipboard", - "@copiedToClipboard": { - "type": "text", - "placeholders": {} - }, - "copy": "Kopyahin", - "@copy": { - "type": "text", - "placeholders": {} - }, - "copyToClipboard": "Kopyahin sa clipboard", - "@copyToClipboard": { - "type": "text", - "placeholders": {} - }, - "countParticipants": "{count} mga kasali", - "@countParticipants": { - "type": "text", - "placeholders": { - "count": {} - } - }, - "createdTheChat": "💬 Ginawa ni {username} ang chat", - "@createdTheChat": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "createGroup": "Gumawa ng grupo", - "@createGroup": {}, - "createNewSpace": "Bagong space", - "@createNewSpace": { - "type": "text", - "placeholders": {} - }, - "currentlyActive": "Kasalukuyang aktibo", - "@currentlyActive": { - "type": "text", - "placeholders": {} - }, - "darkTheme": "Madilim", - "@darkTheme": { - "type": "text", - "placeholders": {} - }, - "displaynameHasBeenChanged": "Pinalitan na ang display name", - "@displaynameHasBeenChanged": { - "type": "text", - "placeholders": {} - }, - "directChats": "Mga Direktang Chat", - "@directChats": { - "type": "text", - "placeholders": {} - }, - "allRooms": "Lahat ng Mga Group Chat", - "@allRooms": { - "type": "text", - "placeholders": {} - }, - "downloadFile": "I-download ang file", - "@downloadFile": { - "type": "text", - "placeholders": {} - }, - "editBlockedServers": "I-edit ang mga naka-block na server", - "@editBlockedServers": { - "type": "text", - "placeholders": {} - }, - "chatPermissions": "Mga pahintulot ng chat", - "@chatPermissions": {}, - "editDisplayname": "I-edit ang display name", - "@editDisplayname": { - "type": "text", - "placeholders": {} - }, - "editRoomAliases": "I-edit ang mga alyas ng room", - "@editRoomAliases": { - "type": "text", - "placeholders": {} - }, - "edit": "I-edit", - "@edit": { - "type": "text", - "placeholders": {} - }, - "editRoomAvatar": "I-edit ang avatar ng room", - "@editRoomAvatar": { - "type": "text", - "placeholders": {} - }, - "emoteExists": "Umiiral na ang emote!", - "@emoteExists": { - "type": "text", - "placeholders": {} - }, - "emptyChat": "Walang lamang chat", - "@emptyChat": { - "type": "text", - "placeholders": {} - }, - "enableEncryption": "I-enable ang encryption", - "@enableEncryption": { - "type": "text", - "placeholders": {} - }, - "encryption": "Pag-encrypt", - "@encryption": { - "type": "text", - "placeholders": {} - }, - "encrypted": "Naka-encrypt", - "@encrypted": { - "type": "text", - "placeholders": {} - }, - "encryptionNotEnabled": "Hindi naka-enable ang encryption", - "@encryptionNotEnabled": { - "type": "text", - "placeholders": {} - }, - "everythingReady": "Handa na ang lahat!", - "@everythingReady": { - "type": "text", - "placeholders": {} - }, - "appLockDescription": "I-lock ang app kapag hindi ginagamit sa pamamagitan ng pin code", - "@appLockDescription": {}, - "commandHint_dm": "Magsimula ng direktong chat\nGumamit ng --no-encryptiom para i-disable ang encryption", - "@commandHint_dm": { - "type": "text", - "description": "Usage hint for the command /dm" - }, - "commandHint_html": "Magpadala ng HTML-formatted na text", - "@commandHint_html": { - "type": "text", - "description": "Usage hint for the command /html" - }, - "commandHint_invite": "Imbitahan ang ibinigay na user sa room na ito", - "@commandHint_invite": { - "type": "text", - "description": "Usage hint for the command /invite" - }, - "commandHint_join": "Sumali sa ibinigay na room", - "@commandHint_join": { - "type": "text", - "description": "Usage hint for the command /join" - }, - "commandHint_kick": "Tanggalin ang ibinigay na user sa room na ito", - "@commandHint_kick": { - "type": "text", - "description": "Usage hint for the command /kick" - }, - "commandHint_leave": "Umalis sa room na ito", - "@commandHint_leave": { - "type": "text", - "description": "Usage hint for the command /leave" - }, - "commandHint_me": "Ilarawan ang iyong sarili", - "@commandHint_me": { - "type": "text", - "description": "Usage hint for the command /me" - }, - "commandHint_myroomavatar": "Ilapat ang iyong larawan para sa room na ito (bilang mxc-uri)", - "@commandHint_myroomavatar": { - "type": "text", - "description": "Usage hint for the command /myroomavatar" - }, - "commandHint_myroomnick": "Ilapat ang iyong display name para sa room na ito", - "@commandHint_myroomnick": { - "type": "text", - "description": "Usage hint for the command /myroomnick" - }, - "commandHint_op": "Ilapat ang level ng lakas sa ibinigay na user (default: 50)", - "@commandHint_op": { - "type": "text", - "description": "Usage hint for the command /op" - }, - "commandHint_react": "Magpadala ng reply bilang reaksyon", - "@commandHint_react": { - "type": "text", - "description": "Usage hint for the command /react" - }, - "commandHint_send": "Magpadala ng text", - "@commandHint_send": { - "type": "text", - "description": "Usage hint for the command /send" - }, - "commandHint_unban": "I-unban ang ibinigay na user sa room na ito", - "@commandHint_unban": { - "type": "text", - "description": "Usage hint for the command /unban" - }, - "commandInvalid": "Hindi wastong command", - "@commandInvalid": { - "type": "text" - }, - "compareEmojiMatch": "Paki-kumpara ang mga emoji", - "@compareEmojiMatch": { - "type": "text", - "placeholders": {} - }, - "connect": "Kumonekta", - "@connect": { - "type": "text", - "placeholders": {} - }, - "containsDisplayName": "Naglalaman ng display name", - "@containsDisplayName": { - "type": "text", - "placeholders": {} - }, - "create": "Gumawa", - "@create": { - "type": "text", - "placeholders": {} - }, - "dateAndTimeOfDay": "{date}, {timeOfDay}", - "@dateAndTimeOfDay": { - "type": "text", - "placeholders": { - "date": {}, - "timeOfDay": {} - } - }, - "dateWithoutYear": "{month}/{day}", - "@dateWithoutYear": { - "type": "text", - "placeholders": { - "month": {}, - "day": {} - } - }, - "dateWithYear": "{month}/{day}/{year}", - "@dateWithYear": { - "type": "text", - "placeholders": { - "year": {}, - "month": {}, - "day": {} - } - }, - "deactivateAccountWarning": "Ide-deactivate nito ang iyong user account. Hindi na ito maaaring bawiin! Sigurado ka?", - "@deactivateAccountWarning": { - "type": "text", - "placeholders": {} - }, - "delete": "Burahin", - "@delete": { - "type": "text", - "placeholders": {} - }, - "deleteMessage": "Burahin ang mensahe", - "@deleteMessage": { - "type": "text", - "placeholders": {} - }, - "device": "Device", - "@device": { - "type": "text", - "placeholders": {} - }, - "deviceId": "ID ng Device", - "@deviceId": { - "type": "text", - "placeholders": {} - }, - "devices": "Mga Device", - "@devices": { - "type": "text", - "placeholders": {} - }, - "emoteInvalid": "Hindi wastong shortcode ng emote!", - "@emoteInvalid": { - "type": "text", - "placeholders": {} - }, - "emoteKeyboardNoRecents": "Ang mga kamakailang ginamit na emote ay lalabas dito...", - "@emoteKeyboardNoRecents": { - "type": "text", - "placeholders": {} - }, - "calls": "Mga Tawag", - "@calls": {}, - "customEmojisAndStickers": "Mga custom emoji at sticker", - "@customEmojisAndStickers": {}, - "customEmojisAndStickersBody": "Magdagdag o magbahagi ng mga custom emoji o sticker na maaring gamitin sa anumang chat.", - "@customEmojisAndStickersBody": {}, - "emoteShortcode": "Shortcode ng emoji", - "@emoteShortcode": { - "type": "text", - "placeholders": {} - }, - "emoteWarnNeedToPick": "Kailangan mong pumili ng emote shortcode at isang larawan!", - "@emoteWarnNeedToPick": { - "type": "text", - "placeholders": {} - }, - "enableEmotesGlobally": "I-enable ang emote pack globally", - "@enableEmotesGlobally": { - "type": "text", - "placeholders": {} - }, - "endedTheCall": "Tinapos ni {senderName} ang tawag", - "@endedTheCall": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "enterAnEmailAddress": "Maglagay ng email address", - "@enterAnEmailAddress": { - "type": "text", - "placeholders": {} - }, - "homeserver": "Homeserver", - "@homeserver": {}, - "enterYourHomeserver": "Ilagay ang iyong homeserver", - "@enterYourHomeserver": { - "type": "text", - "placeholders": {} - }, - "extremeOffensive": "Lubhang nakakasakit", - "@extremeOffensive": { - "type": "text", - "placeholders": {} - }, - "commandHint_plain": "Magpadala ng hindi na-format na text", - "@commandHint_plain": { - "type": "text", - "description": "Usage hint for the command /plain" - }, - "commandMissing": "Hindi isang command ang {command}.", - "@commandMissing": { - "type": "text", - "placeholders": { - "command": {} - }, - "description": "State that {command} is not a valid /command." - }, - "contactHasBeenInvitedToTheGroup": "Inimbita ang contact sa group", - "@contactHasBeenInvitedToTheGroup": { - "type": "text", - "placeholders": {} - }, - "containsUserName": "Naglalaman ng username", - "@containsUserName": { - "type": "text", - "placeholders": {} - }, - "contentHasBeenReported": "Inulat ang nilalaman sa mga pangangasiwa ng server", - "@contentHasBeenReported": { - "type": "text", - "placeholders": {} - }, - "couldNotDecryptMessage": "Hindi ma-decrypt ang mensahe: {error}", - "@couldNotDecryptMessage": { - "type": "text", - "placeholders": { - "error": {} - } - }, - "defaultPermissionLevel": "Default na antas ng pahintulot", - "@defaultPermissionLevel": { - "type": "text", - "placeholders": {} - }, - "deleteAccount": "Burahin ang account", - "@deleteAccount": { - "type": "text", - "placeholders": {} - }, - "emotePacks": "Mga emote pack para sa room", - "@emotePacks": { - "type": "text", - "placeholders": {} - }, - "emoteSettings": "Mga Setting ng Emote", - "@emoteSettings": { - "type": "text", - "placeholders": {} - }, - "globalChatId": "Global chat ID", - "@globalChatId": {}, - "accessAndVisibility": "Pag-access at visibility", - "@accessAndVisibility": {}, - "accessAndVisibilityDescription": "Sino ang pinapayagang sumali sa chat at paano matutuklas ang chat.", - "@accessAndVisibilityDescription": {}, - "enableEncryptionWarning": "Hindi mo madi-disable ang encryption. Sigurado ka ba?", - "@enableEncryptionWarning": { - "type": "text", - "placeholders": {} - }, - "errorObtainingLocation": "Hindi makuha ang lokasyon: {error}", - "@errorObtainingLocation": { - "type": "text", - "placeholders": { - "error": {} - } - }, - "fileName": "Pangalan ng file", - "@fileName": { - "type": "text", - "placeholders": {} - }, - "fluffychat": "FluffyChat", - "@fluffychat": { - "type": "text", - "placeholders": {} - }, - "fontSize": "Laki ng font", - "@fontSize": { - "type": "text", - "placeholders": {} - } -} diff --git a/assets/l10n/intl_ka 2.arb b/assets/l10n/intl_ka 2.arb deleted file mode 100644 index 8c99e3c9a..000000000 --- a/assets/l10n/intl_ka 2.arb +++ /dev/null @@ -1,744 +0,0 @@ -{ - "alias": "მეტსახელი", - "@alias": { - "type": "text", - "placeholders": {} - }, - "appLockDescription": "პინკოდის გამოყენების გარეშე აპლიკაციის ბლოკირება", - "@appLockDescription": {}, - "commandHint_hug": "მეგობრული ჩახუტვის გაგზავნა", - "@commandHint_hug": {}, - "areYouSure": "დარწმუნებული ხართ?", - "@areYouSure": { - "type": "text", - "placeholders": {} - }, - "areYouSureYouWantToLogout": "დარწმუნებული ხართ, რომ გამოსვლა გსურთ?", - "@areYouSureYouWantToLogout": { - "type": "text", - "placeholders": {} - }, - "hugContent": "{senderName} მეგობრულად გეხუტება", - "@hugContent": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "askSSSSSign": "სხვა მომხმარებლის დადასტურებლად, გთხოვთ, ჩაწეროთ თქვენი ან საიდუმლო ფრაზა, ან აღდგენის გასაღები.", - "@askSSSSSign": { - "type": "text", - "placeholders": {} - }, - "autoplayImages": "ანიმირებული სტიკერებისა და ემოჯების ავტომატური ჩართვა", - "@autoplayImages": { - "type": "text", - "placeholder": {} - }, - "banFromChat": "ჩატიდან გაგდება და ბლოკირება", - "@banFromChat": { - "type": "text", - "placeholders": {} - }, - "banned": "დაბლოკილია", - "@banned": { - "type": "text", - "placeholders": {} - }, - "badServerLoginTypesException": "ამ სერვერს აქვს შესვლის მეთოდების მხარდაჭერა:\n{serverVersions}\nმაგრამ ამ აპლიკაციას აქვს მხარდაჭერა მხოლოდ:\n{supportedVersions}", - "@badServerLoginTypesException": { - "type": "text", - "placeholders": { - "serverVersions": {}, - "supportedVersions": {} - } - }, - "sendOnEnter": "გაგზავნა enter-ის დაჭერისას", - "@sendOnEnter": {}, - "bannedUser": "{username} დაბლოკა {targetName}", - "@bannedUser": { - "type": "text", - "placeholders": { - "username": {}, - "targetName": {} - } - }, - "blockDevice": "მოწყობილების ბლოკირება", - "@blockDevice": { - "type": "text", - "placeholders": {} - }, - "blocked": "დაბლოკილია", - "@blocked": { - "type": "text", - "placeholders": {} - }, - "botMessages": "ბოტის შეტყობინებები", - "@botMessages": { - "type": "text", - "placeholders": {} - }, - "cancel": "გაუქმება", - "@cancel": { - "type": "text", - "placeholders": {} - }, - "changedTheHistoryVisibilityTo": "{username} შეცვალა ისტორიის ხილვადობა: {rules}", - "@changedTheHistoryVisibilityTo": { - "type": "text", - "placeholders": { - "username": {}, - "rules": {} - } - }, - "changedTheJoinRules": "{username} გაწევრიანების წესები შეცვალა", - "@changedTheJoinRules": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheProfileAvatar": "{username} შეცვალა პროფილის ფოტო", - "@changedTheProfileAvatar": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "chat": "ჩატი", - "@chat": { - "type": "text", - "placeholders": {} - }, - "changeYourAvatar": "პროფილის ფოტოს შეცვლა", - "@changeYourAvatar": { - "type": "text", - "placeholders": {} - }, - "yourChatBackupHasBeenSetUp": "თქვენი ჩატის სარეზერვო საშუალება კონფიგურირებული იქნა.", - "@yourChatBackupHasBeenSetUp": {}, - "channelCorruptedDecryptError": "დაშიფვრა დაზიანდა", - "@channelCorruptedDecryptError": { - "type": "text", - "placeholders": {} - }, - "chatBackupDescription": "თქვენი ძველი შეტყობინებები დაცულია აღდგების გასაღებით. არ დაკარგოთ ის.", - "@chatBackupDescription": { - "type": "text", - "placeholders": {} - }, - "commandHint_discardsession": "სესიის გაუქმება", - "@commandHint_discardsession": { - "type": "text", - "description": "Usage hint for the command /discardsession" - }, - "commandHint_invite": "მოცემული მომხმარებლის მოწვევა ამ ოთახში", - "@commandHint_invite": { - "type": "text", - "description": "Usage hint for the command /invite" - }, - "commandHint_plain": "არაფორმატირებული ტექსტის გაგზავნა", - "@commandHint_plain": { - "type": "text", - "description": "Usage hint for the command /plain" - }, - "commandHint_send": "ტექსტის გაგზავნა", - "@commandHint_send": { - "type": "text", - "description": "Usage hint for the command /send" - }, - "commandMissing": "{command} არაა ბრძანება.", - "@commandMissing": { - "type": "text", - "placeholders": { - "command": {} - }, - "description": "State that {command} is not a valid /command." - }, - "confirm": "დადასტურება", - "@confirm": { - "type": "text", - "placeholders": {} - }, - "connect": "დაკავშირება", - "@connect": { - "type": "text", - "placeholders": {} - }, - "countParticipants": "{count} მონაწილე", - "@countParticipants": { - "type": "text", - "placeholders": { - "count": {} - } - }, - "createGroup": "ჯგუფის შექმნა", - "@createGroup": {}, - "deactivateAccountWarning": "ეს გააუქმებს თქვენს ანგარიშს. ამის გაუქმება შეუძლებელია. დარწმუნებული ხართ?", - "@deactivateAccountWarning": { - "type": "text", - "placeholders": {} - }, - "devices": "მოწყობილებები", - "@devices": { - "type": "text", - "placeholders": {} - }, - "darkTheme": "ბნელი", - "@darkTheme": { - "type": "text", - "placeholders": {} - }, - "chatPermissions": "ჩატის უფლებები", - "@chatPermissions": {}, - "dateAndTimeOfDay": "{date}, {timeOfDay}", - "@dateAndTimeOfDay": { - "type": "text", - "placeholders": { - "date": {}, - "timeOfDay": {} - } - }, - "editRoomAliases": "ოთახის მეტსახელების შეცვლა", - "@editRoomAliases": { - "type": "text", - "placeholders": {} - }, - "emoteExists": "ეს ემოცია უკვე არსებობს!", - "@emoteExists": { - "type": "text", - "placeholders": {} - }, - "emoteInvalid": "ემოციის არასწორი მოკლე კოდი!", - "@emoteInvalid": { - "type": "text", - "placeholders": {} - }, - "importNow": "იმპორტი", - "@importNow": {}, - "importEmojis": "ემოჯის იმპორტი", - "@importEmojis": {}, - "importFromZipFile": "იმპორტი .zip ფაილიდან", - "@importFromZipFile": {}, - "exportEmotePack": "ემოციების .zip ფაილში ექსპორტი", - "@exportEmotePack": {}, - "replace": "ჩანაცვლება", - "@replace": {}, - "accept": "თანხმობა", - "@accept": { - "type": "text", - "placeholders": {} - }, - "acceptedTheInvitation": "👍 {username} მიიღო მოწვევა", - "@acceptedTheInvitation": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "account": "ანგარიში", - "@account": { - "type": "text", - "placeholders": {} - }, - "addEmail": "ელ.ფოსტის დამატება", - "@addEmail": { - "type": "text", - "placeholders": {} - }, - "confirmMatrixId": "გთხოვთ, დაადასტუროთ თქვენი Matrix ID ანგარიშის წაშლისათვის.", - "@confirmMatrixId": {}, - "addChatDescription": "ჩატის აღწერილობის დამატება...", - "@addChatDescription": {}, - "addToSpace": "სივრცეში დამატება", - "@addToSpace": {}, - "admin": "ადმინი", - "@admin": { - "type": "text", - "placeholders": {} - }, - "all": "ყველა", - "@all": { - "type": "text", - "placeholders": {} - }, - "allChats": "ყველა ჩატი", - "@allChats": { - "type": "text", - "placeholders": {} - }, - "commandHint_cuddle": "ჩახუტების გაგზავნა", - "@commandHint_cuddle": {}, - "answeredTheCall": "{senderName} უპასუხა ზარს", - "@answeredTheCall": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "anyoneCanJoin": "ყველას შეუძლია გაწევრიანება", - "@anyoneCanJoin": { - "type": "text", - "placeholders": {} - }, - "appLock": "აპლიკაციის ბლოკირება", - "@appLock": { - "type": "text", - "placeholders": {} - }, - "archive": "არქივი", - "@archive": { - "type": "text", - "placeholders": {} - }, - "commandHint_googly": "გამოშტერილი თვალების გაგზავნა", - "@commandHint_googly": {}, - "googlyEyesContent": "{senderName} გამოშტერილ თვალებს გიგზავნის", - "@googlyEyesContent": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "cuddleContent": "{senderName} გეხუტება", - "@cuddleContent": { - "type": "text", - "placeholders": { - "senderName": {} - } - }, - "areGuestsAllowedToJoin": "შეუძლიათ თუ არა სტუმარ მომხმარებლებს გაწევრიანება", - "@areGuestsAllowedToJoin": { - "type": "text", - "placeholders": {} - }, - "askVerificationRequest": "მიიღებთ {username} დადასტურების მოთხოვნას?", - "@askVerificationRequest": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "sendTypingNotifications": "წერის შეტყობინების გაგზავნა", - "@sendTypingNotifications": {}, - "cantOpenUri": "ვერ იხსნება ბმული {uri}", - "@cantOpenUri": { - "type": "text", - "placeholders": { - "uri": {} - } - }, - "changeDeviceName": "მოწყობილების გადარქმევა", - "@changeDeviceName": { - "type": "text", - "placeholders": {} - }, - "changedTheChatAvatar": "{username} ჩატის ფოტო შეცვალა", - "@changedTheChatAvatar": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheChatDescriptionTo": "{username} ჩატის ახალი აღწერილობა დააყენა: '{description}'", - "@changedTheChatDescriptionTo": { - "type": "text", - "placeholders": { - "username": {}, - "description": {} - } - }, - "changedTheChatNameTo": "{username} ჩატი გადაარქვა: '{chatname}'", - "@changedTheChatNameTo": { - "type": "text", - "placeholders": { - "username": {}, - "chatname": {} - } - }, - "changedTheChatPermissions": "{username} ჩატის უფლებები შეცვალა", - "@changedTheChatPermissions": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheGuestAccessRules": "{username} შეცვალა სტუმრების წვდომის წესები", - "@changedTheGuestAccessRules": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheGuestAccessRulesTo": "{username} შეცვალა სტუმრების წვდომის წესები: {rules}", - "@changedTheGuestAccessRulesTo": { - "type": "text", - "placeholders": { - "username": {}, - "rules": {} - } - }, - "changedTheHistoryVisibility": "{username} შეცვალა ისტორიის ხილვადობა", - "@changedTheHistoryVisibility": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheJoinRulesTo": "{username} გაწევრიანების წესები შეცვალა: {joinRules}", - "@changedTheJoinRulesTo": { - "type": "text", - "placeholders": { - "username": {}, - "joinRules": {} - } - }, - "changedTheRoomAliases": "{username} ოთახის მეტსახელები შეცვალა", - "@changedTheRoomAliases": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changedTheRoomInvitationLink": "{username} მოწვევის ბმული შეცვალა", - "@changedTheRoomInvitationLink": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "changePassword": "პაროლის შეცვლა", - "@changePassword": { - "type": "text", - "placeholders": {} - }, - "changeTheHomeserver": "სახლის სერვერის შეცვლა", - "@changeTheHomeserver": { - "type": "text", - "placeholders": {} - }, - "changeTheme": "სტილის შეცვლა", - "@changeTheme": { - "type": "text", - "placeholders": {} - }, - "changeTheNameOfTheGroup": "ჯგუფის გადარქმევა", - "@changeTheNameOfTheGroup": { - "type": "text", - "placeholders": {} - }, - "chatBackup": "ჩატის სარეზერვო საშუალება", - "@chatBackup": { - "type": "text", - "placeholders": {} - }, - "chatDetails": "ჩატის დეტალები", - "@chatDetails": { - "type": "text", - "placeholders": {} - }, - "chatHasBeenAddedToThisSpace": "ჩატი დაემატა ამ სივრცეს", - "@chatHasBeenAddedToThisSpace": {}, - "chats": "ჩატები", - "@chats": { - "type": "text", - "placeholders": {} - }, - "chooseAStrongPassword": "ძლიერი პაროლი აარჩიეთ", - "@chooseAStrongPassword": { - "type": "text", - "placeholders": {} - }, - "clearArchive": "არქივის გაწმენდა", - "@clearArchive": {}, - "close": "დახურვა", - "@close": { - "type": "text", - "placeholders": {} - }, - "commandHint_markasgroup": "აღნიშვნა, როგორც ჯგუფის", - "@commandHint_markasgroup": {}, - "commandHint_ban": "მოცემული მომხმარებლის ბლოკირება ამ ოთახში", - "@commandHint_ban": { - "type": "text", - "description": "Usage hint for the command /ban" - }, - "commandHint_clearcache": "­ქეშის გაწმენდა", - "@commandHint_clearcache": { - "type": "text", - "description": "Usage hint for the command /clearcache" - }, - "commandHint_join": "მოცემულ ოთახში გაწევრიანება", - "@commandHint_join": { - "type": "text", - "description": "Usage hint for the command /join" - }, - "commandHint_kick": "მოცემული მომხმარებლის წაშლა ამ ოთახიდან", - "@commandHint_kick": { - "type": "text", - "description": "Usage hint for the command /kick" - }, - "commandHint_leave": "ამ ოთახიდან გასვლა", - "@commandHint_leave": { - "type": "text", - "description": "Usage hint for the command /leave" - }, - "commandHint_me": "აღწერეთ თქვენი თავი", - "@commandHint_me": { - "type": "text", - "description": "Usage hint for the command /me" - }, - "commandHint_unban": "ამ ოთახში მომხმარებლისგან ბლოკის მოხსნა", - "@commandHint_unban": { - "type": "text", - "description": "Usage hint for the command /unban" - }, - "commandInvalid": "არასწორი ბრძანება", - "@commandInvalid": { - "type": "text" - }, - "compareEmojiMatch": "გთხოვთ, შეადაროთ ეს ემოჯი", - "@compareEmojiMatch": { - "type": "text", - "placeholders": {} - }, - "compareNumbersMatch": "გთხოვთ, შეადაროთ ეს რიცხვები", - "@compareNumbersMatch": { - "type": "text", - "placeholders": {} - }, - "configureChat": "ჩატის კონფიგურაცია", - "@configureChat": { - "type": "text", - "placeholders": {} - }, - "contactHasBeenInvitedToTheGroup": "კონტაქტი მოწვეული იქნა ჯგუფში", - "@contactHasBeenInvitedToTheGroup": { - "type": "text", - "placeholders": {} - }, - "containsUserName": "შეიცავს სახელს", - "@containsUserName": { - "type": "text", - "placeholders": {} - }, - "copiedToClipboard": "კოპირებულია ბუფერში", - "@copiedToClipboard": { - "type": "text", - "placeholders": {} - }, - "copy": "კოპირება", - "@copy": { - "type": "text", - "placeholders": {} - }, - "copyToClipboard": "კოპირება ბუფერში", - "@copyToClipboard": { - "type": "text", - "placeholders": {} - }, - "couldNotDecryptMessage": "შეტყობინების გაშიფვრის შეცდომა: {error}", - "@couldNotDecryptMessage": { - "type": "text", - "placeholders": { - "error": {} - } - }, - "create": "შექმნა", - "@create": { - "type": "text", - "placeholders": {} - }, - "createdTheChat": "💬 {username} შექმნა ჩატი", - "@createdTheChat": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "createNewSpace": "ახალი სივრცე", - "@createNewSpace": { - "type": "text", - "placeholders": {} - }, - "currentlyActive": "ახლა აქტიურია", - "@currentlyActive": { - "type": "text", - "placeholders": {} - }, - "dateWithoutYear": "{day}-{month}", - "@dateWithoutYear": { - "type": "text", - "placeholders": { - "month": {}, - "day": {} - } - }, - "dateWithYear": "{day}-{month}-{year}", - "@dateWithYear": { - "type": "text", - "placeholders": { - "year": {}, - "month": {}, - "day": {} - } - }, - "delete": "წაშლა", - "@delete": { - "type": "text", - "placeholders": {} - }, - "deleteAccount": "ანგარიშის წაშლა", - "@deleteAccount": { - "type": "text", - "placeholders": {} - }, - "deleteMessage": "შეტყობინების წაშლა", - "@deleteMessage": { - "type": "text", - "placeholders": {} - }, - "device": "მოწყობილება", - "@device": { - "type": "text", - "placeholders": {} - }, - "deviceId": "მოწყობილების ID", - "@deviceId": { - "type": "text", - "placeholders": {} - }, - "directChats": "პირდაპირი ჩატები", - "@directChats": { - "type": "text", - "placeholders": {} - }, - "allRooms": "ყველა ჯგუფური ჩატები", - "@allRooms": { - "type": "text", - "placeholders": {} - }, - "downloadFile": "ფაილის ჩატვირთვა", - "@downloadFile": { - "type": "text", - "placeholders": {} - }, - "edit": "რედაქტირება", - "@edit": { - "type": "text", - "placeholders": {} - }, - "editBlockedServers": "ბლოკირებული სერვერების რედაქტირება", - "@editBlockedServers": { - "type": "text", - "placeholders": {} - }, - "editRoomAvatar": "ოთახის ფოტოს შეცვლა", - "@editRoomAvatar": { - "type": "text", - "placeholders": {} - }, - "emoteSettings": "ემოციების პარამეტრები", - "@emoteSettings": { - "type": "text", - "placeholders": {} - }, - "globalChatId": "გლობალური ჩატის ID", - "@globalChatId": {}, - "repeatPassword": "გაიმეორეთ პაროლი", - "@repeatPassword": {}, - "notAnImage": "ფაილი არაა სურათი.", - "@notAnImage": {}, - "remove": "წაშლა", - "@remove": { - "type": "text", - "placeholders": {} - }, - "activatedEndToEndEncryption": "🔐 {username} გააქტიურა end to end დაშიფვრა", - "@activatedEndToEndEncryption": { - "type": "text", - "placeholders": { - "username": {} - } - }, - "supposedMxid": "ეს უნდა იყოს {mxid}", - "@supposedMxid": { - "type": "text", - "placeholders": { - "mxid": {} - } - }, - "about": "შესახებ", - "@about": { - "type": "text", - "placeholders": {} - }, - "changedTheDisplaynameTo": "{username} შეცვალა ნაჩვენები სახელი: '{displayname}'", - "@changedTheDisplaynameTo": { - "type": "text", - "placeholders": { - "username": {}, - "displayname": {} - } - }, - "commandHint_create": "ცარიელი ჯგუფური ჩატის შექმნა\nგამოიყენეთ --no-encryption გაშიფვრის გასათიშად", - "@commandHint_create": { - "type": "text", - "description": "Usage hint for the command /create" - }, - "commandHint_dm": "პირდაპირი ჩატის დაწყება\nგამოიყენეთ --no-encryption გაშიფვრის გასათიშად", - "@commandHint_dm": { - "type": "text", - "description": "Usage hint for the command /dm" - }, - "commandHint_html": "HTML ფორმატირებული ტექსტის გაგზავნა", - "@commandHint_html": { - "type": "text", - "description": "Usage hint for the command /html" - }, - "commandHint_myroomavatar": "თქვენი ფოტოს დაყენება ამ ოთახისათვის(mxc-uri-ს დახმარებით)", - "@commandHint_myroomavatar": { - "type": "text", - "description": "Usage hint for the command /myroomavatar" - }, - "commandHint_myroomnick": "ამ ოთახისათვის ნაჩვენები სახელის დაყენება", - "@commandHint_myroomnick": { - "type": "text", - "description": "Usage hint for the command /myroomnick" - }, - "commandHint_op": "მოცემული მომხმარებლისათვის უფლებების დონის დაყენება (ჩვეულებრივ: 50)", - "@commandHint_op": { - "type": "text", - "description": "Usage hint for the command /op" - }, - "commandHint_react": "რეაქციის სახით პასუხის გაგზავნა", - "@commandHint_react": { - "type": "text", - "description": "Usage hint for the command /react" - }, - "containsDisplayName": "ნაჩვენებ სახელს შეიცავს", - "@containsDisplayName": { - "type": "text", - "placeholders": {} - }, - "contentHasBeenReported": "ეს კონტენტი გაგზავნილ იქნა სერვერის ადმინისტრატორებთან", - "@contentHasBeenReported": { - "type": "text", - "placeholders": {} - }, - "defaultPermissionLevel": "ნაგულისხმევი უფლების დონე", - "@defaultPermissionLevel": { - "type": "text", - "placeholders": {} - }, - "displaynameHasBeenChanged": "ნაჩვენები სახელი შეიცვალა", - "@displaynameHasBeenChanged": { - "type": "text", - "placeholders": {} - }, - "editDisplayname": "ნაჩვენები სახელის შეცვლა", - "@editDisplayname": { - "type": "text", - "placeholders": {} - } -} diff --git a/needed-translations.txt b/needed-translations.txt index 17c19e045..1f94a2fec 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -10726,9 +10726,6 @@ "es": [ "searchIn", - "searchMore", - "gallery", - "files", "conversationBotCustomZone_title", "conversationBotCustomZone_customSystemPromptLabel", "conversationBotCustomZone_customSystemPromptPlaceholder", From 8ca44a17ff4f3df3891c7f8af2f76cdba8aebfcd Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Tue, 25 Jun 2024 15:50:40 -0400 Subject: [PATCH 16/30] remove local dev files --- devtools_options 2.yaml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 devtools_options 2.yaml diff --git a/devtools_options 2.yaml b/devtools_options 2.yaml deleted file mode 100644 index fa0b357c4..000000000 --- a/devtools_options 2.yaml +++ /dev/null @@ -1,3 +0,0 @@ -description: This file stores settings for Dart & Flutter DevTools. -documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states -extensions: From 340d0ac1e26ee5678c083d8fb64999aa603968f7 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 26 Jun 2024 14:42:01 -0400 Subject: [PATCH 17/30] Makes error analytics close button more noticeable --- lib/pangea/pages/analytics/construct_list.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pangea/pages/analytics/construct_list.dart b/lib/pangea/pages/analytics/construct_list.dart index e169922ca..8651b7a74 100644 --- a/lib/pangea/pages/analytics/construct_list.dart +++ b/lib/pangea/pages/analytics/construct_list.dart @@ -355,15 +355,17 @@ class ConstructMessagesDialog extends StatelessWidget { final msgEventMatches = controller.getMessageEventMatches(); + final noData = controller.constructs![controller.lemmaIndex].uses.length > + controller._msgEvents.length; + return AlertDialog( title: Center(child: Text(controller.widget.controller.currentLemma!)), content: SizedBox( - height: 350, - width: 500, + height: noData ? 90 : 250, + width: noData ? 200 : 400, child: Column( children: [ - if (controller.constructs![controller.lemmaIndex].uses.length > - controller._msgEvents.length) + if (noData) Center( child: Padding( padding: const EdgeInsets.all(8.0), @@ -398,8 +400,8 @@ class ConstructMessagesDialog extends StatelessWidget { child: Text( L10n.of(context)!.close.toUpperCase(), style: TextStyle( - color: - Theme.of(context).textTheme.bodyMedium?.color?.withAlpha(150), + color: Theme.of(context).colorScheme.primary, + fontWeight: FontWeight.bold, ), ), ), From 47dbe6dfd308658d4a5b09b241288bab52bfb90a Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Wed, 26 Jun 2024 16:21:57 -0400 Subject: [PATCH 18/30] itAutoPlay moved from ToolSettings to PLocalKey --- .../controllers/choreographer.dart | 6 +-- lib/pangea/constants/local.key.dart | 1 + lib/pangea/controllers/local_settings.dart | 3 +- lib/pangea/controllers/user_controller.dart | 18 +++---- lib/pangea/models/class_model.dart | 51 +++++++------------ lib/pangea/models/user_model.dart | 6 +-- .../settings_learning_view.dart | 10 ++++ lib/pangea/widgets/igc/span_card.dart | 4 +- 8 files changed, 47 insertions(+), 52 deletions(-) diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 529ba95b4..ce6dbb04f 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -15,6 +15,7 @@ import 'package:fluffychat/pangea/models/class_model.dart'; import 'package:fluffychat/pangea/models/it_step.dart'; import 'package:fluffychat/pangea/models/representation_content_model.dart'; import 'package:fluffychat/pangea/models/tokens_event_content_model.dart'; +import 'package:fluffychat/pangea/models/user_model.dart'; import 'package:fluffychat/pangea/utils/any_state_holder.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart'; import 'package:fluffychat/pangea/utils/overlay.dart'; @@ -513,9 +514,8 @@ class Choreographer { chatController.room, ); - bool get itAutoPlayEnabled => pangeaController.permissionsController.isToolEnabled( - ToolSetting.itAutoPlay, - chatController.room, + bool get itAutoPlayEnabled => pangeaController.pStoreService.read( + MatrixProfile.itAutoPlay.title, ); bool get definitionsEnabled => diff --git a/lib/pangea/constants/local.key.dart b/lib/pangea/constants/local.key.dart index c0390c2ba..8dc496bf8 100644 --- a/lib/pangea/constants/local.key.dart +++ b/lib/pangea/constants/local.key.dart @@ -11,4 +11,5 @@ class PLocalKey { static const String dismissedPaywall = 'dismissedPaywall'; static const String paywallBackoff = 'paywallBackoff'; static const String autoPlayMessages = 'autoPlayMessages'; + static const String itAutoPlay = 'itAutoPlay'; } diff --git a/lib/pangea/controllers/local_settings.dart b/lib/pangea/controllers/local_settings.dart index d6ae119a5..5984a7bf5 100644 --- a/lib/pangea/controllers/local_settings.dart +++ b/lib/pangea/controllers/local_settings.dart @@ -9,8 +9,7 @@ class LocalSettings { } bool userLanguageToolSetting(ToolSetting setting) => - _pangeaController.pStoreService.read(setting.toString()) - ?? setting != ToolSetting.itAutoPlay; + _pangeaController.pStoreService.read(setting.toString()) ?? true; // bool get userEnableIT => // _pangeaController.pStoreService.read(ToolSetting.interactiveTranslator.toString()) ?? true; diff --git a/lib/pangea/controllers/user_controller.dart b/lib/pangea/controllers/user_controller.dart index 0e336fdf6..31cde897f 100644 --- a/lib/pangea/controllers/user_controller.dart +++ b/lib/pangea/controllers/user_controller.dart @@ -123,10 +123,10 @@ class UserController extends BaseController { : null; final bool? autoPlay = migratedProfileInfo(MatrixProfile.autoPlayMessages); + final bool? itAutoPlay = migratedProfileInfo(MatrixProfile.itAutoPlay); final bool? trial = migratedProfileInfo(MatrixProfile.activatedFreeTrial); final bool? interactiveTranslator = migratedProfileInfo(MatrixProfile.interactiveTranslator); - final bool? itAutoPlay = migratedProfileInfo(MatrixProfile.itAutoPlay); final bool? interactiveGrammar = migratedProfileInfo(MatrixProfile.interactiveGrammar); final bool? immersionMode = @@ -143,9 +143,9 @@ class UserController extends BaseController { await updateMatrixProfile( dateOfBirth: dob, autoPlayMessages: autoPlay, + itAutoPlay: itAutoPlay, activatedFreeTrial: trial, interactiveTranslator: interactiveTranslator, - itAutoPlay: itAutoPlay, interactiveGrammar: interactiveGrammar, immersionMode: immersionMode, definitions: definitions, @@ -225,9 +225,9 @@ class UserController extends BaseController { Future updateMatrixProfile({ String? dateOfBirth, bool? autoPlayMessages, + bool? itAutoPlay, bool? activatedFreeTrial, bool? interactiveTranslator, - bool? itAutoPlay, bool? interactiveGrammar, bool? immersionMode, bool? definitions, @@ -253,6 +253,12 @@ class UserController extends BaseController { autoPlayMessages, ); } + if (itAutoPlay != null) { + await _pangeaController.pStoreService.save( + MatrixProfile.itAutoPlay.title, + itAutoPlay, + ); + } if (activatedFreeTrial != null) { await _pangeaController.pStoreService.save( MatrixProfile.activatedFreeTrial.title, @@ -265,12 +271,6 @@ class UserController extends BaseController { interactiveTranslator, ); } - if (itAutoPlay != null) { - await _pangeaController.pStoreService.save( - MatrixProfile.itAutoPlay.title, - itAutoPlay, - ); - } if (interactiveGrammar != null) { await _pangeaController.pStoreService.save( MatrixProfile.interactiveGrammar.title, diff --git a/lib/pangea/models/class_model.dart b/lib/pangea/models/class_model.dart index f663af8ce..0bebdac2f 100644 --- a/lib/pangea/models/class_model.dart +++ b/lib/pangea/models/class_model.dart @@ -31,13 +31,13 @@ class ClassSettingsModel { }); static ClassSettingsModel get newClass => ClassSettingsModel( - city: null, - country: null, - dominantLanguage: ClassDefaultValues.defaultDominantLanguage, - languageLevel: null, - schoolName: null, - targetLanguage: ClassDefaultValues.defaultTargetLanguage, - ); + city: null, + country: null, + dominantLanguage: ClassDefaultValues.defaultDominantLanguage, + languageLevel: null, + schoolName: null, + targetLanguage: ClassDefaultValues.defaultTargetLanguage, + ); factory ClassSettingsModel.fromJson(Map json) { return ClassSettingsModel( @@ -100,9 +100,9 @@ class ClassSettingsModel { } StateEvent get toStateEvent => StateEvent( - content: toJson(), - type: PangeaEventTypes.classSettings, - ); + content: toJson(), + type: PangeaEventTypes.classSettings, + ); } class PangeaRoomRules { @@ -120,7 +120,6 @@ class PangeaRoomRules { bool isInviteOnlyStudents; // 0 = forbidden, 1 = allow individual to choose, 2 = require int interactiveTranslator; - int itAutoPlay; int interactiveGrammar; int immersionMode; int definitions; @@ -139,7 +138,6 @@ class PangeaRoomRules { this.isVoiceNotes = true, this.isInviteOnlyStudents = true, this.interactiveTranslator = ClassDefaultValues.languageToolPermissions, - this.itAutoPlay = ClassDefaultValues.languageToolPermissions, this.interactiveGrammar = ClassDefaultValues.languageToolPermissions, this.immersionMode = ClassDefaultValues.languageToolPermissions, this.definitions = ClassDefaultValues.languageToolPermissions, @@ -191,9 +189,6 @@ class PangeaRoomRules { case ToolSetting.interactiveTranslator: interactiveTranslator = value; break; - case ToolSetting.itAutoPlay: - itAutoPlay = value; - break; case ToolSetting.interactiveGrammar: interactiveGrammar = value; break; @@ -212,9 +207,9 @@ class PangeaRoomRules { } StateEvent get toStateEvent => StateEvent( - content: toJson(), - type: PangeaEventTypes.rules, - ); + content: toJson(), + type: PangeaEventTypes.rules, + ); factory PangeaRoomRules.fromJson(Map json) => PangeaRoomRules( @@ -232,16 +227,14 @@ class PangeaRoomRules { isInviteOnlyStudents: json['is_invite_only_students'] ?? true, interactiveTranslator: json['interactive_translator'] ?? ClassDefaultValues.languageToolPermissions, - itAutoPlay: json['it_auto_play'] ?? - ClassDefaultValues.languageToolPermissions, interactiveGrammar: json['interactive_grammar'] ?? ClassDefaultValues.languageToolPermissions, immersionMode: json['immersion_mode'] ?? ClassDefaultValues.languageToolPermissions, definitions: - json['definitions'] ?? ClassDefaultValues.languageToolPermissions, + json['definitions'] ?? ClassDefaultValues.languageToolPermissions, translations: - json['translations'] ?? ClassDefaultValues.languageToolPermissions, + json['translations'] ?? ClassDefaultValues.languageToolPermissions, ); Map toJson() { @@ -259,7 +252,6 @@ class PangeaRoomRules { data['is_voice_notes'] = isVoiceNotes; data['is_invite_only_students'] = isInviteOnlyStudents; data['interactive_translator'] = interactiveTranslator; - data['it_auto_play'] = itAutoPlay; data['interactive_grammar'] = interactiveGrammar; data['immersion_mode'] = immersionMode; data['definitions'] = definitions; @@ -271,8 +263,6 @@ class PangeaRoomRules { switch (setting) { case ToolSetting.interactiveTranslator: return interactiveTranslator; - case ToolSetting.itAutoPlay: - return itAutoPlay; case ToolSetting.interactiveGrammar: return interactiveGrammar; case ToolSetting.immersionMode: @@ -287,9 +277,9 @@ class PangeaRoomRules { } String languageToolPermissionsText( - BuildContext context, - ToolSetting setting, - ) { + BuildContext context, + ToolSetting setting, + ) { switch (getToolSettings(setting)) { case 0: return L10n.of(context)!.interactiveTranslatorNotAllowed; @@ -305,7 +295,6 @@ class PangeaRoomRules { enum ToolSetting { interactiveTranslator, - itAutoPlay, interactiveGrammar, immersionMode, definitions, @@ -317,8 +306,6 @@ extension SettingCopy on ToolSetting { switch (this) { case ToolSetting.interactiveTranslator: return L10n.of(context)!.interactiveTranslatorSliderHeader; - case ToolSetting.itAutoPlay: - return L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader; case ToolSetting.interactiveGrammar: return L10n.of(context)!.interactiveGrammarSliderHeader; case ToolSetting.immersionMode: @@ -337,8 +324,6 @@ extension SettingCopy on ToolSetting { return L10n.of(context)!.itToggleDescription; case ToolSetting.interactiveGrammar: return L10n.of(context)!.igcToggleDescription; - case ToolSetting.itAutoPlay: - return L10n.of(context)!.interactiveTranslatorAutoPlayDesc; case ToolSetting.immersionMode: return L10n.of(context)!.toggleImmersionModeDesc; case ToolSetting.definitions: diff --git a/lib/pangea/models/user_model.dart b/lib/pangea/models/user_model.dart index 396bcaccb..3721da95c 100644 --- a/lib/pangea/models/user_model.dart +++ b/lib/pangea/models/user_model.dart @@ -54,9 +54,9 @@ class PUserModel { enum MatrixProfile { dateOfBirth, autoPlayMessages, + itAutoPlay, activatedFreeTrial, interactiveTranslator, - itAutoPlay, interactiveGrammar, immersionMode, definitions, @@ -78,12 +78,12 @@ extension MatrixProfileExtension on MatrixProfile { return ModelKey.userDateOfBirth; case MatrixProfile.autoPlayMessages: return PLocalKey.autoPlayMessages; + case MatrixProfile.itAutoPlay: + return PLocalKey.itAutoPlay; case MatrixProfile.activatedFreeTrial: return PLocalKey.activatedTrialKey; case MatrixProfile.interactiveTranslator: return ToolSetting.interactiveTranslator.toString(); - case MatrixProfile.itAutoPlay: - return ToolSetting.itAutoPlay.toString(); case MatrixProfile.interactiveGrammar: return ToolSetting.interactiveGrammar.toString(); case MatrixProfile.immersionMode: diff --git a/lib/pangea/pages/settings_learning/settings_learning_view.dart b/lib/pangea/pages/settings_learning/settings_learning_view.dart index 6c3a87f00..207600497 100644 --- a/lib/pangea/pages/settings_learning/settings_learning_view.dart +++ b/lib/pangea/pages/settings_learning/settings_learning_view.dart @@ -61,6 +61,16 @@ class SettingsLearningView extends StatelessWidget { pStoreKey: setting.toString(), local: false, ), + PSettingsSwitchListTile.adaptive( + defaultValue: controller.pangeaController.pStoreService.read( + PLocalKey.itAutoPlay, + ) ?? + false, + title: L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader, + subtitle: L10n.of(context)!.interactiveTranslatorAutoPlayDesc, + pStoreKey: PLocalKey.itAutoPlay, + local: false, + ), PSettingsSwitchListTile.adaptive( defaultValue: controller.pangeaController.pStoreService.read( PLocalKey.autoPlayMessages, diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index 75738a687..1f31ea07f 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -1,6 +1,7 @@ import 'dart:developer'; import 'package:fluffychat/config/app_config.dart'; +import 'package:fluffychat/pangea/constants/local.key.dart'; import 'package:fluffychat/pangea/enum/span_data_type.dart'; import 'package:fluffychat/pangea/models/span_data.dart'; import 'package:fluffychat/pangea/utils/bot_style.dart'; @@ -15,7 +16,6 @@ import '../../../widgets/matrix.dart'; import '../../choreographer/widgets/choice_array.dart'; import '../../controllers/pangea_controller.dart'; import '../../enum/span_choice_type.dart'; -import '../../models/class_model.dart'; import '../../models/span_card_model.dart'; import '../common/bot_face_svg.dart'; import 'card_header.dart'; @@ -472,7 +472,7 @@ class DontShowSwitchListTileState extends State { value: switchValue, onChanged: (value) => { widget.controller.pStoreService.save( - ToolSetting.itAutoPlay.toString(), + PLocalKey.itAutoPlay.toString(), value, ), setState(() => switchValue = value), From 04a94b074f7031aec773db5ee04ff604d69c10c6 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 26 Jun 2024 17:52:35 -0400 Subject: [PATCH 19/30] Label analytics filters --- assets/l10n/intl_en.arb | 9 ++++- .../analytics/analytics_language_button.dart | 16 +++++++- .../pages/analytics/base_analytics_view.dart | 21 ++++++---- .../analytics/space_list/space_list_view.dart | 38 ++++++++++--------- .../analytics/time_span_menu_button.dart | 14 ++++++- 5 files changed, 70 insertions(+), 28 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 056c6a347..7df01a3fd 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4058,5 +4058,12 @@ "suggestToSpaceDesc": "Suggested spaces will appear in the chat lists for their parent spaces", "practice": "Practice", "noLanguagesSet": "No languages set", - "noActivitiesFound": "No practice activities found for this message" + "noActivitiesFound": "No practice activities found for this message", + "languageButtonLabel": "Language: {currentLanguage}", + "@languageButtonLabel": { + "type": "text", + "placeholders": { + "currentLanguage": {} + } + } } \ No newline at end of file diff --git a/lib/pangea/pages/analytics/analytics_language_button.dart b/lib/pangea/pages/analytics/analytics_language_button.dart index d74e07be1..2c3923fb4 100644 --- a/lib/pangea/pages/analytics/analytics_language_button.dart +++ b/lib/pangea/pages/analytics/analytics_language_button.dart @@ -16,7 +16,6 @@ class AnalyticsLanguageButton extends StatelessWidget { @override Widget build(BuildContext context) { return PopupMenuButton( - icon: const Icon(Icons.language_outlined), tooltip: L10n.of(context)!.changeAnalyticsLanguage, initialValue: value, onSelected: (LanguageModel? lang) { @@ -33,6 +32,21 @@ class AnalyticsLanguageButton extends StatelessWidget { child: Text(lang.getDisplayName(context) ?? lang.langCode), ); }).toList(), + child: TextButton.icon( + label: Text( + L10n.of(context)!.languageButtonLabel( + value.getDisplayName(context) ?? value.langCode, + ), + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, + ), + ), + icon: Icon( + Icons.language_outlined, + color: Theme.of(context).colorScheme.onSurface, + ), + onPressed: null, + ), ); } } diff --git a/lib/pangea/pages/analytics/base_analytics_view.dart b/lib/pangea/pages/analytics/base_analytics_view.dart index 1c0445d5a..449a8d172 100644 --- a/lib/pangea/pages/analytics/base_analytics_view.dart +++ b/lib/pangea/pages/analytics/base_analytics_view.dart @@ -108,7 +108,10 @@ class BaseAnalyticsView extends StatelessWidget { ? Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: controller.widget.defaultSelected.type == + AnalyticsEntryType.space + ? MainAxisAlignment.spaceEvenly + : MainAxisAlignment.start, children: [ if (controller.widget.defaultSelected.type == AnalyticsEntryType.student) @@ -159,13 +162,15 @@ class BaseAnalyticsView extends StatelessWidget { ), Expanded( child: SingleChildScrollView( - child: SizedBox( - height: max( - controller.widget.tabs[0].items.length + - 1, - controller.widget.tabs[1].items.length, - ) * - 72, + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: max( + controller.widget.tabs[0].items.length + + 1, + controller.widget.tabs[1].items.length, + ) * + 73, + ), child: TabBarView( physics: const NeverScrollableScrollPhysics(), children: [ diff --git a/lib/pangea/pages/analytics/space_list/space_list_view.dart b/lib/pangea/pages/analytics/space_list/space_list_view.dart index 5f5bf22da..877efdca2 100644 --- a/lib/pangea/pages/analytics/space_list/space_list_view.dart +++ b/lib/pangea/pages/analytics/space_list/space_list_view.dart @@ -1,3 +1,4 @@ +import 'package:fluffychat/pangea/enum/time_span.dart'; import 'package:fluffychat/pangea/pages/analytics/analytics_language_button.dart'; import 'package:fluffychat/pangea/pages/analytics/analytics_list_tile.dart'; import 'package:fluffychat/pangea/pages/analytics/time_span_menu_button.dart'; @@ -5,7 +6,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:go_router/go_router.dart'; -import '../../../enum/time_span.dart'; import '../base_analytics.dart'; import 'space_list.dart'; @@ -32,25 +32,29 @@ class AnalyticsSpaceListView extends StatelessWidget { icon: const Icon(Icons.close_outlined), onPressed: () => context.pop(), ), - actions: [ - TimeSpanMenuButton( - value: - controller.pangeaController.analytics.currentAnalyticsTimeSpan, - onChange: (TimeSpan value) => controller.toggleTimeSpan( - context, - value, - ), - ), - AnalyticsLanguageButton( - value: - controller.pangeaController.analytics.currentAnalyticsSpaceLang, - onChange: (lang) => controller.toggleSpaceLang(lang), - languages: controller.pangeaController.pLanguageStore.targetOptions, - ), - ], ), body: Column( children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + TimeSpanMenuButton( + value: controller + .pangeaController.analytics.currentAnalyticsTimeSpan, + onChange: (TimeSpan value) => controller.toggleTimeSpan( + context, + value, + ), + ), + AnalyticsLanguageButton( + value: controller + .pangeaController.analytics.currentAnalyticsSpaceLang, + onChange: (lang) => controller.toggleSpaceLang(lang), + languages: + controller.pangeaController.pLanguageStore.targetOptions, + ), + ], + ), Flexible( child: ListView.builder( itemCount: controller.spaces.length, diff --git a/lib/pangea/pages/analytics/time_span_menu_button.dart b/lib/pangea/pages/analytics/time_span_menu_button.dart index 23d2ad0c8..32f6668bc 100644 --- a/lib/pangea/pages/analytics/time_span_menu_button.dart +++ b/lib/pangea/pages/analytics/time_span_menu_button.dart @@ -15,7 +15,6 @@ class TimeSpanMenuButton extends StatelessWidget { @override Widget build(BuildContext context) { return PopupMenuButton( - icon: const Icon(Icons.calendar_month_outlined), tooltip: L10n.of(context)!.changeDateRange, initialValue: value, onSelected: (TimeSpan? timeSpan) { @@ -32,6 +31,19 @@ class TimeSpanMenuButton extends StatelessWidget { child: Text(timeSpan.string(context)), ); }).toList(), + child: TextButton.icon( + label: Text( + value.string(context), + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, + ), + ), + icon: Icon( + Icons.calendar_month_outlined, + color: Theme.of(context).colorScheme.onSurface, + ), + onPressed: null, + ), ); } } From 122519d9ce1466655c422b3a779df94c4db63268 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Thu, 27 Jun 2024 10:01:20 -0400 Subject: [PATCH 20/30] Make scrollbar draggable --- .../p_class_widgets/class_description_button.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart b/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart index 24c934953..ff7d0068a 100644 --- a/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart +++ b/lib/pangea/pages/class_settings/p_class_widgets/class_description_button.dart @@ -17,6 +17,7 @@ class ClassDescriptionButton extends StatelessWidget { @override Widget build(BuildContext context) { final iconColor = Theme.of(context).textTheme.bodyLarge!.color; + final ScrollController scrollController = ScrollController(); return Column( children: [ ListTile( @@ -31,9 +32,11 @@ class ClassDescriptionButton extends StatelessWidget { maxHeight: 190, ), child: Scrollbar( + controller: scrollController, + interactive: true, child: SingleChildScrollView( + controller: scrollController, primary: false, - controller: ScrollController(), child: Text( room.topic.isEmpty ? (room.isRoomAdmin From 0d896e24d2808a95aeb3ffd556f88e37aa754f5a Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 27 Jun 2024 10:39:35 -0400 Subject: [PATCH 21/30] added explanation for scroll configuation --- lib/pages/chat_details/chat_details_view.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pages/chat_details/chat_details_view.dart b/lib/pages/chat_details/chat_details_view.dart index cf4668637..93496beee 100644 --- a/lib/pages/chat_details/chat_details_view.dart +++ b/lib/pages/chat_details/chat_details_view.dart @@ -105,6 +105,8 @@ class ChatDetailsView extends StatelessWidget { ), body: MaxWidthBody( // #Pangea + // chat description title has its own scrollbar so we disable the parent one + // otherwise they scroll with each other child: ScrollConfiguration( behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false), @@ -420,7 +422,8 @@ class ChatDetailsView extends StatelessWidget { // trailing: const Icon(Icons.chevron_right_outlined), // Pangea# onTap: () => context.push( - '/rooms/${room.id}/details/permissions'), + '/rooms/${room.id}/details/permissions', + ), ), Divider( height: 1, From 8b981ddce9302169cf2e7e192666a5f9be166053 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Thu, 27 Jun 2024 11:08:38 -0400 Subject: [PATCH 22/30] Make buttons same for my and space analytics --- .../pages/analytics/base_analytics_view.dart | 406 +++++++++--------- 1 file changed, 193 insertions(+), 213 deletions(-) diff --git a/lib/pangea/pages/analytics/base_analytics_view.dart b/lib/pangea/pages/analytics/base_analytics_view.dart index 449a8d172..36bda7e48 100644 --- a/lib/pangea/pages/analytics/base_analytics_view.dart +++ b/lib/pangea/pages/analytics/base_analytics_view.dart @@ -104,228 +104,208 @@ class BaseAnalyticsView extends StatelessWidget { ), body: MaxWidthBody( withScrolling: false, - child: controller.widget.selectedView != null - ? Column( + child: Column( + children: [ + if (controller.widget.selectedView != null) + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Row( - mainAxisAlignment: controller.widget.defaultSelected.type == - AnalyticsEntryType.space - ? MainAxisAlignment.spaceEvenly - : MainAxisAlignment.start, + TimeSpanMenuButton( + value: controller.currentTimeSpan, + onChange: (TimeSpan value) => + controller.toggleTimeSpan(context, value), + ), + AnalyticsLanguageButton( + value: controller + .pangeaController.analytics.currentAnalyticsSpaceLang, + onChange: (lang) => controller.toggleSpaceLang(lang), + languages: controller + .pangeaController.pLanguageStore.targetOptions, + ), + ], + ), + if (controller.widget.selectedView != null) + Expanded( + flex: 1, + child: chartView(context), + ), + if (controller.widget.selectedView != null) + Expanded( + flex: 1, + child: DefaultTabController( + length: 2, + child: Column( children: [ - if (controller.widget.defaultSelected.type == - AnalyticsEntryType.student) - IconButton( - icon: const Icon(Icons.refresh), - onPressed: controller.onRefresh, - tooltip: L10n.of(context)!.refresh, - ), - TimeSpanMenuButton( - value: controller.currentTimeSpan, - onChange: (TimeSpan value) => - controller.toggleTimeSpan(context, value), - ), - if (controller.widget.defaultSelected.type == - AnalyticsEntryType.space) - AnalyticsLanguageButton( - value: controller.pangeaController.analytics - .currentAnalyticsSpaceLang, - onChange: (lang) => controller.toggleSpaceLang(lang), - languages: controller - .pangeaController.pLanguageStore.targetOptions, - ), - ], - ), - Expanded( - flex: 1, - child: chartView(context), - ), - Expanded( - flex: 1, - child: DefaultTabController( - length: 2, - child: Column( - children: [ - TabBar( - tabs: [ - ...controller.widget.tabs.map( - (tab) => Tab( - icon: Icon( - tab.icon, - color: Theme.of(context) - .colorScheme - .onSurfaceVariant, - ), - ), - ), - ], - ), - Expanded( - child: SingleChildScrollView( - child: ConstrainedBox( - constraints: BoxConstraints( - maxHeight: max( - controller.widget.tabs[0].items.length + - 1, - controller.widget.tabs[1].items.length, - ) * - 73, - ), - child: TabBarView( - physics: const NeverScrollableScrollPhysics(), - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.stretch, - children: [ - ...controller.widget.tabs[0].items.map( - (item) => AnalyticsListTile( - refreshStream: - controller.refreshStream, - avatar: item.avatar, - defaultSelected: controller - .widget.defaultSelected, - selected: AnalyticsSelected( - item.id, - controller.widget.tabs[0].type, - item.displayName, - ), - isSelected: - controller.isSelected(item.id), - onTap: (_) => - controller.toggleSelection( - AnalyticsSelected( - item.id, - controller.widget.tabs[0].type, - item.displayName, - ), - ), - allowNavigateOnSelect: controller - .widget - .tabs[0] - .allowNavigateOnSelect, - pangeaController: - controller.pangeaController, - controller: controller, - ), - ), - if (controller - .widget.defaultSelected.type == - AnalyticsEntryType.space) - AnalyticsListTile( - refreshStream: - controller.refreshStream, - defaultSelected: controller - .widget.defaultSelected, - avatar: null, - selected: AnalyticsSelected( - controller - .widget.defaultSelected.id, - AnalyticsEntryType.privateChats, - L10n.of(context)!.allPrivateChats, - ), - allowNavigateOnSelect: false, - isSelected: controller.isSelected( - controller - .widget.defaultSelected.id, - ), - onTap: controller.toggleSelection, - pangeaController: - controller.pangeaController, - controller: controller, - ), - ], - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.stretch, - children: controller.widget.tabs[1].items - .map( - (item) => AnalyticsListTile( - refreshStream: - controller.refreshStream, - avatar: item.avatar, - defaultSelected: controller - .widget.defaultSelected, - selected: AnalyticsSelected( - item.id, - controller.widget.tabs[1].type, - item.displayName, - ), - isSelected: controller - .isSelected(item.id), - onTap: controller.toggleSelection, - allowNavigateOnSelect: controller - .widget - .tabs[1] - .allowNavigateOnSelect, - pangeaController: - controller.pangeaController, - controller: controller, - ), - ) - .toList(), - ), - ], - ), + TabBar( + tabs: [ + ...controller.widget.tabs.map( + (tab) => Tab( + icon: Icon( + tab.icon, + color: Theme.of(context) + .colorScheme + .onSurfaceVariant, ), ), ), ], ), - ), + Expanded( + child: SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: max( + controller.widget.tabs[0].items.length + 1, + controller.widget.tabs[1].items.length, + ) * + 73, + ), + child: TabBarView( + physics: const NeverScrollableScrollPhysics(), + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.stretch, + children: [ + ...controller.widget.tabs[0].items.map( + (item) => AnalyticsListTile( + refreshStream: controller.refreshStream, + avatar: item.avatar, + defaultSelected: + controller.widget.defaultSelected, + selected: AnalyticsSelected( + item.id, + controller.widget.tabs[0].type, + item.displayName, + ), + isSelected: + controller.isSelected(item.id), + onTap: (_) => + controller.toggleSelection( + AnalyticsSelected( + item.id, + controller.widget.tabs[0].type, + item.displayName, + ), + ), + allowNavigateOnSelect: controller.widget + .tabs[0].allowNavigateOnSelect, + pangeaController: + controller.pangeaController, + controller: controller, + ), + ), + if (controller + .widget.defaultSelected.type == + AnalyticsEntryType.space) + AnalyticsListTile( + refreshStream: controller.refreshStream, + defaultSelected: + controller.widget.defaultSelected, + avatar: null, + selected: AnalyticsSelected( + controller.widget.defaultSelected.id, + AnalyticsEntryType.privateChats, + L10n.of(context)!.allPrivateChats, + ), + allowNavigateOnSelect: false, + isSelected: controller.isSelected( + controller.widget.defaultSelected.id, + ), + onTap: controller.toggleSelection, + pangeaController: + controller.pangeaController, + controller: controller, + ), + ], + ), + Column( + crossAxisAlignment: + CrossAxisAlignment.stretch, + children: controller.widget.tabs[1].items + .map( + (item) => AnalyticsListTile( + refreshStream: + controller.refreshStream, + avatar: item.avatar, + defaultSelected: + controller.widget.defaultSelected, + selected: AnalyticsSelected( + item.id, + controller.widget.tabs[1].type, + item.displayName, + ), + isSelected: + controller.isSelected(item.id), + onTap: controller.toggleSelection, + allowNavigateOnSelect: controller + .widget + .tabs[1] + .allowNavigateOnSelect, + pangeaController: + controller.pangeaController, + controller: controller, + ), + ) + .toList(), + ), + ], + ), + ), + ), + ), + ], ), - ], - ) - : Column( - children: [ - const Divider(height: 1), - ListTile( - title: Text(L10n.of(context)!.grammarAnalytics), - leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: - Theme.of(context).textTheme.bodyLarge!.color, - child: Icon(BarChartViewSelection.grammar.icon), - ), - trailing: const Icon(Icons.chevron_right), - onTap: () { - String route = - "/rooms/${controller.widget.defaultSelected.type.route}"; - if (controller.widget.defaultSelected.type == - AnalyticsEntryType.space) { - route += "/${controller.widget.defaultSelected.id}"; - } - route += "/${BarChartViewSelection.grammar.route}"; - context.go(route); - }, - ), - const Divider(height: 1), - ListTile( - title: Text(L10n.of(context)!.messageAnalytics), - leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: - Theme.of(context).textTheme.bodyLarge!.color, - child: Icon(BarChartViewSelection.messages.icon), - ), - trailing: const Icon(Icons.chevron_right), - onTap: () { - String route = - "/rooms/${controller.widget.defaultSelected.type.route}"; - if (controller.widget.defaultSelected.type == - AnalyticsEntryType.space) { - route += "/${controller.widget.defaultSelected.id}"; - } - route += "/${BarChartViewSelection.messages.route}"; - context.go(route); - }, - ), - const Divider(height: 1), - ], + ), ), + if (controller.widget.selectedView == null) + const Divider(height: 1), + if (controller.widget.selectedView == null) + ListTile( + title: Text(L10n.of(context)!.grammarAnalytics), + leading: CircleAvatar( + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + foregroundColor: Theme.of(context).textTheme.bodyLarge!.color, + child: Icon(BarChartViewSelection.grammar.icon), + ), + trailing: const Icon(Icons.chevron_right), + onTap: () { + String route = + "/rooms/${controller.widget.defaultSelected.type.route}"; + if (controller.widget.defaultSelected.type == + AnalyticsEntryType.space) { + route += "/${controller.widget.defaultSelected.id}"; + } + route += "/${BarChartViewSelection.grammar.route}"; + context.go(route); + }, + ), + if (controller.widget.selectedView == null) + const Divider(height: 1), + if (controller.widget.selectedView == null) + ListTile( + title: Text(L10n.of(context)!.messageAnalytics), + leading: CircleAvatar( + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + foregroundColor: Theme.of(context).textTheme.bodyLarge!.color, + child: Icon(BarChartViewSelection.messages.icon), + ), + trailing: const Icon(Icons.chevron_right), + onTap: () { + String route = + "/rooms/${controller.widget.defaultSelected.type.route}"; + if (controller.widget.defaultSelected.type == + AnalyticsEntryType.space) { + route += "/${controller.widget.defaultSelected.id}"; + } + route += "/${BarChartViewSelection.messages.route}"; + context.go(route); + }, + ), + if (controller.widget.selectedView == null) + const Divider(height: 1), + ], + ), ), ); } From 0a69ddbe16ecaf479f3aea05037efebea2d603b0 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 27 Jun 2024 11:54:35 -0400 Subject: [PATCH 23/30] reload space analytics list after changing dropdown values --- .../message_analytics_controller.dart | 2 + .../analytics/space_list/space_list.dart | 12 ++ needed-translations.txt | 150 ++++++++++++------ 3 files changed, 114 insertions(+), 50 deletions(-) diff --git a/lib/pangea/controllers/message_analytics_controller.dart b/lib/pangea/controllers/message_analytics_controller.dart index 7083efbfd..531dd4cb3 100644 --- a/lib/pangea/controllers/message_analytics_controller.dart +++ b/lib/pangea/controllers/message_analytics_controller.dart @@ -62,6 +62,7 @@ class AnalyticsController extends BaseController { timeSpan.toString(), local: true, ); + setState(); } ///////// SPACE ANALYTICS LANGUAGES ////////// @@ -89,6 +90,7 @@ class AnalyticsController extends BaseController { lang.langCode, local: true, ); + setState(); } Future myAnalyticsLastUpdated(String type) async { diff --git a/lib/pangea/pages/analytics/space_list/space_list.dart b/lib/pangea/pages/analytics/space_list/space_list.dart index 058d54e63..0965b8334 100644 --- a/lib/pangea/pages/analytics/space_list/space_list.dart +++ b/lib/pangea/pages/analytics/space_list/space_list.dart @@ -22,6 +22,7 @@ class AnalyticsSpaceList extends StatefulWidget { class AnalyticsSpaceListController extends State { PangeaController pangeaController = MatrixState.pangeaController; List spaces = []; + StreamSubscription? stateSub; @override void initState() { @@ -38,6 +39,17 @@ class AnalyticsSpaceListController extends State { spaces = spaceList; setState(() {}); }); + + // reload dropdowns when their values change in analytics page + stateSub = pangeaController.analytics.stateStream.listen( + (_) => setState(() {}), + ); + } + + @override + void dispose() { + stateSub?.cancel(); + super.dispose(); } StreamController refreshStream = StreamController.broadcast(); diff --git a/needed-translations.txt b/needed-translations.txt index 1355bb368..d577d89d9 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -863,7 +863,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "be": [ @@ -2363,7 +2364,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "bn": [ @@ -3859,7 +3861,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "bo": [ @@ -5359,7 +5362,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ca": [ @@ -6261,7 +6265,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "cs": [ @@ -7245,7 +7250,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "de": [ @@ -8112,7 +8118,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "el": [ @@ -9563,7 +9570,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "eo": [ @@ -10712,7 +10720,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "es": [ @@ -10727,7 +10736,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "et": [ @@ -11594,7 +11604,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "eu": [ @@ -12463,7 +12474,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "fa": [ @@ -13469,7 +13481,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "fi": [ @@ -14439,7 +14452,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "fil": [ @@ -15765,7 +15779,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "fr": [ @@ -16770,7 +16785,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ga": [ @@ -17904,7 +17920,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "gl": [ @@ -18771,7 +18788,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "he": [ @@ -20024,7 +20042,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "hi": [ @@ -21517,7 +21536,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "hr": [ @@ -22463,7 +22483,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "hu": [ @@ -23346,7 +23367,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ia": [ @@ -24832,7 +24854,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "id": [ @@ -25705,7 +25728,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ie": [ @@ -26962,7 +26986,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "it": [ @@ -27886,7 +27911,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ja": [ @@ -28921,7 +28947,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ka": [ @@ -30275,7 +30302,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ko": [ @@ -31144,7 +31172,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "lt": [ @@ -32179,7 +32208,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "lv": [ @@ -33054,7 +33084,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "nb": [ @@ -34253,7 +34284,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "nl": [ @@ -35216,7 +35248,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "pl": [ @@ -36188,7 +36221,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "pt": [ @@ -37666,7 +37700,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "pt_BR": [ @@ -38539,7 +38574,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "pt_PT": [ @@ -39739,7 +39775,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ro": [ @@ -40746,7 +40783,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ru": [ @@ -41619,7 +41657,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "sk": [ @@ -42885,7 +42924,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "sl": [ @@ -44281,7 +44321,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "sr": [ @@ -45451,7 +45492,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "sv": [ @@ -46355,7 +46397,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "ta": [ @@ -47852,7 +47895,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "th": [ @@ -49303,7 +49347,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "tr": [ @@ -50170,7 +50215,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "uk": [ @@ -51074,7 +51120,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "vi": [ @@ -52426,7 +52473,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "zh": [ @@ -53293,7 +53341,8 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ], "zh_Hant": [ @@ -54441,6 +54490,7 @@ "suggestToSpaceDesc", "practice", "noLanguagesSet", - "noActivitiesFound" + "noActivitiesFound", + "languageButtonLabel" ] } From 989964681b061b22bbae47437b770cbe01a6ad9a Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 27 Jun 2024 12:14:49 -0400 Subject: [PATCH 24/30] inital work on add language dropdown to my analytics --- .../message_analytics_controller.dart | 99 +++++++++---------- .../pages/analytics/base_analytics.dart | 2 +- .../pages/analytics/base_analytics_view.dart | 2 +- .../analytics/space_list/space_list.dart | 2 +- .../analytics/space_list/space_list_view.dart | 4 +- 5 files changed, 50 insertions(+), 59 deletions(-) diff --git a/lib/pangea/controllers/message_analytics_controller.dart b/lib/pangea/controllers/message_analytics_controller.dart index 531dd4cb3..1475c0e6e 100644 --- a/lib/pangea/controllers/message_analytics_controller.dart +++ b/lib/pangea/controllers/message_analytics_controller.dart @@ -68,7 +68,7 @@ class AnalyticsController extends BaseController { ///////// SPACE ANALYTICS LANGUAGES ////////// String get _analyticsSpaceLangKey => "ANALYTICS_SPACE_LANG_KEY"; - LanguageModel get currentAnalyticsSpaceLang { + LanguageModel get currentAnalyticsLang { try { final String? str = _pangeaController.pStoreService.read( _analyticsSpaceLangKey, @@ -84,7 +84,7 @@ class AnalyticsController extends BaseController { } } - Future setCurrentAnalyticsSpaceLang(LanguageModel lang) async { + Future setCurrentAnalyticsLang(LanguageModel lang) async { await _pangeaController.pStoreService.save( _analyticsSpaceLangKey, lang.langCode, @@ -93,33 +93,34 @@ class AnalyticsController extends BaseController { setState(); } + /// given an analytics event type and the current analytics language, + /// get the last time the user updated their analytics Future myAnalyticsLastUpdated(String type) async { - // given an analytics event type, get the last updated times - // for each of the user's analytics rooms and return the most recent - // Most Recent instead of the oldest because, for instance: - // My last Spanish event was sent 3 days ago. - // My last English event was sent 1 day ago. - // When I go to check if the cached data is out of date, the cached item was set 2 days ago. - // I know there’s new data available because the English update data (the most recent) is after the cache’s creation time. - // So, I should update the cache. final List analyticsRooms = _pangeaController .matrixState.client.allMyAnalyticsRooms .where((room) => room.isAnalyticsRoom) .toList(); - final List lastUpdates = []; + final Map langCodeLastUpdates = {}; for (final Room analyticsRoom in analyticsRooms) { + final String? roomLang = analyticsRoom.madeForLang; + if (roomLang == null) continue; final DateTime? lastUpdated = await analyticsRoom.analyticsLastUpdated( type, _pangeaController.matrixState.client.userID!, ); if (lastUpdated != null) { - lastUpdates.add(lastUpdated); + langCodeLastUpdates[roomLang] = lastUpdated; } } - if (lastUpdates.isEmpty) return null; - return lastUpdates.reduce( + if (langCodeLastUpdates.isEmpty) return null; + final String? l2Code = + _pangeaController.languageController.userL2?.langCode; + if (l2Code != null && langCodeLastUpdates.containsKey(l2Code)) { + return langCodeLastUpdates[l2Code]; + } + return langCodeLastUpdates.values.reduce( (check, mostRecent) => check.isAfter(mostRecent) ? check : mostRecent, ); } @@ -136,7 +137,7 @@ class AnalyticsController extends BaseController { final List> lastUpdatedFutures = []; for (final student in space.students) { final Room? analyticsRoom = _pangeaController.matrixState.client - .analyticsRoomLocal(currentAnalyticsSpaceLang.langCode, student.id); + .analyticsRoomLocal(currentAnalyticsLang.langCode, student.id); if (analyticsRoom == null) continue; lastUpdatedFutures.add( analyticsRoom.analyticsLastUpdated( @@ -179,28 +180,20 @@ class AnalyticsController extends BaseController { //////////////////////////// MESSAGE SUMMARY ANALYTICS //////////////////////////// + /// get all the summary analytics events for the current user + /// in the current language's analytics room Future> mySummaryAnalytics() async { - // gets all the summary analytics events for the user - // since the current timespace's cut off date - final analyticsRooms = - _pangeaController.matrixState.client.allMyAnalyticsRooms; + final Room? analyticsRoom = _pangeaController.matrixState.client + .analyticsRoomLocal(currentAnalyticsLang.langCode); + if (analyticsRoom == null) return []; - final List allEvents = []; - - // TODO switch to using list of futures - for (final Room analyticsRoom in analyticsRooms) { - final List? roomEvents = - await analyticsRoom.getAnalyticsEvents( - type: PangeaEventTypes.summaryAnalytics, - since: currentAnalyticsTimeSpan.cutOffDate, - userId: _pangeaController.matrixState.client.userID!, - ); - - allEvents.addAll( - roomEvents?.cast() ?? [], - ); - } - return allEvents; + final List? roomEvents = + await analyticsRoom.getAnalyticsEvents( + type: PangeaEventTypes.summaryAnalytics, + since: currentAnalyticsTimeSpan.cutOffDate, + userId: _pangeaController.matrixState.client.userID!, + ); + return roomEvents?.cast() ?? []; } Future> spaceMemberAnalytics( @@ -218,7 +211,7 @@ class AnalyticsController extends BaseController { final List analyticsEvents = []; for (final student in space.students) { final Room? analyticsRoom = _pangeaController.matrixState.client - .analyticsRoomLocal(currentAnalyticsSpaceLang.langCode, student.id); + .analyticsRoomLocal(currentAnalyticsLang.langCode, student.id); if (analyticsRoom != null) { final List? roomEvents = @@ -263,7 +256,7 @@ class AnalyticsController extends BaseController { (e.defaultSelected.type == defaultSelected.type) && (e.selected?.id == selected?.id) && (e.selected?.type == selected?.type) && - (e.langCode == currentAnalyticsSpaceLang.langCode), + (e.langCode == currentAnalyticsLang.langCode), ); if (index != -1) { @@ -291,7 +284,7 @@ class AnalyticsController extends BaseController { chartAnalyticsModel: chartAnalyticsModel, defaultSelected: defaultSelected, selected: selected, - langCode: currentAnalyticsSpaceLang.langCode, + langCode: currentAnalyticsLang.langCode, ), ); } @@ -527,20 +520,18 @@ class AnalyticsController extends BaseController { //////////////////////////// CONSTRUCTS //////////////////////////// Future> allMyConstructs() async { - final List analyticsRooms = - _pangeaController.matrixState.client.allMyAnalyticsRooms; + final Room? analyticsRoom = _pangeaController.matrixState.client + .analyticsRoomLocal(currentAnalyticsLang.langCode); + if (analyticsRoom == null) return []; - final List allConstructs = []; - for (final Room analyticsRoom in analyticsRooms) { - final List? roomEvents = - (await analyticsRoom.getAnalyticsEvents( - type: PangeaEventTypes.construct, - since: currentAnalyticsTimeSpan.cutOffDate, - userId: _pangeaController.matrixState.client.userID!, - )) - ?.cast(); - allConstructs.addAll(roomEvents ?? []); - } + final List? roomEvents = + (await analyticsRoom.getAnalyticsEvents( + type: PangeaEventTypes.construct, + since: currentAnalyticsTimeSpan.cutOffDate, + userId: _pangeaController.matrixState.client.userID!, + )) + ?.cast(); + final List allConstructs = roomEvents ?? []; final List adminSpaceRooms = await _pangeaController.matrixState.client.teacherRoomIds; @@ -563,7 +554,7 @@ class AnalyticsController extends BaseController { final List constructEvents = []; for (final student in space.students) { final Room? analyticsRoom = _pangeaController.matrixState.client - .analyticsRoomLocal(currentAnalyticsSpaceLang.langCode, student.id); + .analyticsRoomLocal(currentAnalyticsLang.langCode, student.id); if (analyticsRoom != null) { final List? roomEvents = (await analyticsRoom.getAnalyticsEvents( @@ -663,7 +654,7 @@ class AnalyticsController extends BaseController { e.defaultSelected.type == defaultSelected.type && e.selected?.id == selected?.id && e.selected?.type == selected?.type && - e.langCode == currentAnalyticsSpaceLang.langCode, + e.langCode == currentAnalyticsLang.langCode, ); if (index > -1) { @@ -689,7 +680,7 @@ class AnalyticsController extends BaseController { events: List.from(events), defaultSelected: defaultSelected, selected: selected, - langCode: currentAnalyticsSpaceLang.langCode, + langCode: currentAnalyticsLang.langCode, ); _cachedConstructs.add(entry); } diff --git a/lib/pangea/pages/analytics/base_analytics.dart b/lib/pangea/pages/analytics/base_analytics.dart index f62e5f6b5..0e3ae49a7 100644 --- a/lib/pangea/pages/analytics/base_analytics.dart +++ b/lib/pangea/pages/analytics/base_analytics.dart @@ -159,7 +159,7 @@ class BaseAnalyticsController extends State { } Future toggleSpaceLang(LanguageModel lang) async { - await pangeaController.analytics.setCurrentAnalyticsSpaceLang(lang); + await pangeaController.analytics.setCurrentAnalyticsLang(lang); await setChartData(); refreshStream.add(false); } diff --git a/lib/pangea/pages/analytics/base_analytics_view.dart b/lib/pangea/pages/analytics/base_analytics_view.dart index 36bda7e48..3495591fd 100644 --- a/lib/pangea/pages/analytics/base_analytics_view.dart +++ b/lib/pangea/pages/analytics/base_analytics_view.dart @@ -117,7 +117,7 @@ class BaseAnalyticsView extends StatelessWidget { ), AnalyticsLanguageButton( value: controller - .pangeaController.analytics.currentAnalyticsSpaceLang, + .pangeaController.analytics.currentAnalyticsLang, onChange: (lang) => controller.toggleSpaceLang(lang), languages: controller .pangeaController.pLanguageStore.targetOptions, diff --git a/lib/pangea/pages/analytics/space_list/space_list.dart b/lib/pangea/pages/analytics/space_list/space_list.dart index 0965b8334..bc2f7836c 100644 --- a/lib/pangea/pages/analytics/space_list/space_list.dart +++ b/lib/pangea/pages/analytics/space_list/space_list.dart @@ -61,7 +61,7 @@ class AnalyticsSpaceListController extends State { } Future toggleSpaceLang(LanguageModel lang) async { - await pangeaController.analytics.setCurrentAnalyticsSpaceLang(lang); + await pangeaController.analytics.setCurrentAnalyticsLang(lang); refreshStream.add(false); setState(() {}); } diff --git a/lib/pangea/pages/analytics/space_list/space_list_view.dart b/lib/pangea/pages/analytics/space_list/space_list_view.dart index 877efdca2..7ef5fb45e 100644 --- a/lib/pangea/pages/analytics/space_list/space_list_view.dart +++ b/lib/pangea/pages/analytics/space_list/space_list_view.dart @@ -47,8 +47,8 @@ class AnalyticsSpaceListView extends StatelessWidget { ), ), AnalyticsLanguageButton( - value: controller - .pangeaController.analytics.currentAnalyticsSpaceLang, + value: + controller.pangeaController.analytics.currentAnalyticsLang, onChange: (lang) => controller.toggleSpaceLang(lang), languages: controller.pangeaController.pLanguageStore.targetOptions, From 4749974a9b2b9353b99761a53d6968c60df6ce62 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 27 Jun 2024 12:40:48 -0400 Subject: [PATCH 25/30] set target langs based on user's target language and analytics rooms --- .../student_analytics/student_analytics.dart | 23 +++++++++++++++++++ .../student_analytics_view.dart | 1 + 2 files changed, 24 insertions(+) diff --git a/lib/pangea/pages/analytics/student_analytics/student_analytics.dart b/lib/pangea/pages/analytics/student_analytics/student_analytics.dart index 65bd533e8..d6bc9d766 100644 --- a/lib/pangea/pages/analytics/student_analytics/student_analytics.dart +++ b/lib/pangea/pages/analytics/student_analytics/student_analytics.dart @@ -1,7 +1,12 @@ import 'dart:async'; import 'dart:developer'; +import 'package:fluffychat/pangea/constants/language_keys.dart'; +import 'package:fluffychat/pangea/controllers/language_list_controller.dart'; import 'package:fluffychat/pangea/enum/bar_chart_view_enum.dart'; +import 'package:fluffychat/pangea/extensions/client_extension/client_extension.dart'; +import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart'; +import 'package:fluffychat/pangea/models/language_model.dart'; import 'package:fluffychat/pangea/widgets/common/list_placeholder.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -75,6 +80,24 @@ class StudentAnalyticsController extends State { return id; } + List get targetLanguages { + final LanguageModel? l2 = + _pangeaController.languageController.activeL2Model(); + final List analyticsRoomLangs = + _pangeaController.matrixState.client.allMyAnalyticsRooms + .map((analyticsRoom) => analyticsRoom.madeForLang) + .where((langCode) => langCode != null) + .map((langCode) => PangeaLanguage.byLangCode(langCode!)) + .where( + (langModel) => langModel.langCode != LanguageKeys.unknownLanguage, + ) + .toList(); + if (l2 != null) { + analyticsRoomLangs.add(l2); + } + return analyticsRoomLangs.toSet().toList(); + } + @override Widget build(BuildContext context) { return PLoadingStatusV2( diff --git a/lib/pangea/pages/analytics/student_analytics/student_analytics_view.dart b/lib/pangea/pages/analytics/student_analytics/student_analytics_view.dart index 5b8924581..6ea754891 100644 --- a/lib/pangea/pages/analytics/student_analytics/student_analytics_view.dart +++ b/lib/pangea/pages/analytics/student_analytics/student_analytics_view.dart @@ -59,6 +59,7 @@ class StudentAnalyticsView extends StatelessWidget { AnalyticsEntryType.student, L10n.of(context)!.allChatsAndClasses, ), + targetLanguages: controller.targetLanguages, ) : const SizedBox(); } From a7e1dbc85f770534c5a7e7f8d34351e0ea753551 Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Thu, 27 Jun 2024 12:57:39 -0400 Subject: [PATCH 26/30] remove mysterious auto generated files --- .../widgets/start_igc_button 2.dart | 168 ------------------ .../controllers/span_data_controller 2.dart | 89 ---------- .../room_capacity_button 2.dart | 157 ---------------- lib/utils/voip/video_renderer 2.dart | 86 --------- 4 files changed, 500 deletions(-) delete mode 100644 lib/pangea/choreographer/widgets/start_igc_button 2.dart delete mode 100644 lib/pangea/controllers/span_data_controller 2.dart delete mode 100644 lib/pangea/pages/class_settings/p_class_widgets/room_capacity_button 2.dart delete mode 100644 lib/utils/voip/video_renderer 2.dart diff --git a/lib/pangea/choreographer/widgets/start_igc_button 2.dart b/lib/pangea/choreographer/widgets/start_igc_button 2.dart deleted file mode 100644 index ceb5af193..000000000 --- a/lib/pangea/choreographer/widgets/start_igc_button 2.dart +++ /dev/null @@ -1,168 +0,0 @@ -import 'dart:async'; -import 'dart:math' as math; - -import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart'; -import 'package:fluffychat/pangea/constants/colors.dart'; -import 'package:fluffychat/pangea/controllers/subscription_controller.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/l10n.dart'; - -import '../../../pages/chat/chat.dart'; - -class StartIGCButton extends StatefulWidget { - const StartIGCButton({ - super.key, - required this.controller, - }); - - final ChatController controller; - - @override - State createState() => StartIGCButtonState(); -} - -class StartIGCButtonState extends State - with SingleTickerProviderStateMixin { - AssistanceState get assistanceState => - widget.controller.choreographer.assistanceState; - AnimationController? _controller; - StreamSubscription? choreoListener; - AssistanceState? prevState; - - @override - void initState() { - _controller = AnimationController( - vsync: this, - duration: const Duration(seconds: 2), - ); - choreoListener = widget.controller.choreographer.stateListener.stream - .listen(updateSpinnerState); - super.initState(); - } - - void updateSpinnerState(_) { - if (prevState != AssistanceState.fetching && - assistanceState == AssistanceState.fetching) { - _controller?.repeat(); - } else if (prevState == AssistanceState.fetching && - assistanceState != AssistanceState.fetching) { - _controller?.stop(); - _controller?.reverse(); - } - setState(() => prevState = assistanceState); - } - - @override - Widget build(BuildContext context) { - final bool itEnabled = widget.controller.choreographer.itEnabled; - final bool igcEnabled = widget.controller.choreographer.igcEnabled; - final CanSendStatus canSendStatus = - widget.controller.pangeaController.subscriptionController.canSendStatus; - final bool grammarCorrectionEnabled = - (itEnabled || igcEnabled) && canSendStatus == CanSendStatus.subscribed; - - if (!grammarCorrectionEnabled || - widget.controller.choreographer.isAutoIGCEnabled || - widget.controller.choreographer.choreoMode == ChoreoMode.it) { - return const SizedBox.shrink(); - } - - final Widget icon = Icon( - Icons.autorenew_rounded, - size: 46, - color: assistanceState.stateColor(context), - ); - - return SizedBox( - height: 50, - width: 50, - child: FloatingActionButton( - tooltip: assistanceState.tooltip( - L10n.of(context)!, - ), - backgroundColor: Theme.of(context).scaffoldBackgroundColor, - disabledElevation: 0, - shape: const CircleBorder(), - onPressed: () { - if (assistanceState != AssistanceState.complete) { - widget.controller.choreographer - .getLanguageHelp( - false, - true, - ) - .then((_) { - if (widget.controller.choreographer.igc.igcTextData != null && - widget.controller.choreographer.igc.igcTextData!.matches - .isNotEmpty) { - widget.controller.choreographer.igc.showFirstMatch(context); - } - }); - } - }, - child: Stack( - alignment: Alignment.center, - children: [ - _controller != null - ? RotationTransition( - turns: Tween(begin: 0.0, end: math.pi * 2) - .animate(_controller!), - child: icon, - ) - : icon, - Container( - width: 26, - height: 26, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Theme.of(context).scaffoldBackgroundColor, - ), - ), - Container( - width: 20, - height: 20, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: assistanceState.stateColor(context), - ), - ), - Icon( - size: 16, - Icons.check, - color: Theme.of(context).scaffoldBackgroundColor, - ), - ], - ), - ), - ); - } -} - -extension AssistanceStateExtension on AssistanceState { - Color stateColor(context) { - switch (this) { - case AssistanceState.noMessage: - case AssistanceState.notFetched: - case AssistanceState.fetching: - return Theme.of(context).colorScheme.primary; - case AssistanceState.fetched: - return PangeaColors.igcError; - case AssistanceState.complete: - return AppConfig.success; - } - } - - String tooltip(L10n l10n) { - switch (this) { - case AssistanceState.noMessage: - case AssistanceState.notFetched: - return l10n.runGrammarCorrection; - case AssistanceState.fetching: - return ""; - case AssistanceState.fetched: - return l10n.grammarCorrectionFailed; - case AssistanceState.complete: - return l10n.grammarCorrectionComplete; - } - } -} diff --git a/lib/pangea/controllers/span_data_controller 2.dart b/lib/pangea/controllers/span_data_controller 2.dart deleted file mode 100644 index 5f83f1a53..000000000 --- a/lib/pangea/controllers/span_data_controller 2.dart +++ /dev/null @@ -1,89 +0,0 @@ -import 'dart:async'; -import 'dart:developer'; - -import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart'; -import 'package:fluffychat/pangea/models/span_data.dart'; -import 'package:fluffychat/pangea/repo/span_data_repo.dart'; -import 'package:fluffychat/pangea/utils/error_handler.dart'; -import 'package:flutter/foundation.dart'; - -class _SpanDetailsCacheItem { - Future data; - - _SpanDetailsCacheItem({required this.data}); -} - -class SpanDataController { - late Choreographer choreographer; - final Map _cache = {}; - Timer? _cacheClearTimer; - - SpanDataController(this.choreographer) { - _initializeCacheClearing(); - } - - void _initializeCacheClearing() { - const duration = Duration(minutes: 2); - _cacheClearTimer = Timer.periodic(duration, (Timer t) => clearCache()); - } - - void clearCache() { - _cache.clear(); - } - - void dispose() { - _cacheClearTimer?.cancel(); - } - - Future getSpanDetails(int matchIndex) async { - if (choreographer.igc.igcTextData == null || - choreographer.igc.igcTextData!.matches.isEmpty || - matchIndex < 0 || - matchIndex >= choreographer.igc.igcTextData!.matches.length) { - debugger(when: kDebugMode); - return; - } - - /// Retrieves the span data from the `igcTextData` matches at the specified `matchIndex`. - /// Creates a `SpanDetailsRepoReqAndRes` object with the retrieved span data and other parameters. - /// Generates a cache key based on the created `SpanDetailsRepoReqAndRes` object. - final SpanData span = - choreographer.igc.igcTextData!.matches[matchIndex].match; - final req = SpanDetailsRepoReqAndRes( - userL1: choreographer.l1LangCode!, - userL2: choreographer.l2LangCode!, - enableIGC: choreographer.igcEnabled, - enableIT: choreographer.itEnabled, - span: span, - ); - final int cacheKey = req.hashCode; - - /// Retrieves the [SpanDetailsRepoReqAndRes] response from the cache if it exists, - /// otherwise makes an API call to get the response and stores it in the cache. - Future response; - if (_cache.containsKey(cacheKey)) { - response = _cache[cacheKey]!.data; - } else { - response = SpanDataRepo.getSpanDetails( - await choreographer.accessToken, - request: SpanDetailsRepoReqAndRes( - userL1: choreographer.l1LangCode!, - userL2: choreographer.l2LangCode!, - enableIGC: choreographer.igcEnabled, - enableIT: choreographer.itEnabled, - span: span, - ), - ); - _cache[cacheKey] = _SpanDetailsCacheItem(data: response); - } - - try { - choreographer.igc.igcTextData!.matches[matchIndex].match = - (await response).span; - } catch (err, s) { - ErrorHandler.logError(e: err, s: s); - } - - choreographer.setState(); - } -} diff --git a/lib/pangea/pages/class_settings/p_class_widgets/room_capacity_button 2.dart b/lib/pangea/pages/class_settings/p_class_widgets/room_capacity_button 2.dart deleted file mode 100644 index 7be6e8ec3..000000000 --- a/lib/pangea/pages/class_settings/p_class_widgets/room_capacity_button 2.dart +++ /dev/null @@ -1,157 +0,0 @@ -import 'package:adaptive_dialog/adaptive_dialog.dart'; -import 'package:fluffychat/pages/chat_details/chat_details.dart'; -import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:future_loading_dialog/future_loading_dialog.dart'; -import 'package:matrix/matrix.dart'; - -class RoomCapacityButton extends StatefulWidget { - final Room? room; - final ChatDetailsController? controller; - const RoomCapacityButton({ - super.key, - this.room, - this.controller, - }); - - @override - RoomCapacityButtonState createState() => RoomCapacityButtonState(); -} - -class RoomCapacityButtonState extends State { - int? capacity; - String? nonAdmins; - - RoomCapacityButtonState({Key? key}); - - @override - void initState() { - super.initState(); - capacity = widget.room?.capacity; - widget.room?.numNonAdmins.then( - (value) => setState(() { - nonAdmins = value.toString(); - overCapacity(); - }), - ); - } - - @override - void didUpdateWidget(RoomCapacityButton oldWidget) { - super.didUpdateWidget(oldWidget); - if (oldWidget.room != widget.room) { - capacity = widget.room?.capacity; - widget.room?.numNonAdmins.then( - (value) => setState(() { - nonAdmins = value.toString(); - overCapacity(); - }), - ); - } - } - - Future overCapacity() async { - if ((widget.room?.isRoomAdmin ?? false) && - capacity != null && - nonAdmins != null && - int.parse(nonAdmins!) > capacity!) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - L10n.of(context)!.roomExceedsCapacity, - ), - ), - ); - } - } - - @override - Widget build(BuildContext context) { - final iconColor = Theme.of(context).textTheme.bodyLarge!.color; - return Column( - children: [ - ListTile( - onTap: (widget.room?.isRoomAdmin ?? true) ? setRoomCapacity : null, - leading: CircleAvatar( - backgroundColor: Theme.of(context).scaffoldBackgroundColor, - foregroundColor: iconColor, - child: const Icon(Icons.reduce_capacity), - ), - subtitle: Text( - (capacity == null) - ? L10n.of(context)!.capacityNotSet - : (nonAdmins != null) - ? '$nonAdmins/$capacity' - : '$capacity', - ), - title: Text( - L10n.of(context)!.roomCapacity, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ); - } - - Future setCapacity(int newCapacity) async { - capacity = newCapacity; - } - - Future setRoomCapacity() async { - final input = await showTextInputDialog( - context: context, - title: L10n.of(context)!.roomCapacity, - message: L10n.of(context)!.roomCapacityExplanation, - okLabel: L10n.of(context)!.ok, - cancelLabel: L10n.of(context)!.cancel, - textFields: [ - DialogTextField( - initialText: ((capacity != null) ? '$capacity' : ''), - keyboardType: TextInputType.number, - maxLength: 3, - validator: (value) { - if (value == null || - value.isEmpty || - int.tryParse(value) == null || - int.parse(value) < 0) { - return L10n.of(context)!.enterNumber; - } - if (nonAdmins != null && int.parse(value) < int.parse(nonAdmins!)) { - return L10n.of(context)!.capacitySetTooLow; - } - return null; - }, - ), - ], - ); - if (input == null || - input.first == "" || - int.tryParse(input.first) == null) { - return; - } - - final newCapacity = int.parse(input.first); - final success = await showFutureLoadingDialog( - context: context, - future: () => ((widget.room != null) - ? (widget.room!.updateRoomCapacity( - capacity = newCapacity, - )) - : setCapacity(newCapacity)), - ); - if (success.error == null) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - L10n.of(context)!.roomCapacityHasBeenChanged, - ), - ), - ); - setState(() {}); - } - } -} diff --git a/lib/utils/voip/video_renderer 2.dart b/lib/utils/voip/video_renderer 2.dart deleted file mode 100644 index 46171fdb5..000000000 --- a/lib/utils/voip/video_renderer 2.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; - -import 'package:flutter_webrtc/flutter_webrtc.dart'; -import 'package:matrix/matrix.dart'; - -class VideoRenderer extends StatefulWidget { - final WrappedMediaStream? stream; - final bool mirror; - final RTCVideoViewObjectFit fit; - - const VideoRenderer( - this.stream, { - this.mirror = false, - this.fit = RTCVideoViewObjectFit.RTCVideoViewObjectFitContain, - super.key, - }); - - @override - State createState() => _VideoRendererState(); -} - -class _VideoRendererState extends State { - RTCVideoRenderer? _renderer; - bool _rendererReady = false; - MediaStream? get mediaStream => widget.stream?.stream; - StreamSubscription? _streamChangeSubscription; - - Future _initializeRenderer() async { - _renderer ??= RTCVideoRenderer(); - await _renderer!.initialize(); - _renderer!.srcObject = mediaStream; - return _renderer!; - } - - void disposeRenderer() { - try { - _renderer?.srcObject = null; - _renderer?.dispose(); - _renderer = null; - // ignore: empty_catches - } catch (e) {} - } - - @override - void initState() { - _streamChangeSubscription = - widget.stream?.onStreamChanged.stream.listen((stream) { - setState(() { - _renderer?.srcObject = stream; - }); - }); - setupRenderer(); - super.initState(); - } - - Future setupRenderer() async { - await _initializeRenderer(); - setState(() => _rendererReady = true); - } - - @override - void dispose() { - _streamChangeSubscription?.cancel(); - disposeRenderer(); - super.dispose(); - } - - @override - Widget build(BuildContext context) => !_rendererReady - ? Container() - : Builder( - key: widget.key, - builder: (ctx) { - return RTCVideoView( - _renderer!, - mirror: widget.mirror, - filterQuality: FilterQuality.medium, - objectFit: widget.fit, - placeholderBuilder: (_) => - Container(color: Colors.white.withOpacity(0.18)), - ); - }, - ); -} From ac0031d4915d34250c2945b8c49e2fb35f5db80b Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Thu, 27 Jun 2024 13:11:18 -0400 Subject: [PATCH 27/30] remove more mysterious files --- .../.gradle/6.7.1/fileHashes/fileHashes.lock | Bin 17 -> 39 bytes .../buildOutputCleanup/buildOutputCleanup.lock | Bin 17 -> 39 bytes .../android/.gradle/checksums/checksums.lock | Bin 17 -> 39 bytes sentry 2.properties | 6 ------ 4 files changed, 6 deletions(-) delete mode 100644 sentry 2.properties diff --git a/pangea_packages/fcm_shared_isolate/android/.gradle/6.7.1/fileHashes/fileHashes.lock b/pangea_packages/fcm_shared_isolate/android/.gradle/6.7.1/fileHashes/fileHashes.lock index 7cb52b3f842396598d593e360f52c43265089f07..f1facd8351bcedf036c6985ed1ac7b5c21ff1f87 100644 GIT binary patch literal 39 qcmZQ(pPrsFC-<%*0|YQLGcepv|Nb(2y-ILJJp-$ufrX_x0|Nlj?+P*i literal 17 UcmZQ(pPrsFC-<%*0|YPw04fjzcK`qY diff --git a/pangea_packages/fcm_shared_isolate/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/pangea_packages/fcm_shared_isolate/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 487a88833085c25d183c663046ee06e3b9888272..ea7da199a9aab10e1551a086bd1892ebf1cea816 100644 GIT binary patch literal 39 qcmZQ}bn=zC_JSdv0Rm*085nM-N1x~La=fsziGkJ7z{1j;fdK%xu?aK) literal 17 TcmZQ}bn=zC_JSdv0Rm(IB}W4( diff --git a/pangea_packages/fcm_shared_isolate/android/.gradle/checksums/checksums.lock b/pangea_packages/fcm_shared_isolate/android/.gradle/checksums/checksums.lock index b99989c33f39a2bacad6d6ee7ad3244b27d3a856..a148f5b0ee85072228e5cdc5e1edaa30a4ae84ab 100644 GIT binary patch literal 39 scmZSnAb4*|_KHR73}C?S%gn%VJ6-3|)`{1Oo98gF8X8zwnlmr}0Q(>dwg3PC literal 17 VcmZSnAb4*|_KHR73}C?S3jjDZ1g8K1 diff --git a/sentry 2.properties b/sentry 2.properties deleted file mode 100644 index 876598ba5..000000000 --- a/sentry 2.properties +++ /dev/null @@ -1,6 +0,0 @@ -upload_debug_symbols=true -upload_source_maps=true -upload_sources=true -wait_for_processing=false -log_level=info -commits=auto From bc2d4a38471536136f6f56b0351ad2180d9dfdd3 Mon Sep 17 00:00:00 2001 From: Matthew <119624750+casualWaist@users.noreply.github.com> Date: Wed, 26 Jun 2024 16:21:57 -0400 Subject: [PATCH 28/30] itAutoPlay moved from ToolSettings to PLocalKey --- .../controllers/choreographer.dart | 8 +-- lib/pangea/constants/local.key.dart | 1 + lib/pangea/controllers/local_settings.dart | 3 +- lib/pangea/controllers/user_controller.dart | 18 +++---- lib/pangea/models/class_model.dart | 51 +++++++------------ lib/pangea/models/user_model.dart | 6 +-- .../settings_learning_view.dart | 10 ++++ lib/pangea/widgets/igc/span_card.dart | 4 +- 8 files changed, 48 insertions(+), 53 deletions(-) diff --git a/lib/pangea/choreographer/controllers/choreographer.dart b/lib/pangea/choreographer/controllers/choreographer.dart index 529ba95b4..5921c6eb7 100644 --- a/lib/pangea/choreographer/controllers/choreographer.dart +++ b/lib/pangea/choreographer/controllers/choreographer.dart @@ -15,6 +15,7 @@ import 'package:fluffychat/pangea/models/class_model.dart'; import 'package:fluffychat/pangea/models/it_step.dart'; import 'package:fluffychat/pangea/models/representation_content_model.dart'; import 'package:fluffychat/pangea/models/tokens_event_content_model.dart'; +import 'package:fluffychat/pangea/models/user_model.dart'; import 'package:fluffychat/pangea/utils/any_state_holder.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart'; import 'package:fluffychat/pangea/utils/overlay.dart'; @@ -513,10 +514,9 @@ class Choreographer { chatController.room, ); - bool get itAutoPlayEnabled => pangeaController.permissionsController.isToolEnabled( - ToolSetting.itAutoPlay, - chatController.room, - ); + bool get itAutoPlayEnabled => pangeaController.pStoreService.read( + MatrixProfile.itAutoPlay.title, + ) ?? false; bool get definitionsEnabled => pangeaController.permissionsController.isToolEnabled( diff --git a/lib/pangea/constants/local.key.dart b/lib/pangea/constants/local.key.dart index c0390c2ba..8dc496bf8 100644 --- a/lib/pangea/constants/local.key.dart +++ b/lib/pangea/constants/local.key.dart @@ -11,4 +11,5 @@ class PLocalKey { static const String dismissedPaywall = 'dismissedPaywall'; static const String paywallBackoff = 'paywallBackoff'; static const String autoPlayMessages = 'autoPlayMessages'; + static const String itAutoPlay = 'itAutoPlay'; } diff --git a/lib/pangea/controllers/local_settings.dart b/lib/pangea/controllers/local_settings.dart index d6ae119a5..5984a7bf5 100644 --- a/lib/pangea/controllers/local_settings.dart +++ b/lib/pangea/controllers/local_settings.dart @@ -9,8 +9,7 @@ class LocalSettings { } bool userLanguageToolSetting(ToolSetting setting) => - _pangeaController.pStoreService.read(setting.toString()) - ?? setting != ToolSetting.itAutoPlay; + _pangeaController.pStoreService.read(setting.toString()) ?? true; // bool get userEnableIT => // _pangeaController.pStoreService.read(ToolSetting.interactiveTranslator.toString()) ?? true; diff --git a/lib/pangea/controllers/user_controller.dart b/lib/pangea/controllers/user_controller.dart index 0e336fdf6..31cde897f 100644 --- a/lib/pangea/controllers/user_controller.dart +++ b/lib/pangea/controllers/user_controller.dart @@ -123,10 +123,10 @@ class UserController extends BaseController { : null; final bool? autoPlay = migratedProfileInfo(MatrixProfile.autoPlayMessages); + final bool? itAutoPlay = migratedProfileInfo(MatrixProfile.itAutoPlay); final bool? trial = migratedProfileInfo(MatrixProfile.activatedFreeTrial); final bool? interactiveTranslator = migratedProfileInfo(MatrixProfile.interactiveTranslator); - final bool? itAutoPlay = migratedProfileInfo(MatrixProfile.itAutoPlay); final bool? interactiveGrammar = migratedProfileInfo(MatrixProfile.interactiveGrammar); final bool? immersionMode = @@ -143,9 +143,9 @@ class UserController extends BaseController { await updateMatrixProfile( dateOfBirth: dob, autoPlayMessages: autoPlay, + itAutoPlay: itAutoPlay, activatedFreeTrial: trial, interactiveTranslator: interactiveTranslator, - itAutoPlay: itAutoPlay, interactiveGrammar: interactiveGrammar, immersionMode: immersionMode, definitions: definitions, @@ -225,9 +225,9 @@ class UserController extends BaseController { Future updateMatrixProfile({ String? dateOfBirth, bool? autoPlayMessages, + bool? itAutoPlay, bool? activatedFreeTrial, bool? interactiveTranslator, - bool? itAutoPlay, bool? interactiveGrammar, bool? immersionMode, bool? definitions, @@ -253,6 +253,12 @@ class UserController extends BaseController { autoPlayMessages, ); } + if (itAutoPlay != null) { + await _pangeaController.pStoreService.save( + MatrixProfile.itAutoPlay.title, + itAutoPlay, + ); + } if (activatedFreeTrial != null) { await _pangeaController.pStoreService.save( MatrixProfile.activatedFreeTrial.title, @@ -265,12 +271,6 @@ class UserController extends BaseController { interactiveTranslator, ); } - if (itAutoPlay != null) { - await _pangeaController.pStoreService.save( - MatrixProfile.itAutoPlay.title, - itAutoPlay, - ); - } if (interactiveGrammar != null) { await _pangeaController.pStoreService.save( MatrixProfile.interactiveGrammar.title, diff --git a/lib/pangea/models/class_model.dart b/lib/pangea/models/class_model.dart index f663af8ce..0bebdac2f 100644 --- a/lib/pangea/models/class_model.dart +++ b/lib/pangea/models/class_model.dart @@ -31,13 +31,13 @@ class ClassSettingsModel { }); static ClassSettingsModel get newClass => ClassSettingsModel( - city: null, - country: null, - dominantLanguage: ClassDefaultValues.defaultDominantLanguage, - languageLevel: null, - schoolName: null, - targetLanguage: ClassDefaultValues.defaultTargetLanguage, - ); + city: null, + country: null, + dominantLanguage: ClassDefaultValues.defaultDominantLanguage, + languageLevel: null, + schoolName: null, + targetLanguage: ClassDefaultValues.defaultTargetLanguage, + ); factory ClassSettingsModel.fromJson(Map json) { return ClassSettingsModel( @@ -100,9 +100,9 @@ class ClassSettingsModel { } StateEvent get toStateEvent => StateEvent( - content: toJson(), - type: PangeaEventTypes.classSettings, - ); + content: toJson(), + type: PangeaEventTypes.classSettings, + ); } class PangeaRoomRules { @@ -120,7 +120,6 @@ class PangeaRoomRules { bool isInviteOnlyStudents; // 0 = forbidden, 1 = allow individual to choose, 2 = require int interactiveTranslator; - int itAutoPlay; int interactiveGrammar; int immersionMode; int definitions; @@ -139,7 +138,6 @@ class PangeaRoomRules { this.isVoiceNotes = true, this.isInviteOnlyStudents = true, this.interactiveTranslator = ClassDefaultValues.languageToolPermissions, - this.itAutoPlay = ClassDefaultValues.languageToolPermissions, this.interactiveGrammar = ClassDefaultValues.languageToolPermissions, this.immersionMode = ClassDefaultValues.languageToolPermissions, this.definitions = ClassDefaultValues.languageToolPermissions, @@ -191,9 +189,6 @@ class PangeaRoomRules { case ToolSetting.interactiveTranslator: interactiveTranslator = value; break; - case ToolSetting.itAutoPlay: - itAutoPlay = value; - break; case ToolSetting.interactiveGrammar: interactiveGrammar = value; break; @@ -212,9 +207,9 @@ class PangeaRoomRules { } StateEvent get toStateEvent => StateEvent( - content: toJson(), - type: PangeaEventTypes.rules, - ); + content: toJson(), + type: PangeaEventTypes.rules, + ); factory PangeaRoomRules.fromJson(Map json) => PangeaRoomRules( @@ -232,16 +227,14 @@ class PangeaRoomRules { isInviteOnlyStudents: json['is_invite_only_students'] ?? true, interactiveTranslator: json['interactive_translator'] ?? ClassDefaultValues.languageToolPermissions, - itAutoPlay: json['it_auto_play'] ?? - ClassDefaultValues.languageToolPermissions, interactiveGrammar: json['interactive_grammar'] ?? ClassDefaultValues.languageToolPermissions, immersionMode: json['immersion_mode'] ?? ClassDefaultValues.languageToolPermissions, definitions: - json['definitions'] ?? ClassDefaultValues.languageToolPermissions, + json['definitions'] ?? ClassDefaultValues.languageToolPermissions, translations: - json['translations'] ?? ClassDefaultValues.languageToolPermissions, + json['translations'] ?? ClassDefaultValues.languageToolPermissions, ); Map toJson() { @@ -259,7 +252,6 @@ class PangeaRoomRules { data['is_voice_notes'] = isVoiceNotes; data['is_invite_only_students'] = isInviteOnlyStudents; data['interactive_translator'] = interactiveTranslator; - data['it_auto_play'] = itAutoPlay; data['interactive_grammar'] = interactiveGrammar; data['immersion_mode'] = immersionMode; data['definitions'] = definitions; @@ -271,8 +263,6 @@ class PangeaRoomRules { switch (setting) { case ToolSetting.interactiveTranslator: return interactiveTranslator; - case ToolSetting.itAutoPlay: - return itAutoPlay; case ToolSetting.interactiveGrammar: return interactiveGrammar; case ToolSetting.immersionMode: @@ -287,9 +277,9 @@ class PangeaRoomRules { } String languageToolPermissionsText( - BuildContext context, - ToolSetting setting, - ) { + BuildContext context, + ToolSetting setting, + ) { switch (getToolSettings(setting)) { case 0: return L10n.of(context)!.interactiveTranslatorNotAllowed; @@ -305,7 +295,6 @@ class PangeaRoomRules { enum ToolSetting { interactiveTranslator, - itAutoPlay, interactiveGrammar, immersionMode, definitions, @@ -317,8 +306,6 @@ extension SettingCopy on ToolSetting { switch (this) { case ToolSetting.interactiveTranslator: return L10n.of(context)!.interactiveTranslatorSliderHeader; - case ToolSetting.itAutoPlay: - return L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader; case ToolSetting.interactiveGrammar: return L10n.of(context)!.interactiveGrammarSliderHeader; case ToolSetting.immersionMode: @@ -337,8 +324,6 @@ extension SettingCopy on ToolSetting { return L10n.of(context)!.itToggleDescription; case ToolSetting.interactiveGrammar: return L10n.of(context)!.igcToggleDescription; - case ToolSetting.itAutoPlay: - return L10n.of(context)!.interactiveTranslatorAutoPlayDesc; case ToolSetting.immersionMode: return L10n.of(context)!.toggleImmersionModeDesc; case ToolSetting.definitions: diff --git a/lib/pangea/models/user_model.dart b/lib/pangea/models/user_model.dart index 396bcaccb..3721da95c 100644 --- a/lib/pangea/models/user_model.dart +++ b/lib/pangea/models/user_model.dart @@ -54,9 +54,9 @@ class PUserModel { enum MatrixProfile { dateOfBirth, autoPlayMessages, + itAutoPlay, activatedFreeTrial, interactiveTranslator, - itAutoPlay, interactiveGrammar, immersionMode, definitions, @@ -78,12 +78,12 @@ extension MatrixProfileExtension on MatrixProfile { return ModelKey.userDateOfBirth; case MatrixProfile.autoPlayMessages: return PLocalKey.autoPlayMessages; + case MatrixProfile.itAutoPlay: + return PLocalKey.itAutoPlay; case MatrixProfile.activatedFreeTrial: return PLocalKey.activatedTrialKey; case MatrixProfile.interactiveTranslator: return ToolSetting.interactiveTranslator.toString(); - case MatrixProfile.itAutoPlay: - return ToolSetting.itAutoPlay.toString(); case MatrixProfile.interactiveGrammar: return ToolSetting.interactiveGrammar.toString(); case MatrixProfile.immersionMode: diff --git a/lib/pangea/pages/settings_learning/settings_learning_view.dart b/lib/pangea/pages/settings_learning/settings_learning_view.dart index 6c3a87f00..207600497 100644 --- a/lib/pangea/pages/settings_learning/settings_learning_view.dart +++ b/lib/pangea/pages/settings_learning/settings_learning_view.dart @@ -61,6 +61,16 @@ class SettingsLearningView extends StatelessWidget { pStoreKey: setting.toString(), local: false, ), + PSettingsSwitchListTile.adaptive( + defaultValue: controller.pangeaController.pStoreService.read( + PLocalKey.itAutoPlay, + ) ?? + false, + title: L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader, + subtitle: L10n.of(context)!.interactiveTranslatorAutoPlayDesc, + pStoreKey: PLocalKey.itAutoPlay, + local: false, + ), PSettingsSwitchListTile.adaptive( defaultValue: controller.pangeaController.pStoreService.read( PLocalKey.autoPlayMessages, diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index 75738a687..1f31ea07f 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -1,6 +1,7 @@ import 'dart:developer'; import 'package:fluffychat/config/app_config.dart'; +import 'package:fluffychat/pangea/constants/local.key.dart'; import 'package:fluffychat/pangea/enum/span_data_type.dart'; import 'package:fluffychat/pangea/models/span_data.dart'; import 'package:fluffychat/pangea/utils/bot_style.dart'; @@ -15,7 +16,6 @@ import '../../../widgets/matrix.dart'; import '../../choreographer/widgets/choice_array.dart'; import '../../controllers/pangea_controller.dart'; import '../../enum/span_choice_type.dart'; -import '../../models/class_model.dart'; import '../../models/span_card_model.dart'; import '../common/bot_face_svg.dart'; import 'card_header.dart'; @@ -472,7 +472,7 @@ class DontShowSwitchListTileState extends State { value: switchValue, onChanged: (value) => { widget.controller.pStoreService.save( - ToolSetting.itAutoPlay.toString(), + PLocalKey.itAutoPlay.toString(), value, ), setState(() => switchValue = value), From c8079b7df1b67699cddb918773dd20302b4177c2 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 28 Jun 2024 12:16:19 -0400 Subject: [PATCH 29/30] commented out postframe callback around showing toolbar to prevent delay in showing toolbar after message tap --- lib/pangea/widgets/chat/message_toolbar.dart | 103 ++++++++++--------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index 2468d6b96..dda1fd01c 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -94,59 +94,62 @@ class ToolbarDisplayController { previousEvent: previousEvent, ); - WidgetsBinding.instance.addPostFrameCallback((timeStamp) { - Widget overlayEntry; - if (toolbar == null) return; - try { - overlayEntry = Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: pangeaMessageEvent.ownMessage - ? CrossAxisAlignment.end - : CrossAxisAlignment.start, - children: [ - toolbarUp ? toolbar! : overlayMessage, - const SizedBox(height: 6), - toolbarUp ? overlayMessage : toolbar!, - ], - ); - } catch (err) { - debugger(when: kDebugMode); - ErrorHandler.logError(e: err, s: StackTrace.current); - return; - } - - OverlayUtil.showOverlay( - context: context, - child: overlayEntry, - transformTargetId: targetId, - targetAnchor: pangeaMessageEvent.ownMessage - ? toolbarUp - ? Alignment.bottomRight - : Alignment.topRight - : toolbarUp - ? Alignment.bottomLeft - : Alignment.topLeft, - followerAnchor: pangeaMessageEvent.ownMessage - ? toolbarUp - ? Alignment.bottomRight - : Alignment.topRight - : toolbarUp - ? Alignment.bottomLeft - : Alignment.topLeft, - backgroundColor: const Color.fromRGBO(0, 0, 0, 1).withAlpha(100), + // I'm not sure why I put this here, but it causes the toolbar + // not to open immediately after clicking (user has to scroll or move their cursor) + // so I'm commenting it out for now + // WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + Widget overlayEntry; + if (toolbar == null) return; + try { + overlayEntry = Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: pangeaMessageEvent.ownMessage + ? CrossAxisAlignment.end + : CrossAxisAlignment.start, + children: [ + toolbarUp ? toolbar! : overlayMessage, + const SizedBox(height: 6), + toolbarUp ? overlayMessage : toolbar!, + ], ); + } catch (err) { + debugger(when: kDebugMode); + ErrorHandler.logError(e: err, s: StackTrace.current); + return; + } - if (MatrixState.pAnyState.entries.isNotEmpty) { - overlayId = MatrixState.pAnyState.entries.last.hashCode.toString(); - } + OverlayUtil.showOverlay( + context: context, + child: overlayEntry, + transformTargetId: targetId, + targetAnchor: pangeaMessageEvent.ownMessage + ? toolbarUp + ? Alignment.bottomRight + : Alignment.topRight + : toolbarUp + ? Alignment.bottomLeft + : Alignment.topLeft, + followerAnchor: pangeaMessageEvent.ownMessage + ? toolbarUp + ? Alignment.bottomRight + : Alignment.topRight + : toolbarUp + ? Alignment.bottomLeft + : Alignment.topLeft, + backgroundColor: const Color.fromRGBO(0, 0, 0, 1).withAlpha(100), + ); - if (mode != null) { - Future.delayed( - const Duration(milliseconds: 100), - () => toolbarModeStream.add(mode), - ); - } - }); + if (MatrixState.pAnyState.entries.isNotEmpty) { + overlayId = MatrixState.pAnyState.entries.last.hashCode.toString(); + } + + if (mode != null) { + Future.delayed( + const Duration(milliseconds: 100), + () => toolbarModeStream.add(mode), + ); + } + // }); } bool get highlighted { From ccca876bb07392d6ce36dda395337e12b7c22020 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 28 Jun 2024 12:34:07 -0400 Subject: [PATCH 30/30] move _instructionsShown up to be the first check in instructions show function --- lib/pangea/utils/instructions.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pangea/utils/instructions.dart b/lib/pangea/utils/instructions.dart index d3a2b0ba0..ff0fea8f6 100644 --- a/lib/pangea/utils/instructions.dart +++ b/lib/pangea/utils/instructions.dart @@ -41,6 +41,11 @@ class InstructionsController { String transformTargetKey, [ bool showToggle = true, ]) async { + if (_instructionsShown[key] ?? false) { + return; + } + _instructionsShown[key] = true; + if (wereInstructionsTurnedOff(key)) { return; } @@ -51,9 +56,6 @@ class InstructionsController { ); return; } - if (_instructionsShown[key] ?? false) { - return; - } final bool userLangsSet = await _pangeaController.userController.areUserLanguagesSet; @@ -61,8 +63,6 @@ class InstructionsController { return; } - _instructionsShown[key] = true; - final botStyle = BotStyle.text(context); Future.delayed( const Duration(seconds: 1),