From cb5b92c94cb8646ad975e4e92e29e63495d2830e Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Wed, 15 May 2024 13:28:44 -0400 Subject: [PATCH 01/40] implement bot preset select --- assets/l10n/intl_en.arb | 7 +- lib/pangea/constants/model_keys.dart | 2 + lib/pangea/models/bot_options_model.dart | 6 + .../conversation_bot_mode_select.dart | 78 ++++ .../conversation_bot_settings.dart | 111 +++-- needed-translations.txt | 384 +++++++++++++++--- 6 files changed, 495 insertions(+), 93 deletions(-) create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 41eeb498d..cb3375244 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3945,5 +3945,10 @@ "accuracy": "Accuracy", "points": "Points", "noPaymentInfo": "No payment info necessary!", - "updatePhoneOS": "You may need to update your device's OS version." + "updatePhoneOS": "You may need to update your device's OS version.", + "conversationBotPresetSelectDescription": "Bot preset", + "conversationBotPresetSelectOption_discussion": "Discussion", + "conversationBotPresetSelectOption_custom": "Custom", + "conversationBotPresetSelectOption_conversation": "Conversation", + "conversationBotPresetSelectOption_textAdventure": "Text Adventure" } \ No newline at end of file diff --git a/lib/pangea/constants/model_keys.dart b/lib/pangea/constants/model_keys.dart index dd9764fb9..a3d54a408 100644 --- a/lib/pangea/constants/model_keys.dart +++ b/lib/pangea/constants/model_keys.dart @@ -99,4 +99,6 @@ class ModelKey { static const String conversationTopic = "conversation_topic"; static const String keywords = "keywords"; static const String safetyModeration = "safety_moderation"; + static const String preset = "preset"; + static const String custom = "custom"; } diff --git a/lib/pangea/models/bot_options_model.dart b/lib/pangea/models/bot_options_model.dart index 0cba5fd78..041c4f0d3 100644 --- a/lib/pangea/models/bot_options_model.dart +++ b/lib/pangea/models/bot_options_model.dart @@ -12,12 +12,16 @@ class BotOptionsModel { String topic; List keywords; bool safetyModeration; + String preset; + String? custom; BotOptionsModel({ this.languageLevel, this.topic = "General Conversation", this.keywords = const [], this.safetyModeration = true, + this.preset = "discussion", + this.custom = "", }); factory BotOptionsModel.fromJson(json) { @@ -26,6 +30,8 @@ class BotOptionsModel { topic: json[ModelKey.conversationTopic] ?? "General Conversation", keywords: (json[ModelKey.keywords] ?? []).cast(), safetyModeration: json[ModelKey.safetyModeration] ?? true, + preset: json[ModelKey.preset] ?? "discussion", + custom: json[ModelKey.custom], ); } diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart new file mode 100644 index 000000000..410d8a503 --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart @@ -0,0 +1,78 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; + +class ConversationBotPresetSelect extends StatelessWidget { + final String? initialMode; + final void Function(String?)? onChanged; + + const ConversationBotPresetSelect({ + super.key, + this.initialMode, + this.onChanged, + }); + + @override + Widget build(BuildContext context) { + final Map options = { + "discussion": + L10n.of(context)!.conversationBotPresetSelectOption_discussion, + "custom": L10n.of(context)!.conversationBotPresetSelectOption_custom, + "conversation": + L10n.of(context)!.conversationBotPresetSelectOption_conversation, + "text_adventure": + L10n.of(context)!.conversationBotPresetSelectOption_textAdventure, + }; + + return Padding( + padding: const EdgeInsets.all(12.0), + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: Theme.of(context).colorScheme.secondary, + width: 0.5, + ), + borderRadius: const BorderRadius.all(Radius.circular(10)), + ), + child: DropdownButton( + // Initial Value + hint: Padding( + padding: const EdgeInsets.only(left: 15), + child: Text( + options[initialMode ?? "discussion"]!, + style: const TextStyle().copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 14, + ), + overflow: TextOverflow.clip, + textAlign: TextAlign.center, + ), + ), + isExpanded: true, + underline: Container(), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + // Array list of items + items: [ + for (final entry in options.entries) + DropdownMenuItem( + value: entry.key, + child: Padding( + padding: const EdgeInsets.only(left: 15), + child: Text( + entry.value, + style: const TextStyle().copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 14, + ), + overflow: TextOverflow.clip, + textAlign: TextAlign.center, + ), + ), + ), + ], + onChanged: onChanged, + ), + ), + ); + } +} diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart index 0227c243a..fcaf11b60 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart @@ -1,10 +1,10 @@ import 'dart:developer'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:fluffychat/config/app_config.dart'; 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_select.dart'; import 'package:fluffychat/pangea/widgets/space/language_level_dropdown.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -156,49 +156,49 @@ class ConversationBotSettingsState extends State { ), ), if (addBot) ...[ - Padding( - padding: const EdgeInsets.only(left: 16), - child: ListTile( - onTap: () async { - final topic = await showTextInputDialog( - context: context, - textFields: [ - DialogTextField( - initialText: botOptions.topic.isEmpty - ? "" - : botOptions.topic, - hintText: - L10n.of(context)!.enterAConversationTopic, - ), - ], - title: L10n.of(context)!.conversationTopic, - ); - if (topic == null) return; - updateBotOption(() { - botOptions.topic = topic.single; - }); - }, - leading: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: - Theme.of(context).textTheme.bodyLarge!.color, - child: const Icon(Icons.topic_outlined), - ), - subtitle: Text( - botOptions.topic.isEmpty - ? L10n.of(context)!.enterAConversationTopic - : botOptions.topic, - ), - title: Text( - L10n.of(context)!.conversationTopic, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - ), - ), + // Padding( + // padding: const EdgeInsets.only(left: 16), + // child: ListTile( + // onTap: () async { + // final topic = await showTextInputDialog( + // context: context, + // textFields: [ + // DialogTextField( + // initialText: botOptions.topic.isEmpty + // ? "" + // : botOptions.topic, + // hintText: + // L10n.of(context)!.enterAConversationTopic, + // ), + // ], + // title: L10n.of(context)!.conversationTopic, + // ); + // if (topic == null) return; + // updateBotOption(() { + // botOptions.topic = topic.single; + // }); + // }, + // leading: CircleAvatar( + // backgroundColor: + // Theme.of(context).scaffoldBackgroundColor, + // foregroundColor: + // Theme.of(context).textTheme.bodyLarge!.color, + // child: const Icon(Icons.topic_outlined), + // ), + // subtitle: Text( + // botOptions.topic.isEmpty + // ? L10n.of(context)!.enterAConversationTopic + // : botOptions.topic, + // ), + // title: Text( + // L10n.of(context)!.conversationTopic, + // style: TextStyle( + // color: Theme.of(context).colorScheme.secondary, + // fontWeight: FontWeight.bold, + // ), + // ), + // ), + // ), // Padding( // padding: const EdgeInsets.only(left: 16), // child: SwitchListTile.adaptive( @@ -244,6 +244,29 @@ class ConversationBotSettingsState extends State { }), ), ), + Padding( + padding: const EdgeInsets.fromLTRB(32, 16, 0, 0), + child: Text( + L10n.of(context)! + .conversationBotPresetSelectDescription, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + ), + Padding( + padding: const EdgeInsets.only(left: 16), + child: ConversationBotPresetSelect( + initialMode: botOptions.preset, + onChanged: (String? preset) => updateBotOption( + () { + botOptions.preset = preset ?? "discussion"; + }, + ), + ), + ), const SizedBox(height: 16), ], ], diff --git a/needed-translations.txt b/needed-translations.txt index c93f52d05..3359206d2 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -820,7 +820,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "be": [ @@ -2239,7 +2245,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "bn": [ @@ -3120,7 +3132,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "bo": [ @@ -4001,7 +4019,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ca": [ @@ -4882,7 +4906,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "cs": [ @@ -5763,7 +5793,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "de": [ @@ -6591,7 +6627,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "el": [ @@ -7472,7 +7514,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "eo": [ @@ -8353,7 +8401,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "es": [ @@ -8382,7 +8436,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "et": [ @@ -9206,7 +9266,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "eu": [ @@ -10030,7 +10096,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "fa": [ @@ -10911,7 +10983,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "fi": [ @@ -11792,7 +11870,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "fr": [ @@ -12673,7 +12757,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ga": [ @@ -13554,7 +13644,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "gl": [ @@ -14378,7 +14474,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "he": [ @@ -15259,7 +15361,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "hi": [ @@ -16140,7 +16248,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "hr": [ @@ -17008,7 +17122,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "hu": [ @@ -17889,7 +18009,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ia": [ @@ -19294,7 +19420,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "id": [ @@ -20175,7 +20307,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ie": [ @@ -21056,7 +21194,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "it": [ @@ -21922,7 +22066,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ja": [ @@ -22803,7 +22953,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ko": [ @@ -23684,7 +23840,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "lt": [ @@ -24565,7 +24727,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "lv": [ @@ -25446,7 +25614,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "nb": [ @@ -26327,7 +26501,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "nl": [ @@ -27208,7 +27388,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "pl": [ @@ -28089,7 +28275,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "pt": [ @@ -28970,7 +29162,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "pt_BR": [ @@ -29820,7 +30018,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "pt_PT": [ @@ -30701,7 +30905,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ro": [ @@ -31582,7 +31792,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ru": [ @@ -32406,7 +32622,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "sk": [ @@ -33287,7 +33509,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "sl": [ @@ -34168,7 +34396,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "sr": [ @@ -35049,7 +35283,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "sv": [ @@ -35895,7 +36135,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "ta": [ @@ -36776,7 +37022,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "th": [ @@ -37657,7 +37909,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "tr": [ @@ -38523,7 +38781,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "uk": [ @@ -39347,7 +39611,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "vi": [ @@ -40228,7 +40498,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "zh": [ @@ -41052,7 +41328,13 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ], "zh_Hant": [ @@ -41933,6 +42215,12 @@ "score", "accuracy", "points", - "noPaymentInfo" + "noPaymentInfo", + "updatePhoneOS", + "conversationBotPresetSelectDescription", + "conversationBotPresetSelectOption_discussion", + "conversationBotPresetSelectOption_custom", + "conversationBotPresetSelectOption_conversation", + "conversationBotPresetSelectOption_textAdventure" ] } From 2cb33d7ce1a326f759c11efb005e5d0b11c378e3 Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Wed, 15 May 2024 15:14:44 -0400 Subject: [PATCH 02/40] implement dynamic zone with 4 modes --- assets/l10n/intl_en.arb | 10 +- lib/pangea/constants/model_keys.dart | 2 +- lib/pangea/models/bot_options_model.dart | 6 +- .../conversation_bot_conversation_zone.dart | 16 + .../conversation_bot_custom_zone.dart | 16 + .../conversation_bot_discussion_zone.dart | 16 + .../conversation_bot_mode_dynamic_zone.dart | 35 ++ .../conversation_bot_mode_select.dart | 12 +- .../conversation_bot_settings.dart | 18 +- .../conversation_bot_text_adventure_zone.dart | 16 + needed-translations.txt | 480 +++++++++--------- 11 files changed, 366 insertions(+), 261 deletions(-) create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_conversation_zone.dart create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index cb3375244..108462160 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3946,9 +3946,9 @@ "points": "Points", "noPaymentInfo": "No payment info necessary!", "updatePhoneOS": "You may need to update your device's OS version.", - "conversationBotPresetSelectDescription": "Bot preset", - "conversationBotPresetSelectOption_discussion": "Discussion", - "conversationBotPresetSelectOption_custom": "Custom", - "conversationBotPresetSelectOption_conversation": "Conversation", - "conversationBotPresetSelectOption_textAdventure": "Text Adventure" + "conversationBotModeSelectDescription": "Bot mode", + "conversationBotModeSelectOption_discussion": "Discussion", + "conversationBotModeSelectOption_custom": "Custom", + "conversationBotModeSelectOption_conversation": "Conversation", + "conversationBotModeSelectOption_textAdventure": "Text Adventure" } \ No newline at end of file diff --git a/lib/pangea/constants/model_keys.dart b/lib/pangea/constants/model_keys.dart index a3d54a408..163a92d8f 100644 --- a/lib/pangea/constants/model_keys.dart +++ b/lib/pangea/constants/model_keys.dart @@ -99,6 +99,6 @@ class ModelKey { static const String conversationTopic = "conversation_topic"; static const String keywords = "keywords"; static const String safetyModeration = "safety_moderation"; - static const String preset = "preset"; + static const String mode = "mode"; static const String custom = "custom"; } diff --git a/lib/pangea/models/bot_options_model.dart b/lib/pangea/models/bot_options_model.dart index 041c4f0d3..5038c58af 100644 --- a/lib/pangea/models/bot_options_model.dart +++ b/lib/pangea/models/bot_options_model.dart @@ -12,7 +12,7 @@ class BotOptionsModel { String topic; List keywords; bool safetyModeration; - String preset; + String mode; String? custom; BotOptionsModel({ @@ -20,7 +20,7 @@ class BotOptionsModel { this.topic = "General Conversation", this.keywords = const [], this.safetyModeration = true, - this.preset = "discussion", + this.mode = "discussion", this.custom = "", }); @@ -30,7 +30,7 @@ class BotOptionsModel { topic: json[ModelKey.conversationTopic] ?? "General Conversation", keywords: (json[ModelKey.keywords] ?? []).cast(), safetyModeration: json[ModelKey.safetyModeration] ?? true, - preset: json[ModelKey.preset] ?? "discussion", + mode: json[ModelKey.mode] ?? "discussion", custom: json[ModelKey.custom], ); } diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_conversation_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_conversation_zone.dart new file mode 100644 index 000000000..975cc1d0d --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_conversation_zone.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class ConversationBotConversationZone extends StatelessWidget { + const ConversationBotConversationZone({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return const Column( + children: [ + Text('Conversation Zone'), + ], + ); + } +} diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart new file mode 100644 index 000000000..5fe8880ea --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class ConversationBotCustomZone extends StatelessWidget { + const ConversationBotCustomZone({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return const Column( + children: [ + Text('Custom Zone'), + ], + ); + } +} diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart new file mode 100644 index 000000000..9e7449a11 --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class ConversationBotDiscussionZone extends StatelessWidget { + const ConversationBotDiscussionZone({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return const Column( + children: [ + Text('Discussion Zone'), + ], + ); + } +} 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 new file mode 100644 index 000000000..580dd060f --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart @@ -0,0 +1,35 @@ +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'; + +class ConversationBotModeDynamicZone extends StatelessWidget { + final String? mode; + + const ConversationBotModeDynamicZone({ + super.key, + this.mode, + }); + + @override + Widget build(BuildContext context) { + final zoneMap = { + 'discussion': const ConversationBotDiscussionZone(), + "custom": const ConversationBotCustomZone(), + "conversation": const ConversationBotConversationZone(), + "text_adventure": const ConversationBotTextAdventureZone(), + }; + return Container( + decoration: BoxDecoration( + border: Border.all( + color: Theme.of(context).colorScheme.secondary, + width: 0.5, + ), + borderRadius: const BorderRadius.all(Radius.circular(10)), + ), + child: zoneMap[mode ?? 'discussion'], + ); + } +} 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 410d8a503..70675e898 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; -class ConversationBotPresetSelect extends StatelessWidget { +class ConversationBotModeSelect extends StatelessWidget { final String? initialMode; final void Function(String?)? onChanged; - const ConversationBotPresetSelect({ + const ConversationBotModeSelect({ super.key, this.initialMode, this.onChanged, @@ -15,12 +15,12 @@ class ConversationBotPresetSelect extends StatelessWidget { Widget build(BuildContext context) { final Map options = { "discussion": - L10n.of(context)!.conversationBotPresetSelectOption_discussion, - "custom": L10n.of(context)!.conversationBotPresetSelectOption_custom, + L10n.of(context)!.conversationBotModeSelectOption_discussion, + "custom": L10n.of(context)!.conversationBotModeSelectOption_custom, "conversation": - L10n.of(context)!.conversationBotPresetSelectOption_conversation, + L10n.of(context)!.conversationBotModeSelectOption_conversation, "text_adventure": - L10n.of(context)!.conversationBotPresetSelectOption_textAdventure, + L10n.of(context)!.conversationBotModeSelectOption_textAdventure, }; return Padding( diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart index fcaf11b60..5aeb9b82e 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/config/app_config.dart'; 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'; @@ -247,8 +248,7 @@ class ConversationBotSettingsState extends State { Padding( padding: const EdgeInsets.fromLTRB(32, 16, 0, 0), child: Text( - L10n.of(context)! - .conversationBotPresetSelectDescription, + L10n.of(context)!.conversationBotModeSelectDescription, style: TextStyle( color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, @@ -258,15 +258,21 @@ class ConversationBotSettingsState extends State { ), Padding( padding: const EdgeInsets.only(left: 16), - child: ConversationBotPresetSelect( - initialMode: botOptions.preset, - onChanged: (String? preset) => updateBotOption( + child: ConversationBotModeSelect( + initialMode: botOptions.mode, + onChanged: (String? mode) => updateBotOption( () { - botOptions.preset = preset ?? "discussion"; + botOptions.mode = mode ?? "discussion"; }, ), ), ), + Padding( + padding: const EdgeInsets.fromLTRB(32, 16, 0, 0), + child: ConversationBotModeDynamicZone( + mode: botOptions.mode, + ), + ), const SizedBox(height: 16), ], ], diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart new file mode 100644 index 000000000..2f65348cf --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class ConversationBotTextAdventureZone extends StatelessWidget { + const ConversationBotTextAdventureZone({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return const Column( + children: [ + Text('Text Adventure Zone'), + ], + ); + } +} diff --git a/needed-translations.txt b/needed-translations.txt index 3359206d2..c3a8a46fe 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -822,11 +822,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "be": [ @@ -2247,11 +2247,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "bn": [ @@ -3134,11 +3134,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "bo": [ @@ -4021,11 +4021,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ca": [ @@ -4908,11 +4908,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "cs": [ @@ -5795,11 +5795,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "de": [ @@ -6629,11 +6629,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "el": [ @@ -7516,11 +7516,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "eo": [ @@ -8403,11 +8403,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "es": [ @@ -8438,11 +8438,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "et": [ @@ -9268,11 +9268,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "eu": [ @@ -10098,11 +10098,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "fa": [ @@ -10985,11 +10985,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "fi": [ @@ -11872,11 +11872,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "fr": [ @@ -12759,11 +12759,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ga": [ @@ -13646,11 +13646,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "gl": [ @@ -14476,11 +14476,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "he": [ @@ -15363,11 +15363,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "hi": [ @@ -16250,11 +16250,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "hr": [ @@ -17124,11 +17124,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "hu": [ @@ -18011,11 +18011,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ia": [ @@ -19422,11 +19422,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "id": [ @@ -20309,11 +20309,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ie": [ @@ -21196,11 +21196,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "it": [ @@ -22068,11 +22068,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ja": [ @@ -22955,11 +22955,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ko": [ @@ -23842,11 +23842,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "lt": [ @@ -24729,11 +24729,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "lv": [ @@ -25616,11 +25616,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "nb": [ @@ -26503,11 +26503,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "nl": [ @@ -27390,11 +27390,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "pl": [ @@ -28277,11 +28277,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "pt": [ @@ -29164,11 +29164,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "pt_BR": [ @@ -30020,11 +30020,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "pt_PT": [ @@ -30907,11 +30907,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ro": [ @@ -31794,11 +31794,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ru": [ @@ -32624,11 +32624,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "sk": [ @@ -33511,11 +33511,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "sl": [ @@ -34398,11 +34398,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "sr": [ @@ -35285,11 +35285,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "sv": [ @@ -36137,11 +36137,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "ta": [ @@ -37024,11 +37024,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "th": [ @@ -37911,11 +37911,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "tr": [ @@ -38783,11 +38783,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "uk": [ @@ -39613,11 +39613,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "vi": [ @@ -40500,11 +40500,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "zh": [ @@ -41330,11 +41330,11 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ], "zh_Hant": [ @@ -42217,10 +42217,10 @@ "points", "noPaymentInfo", "updatePhoneOS", - "conversationBotPresetSelectDescription", - "conversationBotPresetSelectOption_discussion", - "conversationBotPresetSelectOption_custom", - "conversationBotPresetSelectOption_conversation", - "conversationBotPresetSelectOption_textAdventure" + "conversationBotModeSelectDescription", + "conversationBotModeSelectOption_discussion", + "conversationBotModeSelectOption_custom", + "conversationBotModeSelectOption_conversation", + "conversationBotModeSelectOption_textAdventure" ] } From a0ee1965b3aa5e9d5010b3e26a4675a770fb6687 Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Wed, 15 May 2024 15:18:47 -0400 Subject: [PATCH 03/40] update conversation bot setting to write bot options to matrix --- lib/pangea/models/bot_options_model.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/pangea/models/bot_options_model.dart b/lib/pangea/models/bot_options_model.dart index 5038c58af..7ede3c7ab 100644 --- a/lib/pangea/models/bot_options_model.dart +++ b/lib/pangea/models/bot_options_model.dart @@ -43,6 +43,8 @@ class BotOptionsModel { data[ModelKey.conversationTopic] = topic; data[ModelKey.keywords] = keywords; data[ModelKey.safetyModeration] = safetyModeration; + data[ModelKey.mode] = mode; + data[ModelKey.custom] = custom; return data; } catch (e, s) { debugger(when: kDebugMode); @@ -66,6 +68,12 @@ class BotOptionsModel { case ModelKey.safetyModeration: safetyModeration = value; break; + case ModelKey.mode: + mode = value; + break; + case ModelKey.custom: + custom = value; + break; default: throw Exception('Invalid key for bot options - $key'); } From 8c19eb25dd20c75bc5b70d50209d043be6c4bf1c Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Thu, 16 May 2024 11:25:31 -0400 Subject: [PATCH 04/40] add discussion topic and keywords input --- assets/l10n/intl_en.arb | 6 +- lib/pangea/constants/model_keys.dart | 2 + lib/pangea/models/bot_options_model.dart | 8 + .../conversation_bot_discussion_zone.dart | 79 ++++- .../conversation_bot_mode_dynamic_zone.dart | 14 +- .../conversation_bot_settings.dart | 11 +- needed-translations.txt | 288 +++++++++++++++--- 7 files changed, 351 insertions(+), 57 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 108462160..7acfde750 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3950,5 +3950,9 @@ "conversationBotModeSelectOption_discussion": "Discussion", "conversationBotModeSelectOption_custom": "Custom", "conversationBotModeSelectOption_conversation": "Conversation", - "conversationBotModeSelectOption_textAdventure": "Text Adventure" + "conversationBotModeSelectOption_textAdventure": "Text Adventure", + "conversationBotDiscussionZone_title": "Discussion Settings", + "conversationBotDiscussionZone_discussionTopicLabel": "Discussion Topic", + "conversationBotDiscussionZone_discussionKeywordsLabel": "Discussion Keywords", + "conversationBotDiscussionZone_discussionKeywordsHintText": "Comma separated list of keywords to guide the discussion" } \ No newline at end of file diff --git a/lib/pangea/constants/model_keys.dart b/lib/pangea/constants/model_keys.dart index 163a92d8f..3dc35159f 100644 --- a/lib/pangea/constants/model_keys.dart +++ b/lib/pangea/constants/model_keys.dart @@ -101,4 +101,6 @@ class ModelKey { 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"; } diff --git a/lib/pangea/models/bot_options_model.dart b/lib/pangea/models/bot_options_model.dart index 7ede3c7ab..6fe6db303 100644 --- a/lib/pangea/models/bot_options_model.dart +++ b/lib/pangea/models/bot_options_model.dart @@ -14,6 +14,8 @@ class BotOptionsModel { bool safetyModeration; String mode; String? custom; + String? discussionTopic; + String? discussionKeywords; BotOptionsModel({ this.languageLevel, @@ -22,6 +24,8 @@ class BotOptionsModel { this.safetyModeration = true, this.mode = "discussion", this.custom = "", + this.discussionTopic, + this.discussionKeywords, }); factory BotOptionsModel.fromJson(json) { @@ -32,6 +36,8 @@ class BotOptionsModel { safetyModeration: json[ModelKey.safetyModeration] ?? true, mode: json[ModelKey.mode] ?? "discussion", custom: json[ModelKey.custom], + discussionTopic: json[ModelKey.discussionTopic], + discussionKeywords: json[ModelKey.discussionKeywords], ); } @@ -45,6 +51,8 @@ class BotOptionsModel { data[ModelKey.safetyModeration] = safetyModeration; data[ModelKey.mode] = mode; data[ModelKey.custom] = custom; + data[ModelKey.discussionTopic] = discussionTopic; + data[ModelKey.discussionKeywords] = discussionKeywords; return data; } catch (e, s) { debugger(when: kDebugMode); 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 9e7449a11..eff20a13b 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart @@ -1,15 +1,90 @@ +import 'package:fluffychat/pangea/models/bot_options_model.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; class ConversationBotDiscussionZone extends StatelessWidget { + final BotOptionsModel initialBotOptions; + // call this to update propagate changes to parents + final void Function(BotOptionsModel?)? onChanged; + const ConversationBotDiscussionZone({ super.key, + required this.initialBotOptions, + required this.onChanged, }); @override Widget build(BuildContext context) { - return const Column( + String discussionTopic = initialBotOptions.discussionTopic ?? ""; + String discussionKeywords = initialBotOptions.discussionKeywords ?? ""; + return Column( children: [ - Text('Discussion Zone'), + const SizedBox(height: 12), + Text( + L10n.of(context)!.conversationBotDiscussionZone_title, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + const Divider( + color: Colors.grey, + thickness: 1, + ), + const SizedBox(height: 12), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: TextEditingController(text: discussionTopic), + onChanged: (value) { + discussionTopic = value; + }, + decoration: InputDecoration( + labelText: L10n.of(context)! + .conversationBotDiscussionZone_discussionTopicLabel, + floatingLabelBehavior: FloatingLabelBehavior.auto, + suffixIcon: IconButton( + icon: const Icon(Icons.check), + onPressed: () { + if (discussionTopic != initialBotOptions.discussionTopic) { + initialBotOptions.discussionTopic = discussionTopic; + onChanged?.call( + initialBotOptions, + ); + } + }, + ), + ), + ), + ), + const SizedBox(height: 12), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: TextEditingController(text: discussionKeywords), + onChanged: (value) { + discussionKeywords = value; + }, + decoration: InputDecoration( + labelText: L10n.of(context)! + .conversationBotDiscussionZone_discussionKeywordsLabel, + floatingLabelBehavior: FloatingLabelBehavior.auto, + hintText: L10n.of(context)! + .conversationBotDiscussionZone_discussionKeywordsHintText, + suffixIcon: IconButton( + icon: const Icon(Icons.check), + onPressed: () { + if (discussionTopic != initialBotOptions.discussionKeywords) { + initialBotOptions.discussionKeywords = discussionKeywords; + onChanged?.call( + initialBotOptions, + ); + } + }, + ), + ), + ), + ), ], ); } 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 580dd060f..38019a646 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,3 +1,4 @@ +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'; @@ -6,17 +7,22 @@ import 'package:flutter/material.dart'; import 'conversation_bot_discussion_zone.dart'; class ConversationBotModeDynamicZone extends StatelessWidget { - final String? mode; + final BotOptionsModel initialBotOptions; + final void Function(BotOptionsModel?)? onChanged; const ConversationBotModeDynamicZone({ super.key, - this.mode, + required this.initialBotOptions, + required this.onChanged, }); @override Widget build(BuildContext context) { final zoneMap = { - 'discussion': const ConversationBotDiscussionZone(), + 'discussion': ConversationBotDiscussionZone( + initialBotOptions: initialBotOptions, + onChanged: onChanged, + ), "custom": const ConversationBotCustomZone(), "conversation": const ConversationBotConversationZone(), "text_adventure": const ConversationBotTextAdventureZone(), @@ -29,7 +35,7 @@ class ConversationBotModeDynamicZone extends StatelessWidget { ), borderRadius: const BorderRadius.all(Radius.circular(10)), ), - child: zoneMap[mode ?? 'discussion'], + child: zoneMap[initialBotOptions.mode], ); } } diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart index 5aeb9b82e..0558307d6 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart @@ -268,9 +268,16 @@ class ConversationBotSettingsState extends State { ), ), Padding( - padding: const EdgeInsets.fromLTRB(32, 16, 0, 0), + padding: const EdgeInsets.fromLTRB(28, 0, 12, 0), child: ConversationBotModeDynamicZone( - mode: botOptions.mode, + initialBotOptions: botOptions, + onChanged: (BotOptionsModel? newOptions) { + updateBotOption(() { + if (newOptions != null) { + botOptions = newOptions; + } + }); + }, ), ), const SizedBox(height: 16), diff --git a/needed-translations.txt b/needed-translations.txt index c3a8a46fe..6fe5cae01 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -826,7 +826,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "be": [ @@ -2251,7 +2255,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "bn": [ @@ -3138,7 +3146,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "bo": [ @@ -4025,7 +4037,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ca": [ @@ -4912,7 +4928,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "cs": [ @@ -5799,7 +5819,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "de": [ @@ -6633,7 +6657,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "el": [ @@ -7520,7 +7548,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "eo": [ @@ -8407,7 +8439,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "es": [ @@ -8442,7 +8478,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "et": [ @@ -9272,7 +9312,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "eu": [ @@ -10102,7 +10146,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "fa": [ @@ -10989,7 +11037,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "fi": [ @@ -11876,7 +11928,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "fr": [ @@ -12763,7 +12819,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ga": [ @@ -13650,7 +13710,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "gl": [ @@ -14480,7 +14544,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "he": [ @@ -15367,7 +15435,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "hi": [ @@ -16254,7 +16326,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "hr": [ @@ -17128,7 +17204,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "hu": [ @@ -18015,7 +18095,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ia": [ @@ -19426,7 +19510,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "id": [ @@ -20313,7 +20401,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ie": [ @@ -21200,7 +21292,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "it": [ @@ -22072,7 +22168,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ja": [ @@ -22959,7 +23059,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ko": [ @@ -23846,7 +23950,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "lt": [ @@ -24733,7 +24841,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "lv": [ @@ -25620,7 +25732,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "nb": [ @@ -26507,7 +26623,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "nl": [ @@ -27394,7 +27514,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "pl": [ @@ -28281,7 +28405,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "pt": [ @@ -29168,7 +29296,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "pt_BR": [ @@ -30024,7 +30156,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "pt_PT": [ @@ -30911,7 +31047,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ro": [ @@ -31798,7 +31938,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ru": [ @@ -32628,7 +32772,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "sk": [ @@ -33515,7 +33663,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "sl": [ @@ -34402,7 +34554,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "sr": [ @@ -35289,7 +35445,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "sv": [ @@ -36141,7 +36301,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "ta": [ @@ -37028,7 +37192,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "th": [ @@ -37915,7 +38083,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "tr": [ @@ -38787,7 +38959,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "uk": [ @@ -39617,7 +39793,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "vi": [ @@ -40504,7 +40684,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "zh": [ @@ -41334,7 +41518,11 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ], "zh_Hant": [ @@ -42221,6 +42409,10 @@ "conversationBotModeSelectOption_discussion", "conversationBotModeSelectOption_custom", "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure" + "conversationBotModeSelectOption_textAdventure", + "conversationBotDiscussionZone_title", + "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsHintText" ] } From a8473896209772899a270908526b648eaa1db038 Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Thu, 16 May 2024 13:35:06 -0400 Subject: [PATCH 05/40] add trigger and reaction input --- assets/l10n/intl_en.arb | 6 +- lib/pangea/constants/model_keys.dart | 10 +- lib/pangea/models/bot_options_model.dart | 51 +++- .../conversation_bot_discussion_zone.dart | 138 +++++++++ needed-translations.txt | 288 +++++++++++++++--- 5 files changed, 432 insertions(+), 61 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 7acfde750..75a24024b 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3954,5 +3954,9 @@ "conversationBotDiscussionZone_title": "Discussion Settings", "conversationBotDiscussionZone_discussionTopicLabel": "Discussion Topic", "conversationBotDiscussionZone_discussionKeywordsLabel": "Discussion Keywords", - "conversationBotDiscussionZone_discussionKeywordsHintText": "Comma separated list of keywords to guide the discussion" + "conversationBotDiscussionZone_discussionKeywordsHintText": "Comma separated list of keywords to guide the discussion", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel": "Send discussion prompt on a schedule", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Hours between discussion prompts", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Send discussion prompt on reaction to bot's message", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reaction to send discussion prompt" } \ No newline at end of file diff --git a/lib/pangea/constants/model_keys.dart b/lib/pangea/constants/model_keys.dart index 3dc35159f..ce427f3d3 100644 --- a/lib/pangea/constants/model_keys.dart +++ b/lib/pangea/constants/model_keys.dart @@ -96,11 +96,17 @@ class ModelKey { // bot options static const String languageLevel = "difficulty"; - static const String conversationTopic = "conversation_topic"; - static const String keywords = "keywords"; 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 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"; } diff --git a/lib/pangea/models/bot_options_model.dart b/lib/pangea/models/bot_options_model.dart index 6fe6db303..0b437159e 100644 --- a/lib/pangea/models/bot_options_model.dart +++ b/lib/pangea/models/bot_options_model.dart @@ -16,6 +16,10 @@ class BotOptionsModel { String? custom; String? discussionTopic; String? discussionKeywords; + bool? discussionTriggerScheduleEnabled; + int? discussionTriggerScheduleHourInterval; + bool? discussionTriggerReactionEnabled; + String? discussionTriggerReactionKey; BotOptionsModel({ this.languageLevel, @@ -26,18 +30,27 @@ class BotOptionsModel { this.custom = "", this.discussionTopic, this.discussionKeywords, + this.discussionTriggerScheduleEnabled, + this.discussionTriggerScheduleHourInterval, + this.discussionTriggerReactionEnabled, + this.discussionTriggerReactionKey, }); factory BotOptionsModel.fromJson(json) { return BotOptionsModel( languageLevel: json[ModelKey.languageLevel], - topic: json[ModelKey.conversationTopic] ?? "General Conversation", - keywords: (json[ModelKey.keywords] ?? []).cast(), safetyModeration: json[ModelKey.safetyModeration] ?? true, mode: json[ModelKey.mode] ?? "discussion", custom: json[ModelKey.custom], discussionTopic: json[ModelKey.discussionTopic], discussionKeywords: json[ModelKey.discussionKeywords], + discussionTriggerScheduleEnabled: + json[ModelKey.discussionTriggerScheduleEnabled], + discussionTriggerScheduleHourInterval: + json[ModelKey.discussionTriggerScheduleHourInterval], + discussionTriggerReactionEnabled: + json[ModelKey.discussionTriggerReactionEnabled], + discussionTriggerReactionKey: json[ModelKey.discussionTriggerReactionKey], ); } @@ -46,13 +59,19 @@ class BotOptionsModel { try { // data[ModelKey.isConversationBotChat] = isConversationBotChat; data[ModelKey.languageLevel] = languageLevel; - data[ModelKey.conversationTopic] = topic; - data[ModelKey.keywords] = keywords; data[ModelKey.safetyModeration] = safetyModeration; data[ModelKey.mode] = mode; 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; return data; } catch (e, s) { debugger(when: kDebugMode); @@ -67,12 +86,6 @@ class BotOptionsModel { case ModelKey.languageLevel: languageLevel = value; break; - case ModelKey.conversationTopic: - topic = value; - break; - case ModelKey.keywords: - keywords = value; - break; case ModelKey.safetyModeration: safetyModeration = value; break; @@ -82,6 +95,24 @@ class BotOptionsModel { case ModelKey.custom: custom = value; break; + case ModelKey.discussionTopic: + discussionTopic = value; + break; + 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; default: throw Exception('Invalid key for bot options - $key'); } 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 eff20a13b..c4e4f1359 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart @@ -17,6 +17,11 @@ class ConversationBotDiscussionZone extends StatelessWidget { Widget build(BuildContext context) { String discussionTopic = initialBotOptions.discussionTopic ?? ""; String discussionKeywords = initialBotOptions.discussionKeywords ?? ""; + int discussionTriggerScheduleHourInterval = + initialBotOptions.discussionTriggerScheduleHourInterval ?? 24; + final String discussionTriggerReactionKey = + initialBotOptions.discussionTriggerReactionKey ?? "⏩"; + final List reactionKeyOptions = ["⏩"]; return Column( children: [ const SizedBox(height: 12), @@ -85,6 +90,139 @@ class ConversationBotDiscussionZone extends StatelessWidget { ), ), ), + const SizedBox(height: 12), + CheckboxListTile( + title: Text( + L10n.of(context)! + .conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel, + ), + value: initialBotOptions.discussionTriggerScheduleEnabled ?? false, + onChanged: (value) { + initialBotOptions.discussionTriggerScheduleEnabled = value ?? false; + onChanged?.call(initialBotOptions); + }, + ), + if (initialBotOptions.discussionTriggerScheduleEnabled == true) + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + keyboardType: TextInputType.number, + controller: TextEditingController( + text: discussionTriggerScheduleHourInterval.toString(), + ), + onChanged: (value) { + discussionTriggerScheduleHourInterval = + int.tryParse(value) ?? 0; + }, + decoration: InputDecoration( + labelText: L10n.of(context)! + .conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel, + floatingLabelBehavior: FloatingLabelBehavior.auto, + suffixIcon: IconButton( + icon: const Icon(Icons.check), + onPressed: () { + if (discussionTriggerScheduleHourInterval != + initialBotOptions + .discussionTriggerScheduleHourInterval) { + initialBotOptions.discussionTriggerScheduleHourInterval = + discussionTriggerScheduleHourInterval; + onChanged?.call( + initialBotOptions, + ); + } + }, + ), + ), + ), + ), + const SizedBox(height: 12), + CheckboxListTile( + title: Text( + L10n.of(context)! + .conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel, + ), + value: initialBotOptions.discussionTriggerReactionEnabled ?? false, + onChanged: (value) { + initialBotOptions.discussionTriggerReactionEnabled = value ?? false; + onChanged?.call(initialBotOptions); + }, + ), + if (initialBotOptions.discussionTriggerReactionEnabled == true) + Padding( + padding: const EdgeInsets.all(8), + child: Column( + children: [ + Text( + L10n.of(context)! + .conversationBotDiscussionZone_discussionTriggerReactionKeyLabel, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.left, + ), + Container( + decoration: BoxDecoration( + border: Border.all( + color: Theme.of(context).colorScheme.secondary, + width: 0.5, + ), + borderRadius: const BorderRadius.all(Radius.circular(10)), + ), + child: DropdownButton( + // Initial Value + hint: Padding( + padding: const EdgeInsets.only(left: 15), + child: Text( + reactionKeyOptions[0], + style: const TextStyle().copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 14, + ), + overflow: TextOverflow.clip, + textAlign: TextAlign.center, + ), + ), + isExpanded: true, + underline: Container(), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + // Array list of items + items: [ + for (final entry in reactionKeyOptions) + DropdownMenuItem( + value: entry, + child: Padding( + padding: const EdgeInsets.only(left: 15), + child: Text( + entry, + style: const TextStyle().copyWith( + color: Theme.of(context) + .textTheme + .bodyLarge! + .color, + fontSize: 14, + ), + overflow: TextOverflow.clip, + textAlign: TextAlign.center, + ), + ), + ), + ], + onChanged: (String? value) { + if (value != + initialBotOptions.discussionTriggerReactionKey) { + initialBotOptions.discussionTriggerReactionKey = value; + onChanged?.call( + initialBotOptions, + ); + } + }, + ), + ), + ], + ), + ), ], ); } diff --git a/needed-translations.txt b/needed-translations.txt index 6fe5cae01..5d9b0cc24 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -830,7 +830,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "be": [ @@ -2259,7 +2263,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "bn": [ @@ -3150,7 +3158,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "bo": [ @@ -4041,7 +4053,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ca": [ @@ -4932,7 +4948,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "cs": [ @@ -5823,7 +5843,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "de": [ @@ -6661,7 +6685,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "el": [ @@ -7552,7 +7580,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "eo": [ @@ -8443,7 +8475,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "es": [ @@ -8482,7 +8518,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "et": [ @@ -9316,7 +9356,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "eu": [ @@ -10150,7 +10194,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "fa": [ @@ -11041,7 +11089,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "fi": [ @@ -11932,7 +11984,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "fr": [ @@ -12823,7 +12879,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ga": [ @@ -13714,7 +13774,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "gl": [ @@ -14548,7 +14612,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "he": [ @@ -15439,7 +15507,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "hi": [ @@ -16330,7 +16402,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "hr": [ @@ -17208,7 +17284,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "hu": [ @@ -18099,7 +18179,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ia": [ @@ -19514,7 +19598,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "id": [ @@ -20405,7 +20493,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ie": [ @@ -21296,7 +21388,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "it": [ @@ -22172,7 +22268,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ja": [ @@ -23063,7 +23163,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ko": [ @@ -23954,7 +24058,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "lt": [ @@ -24845,7 +24953,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "lv": [ @@ -25736,7 +25848,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "nb": [ @@ -26627,7 +26743,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "nl": [ @@ -27518,7 +27638,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "pl": [ @@ -28409,7 +28533,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "pt": [ @@ -29300,7 +29428,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "pt_BR": [ @@ -30160,7 +30292,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "pt_PT": [ @@ -31051,7 +31187,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ro": [ @@ -31942,7 +32082,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ru": [ @@ -32776,7 +32920,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "sk": [ @@ -33667,7 +33815,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "sl": [ @@ -34558,7 +34710,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "sr": [ @@ -35449,7 +35605,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "sv": [ @@ -36305,7 +36465,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "ta": [ @@ -37196,7 +37360,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "th": [ @@ -38087,7 +38255,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "tr": [ @@ -38963,7 +39135,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "uk": [ @@ -39797,7 +39973,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "vi": [ @@ -40688,7 +40868,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "zh": [ @@ -41522,7 +41706,11 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ], "zh_Hant": [ @@ -42413,6 +42601,10 @@ "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsHintText" + "conversationBotDiscussionZone_discussionKeywordsHintText", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", + "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel" ] } From c7c0634792776238d1ff2ce316df75e4c7031fbf Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Thu, 16 May 2024 14:17:51 -0400 Subject: [PATCH 06/40] temporarily remove schedule and specific reaction --- assets/l10n/intl_en.arb | 2 +- .../conversation_bot_discussion_zone.dart | 253 +++++++++--------- 2 files changed, 129 insertions(+), 126 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 75a24024b..43c9bc133 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3957,6 +3957,6 @@ "conversationBotDiscussionZone_discussionKeywordsHintText": "Comma separated list of keywords to guide the discussion", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel": "Send discussion prompt on a schedule", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Hours between discussion prompts", - "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Send discussion prompt on reaction to bot's message", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Send discussion prompt when user reacts ⏩ to bot message", "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reaction to send discussion prompt" } \ No newline at end of file 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 c4e4f1359..1f13139ee 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart @@ -17,11 +17,11 @@ class ConversationBotDiscussionZone extends StatelessWidget { Widget build(BuildContext context) { String discussionTopic = initialBotOptions.discussionTopic ?? ""; String discussionKeywords = initialBotOptions.discussionKeywords ?? ""; - int discussionTriggerScheduleHourInterval = - initialBotOptions.discussionTriggerScheduleHourInterval ?? 24; - final String discussionTriggerReactionKey = - initialBotOptions.discussionTriggerReactionKey ?? "⏩"; - final List reactionKeyOptions = ["⏩"]; + // int discussionTriggerScheduleHourInterval = + // initialBotOptions.discussionTriggerScheduleHourInterval ?? 24; + // String discussionTriggerReactionKey = + // initialBotOptions.discussionTriggerReactionKey ?? "⏩"; + // List reactionKeyOptions = ["⏩"]; return Column( children: [ const SizedBox(height: 12), @@ -91,50 +91,50 @@ class ConversationBotDiscussionZone extends StatelessWidget { ), ), const SizedBox(height: 12), - CheckboxListTile( - title: Text( - L10n.of(context)! - .conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel, - ), - value: initialBotOptions.discussionTriggerScheduleEnabled ?? false, - onChanged: (value) { - initialBotOptions.discussionTriggerScheduleEnabled = value ?? false; - onChanged?.call(initialBotOptions); - }, - ), - if (initialBotOptions.discussionTriggerScheduleEnabled == true) - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - keyboardType: TextInputType.number, - controller: TextEditingController( - text: discussionTriggerScheduleHourInterval.toString(), - ), - onChanged: (value) { - discussionTriggerScheduleHourInterval = - int.tryParse(value) ?? 0; - }, - decoration: InputDecoration( - labelText: L10n.of(context)! - .conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel, - floatingLabelBehavior: FloatingLabelBehavior.auto, - suffixIcon: IconButton( - icon: const Icon(Icons.check), - onPressed: () { - if (discussionTriggerScheduleHourInterval != - initialBotOptions - .discussionTriggerScheduleHourInterval) { - initialBotOptions.discussionTriggerScheduleHourInterval = - discussionTriggerScheduleHourInterval; - onChanged?.call( - initialBotOptions, - ); - } - }, - ), - ), - ), - ), + // CheckboxListTile( + // title: Text( + // L10n.of(context)! + // .conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel, + // ), + // value: initialBotOptions.discussionTriggerScheduleEnabled ?? false, + // onChanged: (value) { + // initialBotOptions.discussionTriggerScheduleEnabled = value ?? false; + // onChanged?.call(initialBotOptions); + // }, + // ), + // if (initialBotOptions.discussionTriggerScheduleEnabled == true) + // Padding( + // padding: const EdgeInsets.all(8), + // child: TextField( + // keyboardType: TextInputType.number, + // controller: TextEditingController( + // text: discussionTriggerScheduleHourInterval.toString(), + // ), + // onChanged: (value) { + // discussionTriggerScheduleHourInterval = + // int.tryParse(value) ?? 0; + // }, + // decoration: InputDecoration( + // labelText: L10n.of(context)! + // .conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel, + // floatingLabelBehavior: FloatingLabelBehavior.auto, + // suffixIcon: IconButton( + // icon: const Icon(Icons.check), + // onPressed: () { + // if (discussionTriggerScheduleHourInterval != + // initialBotOptions + // .discussionTriggerScheduleHourInterval) { + // initialBotOptions.discussionTriggerScheduleHourInterval = + // discussionTriggerScheduleHourInterval; + // onChanged?.call( + // initialBotOptions, + // ); + // } + // }, + // ), + // ), + // ), + // ), const SizedBox(height: 12), CheckboxListTile( title: Text( @@ -144,85 +144,88 @@ class ConversationBotDiscussionZone extends StatelessWidget { value: initialBotOptions.discussionTriggerReactionEnabled ?? false, onChanged: (value) { initialBotOptions.discussionTriggerReactionEnabled = value ?? false; + initialBotOptions.discussionTriggerReactionKey = + "⏩"; // hard code this for now onChanged?.call(initialBotOptions); }, ), - if (initialBotOptions.discussionTriggerReactionEnabled == true) - Padding( - padding: const EdgeInsets.all(8), - child: Column( - children: [ - Text( - L10n.of(context)! - .conversationBotDiscussionZone_discussionTriggerReactionKeyLabel, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - textAlign: TextAlign.left, - ), - Container( - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context).colorScheme.secondary, - width: 0.5, - ), - borderRadius: const BorderRadius.all(Radius.circular(10)), - ), - child: DropdownButton( - // Initial Value - hint: Padding( - padding: const EdgeInsets.only(left: 15), - child: Text( - reactionKeyOptions[0], - style: const TextStyle().copyWith( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 14, - ), - overflow: TextOverflow.clip, - textAlign: TextAlign.center, - ), - ), - isExpanded: true, - underline: Container(), - // Down Arrow Icon - icon: const Icon(Icons.keyboard_arrow_down), - // Array list of items - items: [ - for (final entry in reactionKeyOptions) - DropdownMenuItem( - value: entry, - child: Padding( - padding: const EdgeInsets.only(left: 15), - child: Text( - entry, - style: const TextStyle().copyWith( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color, - fontSize: 14, - ), - overflow: TextOverflow.clip, - textAlign: TextAlign.center, - ), - ), - ), - ], - onChanged: (String? value) { - if (value != - initialBotOptions.discussionTriggerReactionKey) { - initialBotOptions.discussionTriggerReactionKey = value; - onChanged?.call( - initialBotOptions, - ); - } - }, - ), - ), - ], - ), - ), + // if (initialBotOptions.discussionTriggerReactionEnabled == true) + // Padding( + // padding: const EdgeInsets.all(8), + // child: Column( + // children: [ + // Text( + // L10n.of(context)! + // .conversationBotDiscussionZone_discussionTriggerReactionKeyLabel, + // style: TextStyle( + // color: Theme.of(context).colorScheme.secondary, + // fontWeight: FontWeight.bold, + // ), + // textAlign: TextAlign.left, + // ), + // Container( + // decoration: BoxDecoration( + // border: Border.all( + // color: Theme.of(context).colorScheme.secondary, + // width: 0.5, + // ), + // borderRadius: const BorderRadius.all(Radius.circular(10)), + // ), + // child: DropdownButton( + // // Initial Value + // hint: Padding( + // padding: const EdgeInsets.only(left: 15), + // child: Text( + // reactionKeyOptions[0], + // style: const TextStyle().copyWith( + // color: Theme.of(context).textTheme.bodyLarge!.color, + // fontSize: 14, + // ), + // overflow: TextOverflow.clip, + // textAlign: TextAlign.center, + // ), + // ), + // isExpanded: true, + // underline: Container(), + // // Down Arrow Icon + // icon: const Icon(Icons.keyboard_arrow_down), + // // Array list of items + // items: [ + // for (final entry in reactionKeyOptions) + // DropdownMenuItem( + // value: entry, + // child: Padding( + // padding: const EdgeInsets.only(left: 15), + // child: Text( + // entry, + // style: const TextStyle().copyWith( + // color: Theme.of(context) + // .textTheme + // .bodyLarge! + // .color, + // fontSize: 14, + // ), + // overflow: TextOverflow.clip, + // textAlign: TextAlign.center, + // ), + // ), + // ), + // ], + // onChanged: (String? value) { + // if (value != + // initialBotOptions.discussionTriggerReactionKey) { + // initialBotOptions.discussionTriggerReactionKey = value; + // onChanged?.call( + // initialBotOptions, + // ); + // } + // }, + // ), + // ), + // ], + // ), + // ), + const SizedBox(height: 12), ], ); } From d5fc7b5e7804f41e94f2d5ce4a54a6760426c440 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 16 May 2024 14:46:08 -0400 Subject: [PATCH 07/40] fix for error with msg events with multiple of the same type of pangea match only showing the first instance --- .../pangea_message_event.dart | 17 +++-- .../class_analytics/class_analytics_view.dart | 8 ++- .../pages/analytics/construct_list.dart | 66 ++++++++++++++++--- 3 files changed, 75 insertions(+), 16 deletions(-) diff --git a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart index 3f2f23616..cb7cba52a 100644 --- a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart +++ b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart @@ -564,17 +564,20 @@ class PangeaMessageEvent { return langCode ?? LanguageKeys.unknownLanguage; } - PangeaMatch? firstErrorStep(String lemma) { + List? errorSteps(String lemma) { final RepresentationEvent? repEvent = originalSent ?? originalWritten; if (repEvent?.choreo == null) return null; - final PangeaMatch? step = repEvent!.choreo!.choreoSteps - .firstWhereOrNull( - (element) => - element.acceptedOrIgnoredMatch?.match.shortMessage == lemma, + final List steps = repEvent!.choreo!.choreoSteps + .where( + (choreoStep) => + choreoStep.acceptedOrIgnoredMatch != null && + choreoStep.acceptedOrIgnoredMatch?.match.shortMessage == lemma, ) - ?.acceptedOrIgnoredMatch; - return step; + .map((element) => element.acceptedOrIgnoredMatch) + .cast() + .toList(); + return steps; } // List get activities => diff --git a/lib/pangea/pages/analytics/class_analytics/class_analytics_view.dart b/lib/pangea/pages/analytics/class_analytics/class_analytics_view.dart index dfb44e106..88c15bdf5 100644 --- a/lib/pangea/pages/analytics/class_analytics/class_analytics_view.dart +++ b/lib/pangea/pages/analytics/class_analytics/class_analytics_view.dart @@ -1,3 +1,4 @@ +import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -20,7 +21,12 @@ class ClassAnalyticsView extends StatelessWidget { .map( (room) => TabItem( avatar: room.avatarUrl, - displayName: room.name ?? "", + displayName: room.name ?? + Matrix.of(context) + .client + .getRoomById(room.roomId) + ?.getLocalizedDisplayname() ?? + "", id: room.roomId, ), ) diff --git a/lib/pangea/pages/analytics/construct_list.dart b/lib/pangea/pages/analytics/construct_list.dart index 838f766a3..ffcf0e79a 100644 --- a/lib/pangea/pages/analytics/construct_list.dart +++ b/lib/pangea/pages/analytics/construct_list.dart @@ -248,6 +248,38 @@ class ConstructListViewState extends State { (element) => element.content.lemma == widget.controller.currentLemma, ); + // given the current lemma and list of message events, return a list of + // MessageEventMatch objects, which contain one PangeaMessageEvent to one PangeaMatch + // this is because some message events may have has more than one PangeaMatch of a + // given lemma type. + List getMessageEventMatches() { + if (widget.controller.currentLemma == null) return []; + final List allMsgErrorSteps = []; + + for (final msgEvent in _msgEvents) { + if (allMsgErrorSteps.any( + (element) => element.msgEvent.eventId == msgEvent.eventId, + )) { + continue; + } + // get all the pangea matches in that message which have that lemma + final List? msgErrorSteps = msgEvent.errorSteps( + widget.controller.currentLemma!, + ); + if (msgErrorSteps == null) continue; + + allMsgErrorSteps.addAll( + msgErrorSteps.map( + (errorStep) => MessageEventMatch( + msgEvent: msgEvent, + lemmaMatch: errorStep, + ), + ), + ); + } + return allMsgErrorSteps; + } + @override Widget build(BuildContext context) { if (!widget.init || fetchingUses) { @@ -262,6 +294,8 @@ class ConstructListViewState extends State { ); } + final msgEventMatches = getMessageEventMatches(); + return widget.controller.currentLemma == null ? Expanded( child: ListView.builder( @@ -299,11 +333,12 @@ class ConstructListViewState extends State { child: ListView.separated( separatorBuilder: (context, index) => const Divider(height: 1), - itemCount: _msgEvents.length, + itemCount: msgEventMatches.length, itemBuilder: (context, index) { return ConstructMessage( - msgEvent: _msgEvents[index], + msgEvent: msgEventMatches[index].msgEvent, lemma: widget.controller.currentLemma!, + errorMessage: msgEventMatches[index].lemmaMatch, ); }, ), @@ -316,21 +351,18 @@ class ConstructListViewState extends State { class ConstructMessage extends StatelessWidget { final PangeaMessageEvent msgEvent; + final PangeaMatch errorMessage; final String lemma; const ConstructMessage({ super.key, required this.msgEvent, + required this.errorMessage, required this.lemma, }); @override Widget build(BuildContext context) { - final PangeaMatch? errorMessage = msgEvent.firstErrorStep(lemma); - if (errorMessage == null) { - return const SizedBox.shrink(); - } - final String? chosen = errorMessage.match.choices ?.firstWhereOrNull( (element) => element.selected == true, @@ -488,6 +520,14 @@ class ConstructMessageMetadata extends StatelessWidget { @override Widget build(BuildContext context) { + final String roomName = msgEvent.event.room.name.isEmpty + ? Matrix.of(context) + .client + .getRoomById(msgEvent.event.room.id) + ?.getLocalizedDisplayname() ?? + "" + : msgEvent.event.room.name; + return Padding( padding: const EdgeInsets.fromLTRB(10, 0, 30, 0), child: Column( @@ -496,9 +536,19 @@ class ConstructMessageMetadata extends StatelessWidget { msgEvent.event.originServerTs.localizedTime(context), style: TextStyle(fontSize: 13 * AppConfig.fontSizeFactor), ), - Text(msgEvent.event.room.name), + Text(roomName), ], ), ); } } + +class MessageEventMatch { + final PangeaMessageEvent msgEvent; + final PangeaMatch lemmaMatch; + + MessageEventMatch({ + required this.msgEvent, + required this.lemmaMatch, + }); +} From 0b0d40c13ef3a39f02c8bc25e3844b3f549deefb Mon Sep 17 00:00:00 2001 From: Kelrap Date: Thu, 16 May 2024 16:24:09 -0400 Subject: [PATCH 08/40] Fixed bug where redacted messages sometimes showed in chat subtitle --- lib/pangea/utils/get_chat_list_item_subtitle.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pangea/utils/get_chat_list_item_subtitle.dart b/lib/pangea/utils/get_chat_list_item_subtitle.dart index 6d41a9605..2fee578bf 100644 --- a/lib/pangea/utils/get_chat_list_item_subtitle.dart +++ b/lib/pangea/utils/get_chat_list_item_subtitle.dart @@ -43,6 +43,7 @@ class GetChatListItemSubtitle { } if (!pangeaController.languageController.languagesSet || + event.redacted || event.type != EventTypes.Message || event.messageType != MessageTypes.Text || !pangeaController.permissionsController From 19809a6f2deff8ab206b0d4f40b36616b099ab20 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Fri, 17 May 2024 12:10:36 -0400 Subject: [PATCH 09/40] When a user creates a new group from inside a class, the space ID will be stored via query --- lib/config/routes.dart | 30 +++++++++++++++---------- lib/pages/chat_list/start_chat_fab.dart | 6 +++-- lib/pages/new_group/new_group.dart | 9 +++++++- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 8d4d4f181..e6ab37967 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -232,20 +232,26 @@ abstract class AppRoutes { pageBuilder: (context, state) => defaultPageBuilder( context, state, - const NewGroup(), + NewGroup( + // #Pangea + spaceId: state.uri.queryParameters['spaceId'], + // Pangea# + ), ), redirect: loggedOutRedirect, - routes: [ - GoRoute( - path: ':spaceid', - pageBuilder: (context, state) => defaultPageBuilder( - context, - state, - const NewGroup(), - ), - redirect: loggedOutRedirect, - ), - ], + // #Pangea + // routes: [ + // GoRoute( + // path: ':spaceid', + // pageBuilder: (context, state) => defaultPageBuilder( + // context, + // state, + // const NewGroup(), + // ), + // redirect: loggedOutRedirect, + // ), + // ], + // Pangea# ), GoRoute( path: 'newspace', diff --git a/lib/pages/chat_list/start_chat_fab.dart b/lib/pages/chat_list/start_chat_fab.dart index 2bea8537e..c9175b8d6 100644 --- a/lib/pages/chat_list/start_chat_fab.dart +++ b/lib/pages/chat_list/start_chat_fab.dart @@ -30,7 +30,8 @@ class StartChatFloatingActionButton extends StatelessWidget { void _onPressed(BuildContext context) async { //#Pangea if (controller.activeSpaceId != null) { - context.go('/rooms/newgroup/${controller.activeSpaceId ?? ''}'); + // context.go('/rooms/newgroup/${controller.activeSpaceId ?? ''}'); + context.go('/rooms/newgroup?spaceId=${controller.activeSpaceId ?? ''}'); return; } //Pangea# @@ -44,7 +45,8 @@ class StartChatFloatingActionButton extends StatelessWidget { case ActiveFilter.groups: // #Pangea // context.go('/rooms/newgroup'); - context.go('/rooms/newgroup/${controller.activeSpaceId ?? ''}'); + // context.go('/rooms/newgroup/${controller.activeSpaceId ?? ''}'); + context.go('/rooms/newgroup?spaceId=${controller.activeSpaceId ?? ''}'); // Pangea# break; case ActiveFilter.spaces: diff --git a/lib/pages/new_group/new_group.dart b/lib/pages/new_group/new_group.dart index 16d4e2cdb..90c658a45 100644 --- a/lib/pages/new_group/new_group.dart +++ b/lib/pages/new_group/new_group.dart @@ -17,7 +17,14 @@ import 'package:go_router/go_router.dart'; import 'package:matrix/matrix.dart' as sdk; class NewGroup extends StatefulWidget { - const NewGroup({super.key}); + // #Pangea + final String? spaceId; + + const NewGroup({ + super.key, + this.spaceId, + }); + // Pangea# @override NewGroupController createState() => NewGroupController(); From f27c5981e86e5c53a5430322f959d2e93023d8c4 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Fri, 17 May 2024 14:06:22 -0400 Subject: [PATCH 10/40] Checks the user is member of room and admin before showing option to remove room from space --- lib/pages/chat_list/space_view.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 856bed7d1..348550c65 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -237,6 +237,10 @@ class _SpaceViewState extends State { icon: Icons.send_outlined, ), if (spaceChild != null && + // #Pangea + room != null && + room.ownPowerLevel >= ClassDefaultValues.powerLevelOfAdmin && + // Pangea# (activeSpace?.canChangeStateEvent(EventTypes.spaceChild) ?? false)) SheetAction( key: SpaceChildContextAction.removeFromSpace, From c74b2c290a7ec6318f76a404e85075a813b20755 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Fri, 17 May 2024 14:35:21 -0400 Subject: [PATCH 11/40] Non-text messages cannot be edited --- lib/pages/chat/chat.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 0b9078ebb..460de198c 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -1078,6 +1078,9 @@ class ChatController extends State bool get canEditSelectedEvents { if (isArchived || selectedEvents.length != 1 || + // #Pangea + selectedEvents.single.messageType != MessageTypes.Text || + // Pangea# !selectedEvents.first.status.isSent) { return false; } From c03ca24efe8ebfd71dfd84e7446bd6b600c8bf4e Mon Sep 17 00:00:00 2001 From: Kelrap <99418823+Kelrap@users.noreply.github.com> Date: Fri, 17 May 2024 15:42:37 -0400 Subject: [PATCH 12/40] limit new group name length to 32 --- lib/pages/new_group/new_group_view.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pages/new_group/new_group_view.dart b/lib/pages/new_group/new_group_view.dart index ac3d9dacc..523f3002e 100644 --- a/lib/pages/new_group/new_group_view.dart +++ b/lib/pages/new_group/new_group_view.dart @@ -57,6 +57,9 @@ class NewGroupView extends StatelessWidget { const SizedBox(width: 16), Expanded( child: TextField( + // #Pangea + maxLength: 32, + // Pangea# controller: controller.nameController, autocorrect: false, readOnly: controller.loading, From f84e92d9d09c6c30613634faa6d20460e9882de7 Mon Sep 17 00:00:00 2001 From: Kelrap <99418823+Kelrap@users.noreply.github.com> Date: Fri, 17 May 2024 15:43:36 -0400 Subject: [PATCH 13/40] limit new space name length to 32 --- lib/pages/new_space/new_space_view.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pages/new_space/new_space_view.dart b/lib/pages/new_space/new_space_view.dart index e550d0019..23f81b7ab 100644 --- a/lib/pages/new_space/new_space_view.dart +++ b/lib/pages/new_space/new_space_view.dart @@ -95,6 +95,9 @@ class NewSpaceView extends StatelessWidget { const SizedBox(width: 16), Expanded( child: TextField( + // #Pangea + maxLength: 32, + // Pangea# controller: controller.nameController, autocorrect: false, readOnly: controller.loading, From 09f26fb91faa3f9f3cfe7ab1abf8d69e47a28042 Mon Sep 17 00:00:00 2001 From: Kelrap <99418823+Kelrap@users.noreply.github.com> Date: Fri, 17 May 2024 15:45:14 -0400 Subject: [PATCH 14/40] Limit display name length to 32 --- lib/pages/settings/settings.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index 988ec3ff4..0e32fe478 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -42,6 +42,9 @@ class SettingsController extends State { cancelLabel: L10n.of(context)!.cancel, textFields: [ DialogTextField( + // #Pangea + maxLength: 32, + // Pangea# initialText: profile?.displayName ?? Matrix.of(context).client.userID!.localpart, ), From d247abb320c0a425e9098ff3139652620c8674cc Mon Sep 17 00:00:00 2001 From: Kelrap <99418823+Kelrap@users.noreply.github.com> Date: Fri, 17 May 2024 15:46:27 -0400 Subject: [PATCH 15/40] Limited edited class name length to 32 --- lib/pangea/utils/set_class_name.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pangea/utils/set_class_name.dart b/lib/pangea/utils/set_class_name.dart index 92909034a..1fd2ab66d 100644 --- a/lib/pangea/utils/set_class_name.dart +++ b/lib/pangea/utils/set_class_name.dart @@ -27,6 +27,7 @@ void setClassDisplayname(BuildContext context, String? roomId) async { : L10n.of(context)!.changeTheNameOfTheChat, ), content: TextField( + maxLength: 32, controller: textFieldController, ), actions: [ From b2166906c37be52a963005345ca79b96a2d11041 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Fri, 17 May 2024 16:26:04 -0400 Subject: [PATCH 16/40] Use query parameter to autoselect class --- lib/pages/new_group/new_group.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/new_group/new_group.dart b/lib/pages/new_group/new_group.dart index 90c658a45..2ada80dfa 100644 --- a/lib/pages/new_group/new_group.dart +++ b/lib/pages/new_group/new_group.dart @@ -57,7 +57,7 @@ class NewGroupController extends State { void setVocab(List vocab) => setState(() => chatTopic.vocab = vocab); String? get activeSpaceId => - GoRouterState.of(context).pathParameters['spaceid']; + GoRouterState.of(context).uri.queryParameters['spaceId']; // Pangea# void setPublicGroup(bool b) => setState(() => publicGroup = b); From c88970d8598c4a686bbba6646e314a835f9da9b9 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 17 May 2024 16:37:39 -0400 Subject: [PATCH 17/40] removed unused comments --- lib/pages/chat_list/start_chat_fab.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/pages/chat_list/start_chat_fab.dart b/lib/pages/chat_list/start_chat_fab.dart index c9175b8d6..117833ff0 100644 --- a/lib/pages/chat_list/start_chat_fab.dart +++ b/lib/pages/chat_list/start_chat_fab.dart @@ -30,7 +30,6 @@ class StartChatFloatingActionButton extends StatelessWidget { void _onPressed(BuildContext context) async { //#Pangea if (controller.activeSpaceId != null) { - // context.go('/rooms/newgroup/${controller.activeSpaceId ?? ''}'); context.go('/rooms/newgroup?spaceId=${controller.activeSpaceId ?? ''}'); return; } @@ -45,7 +44,6 @@ class StartChatFloatingActionButton extends StatelessWidget { case ActiveFilter.groups: // #Pangea // context.go('/rooms/newgroup'); - // context.go('/rooms/newgroup/${controller.activeSpaceId ?? ''}'); context.go('/rooms/newgroup?spaceId=${controller.activeSpaceId ?? ''}'); // Pangea# break; From f797cdbb4afadb211a0b83efe1420ba2eb314831 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Mon, 20 May 2024 12:34:36 -0400 Subject: [PATCH 18/40] ensure speech_to_text endpoint is only called once, round words for per minute string, always auto-speech-to-text for audio message toolbar --- lib/pangea/enum/message_mode_enum.dart | 14 +++++++++++ .../pangea_message_event.dart | 13 ++++++++++ .../pangea_representation_event.dart | 5 ---- .../chat/message_speech_to_text_card.dart | 2 +- lib/pangea/widgets/chat/message_toolbar.dart | 25 +++++++++++++++---- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/lib/pangea/enum/message_mode_enum.dart b/lib/pangea/enum/message_mode_enum.dart index c64861dc0..25948d23b 100644 --- a/lib/pangea/enum/message_mode_enum.dart +++ b/lib/pangea/enum/message_mode_enum.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:material_symbols_icons/symbols.dart'; +import 'package:matrix/matrix.dart'; enum MessageMode { translation, definition, speechToText, textToSpeech } @@ -52,4 +53,17 @@ extension MessageModeExtension on MessageMode { .oopsSomethingWentWrong; // Title to indicate an error or unsupported mode } } + + bool isValidMode(Event event) { + switch (this) { + case MessageMode.translation: + case MessageMode.textToSpeech: + case MessageMode.definition: + return event.messageType == MessageTypes.Text; + case MessageMode.speechToText: + return event.messageType == MessageTypes.Audio; + default: + return true; + } + } } diff --git a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart index cb7cba52a..db5c7902a 100644 --- a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart +++ b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart @@ -346,6 +346,19 @@ class PangeaMessageEvent { ), ); + _representations?.add( + RepresentationEvent( + timeline: timeline, + content: PangeaRepresentation( + langCode: response.langCode, + text: response.transcript.text, + originalSent: false, + originalWritten: false, + speechToText: response, + ), + ), + ); + return response; } diff --git a/lib/pangea/matrix_event_wrappers/pangea_representation_event.dart b/lib/pangea/matrix_event_wrappers/pangea_representation_event.dart index 0796f7f5d..e774dc4f2 100644 --- a/lib/pangea/matrix_event_wrappers/pangea_representation_event.dart +++ b/lib/pangea/matrix_event_wrappers/pangea_representation_event.dart @@ -3,7 +3,6 @@ import 'dart:developer'; import 'package:fluffychat/pangea/extensions/pangea_event_extension.dart'; import 'package:fluffychat/pangea/matrix_event_wrappers/pangea_choreo_event.dart'; import 'package:fluffychat/pangea/models/pangea_token_model.dart'; -import 'package:fluffychat/pangea/models/speech_to_text_models.dart'; import 'package:fluffychat/pangea/models/tokens_event_content_model.dart'; import 'package:fluffychat/pangea/repo/tokens_repo.dart'; import 'package:flutter/foundation.dart'; @@ -27,15 +26,12 @@ class RepresentationEvent { ChoreoRecord? _choreo; Timeline timeline; - SpeechToTextModel? _speechToTextResponse; - RepresentationEvent({ required this.timeline, Event? event, PangeaRepresentation? content, PangeaMessageTokens? tokens, ChoreoRecord? choreo, - SpeechToTextModel? speechToTextResponse, }) { if (event != null && event.type != PangeaEventTypes.representation) { throw Exception( @@ -46,7 +42,6 @@ class RepresentationEvent { _content = content; _tokens = tokens; _choreo = choreo; - _speechToTextResponse = speechToTextResponse; } Event? get event => _event; diff --git a/lib/pangea/widgets/chat/message_speech_to_text_card.dart b/lib/pangea/widgets/chat/message_speech_to_text_card.dart index bc2cf3327..37b013b53 100644 --- a/lib/pangea/widgets/chat/message_speech_to_text_card.dart +++ b/lib/pangea/widgets/chat/message_speech_to_text_card.dart @@ -138,7 +138,7 @@ class MessageSpeechToTextCardState extends State { } String? get wordsPerMinuteString => - speechToTextResponse?.transcript.wordsPerMinute?.toString(); + speechToTextResponse?.transcript.wordsPerMinute?.toStringAsFixed(2); @override Widget build(BuildContext context) { diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index b2c61a354..81884ffca 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -172,6 +172,19 @@ class MessageToolbarState extends State { debugPrint("updating toolbar mode"); final bool subscribed = MatrixState.pangeaController.subscriptionController.isSubscribed; + + if (!newMode.isValidMode(widget.pangeaMessageEvent.event)) { + ErrorHandler.logError( + e: "Invalid mode for event", + s: StackTrace.current, + data: { + "newMode": newMode, + "event": widget.pangeaMessageEvent.event, + }, + ); + return; + } + setState(() { currentMode = newMode; updatingMode = true; @@ -274,12 +287,14 @@ class MessageToolbarState extends State { PLocalKey.autoPlayMessages, ) ?? true; + + if (widget.pangeaMessageEvent.isAudioMessage) { + updateMode(MessageMode.speechToText); + return; + } + autoplay - ? updateMode( - widget.pangeaMessageEvent.isAudioMessage - ? MessageMode.speechToText - : MessageMode.textToSpeech, - ) + ? updateMode(MessageMode.textToSpeech) : updateMode(MessageMode.translation); }); From 6210f743b0693c054be0b4fe79601285fe1e173f Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Mon, 20 May 2024 13:22:13 -0400 Subject: [PATCH 19/40] remove excess bot options --- .../conversation_bot/conversation_bot_mode_select.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 70675e898..9662dec55 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart @@ -16,11 +16,11 @@ class ConversationBotModeSelect extends StatelessWidget { final Map options = { "discussion": L10n.of(context)!.conversationBotModeSelectOption_discussion, - "custom": L10n.of(context)!.conversationBotModeSelectOption_custom, - "conversation": - L10n.of(context)!.conversationBotModeSelectOption_conversation, - "text_adventure": - L10n.of(context)!.conversationBotModeSelectOption_textAdventure, + // "custom": L10n.of(context)!.conversationBotModeSelectOption_custom, + // "conversation": + // L10n.of(context)!.conversationBotModeSelectOption_conversation, + // "text_adventure": + // L10n.of(context)!.conversationBotModeSelectOption_textAdventure, }; return Padding( From 39c8012137740463d1c30c725092ac1b8919f50a Mon Sep 17 00:00:00 2001 From: Kelrap Date: Mon, 20 May 2024 13:52:14 -0400 Subject: [PATCH 20/40] Archive list does not show spaces/analytics rooms --- lib/pages/archive/archive.dart | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/pages/archive/archive.dart b/lib/pages/archive/archive.dart index a3c35c347..06d80b7df 100644 --- a/lib/pages/archive/archive.dart +++ b/lib/pages/archive/archive.dart @@ -1,13 +1,12 @@ -import 'package:flutter/material.dart'; - import 'package:adaptive_dialog/adaptive_dialog.dart'; +import 'package:fluffychat/pages/archive/archive_view.dart'; +import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart'; +import 'package:fluffychat/widgets/matrix.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'; -import 'package:fluffychat/pages/archive/archive_view.dart'; -import 'package:fluffychat/widgets/matrix.dart'; - class Archive extends StatefulWidget { const Archive({super.key}); @@ -20,7 +19,11 @@ class ArchiveController extends State { Future> getArchive(BuildContext context) async { if (archive.isNotEmpty) return archive; - return archive = await Matrix.of(context).client.loadArchive(); + // #Pangea + return archive = (await Matrix.of(context).client.loadArchive()) + .where((e) => (!e.isSpace && !e.isAnalyticsRoom)) + .toList(); + // Pangea# } void forgetRoomAction(int i) async { From 5f839555440df8c33ef5af771457263fbc7ef37d Mon Sep 17 00:00:00 2001 From: Kelrap Date: Mon, 20 May 2024 14:26:18 -0400 Subject: [PATCH 21/40] Archived chats don't show Chat Details or Leave --- lib/pages/archive/archive.dart | 1 + lib/pages/chat/chat_view.dart | 3 +- lib/widgets/chat_settings_popup_menu.dart | 39 ++++++++++++++++------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/lib/pages/archive/archive.dart b/lib/pages/archive/archive.dart index 06d80b7df..78e735d05 100644 --- a/lib/pages/archive/archive.dart +++ b/lib/pages/archive/archive.dart @@ -20,6 +20,7 @@ class ArchiveController extends State { Future> getArchive(BuildContext context) async { if (archive.isNotEmpty) return archive; // #Pangea + //return archive = await Matrix.of(context).client.loadArchive(); return archive = (await Matrix.of(context).client.loadArchive()) .where((e) => (!e.isSpace && !e.isAnalyticsRoom)) .toList(); diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index 57255ffc9..21789f527 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -116,7 +116,8 @@ class ChatView extends StatelessWidget { // #Pangea } else { return [ - ChatSettingsPopupMenu(controller.room, !controller.room.isDirectChat), + ChatSettingsPopupMenu(controller.room, + (!controller.room.isDirectChat && !controller.room.isArchived)), ]; } diff --git a/lib/widgets/chat_settings_popup_menu.dart b/lib/widgets/chat_settings_popup_menu.dart index f10f08ff7..1feadc459 100644 --- a/lib/widgets/chat_settings_popup_menu.dart +++ b/lib/widgets/chat_settings_popup_menu.dart @@ -83,19 +83,34 @@ class ChatSettingsPopupMenuState extends State { ], ), ), - PopupMenuItem( - value: 'leave', - child: Row( - children: [ - // #Pangea - // const Icon(Icons.delete_outlined), - const Icon(Icons.arrow_forward), - // Pangea# - const SizedBox(width: 12), - Text(L10n.of(context)!.leave), - ], + // #Pangea + // PopupMenuItem( + // value: 'leave', + // child: Row( + // children: [ + // // #Pangea + // // const Icon(Icons.delete_outlined), + // const Icon(Icons.arrow_forward), + // // Pangea# + // const SizedBox(width: 12), + // Text(L10n.of(context)!.leave), + // ], + // ), + // ), + if (!widget.room.isArchived) + PopupMenuItem( + value: 'leave', + child: Row( + children: [ + // #Pangea + // const Icon(Icons.delete_outlined), + const Icon(Icons.arrow_forward), + // Pangea# + const SizedBox(width: 12), + Text(L10n.of(context)!.leave), + ], + ), ), - ), // #Pangea if (classSettings != null) PopupMenuItem( From 8c421d80cc82427e4d1579366d0c115c97bfc3b9 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Mon, 20 May 2024 14:38:17 -0400 Subject: [PATCH 22/40] adjusted pangea comments --- lib/widgets/chat_settings_popup_menu.dart | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/widgets/chat_settings_popup_menu.dart b/lib/widgets/chat_settings_popup_menu.dart index 1feadc459..781b8ab61 100644 --- a/lib/widgets/chat_settings_popup_menu.dart +++ b/lib/widgets/chat_settings_popup_menu.dart @@ -84,20 +84,8 @@ class ChatSettingsPopupMenuState extends State { ), ), // #Pangea - // PopupMenuItem( - // value: 'leave', - // child: Row( - // children: [ - // // #Pangea - // // const Icon(Icons.delete_outlined), - // const Icon(Icons.arrow_forward), - // // Pangea# - // const SizedBox(width: 12), - // Text(L10n.of(context)!.leave), - // ], - // ), - // ), if (!widget.room.isArchived) + // Pangea# PopupMenuItem( value: 'leave', child: Row( From 9a6a58e53cb6ea54daffaff01382ddc1fe609149 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Mon, 20 May 2024 16:33:33 -0400 Subject: [PATCH 23/40] Prevent non-admins of room from toggling class membership --- lib/pangea/extensions/pangea_room_extension.dart | 3 +++ lib/pangea/widgets/class/add_space_toggles.dart | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/pangea/extensions/pangea_room_extension.dart b/lib/pangea/extensions/pangea_room_extension.dart index bf152012a..febd17fa8 100644 --- a/lib/pangea/extensions/pangea_room_extension.dart +++ b/lib/pangea/extensions/pangea_room_extension.dart @@ -815,6 +815,9 @@ extension PangeaRoom on Room { ); return false; } + if (room != null && !room.isRoomAdmin) { + return false; + } if (!pangeaCanSendEvent(EventTypes.spaceChild) && !isRoomAdmin) { return false; } diff --git a/lib/pangea/widgets/class/add_space_toggles.dart b/lib/pangea/widgets/class/add_space_toggles.dart index cd875cd95..eb06cd26a 100644 --- a/lib/pangea/widgets/class/add_space_toggles.dart +++ b/lib/pangea/widgets/class/add_space_toggles.dart @@ -235,8 +235,13 @@ class AddToSpaceState extends State { ), activeColor: AppConfig.activeToggleColor, value: isSuggestedInSpace(possibleParent), - onChanged: (bool suggest) => - setSuggested(suggest, possibleParent), + onChanged: (bool suggest) => canAdd + ? setSuggested(suggest, possibleParent) + : ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(L10n.of(context)!.noPermission), + ), + ), ) : Container(), ), From 0aacd6407cb3d5f926aa1a4308a77c9bdf9be4bd Mon Sep 17 00:00:00 2001 From: ggurdin Date: Mon, 20 May 2024 16:52:56 -0400 Subject: [PATCH 24/40] don't add spaceId query parameter if activeSpaceId is null --- lib/pages/chat_list/start_chat_fab.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pages/chat_list/start_chat_fab.dart b/lib/pages/chat_list/start_chat_fab.dart index 117833ff0..f25374f4e 100644 --- a/lib/pages/chat_list/start_chat_fab.dart +++ b/lib/pages/chat_list/start_chat_fab.dart @@ -30,7 +30,9 @@ class StartChatFloatingActionButton extends StatelessWidget { void _onPressed(BuildContext context) async { //#Pangea if (controller.activeSpaceId != null) { - context.go('/rooms/newgroup?spaceId=${controller.activeSpaceId ?? ''}'); + context.go( + '/rooms/newgroup${controller.activeSpaceId != null ? '?spaceId=${controller.activeSpaceId}' : ''}', + ); return; } //Pangea# @@ -44,7 +46,9 @@ class StartChatFloatingActionButton extends StatelessWidget { case ActiveFilter.groups: // #Pangea // context.go('/rooms/newgroup'); - context.go('/rooms/newgroup?spaceId=${controller.activeSpaceId ?? ''}'); + context.go( + '/rooms/newgroup${controller.activeSpaceId != null ? '?spaceId=${controller.activeSpaceId}' : ''}', + ); // Pangea# break; case ActiveFilter.spaces: From 733f37717cffcdf83da6a3ae61848656a2fd6134 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Tue, 21 May 2024 11:11:55 -0400 Subject: [PATCH 25/40] When user changes languages, updates learning settings --- .../settings_learning/settings_learning.dart | 7 +++++-- .../settings_learning_view.dart | 2 +- .../widgets/user_settings/language_tile.dart | 16 ++++++++++------ .../widgets/user_settings/p_language_dialog.dart | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/pangea/pages/settings_learning/settings_learning.dart b/lib/pangea/pages/settings_learning/settings_learning.dart index f699fc7b5..0785f3407 100644 --- a/lib/pangea/pages/settings_learning/settings_learning.dart +++ b/lib/pangea/pages/settings_learning/settings_learning.dart @@ -1,10 +1,9 @@ import 'dart:async'; -import 'package:flutter/material.dart'; - import 'package:fluffychat/pangea/controllers/pangea_controller.dart'; import 'package:fluffychat/pangea/pages/settings_learning/settings_learning_view.dart'; import 'package:fluffychat/widgets/matrix.dart'; +import 'package:flutter/material.dart'; class SettingsLearning extends StatefulWidget { const SettingsLearning({super.key}); @@ -32,6 +31,10 @@ class SettingsLearningController extends State { }); } + Future refresh() async { + setState(() {}); + } + @override void dispose() { super.dispose(); diff --git a/lib/pangea/pages/settings_learning/settings_learning_view.dart b/lib/pangea/pages/settings_learning/settings_learning_view.dart index d878dcb42..6c3a87f00 100644 --- a/lib/pangea/pages/settings_learning/settings_learning_view.dart +++ b/lib/pangea/pages/settings_learning/settings_learning_view.dart @@ -31,7 +31,7 @@ class SettingsLearningView extends StatelessWidget { withScrolling: true, child: Column( children: [ - LanguageTile(), + LanguageTile(controller), CountryPickerTile(), const SizedBox(height: 8), const Divider(height: 1), diff --git a/lib/pangea/widgets/user_settings/language_tile.dart b/lib/pangea/widgets/user_settings/language_tile.dart index 085779781..95ff42f86 100644 --- a/lib/pangea/widgets/user_settings/language_tile.dart +++ b/lib/pangea/widgets/user_settings/language_tile.dart @@ -1,19 +1,20 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_gen/gen_l10n/l10n.dart'; - import 'package:fluffychat/pangea/controllers/pangea_controller.dart'; import 'package:fluffychat/pangea/models/language_model.dart'; +import 'package:fluffychat/pangea/pages/settings_learning/settings_learning.dart'; import 'package:fluffychat/widgets/matrix.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; + import '../flag.dart'; import 'p_language_dialog.dart'; //PTODO - move this to settings_learning_view.dart and make callback a setState class LanguageTile extends StatelessWidget { + final SettingsLearningController learningController; final PangeaController pangeaController = MatrixState.pangeaController; - LanguageTile({super.key}); + LanguageTile(this.learningController, {super.key}); @override Widget build(BuildContext context) { @@ -81,7 +82,10 @@ class LanguageTile extends StatelessWidget { ], ), trailing: const Icon(Icons.edit_outlined), - onTap: () => pLanguageDialog(context, () {}), + onTap: () async { + await pLanguageDialog(context, () {}); + learningController.refresh(); + }, ); } } diff --git a/lib/pangea/widgets/user_settings/p_language_dialog.dart b/lib/pangea/widgets/user_settings/p_language_dialog.dart index 077959ead..4d09b506e 100644 --- a/lib/pangea/widgets/user_settings/p_language_dialog.dart +++ b/lib/pangea/widgets/user_settings/p_language_dialog.dart @@ -15,7 +15,7 @@ import '../../../widgets/matrix.dart'; import 'p_language_dropdown.dart'; import 'p_question_container.dart'; -pLanguageDialog(BuildContext parentContext, Function callback) { +pLanguageDialog(BuildContext parentContext, Function callback) async { final PangeaController pangeaController = MatrixState.pangeaController; //PTODO: if source language not set by user, default to languge from device settings final LanguageModel? userL1 = pangeaController.languageController.userL1; From 8b0104db06da84a2ea3a184030b1485cacad0467 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Tue, 21 May 2024 11:51:30 -0400 Subject: [PATCH 26/40] Moved state-related functionality to controller --- lib/pangea/pages/settings_learning/settings_learning.dart | 4 +++- lib/pangea/widgets/user_settings/language_tile.dart | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pangea/pages/settings_learning/settings_learning.dart b/lib/pangea/pages/settings_learning/settings_learning.dart index 0785f3407..c560fef57 100644 --- a/lib/pangea/pages/settings_learning/settings_learning.dart +++ b/lib/pangea/pages/settings_learning/settings_learning.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:fluffychat/pangea/controllers/pangea_controller.dart'; import 'package:fluffychat/pangea/pages/settings_learning/settings_learning_view.dart'; +import 'package:fluffychat/pangea/widgets/user_settings/p_language_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/material.dart'; @@ -31,7 +32,8 @@ class SettingsLearningController extends State { }); } - Future refresh() async { + Future changeLanguage() async { + await pLanguageDialog(context, () {}); setState(() {}); } diff --git a/lib/pangea/widgets/user_settings/language_tile.dart b/lib/pangea/widgets/user_settings/language_tile.dart index 95ff42f86..d66335300 100644 --- a/lib/pangea/widgets/user_settings/language_tile.dart +++ b/lib/pangea/widgets/user_settings/language_tile.dart @@ -6,7 +6,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import '../flag.dart'; -import 'p_language_dialog.dart'; //PTODO - move this to settings_learning_view.dart and make callback a setState @@ -83,8 +82,7 @@ class LanguageTile extends StatelessWidget { ), trailing: const Icon(Icons.edit_outlined), onTap: () async { - await pLanguageDialog(context, () {}); - learningController.refresh(); + learningController.changeLanguage(); }, ); } From aea0c9ccecd9cb53e4e4b5c67732a8a29a3ea7eb Mon Sep 17 00:00:00 2001 From: William Jordan-Cooley Date: Tue, 21 May 2024 17:44:09 -0400 Subject: [PATCH 27/40] added language detection controller, edited README, and removed some old code --- README.md | 66 ++-------- .../controllers/analytics_sender.dart | 24 ---- .../language_detection_controller.dart | 122 ++++++++++++++++++ lib/pangea/network/urls.dart | 7 +- lib/pangea/repo/message_service.repo.dart | 55 -------- needed-translations.txt | 99 ++++++++++++++ 6 files changed, 233 insertions(+), 140 deletions(-) delete mode 100644 lib/pangea/choreographer/controllers/analytics_sender.dart create mode 100644 lib/pangea/controllers/language_detection_controller.dart delete mode 100644 lib/pangea/repo/message_service.repo.dart diff --git a/README.md b/README.md index 7c4970e00..7c27b6e2e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ -Pangea Chat Client Setup: +# Overview -* Download VSCode if you do not already have it installed +[Pangea Chat](https://pangea.chat) is a web and mobile platform which lets students ‘learn a language while texting their friends.’ Addressing the gap in communicative language teaching, especially for beginners lacking skill and confidence, Pangea Chat provides a low-stress, high-support environment for language learning through authentic conversations. By integrating human and artificial intelligence, the app enhances communicative abilities and supports educators. Pangea Chat has been grant funded by the National Science Foundation and Virginia Innovation Partnership Corporation based on its technical innovation and potential for broad social impact. Our mission is to build a global, decentralized learning network supporting intercultural learning and exchange. + +# Pangea Chat Client Setup + +* Download VSCode if you do not already have it installed. This is the preferred IDE for development with Pangea Chat. * Download flutter on your device using this guide: https://docs.flutter.dev/get-started/install * Test to make sure that flutter is properly installed by running “flutter –version” * You may need to add flutter to your path manually. Instructions can be found here: https://docs.flutter.dev/get-started/install/macos/mobile-ios?tab=download#add-flutter-to-your-path @@ -14,7 +18,7 @@ Pangea Chat Client Setup: * Run “brew install cocoapods” to install cocoapods * Run “flutter doctor” and for any missing components, follow the instructions from the print out to install / setup * Clone the client repo -* Copy the .env file (and the .env.prod file, if you want to run production builds), into the root folder of the client and the assets/ folder +* Copy the .env file (and the .env.prod file, if you want to run production builds), into the root folder of the client and the assets/ folder. Contact Gabby for a copy of this file. * Uncomment the lines in the pubspec.yaml file in the assets section with paths to .env file * To run on iOS: * Run “flutter precache --ios” @@ -25,62 +29,10 @@ Pangea Chat Client Setup: * On web, run `flutter run -d chrome –hot` * On mobile device or simulator, run `flutter run –hot -d ` -![Screenshot](https://github.com/krille-chan/fluffychat/blob/main/assets/banner_transparent.png?raw=true) - -[FluffyChat](https://fluffychat.im) is an open source, nonprofit and cute [[matrix](https://matrix.org)] client written in [Flutter](https://flutter.dev). The goal of the app is to create an easy to use instant messenger which is open source and accessible for everyone. - -### Links: - -- 🌐 [[Weblate] Translate FluffyChat into your language](https://hosted.weblate.org/projects/fluffychat/) -- 🌍 [[m] Join the community](https://matrix.to/#/#fluffychat:matrix.org) -- 📰 [[Mastodon] Get updates on social media](https://mastodon.art/@krille) -- 🖥️ [[Famedly] Server hosting and professional support](https://famedly.com/kontakt) -- 💝 [[Liberapay] Support FluffyChat development](https://de.liberapay.com/KrilleChritzelius) - -Buy Me a Coffee at ko-fi.com - -### Screenshots: - -![Screenshot](https://github.com/krille-chan/fluffychat/blob/main/docs/screenshots/product.jpeg?raw=true) - -# Features - -- 📩 Send all kinds of messages, images and files -- 🎙️ Voice messages -- 📍 Location sharing -- 🔔 Push notifications -- 💬 Unlimited private and public group chats -- 📣 Public channels with thousands of participants -- 🛠️ Feature rich group moderation including all matrix features -- 🔍 Discover and join public groups -- 🌙 Dark mode -- 🎨 Material You design -- 📟 Hides complexity of Matrix IDs behind simple QR codes -- 😄 Custom emotes and stickers -- 🌌 Spaces -- 🔄 Compatible with Element, Nheko, NeoChat and all other Matrix apps -- 🔐 End to end encryption -- 🔒 Encrypted chat backup -- 😀 Emoji verification & cross signing - -... and much more. - - -# Installation - -Please visit the website for installation instructions: - -- https://fluffychat.im - -# How to build - -Please visit the [Wiki](https://github.com/krille-chan/fluffychat/wiki) for build instructions: - -- https://github.com/krille-chan/fluffychat/wiki/How-To-Build - - # Special thanks +* Pangea Chat is a fork of [FluffyChat](https://fluffychat.im), is an open source, nonprofit and cute [[matrix](https://matrix.org)] client written in [Flutter](https://flutter.dev). The goal of FluffyChat is to create an easy to use instant messenger which is open source and accessible for everyone. You can [support the primary maker of FluffyChat directly here.](https://ko-fi.com/C1C86VN53) + * Fabiyamada is a graphics designer and has made the fluffychat logo and the banner. Big thanks for her great designs. * Advocatux has made the Spanish translation with great love and care. He always stands by my side and supports my work with great commitment. diff --git a/lib/pangea/choreographer/controllers/analytics_sender.dart b/lib/pangea/choreographer/controllers/analytics_sender.dart deleted file mode 100644 index fe4575f38..000000000 --- a/lib/pangea/choreographer/controllers/analytics_sender.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:fluffychat/pangea/choreographer/controllers/it_controller.dart'; - -class MlController { - final ITController controller; - MlController(this.controller); - - // sendPayloads(String message, String messageId) async { - // final MessageServiceModel serviceModel = MessageServiceModel( - // classId: controller.state!.classId, - // roomId: controller.state!.roomId, - // message: message.toString(), - // messageId: messageId.toString(), - // payloadIds: controller.state!.payLoadIds, - // userId: controller.state!.userId!, - // l1Lang: controller.state!.sourceLangCode, - // l2Lang: controller.state!.targetLangCode!, - // ); - // try { - // await MessageServiceRepo.sendPayloads(serviceModel); - // } catch (err) { - // debugPrint('$err in sendPayloads'); - // } - // } -} diff --git a/lib/pangea/controllers/language_detection_controller.dart b/lib/pangea/controllers/language_detection_controller.dart new file mode 100644 index 000000000..400cd4419 --- /dev/null +++ b/lib/pangea/controllers/language_detection_controller.dart @@ -0,0 +1,122 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:fluffychat/pangea/config/environment.dart'; +import 'package:fluffychat/pangea/controllers/pangea_controller.dart'; +import 'package:fluffychat/pangea/network/urls.dart'; +import 'package:http/http.dart' as http; + +import '../network/requests.dart'; + +class LanguageDetectionRequest { + String fullText; + String userL1; + String userL2; + + LanguageDetectionRequest({ + required this.fullText, + this.userL1 = "", + required this.userL2, + }); + + Map toJson() => { + 'full_text': fullText, + 'user_l1': userL1, + 'user_l2': userL2, + }; + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + return other is LanguageDetectionRequest && + other.fullText == fullText && + other.userL1 == userL1 && + other.userL2 == userL2; + } + + @override + int get hashCode => fullText.hashCode ^ userL1.hashCode ^ userL2.hashCode; +} + +class LanguageDetectionResponse { + List> detections; + String fullText; + + LanguageDetectionResponse({ + required this.detections, + required this.fullText, + }); + + factory LanguageDetectionResponse.fromJson(Map json) { + return LanguageDetectionResponse( + detections: List>.from(json['detections']), + fullText: json['full_text'], + ); + } +} + +class _LanguageDetectionCacheItem { + Future data; + + _LanguageDetectionCacheItem({ + required this.data, + }); +} + +class LanguageDetectionController { + static final Map + _cache = {}; + late final PangeaController _pangeaController; + Timer? _cacheClearTimer; + + LanguageDetectionController(PangeaController pangeaController) { + _pangeaController = pangeaController; + _initializeCacheClearing(); + } + + void _initializeCacheClearing() { + const duration = Duration(minutes: 15); // Adjust the duration as needed + _cacheClearTimer = Timer.periodic(duration, (Timer t) => _clearCache()); + } + + void _clearCache() { + _cache.clear(); + } + + void dispose() { + _cacheClearTimer?.cancel(); + } + + Future get( + LanguageDetectionRequest params, + ) async { + if (_cache.containsKey(params)) { + return _cache[params]!.data; + } else { + final Future response = _fetchResponse( + await _pangeaController.userController.accessToken, + params, + ); + _cache[params] = _LanguageDetectionCacheItem(data: response); + return response; + } + } + + static Future _fetchResponse( + String accessToken, + LanguageDetectionRequest params, + ) async { + final Requests request = Requests( + choreoApiKey: Environment.choreoApi, + accessToken: accessToken, + ); + + final http.Response res = await request.post( + url: PApiUrls.languageDetection, + body: params.toJson(), + ); + + final Map json = jsonDecode(res.body); + return LanguageDetectionResponse.fromJson(json); + } +} diff --git a/lib/pangea/network/urls.dart b/lib/pangea/network/urls.dart index 16d8bcd23..ff0404947 100644 --- a/lib/pangea/network/urls.dart +++ b/lib/pangea/network/urls.dart @@ -24,13 +24,12 @@ class PApiUrls { /// ---------------------- Conversation Partner ------------------------- static String searchUserProfiles = "/account/search"; - ///-------------------------------- Deprecated analytics -------------------- - static String classAnalytics = "${Environment.choreoApi}/class_analytics"; - static String messageService = "/message_service"; - ///-------------------------------- choreo -------------------------- static String igc = "${Environment.choreoApi}/grammar"; + static String languageDetection = + "${Environment.choreoApi}/language_detection"; + static String igcLite = "${Environment.choreoApi}/grammar_lite"; static String spanDetails = "${Environment.choreoApi}/span_details"; diff --git a/lib/pangea/repo/message_service.repo.dart b/lib/pangea/repo/message_service.repo.dart deleted file mode 100644 index ce51a3802..000000000 --- a/lib/pangea/repo/message_service.repo.dart +++ /dev/null @@ -1,55 +0,0 @@ -import '../config/environment.dart'; -import '../network/requests.dart'; -import '../network/urls.dart'; - -class MessageServiceRepo { - static Future sendPayloads( - MessageServiceModel serviceModel, - String messageId, - ) async { - final Requests req = Requests( - baseUrl: Environment.choreoApi, - choreoApiKey: Environment.choreoApiKey, - ); - - final json = serviceModel.toJson(); - json["msg_id"] = messageId; - - await req.post(url: PApiUrls.messageService, body: json); - } -} - -class MessageServiceModel { - List payloadIds; - String? messageId; - String message; - String userId; - String roomId; - String? classId; - String? l1Lang; - String l2Lang; - - MessageServiceModel({ - required this.payloadIds, - required this.messageId, - required this.message, - required this.userId, - required this.roomId, - required this.classId, - required this.l1Lang, - required this.l2Lang, - }); - - toJson() { - return { - 'payload_ids': payloadIds, - 'msg_id': messageId, - 'message': message, - 'user_id': userId, - 'room_id': roomId, - 'class_id': classId, - 'l1_lang': l1Lang, - 'l2_lang': l2Lang, - }; - } -} diff --git a/needed-translations.txt b/needed-translations.txt index 7cbcc8a05..120bd4255 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -821,6 +821,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -2242,6 +2244,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -3125,6 +3129,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -4008,6 +4014,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -4891,6 +4899,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -5774,6 +5784,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -6604,6 +6616,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -7487,6 +7501,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -8370,10 +8386,17 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], + "es": [ + "studentAnalyticsNotAvailable", + "roomDataMissing" + ], + "et": [ "accountInformation", "addGroupDescription", @@ -9196,6 +9219,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -10022,6 +10047,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -10905,6 +10932,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -11788,6 +11817,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -12671,6 +12702,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -13554,6 +13587,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -14380,6 +14415,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -15263,6 +15300,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -16146,6 +16185,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -17016,6 +17057,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -17899,6 +17942,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -19306,6 +19351,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -20189,6 +20236,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -21072,6 +21121,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -21940,6 +21991,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -22823,6 +22876,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -23706,6 +23761,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -24589,6 +24646,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -25472,6 +25531,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -26355,6 +26416,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -27238,6 +27301,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -28121,6 +28186,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -29004,6 +29071,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -29856,6 +29925,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -30739,6 +30810,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -31622,6 +31695,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -32448,6 +32523,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -33331,6 +33408,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -34214,6 +34293,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -35097,6 +35178,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -35945,6 +36028,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -36828,6 +36913,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -37711,6 +37798,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -38579,6 +38668,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -39405,6 +39496,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -40288,6 +40381,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -41114,6 +41209,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ], @@ -41997,6 +42094,8 @@ "accuracy", "points", "noPaymentInfo", + "studentAnalyticsNotAvailable", + "roomDataMissing", "updatePhoneOS", "wordsPerMinute" ] From 757e9be21222e518d6e051c4197f32b30ea4401d Mon Sep 17 00:00:00 2001 From: William Jordan-Cooley Date: Tue, 21 May 2024 17:53:37 -0400 Subject: [PATCH 28/40] allowing user_l1 and user_l2 to be nullable in request --- .../controllers/language_detection_controller.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/pangea/controllers/language_detection_controller.dart b/lib/pangea/controllers/language_detection_controller.dart index 400cd4419..0a233a12d 100644 --- a/lib/pangea/controllers/language_detection_controller.dart +++ b/lib/pangea/controllers/language_detection_controller.dart @@ -9,9 +9,18 @@ import 'package:http/http.dart' as http; import '../network/requests.dart'; class LanguageDetectionRequest { + /// The full text from which to detect the language. String fullText; - String userL1; - String userL2; + + /// The base language of the user, if known. Including this is much preferred + /// and should return better results; however, it is not absolutely necessary. + /// This property is nullable to allow for situations where the languages are not set + /// at the time of the request. + String? userL1; + + /// The target language of the user. This is expected to be set for the request + /// but is nullable to handle edge cases where it might not be. + String? userL2; LanguageDetectionRequest({ required this.fullText, From 1724871de4255e9e090255cf145230bb58b139e7 Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Wed, 22 May 2024 09:01:36 -0400 Subject: [PATCH 29/40] remove discussion mode selects --- .../conversation_bot_settings.dart | 45 +++++++++---------- macos/Flutter/GeneratedPluginRegistrant.swift | 4 +- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart index 0558307d6..d10fd6980 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart @@ -5,7 +5,6 @@ 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'; @@ -245,28 +244,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/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index ce6ae4707..09c588b29 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -28,7 +28,7 @@ import package_info_plus import pasteboard import path_provider_foundation import purchases_flutter -import record_macos +import record_darwin import sentry_flutter import share_plus import shared_preferences_foundation @@ -64,7 +64,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PurchasesFlutterPlugin.register(with: registry.registrar(forPlugin: "PurchasesFlutterPlugin")) - RecordMacosPlugin.register(with: registry.registrar(forPlugin: "RecordMacosPlugin")) + RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin")) SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) From 392aad50bbf234f09582ffff18989fcbb6e1ef07 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 22 May 2024 09:43:56 -0400 Subject: [PATCH 30/40] added language detection controller to pangea controller --- .../controllers/it_controller.dart | 27 +++++++++---------- .../language_detection_controller.dart | 7 +++++ lib/pangea/controllers/pangea_controller.dart | 3 +++ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index 74d0b0159..83d678e98 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -15,7 +15,6 @@ import '../../models/it_response_model.dart'; import '../../models/it_step.dart'; import '../../models/system_choice_translation_model.dart'; import '../../repo/interactive_translation_repo.dart'; -import '../../repo/message_service.repo.dart'; import 'choreographer.dart'; class ITController { @@ -247,19 +246,19 @@ class ITController { ), ); - MessageServiceModel? messageServiceModelWithMessageId() => - usedInteractiveTranslation - ? MessageServiceModel( - classId: choreographer.classId, - roomId: choreographer.roomId, - message: choreographer.currentText, - messageId: null, - payloadIds: payLoadIds, - userId: choreographer.userId!, - l1Lang: sourceLangCode, - l2Lang: targetLangCode, - ) - : null; + // MessageServiceModel? messageServiceModelWithMessageId() => + // usedInteractiveTranslation + // ? MessageServiceModel( + // classId: choreographer.classId, + // roomId: choreographer.roomId, + // message: choreographer.currentText, + // messageId: null, + // payloadIds: payLoadIds, + // userId: choreographer.userId!, + // l1Lang: sourceLangCode, + // l2Lang: targetLangCode, + // ) + // : null; //maybe we store IT data in the same format? make a specific kind of match? void selectTranslation(int chosenIndex) { diff --git a/lib/pangea/controllers/language_detection_controller.dart b/lib/pangea/controllers/language_detection_controller.dart index 0a233a12d..7b4571c5d 100644 --- a/lib/pangea/controllers/language_detection_controller.dart +++ b/lib/pangea/controllers/language_detection_controller.dart @@ -62,6 +62,13 @@ class LanguageDetectionResponse { fullText: json['full_text'], ); } + + Map toJson() { + return { + 'detections': detections, + 'full_text': fullText, + }; + } } class _LanguageDetectionCacheItem { diff --git a/lib/pangea/controllers/pangea_controller.dart b/lib/pangea/controllers/pangea_controller.dart index 204ef9307..753a8c9e6 100644 --- a/lib/pangea/controllers/pangea_controller.dart +++ b/lib/pangea/controllers/pangea_controller.dart @@ -6,6 +6,7 @@ import 'package:fluffychat/pangea/constants/pangea_event_types.dart'; import 'package:fluffychat/pangea/controllers/class_controller.dart'; import 'package:fluffychat/pangea/controllers/contextual_definition_controller.dart'; import 'package:fluffychat/pangea/controllers/language_controller.dart'; +import 'package:fluffychat/pangea/controllers/language_detection_controller.dart'; import 'package:fluffychat/pangea/controllers/language_list_controller.dart'; import 'package:fluffychat/pangea/controllers/local_settings.dart'; import 'package:fluffychat/pangea/controllers/message_data_controller.dart'; @@ -51,6 +52,7 @@ class PangeaController { late SubscriptionController subscriptionController; late TextToSpeechController textToSpeech; late SpeechToTextController speechToText; + late LanguageDetectionController languageDetection; ///store Services late PLocalStore pStoreService; @@ -98,6 +100,7 @@ class PangeaController { itFeedback = ITFeedbackController(this); textToSpeech = TextToSpeechController(this); speechToText = SpeechToTextController(this); + languageDetection = LanguageDetectionController(this); PAuthGaurd.pController = this; } From 38634b8dc7351846bad1fa2bb8cc1ebadae70697 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 22 May 2024 10:05:33 -0400 Subject: [PATCH 31/40] fix for empty data returned from wordnet --- lib/pangea/models/word_data_model.dart | 6 +- lib/pangea/widgets/igc/word_data_card.dart | 89 ++++++++++++---------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/lib/pangea/models/word_data_model.dart b/lib/pangea/models/word_data_model.dart index 838240725..c4c059241 100644 --- a/lib/pangea/models/word_data_model.dart +++ b/lib/pangea/models/word_data_model.dart @@ -1,9 +1,8 @@ import 'dart:developer'; -import 'package:flutter/foundation.dart'; - import 'package:fluffychat/pangea/constants/model_keys.dart'; import 'package:fluffychat/pangea/widgets/igc/word_data_card.dart'; +import 'package:flutter/foundation.dart'; class WordData { final String word; @@ -102,10 +101,11 @@ class WordData { }) => word == w && userL1 == l1 && userL2 == l2 && fullText == f; - String formattedPartOfSpeech(LanguageType languageType) { + String? formattedPartOfSpeech(LanguageType languageType) { final String pos = languageType == LanguageType.base ? basePartOfSpeech : targetPartOfSpeech; + if (pos.isEmpty) return null; return pos[0].toUpperCase() + pos.substring(1); } diff --git a/lib/pangea/widgets/igc/word_data_card.dart b/lib/pangea/widgets/igc/word_data_card.dart index a6ef7b511..4b8445417 100644 --- a/lib/pangea/widgets/igc/word_data_card.dart +++ b/lib/pangea/widgets/igc/word_data_card.dart @@ -314,6 +314,23 @@ class PartOfSpeechBlock extends StatelessWidget { required this.languageType, }); + String get exampleSentence => languageType == LanguageType.target + ? wordData.targetExampleSentence + : wordData.baseExampleSentence; + + String get definition => languageType == LanguageType.target + ? wordData.targetDefinition + : wordData.baseDefinition; + + String formattedTitle(BuildContext context) { + final String word = languageType == LanguageType.target + ? wordData.targetWord + : wordData.baseWord; + String? pos = wordData.formattedPartOfSpeech(languageType); + if (pos == null || pos.isEmpty) pos = L10n.of(context)!.unkDisplayName; + return "$word (${wordData.formattedPartOfSpeech(languageType)})"; + } + @override Widget build(BuildContext context) { return Padding( @@ -324,9 +341,7 @@ class PartOfSpeechBlock extends StatelessWidget { Align( alignment: Alignment.centerLeft, child: Text( - languageType == LanguageType.target - ? "${wordData.targetWord} (${wordData.formattedPartOfSpeech(languageType)})" - : "${wordData.baseWord} (${wordData.formattedPartOfSpeech(languageType)})", + formattedTitle(context), style: BotStyle.text(context, italics: true, bold: false), ), ), @@ -337,47 +352,43 @@ class PartOfSpeechBlock extends StatelessWidget { alignment: Alignment.centerLeft, child: Column( children: [ - RichText( - text: TextSpan( - style: BotStyle.text( - context, - italics: false, - bold: false, + if (definition.isNotEmpty) + RichText( + text: TextSpan( + style: BotStyle.text( + context, + italics: false, + bold: false, + ), + children: [ + TextSpan( + text: "${L10n.of(context)!.definition}: ", + style: const TextStyle(fontWeight: FontWeight.bold), + ), + TextSpan(text: definition), + ], ), - children: [ - TextSpan( - text: "${L10n.of(context)!.definition}: ", - style: const TextStyle(fontWeight: FontWeight.bold), - ), - TextSpan( - text: languageType == LanguageType.target - ? wordData.targetDefinition - : wordData.baseDefinition, - ), - ], ), - ), const SizedBox(height: 10), - RichText( - text: TextSpan( - style: BotStyle.text( - context, - italics: false, - bold: false, + if (exampleSentence.isNotEmpty) + RichText( + text: TextSpan( + style: BotStyle.text( + context, + italics: false, + bold: false, + ), + children: [ + TextSpan( + text: "${L10n.of(context)!.exampleSentence}: ", + style: const TextStyle( + fontWeight: FontWeight.bold, + ), + ), + TextSpan(text: exampleSentence), + ], ), - children: [ - TextSpan( - text: "${L10n.of(context)!.exampleSentence}: ", - style: const TextStyle(fontWeight: FontWeight.bold), - ), - TextSpan( - text: languageType == LanguageType.target - ? wordData.targetExampleSentence - : wordData.baseExampleSentence, - ), - ], ), - ), ], ), ), From ab33ec2b3f0ed9356d40777abc16f47351142bee Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 22 May 2024 12:58:35 -0400 Subject: [PATCH 32/40] don't show rich text for own messages if they're not overlay --- lib/pages/chat/events/message_content.dart | 8 ++- .../pangea_message_event.dart | 11 ++++- lib/pangea/widgets/chat/message_toolbar.dart | 7 ++- lib/pangea/widgets/chat/overlay_message.dart | 1 + lib/pangea/widgets/igc/pangea_rich_text.dart | 49 ++++++++++--------- 5 files changed, 46 insertions(+), 30 deletions(-) diff --git a/lib/pages/chat/events/message_content.dart b/lib/pages/chat/events/message_content.dart index 9866ddb2d..f04296d38 100644 --- a/lib/pages/chat/events/message_content.dart +++ b/lib/pages/chat/events/message_content.dart @@ -38,6 +38,7 @@ class MessageContent extends StatelessWidget { //further down in the chain is also using pangeaController so its not constant final bool immersionMode; final ToolbarDisplayController? toolbarController; + final bool isOverlay; // Pangea# const MessageContent( @@ -50,6 +51,7 @@ class MessageContent extends StatelessWidget { this.pangeaMessageEvent, required this.immersionMode, required this.toolbarController, + this.isOverlay = false, // Pangea# required this.borderRadius, }); @@ -203,7 +205,8 @@ class MessageContent extends StatelessWidget { && !(pangeaMessageEvent?.showRichText( selected, - toolbarController?.highlighted ?? false, + isOverlay: isOverlay, + highlighted: toolbarController?.highlighted ?? false, ) ?? false) // Pangea# @@ -305,7 +308,8 @@ class MessageContent extends StatelessWidget { ); if (pangeaMessageEvent?.showRichText( selected, - toolbarController?.highlighted ?? false, + isOverlay: isOverlay, + highlighted: toolbarController?.highlighted ?? false, ) ?? false) { return PangeaRichText( diff --git a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart index db5c7902a..fd669f6ec 100644 --- a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart +++ b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart @@ -80,7 +80,11 @@ class PangeaMessageEvent { return _latestEdit; } - bool showRichText(bool selected, bool highlighted) { + bool showRichText( + bool selected, { + bool highlighted = false, + bool isOverlay = false, + }) { if (!_isValidPangeaMessageEvent) { return false; } @@ -90,8 +94,11 @@ class PangeaMessageEvent { if ([EventStatus.error, EventStatus.sending].contains(_event.status)) { return false; } - if (ownMessage && !selected && !highlighted) return false; + if (isOverlay) return true; + if (ownMessage && !selected && !highlighted) { + return false; + } return true; } diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index 81884ffca..2f6d82ef1 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -134,8 +134,11 @@ class ToolbarDisplayController { }); } - bool get highlighted => - MatrixState.pAnyState.overlay.hashCode.toString() == overlayId; + bool get highlighted { + if (overlayId == null) return false; + if (MatrixState.pAnyState.overlay == null) overlayId = null; + return MatrixState.pAnyState.overlay.hashCode.toString() == overlayId; + } } class MessageToolbar extends StatefulWidget { diff --git a/lib/pangea/widgets/chat/overlay_message.dart b/lib/pangea/widgets/chat/overlay_message.dart index 5c7ccdef0..e8143b376 100644 --- a/lib/pangea/widgets/chat/overlay_message.dart +++ b/lib/pangea/widgets/chat/overlay_message.dart @@ -141,6 +141,7 @@ class OverlayMessage extends StatelessWidget { pangeaMessageEvent: pangeaMessageEvent, immersionMode: immersionMode, toolbarController: toolbarController, + isOverlay: true, ), if (event.hasAggregatedEvents( timeline, diff --git a/lib/pangea/widgets/igc/pangea_rich_text.dart b/lib/pangea/widgets/igc/pangea_rich_text.dart index 779955f82..43416e006 100644 --- a/lib/pangea/widgets/igc/pangea_rich_text.dart +++ b/lib/pangea/widgets/igc/pangea_rich_text.dart @@ -48,28 +48,33 @@ class PangeaRichTextState extends State { @override void initState() { super.initState(); - updateTextSpan(); - } - - void updateTextSpan() { - setState(() { - textSpan = getTextSpan(); - }); + setTextSpan(); } @override void didUpdateWidget(PangeaRichText oldWidget) { super.didUpdateWidget(oldWidget); - updateTextSpan(); + setTextSpan(); } - String getTextSpan() { + void _setTextSpan(String newTextSpan) { + widget.toolbarController?.toolbar?.textSelection.setMessageText( + newTextSpan, + ); + setState(() { + textSpan = newTextSpan; + }); + } + + void setTextSpan() { if (_fetchingRepresentation == true) { - return widget.pangeaMessageEvent.body; + _setTextSpan(textSpan = widget.pangeaMessageEvent.body); + return; } if (repEvent != null) { - return repEvent!.text; + _setTextSpan(repEvent!.text); + return; } if (widget.pangeaMessageEvent.eventId.contains("webdebug")) { @@ -84,7 +89,6 @@ class PangeaRichTextState extends State { if (repEvent == null) { setState(() => _fetchingRepresentation = true); - widget.pangeaMessageEvent .representationByLanguageGlobal( langCode: widget.pangeaMessageEvent.messageDisplayLangCode, @@ -95,23 +99,17 @@ class PangeaRichTextState extends State { ) .then((event) { repEvent = event; - widget.toolbarController?.toolbar?.textSelection.setMessageText( - repEvent?.text ?? widget.pangeaMessageEvent.body, - ); + _setTextSpan(repEvent?.text ?? widget.pangeaMessageEvent.body); }).whenComplete(() { if (mounted) { setState(() => _fetchingRepresentation = false); } }); - return widget.pangeaMessageEvent.body; - } else { - widget.toolbarController?.toolbar?.textSelection.setMessageText( - repEvent!.text, - ); - setState(() {}); - } - return repEvent!.text; + _setTextSpan(widget.pangeaMessageEvent.body); + } else { + _setTextSpan(repEvent!.text); + } } @override @@ -190,7 +188,10 @@ class PangeaRichTextState extends State { return blur > 0 ? ImageFiltered( - imageFilter: ImageFilter.blur(sigmaX: blur, sigmaY: blur), + imageFilter: ImageFilter.blur( + sigmaX: blur, + sigmaY: blur, + ), child: richText, ) : richText; From 087c0d05e9004b12c47c8b05aaa18a40008c73c1 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 22 May 2024 13:04:23 -0400 Subject: [PATCH 33/40] fix for showRichText function --- .../matrix_event_wrappers/pangea_message_event.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart index fd669f6ec..91f19f6e7 100644 --- a/lib/pangea/matrix_event_wrappers/pangea_message_event.dart +++ b/lib/pangea/matrix_event_wrappers/pangea_message_event.dart @@ -88,15 +88,16 @@ class PangeaMessageEvent { if (!_isValidPangeaMessageEvent) { return false; } - // if (URLFinder.getMatches(event.body).isNotEmpty) { - // return false; - // } + if ([EventStatus.error, EventStatus.sending].contains(_event.status)) { return false; } if (isOverlay) return true; - if (ownMessage && !selected && !highlighted) { + + // if ownMessage, don't show rich text if not selected or highlighted + // and don't show is the message is not an overlay + if (ownMessage && ((!selected && !highlighted) || !isOverlay)) { return false; } return true; From 20733e6645a95c20ed9ee4e55ea753845735d4f1 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 22 May 2024 13:21:08 -0400 Subject: [PATCH 34/40] fix for API key --- lib/pangea/controllers/language_detection_controller.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pangea/controllers/language_detection_controller.dart b/lib/pangea/controllers/language_detection_controller.dart index 7b4571c5d..0ff18b556 100644 --- a/lib/pangea/controllers/language_detection_controller.dart +++ b/lib/pangea/controllers/language_detection_controller.dart @@ -123,7 +123,7 @@ class LanguageDetectionController { LanguageDetectionRequest params, ) async { final Requests request = Requests( - choreoApiKey: Environment.choreoApi, + choreoApiKey: Environment.choreoApiKey, accessToken: accessToken, ); From e935ba33f192757f9cce5ba732b89695066d68c8 Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Wed, 22 May 2024 13:27:44 -0400 Subject: [PATCH 35/40] change discussion topic and keywords input to use dialog input --- assets/l10n/intl_en.arb | 2 + ...rsation_bot_discussion_keywords_input.dart | 71 ++++++++++++++ ...nversation_bot_discussion_topic_input.dart | 70 ++++++++++++++ .../conversation_bot_discussion_zone.dart | 85 ++++++++-------- .../conversation_bot_mode_dynamic_zone.dart | 2 +- needed-translations.txt | 96 +++++++++++++++++++ 6 files changed, 279 insertions(+), 47 deletions(-) create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_discussion_keywords_input.dart create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_discussion_topic_input.dart diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 43c9bc133..aba4b4ac3 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3953,7 +3953,9 @@ "conversationBotModeSelectOption_textAdventure": "Text Adventure", "conversationBotDiscussionZone_title": "Discussion Settings", "conversationBotDiscussionZone_discussionTopicLabel": "Discussion Topic", + "conversationBotDiscussionZone_discussionTopicPlaceholder": "Set Discussion Topic", "conversationBotDiscussionZone_discussionKeywordsLabel": "Discussion Keywords", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder": "Set Discussion Keywords", "conversationBotDiscussionZone_discussionKeywordsHintText": "Comma separated list of keywords to guide the discussion", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel": "Send discussion prompt on a schedule", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Hours between discussion prompts", diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_keywords_input.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_keywords_input.dart new file mode 100644 index 000000000..9024e41bb --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_keywords_input.dart @@ -0,0 +1,71 @@ +import 'package:fluffychat/pangea/models/bot_options_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; + +class ConversationBotDiscussionKeywordsInput extends StatelessWidget { + final BotOptionsModel initialBotOptions; + // call this to update propagate changes to parents + final void Function(BotOptionsModel) onChanged; + + const ConversationBotDiscussionKeywordsInput({ + super.key, + required this.initialBotOptions, + required this.onChanged, + }); + + @override + Widget build(BuildContext context) { + String discussionKeywords = initialBotOptions.discussionKeywords ?? ""; + + final TextEditingController textFieldController = + TextEditingController(text: discussionKeywords); + + void setBotDiscussionKeywordsAction() async { + showDialog( + context: context, + useRootNavigator: false, + builder: (BuildContext context) => AlertDialog( + title: Text( + L10n.of(context)! + .conversationBotDiscussionZone_discussionKeywordsLabel, + ), + content: TextField( + controller: textFieldController, + onChanged: (value) { + discussionKeywords = value; + }, + ), + actions: [ + TextButton( + child: Text(L10n.of(context)!.cancel), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text(L10n.of(context)!.ok), + onPressed: () { + if (discussionKeywords == "") return; + if (discussionKeywords != + initialBotOptions.discussionKeywords) { + initialBotOptions.discussionKeywords = discussionKeywords; + onChanged.call(initialBotOptions); + Navigator.of(context).pop(); + } + }, + ), + ], + ), + ); + } + + return ListTile( + onTap: setBotDiscussionKeywordsAction, + title: Text( + initialBotOptions.discussionKeywords ?? + L10n.of(context)! + .conversationBotDiscussionZone_discussionKeywordsPlaceholder, + ), + ); + } +} diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_topic_input.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_topic_input.dart new file mode 100644 index 000000000..72caa3839 --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_topic_input.dart @@ -0,0 +1,70 @@ +import 'package:fluffychat/pangea/models/bot_options_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; + +class ConversationBotDiscussionTopicInput extends StatelessWidget { + final BotOptionsModel initialBotOptions; + // call this to update propagate changes to parents + final void Function(BotOptionsModel) onChanged; + + const ConversationBotDiscussionTopicInput({ + super.key, + required this.initialBotOptions, + required this.onChanged, + }); + + @override + Widget build(BuildContext context) { + String discussionTopic = initialBotOptions.discussionTopic ?? ""; + + final TextEditingController textFieldController = + TextEditingController(text: discussionTopic); + + void setBotDiscussionTopicAction() async { + showDialog( + context: context, + useRootNavigator: false, + builder: (BuildContext context) => AlertDialog( + title: Text( + L10n.of(context)! + .conversationBotDiscussionZone_discussionTopicLabel, + ), + content: TextField( + controller: textFieldController, + onChanged: (value) { + discussionTopic = value; + }, + ), + actions: [ + TextButton( + child: Text(L10n.of(context)!.cancel), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text(L10n.of(context)!.ok), + onPressed: () { + if (discussionTopic == "") return; + if (discussionTopic != initialBotOptions.discussionTopic) { + initialBotOptions.discussionTopic = discussionTopic; + onChanged.call(initialBotOptions); + Navigator.of(context).pop(); + } + }, + ), + ], + ), + ); + } + + return ListTile( + onTap: setBotDiscussionTopicAction, + title: Text( + initialBotOptions.discussionTopic ?? + L10n.of(context)! + .conversationBotDiscussionZone_discussionTopicPlaceholder, + ), + ); + } +} 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 1f13139ee..57c25e133 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart @@ -1,11 +1,13 @@ import 'package:fluffychat/pangea/models/bot_options_model.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_discussion_keywords_input.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_discussion_topic_input.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; class ConversationBotDiscussionZone extends StatelessWidget { final BotOptionsModel initialBotOptions; // call this to update propagate changes to parents - final void Function(BotOptionsModel?)? onChanged; + final void Function(BotOptionsModel) onChanged; const ConversationBotDiscussionZone({ super.key, @@ -15,8 +17,9 @@ class ConversationBotDiscussionZone extends StatelessWidget { @override Widget build(BuildContext context) { - String discussionTopic = initialBotOptions.discussionTopic ?? ""; - String discussionKeywords = initialBotOptions.discussionKeywords ?? ""; + final String discussionTopic = initialBotOptions.discussionTopic ?? ""; + final String discussionKeywords = + initialBotOptions.discussionKeywords ?? ""; // int discussionTriggerScheduleHourInterval = // initialBotOptions.discussionTriggerScheduleHourInterval ?? 24; // String discussionTriggerReactionKey = @@ -37,59 +40,49 @@ class ConversationBotDiscussionZone extends StatelessWidget { thickness: 1, ), const SizedBox(height: 12), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: TextEditingController(text: discussionTopic), - onChanged: (value) { - discussionTopic = value; - }, - decoration: InputDecoration( - labelText: L10n.of(context)! + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.fromLTRB(12, 0, 0, 0), + child: Text( + L10n.of(context)! .conversationBotDiscussionZone_discussionTopicLabel, - floatingLabelBehavior: FloatingLabelBehavior.auto, - suffixIcon: IconButton( - icon: const Icon(Icons.check), - onPressed: () { - if (discussionTopic != initialBotOptions.discussionTopic) { - initialBotOptions.discussionTopic = discussionTopic; - onChanged?.call( - initialBotOptions, - ); - } - }, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, ), ), ), ), - const SizedBox(height: 12), Padding( padding: const EdgeInsets.all(8), - child: TextField( - controller: TextEditingController(text: discussionKeywords), - onChanged: (value) { - discussionKeywords = value; - }, - decoration: InputDecoration( - labelText: L10n.of(context)! + child: ConversationBotDiscussionTopicInput( + initialBotOptions: initialBotOptions, + onChanged: onChanged, + ), + ), + const SizedBox(height: 12), + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.fromLTRB(12, 0, 0, 0), + child: Text( + L10n.of(context)! .conversationBotDiscussionZone_discussionKeywordsLabel, - floatingLabelBehavior: FloatingLabelBehavior.auto, - hintText: L10n.of(context)! - .conversationBotDiscussionZone_discussionKeywordsHintText, - suffixIcon: IconButton( - icon: const Icon(Icons.check), - onPressed: () { - if (discussionTopic != initialBotOptions.discussionKeywords) { - initialBotOptions.discussionKeywords = discussionKeywords; - onChanged?.call( - initialBotOptions, - ); - } - }, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, ), ), ), ), + Padding( + padding: const EdgeInsets.all(8), + child: ConversationBotDiscussionKeywordsInput( + initialBotOptions: initialBotOptions, + onChanged: onChanged, + ), + ), const SizedBox(height: 12), // CheckboxListTile( // title: Text( @@ -135,7 +128,7 @@ class ConversationBotDiscussionZone extends StatelessWidget { // ), // ), // ), - const SizedBox(height: 12), + // const SizedBox(height: 12), CheckboxListTile( title: Text( L10n.of(context)! @@ -146,7 +139,7 @@ class ConversationBotDiscussionZone extends StatelessWidget { initialBotOptions.discussionTriggerReactionEnabled = value ?? false; initialBotOptions.discussionTriggerReactionKey = "⏩"; // hard code this for now - onChanged?.call(initialBotOptions); + onChanged.call(initialBotOptions); }, ), // if (initialBotOptions.discussionTriggerReactionEnabled == true) 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 38019a646..b0c78888f 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 @@ -8,7 +8,7 @@ import 'conversation_bot_discussion_zone.dart'; class ConversationBotModeDynamicZone extends StatelessWidget { final BotOptionsModel initialBotOptions; - final void Function(BotOptionsModel?)? onChanged; + final void Function(BotOptionsModel) onChanged; const ConversationBotModeDynamicZone({ super.key, diff --git a/needed-translations.txt b/needed-translations.txt index 5d9b0cc24..60c1be8f4 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -829,7 +829,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -2262,7 +2264,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -3157,7 +3161,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -4052,7 +4058,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -4947,7 +4955,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -5842,7 +5852,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -6684,7 +6696,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -7579,7 +7593,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -8474,7 +8490,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -8517,7 +8535,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -9355,7 +9375,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -10193,7 +10215,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -11088,7 +11112,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -11983,7 +12009,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -12878,7 +12906,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -13773,7 +13803,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -14611,7 +14643,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -15506,7 +15540,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -16401,7 +16437,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -17283,7 +17321,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -18178,7 +18218,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -19597,7 +19639,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -20492,7 +20536,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -21387,7 +21433,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -22267,7 +22315,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -23162,7 +23212,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -24057,7 +24109,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -24952,7 +25006,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -25847,7 +25903,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -26742,7 +26800,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -27637,7 +27697,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -28532,7 +28594,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -29427,7 +29491,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -30291,7 +30357,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -31186,7 +31254,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -32081,7 +32151,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -32919,7 +32991,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -33814,7 +33888,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -34709,7 +34785,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -35604,7 +35682,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -36464,7 +36544,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -37359,7 +37441,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -38254,7 +38338,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -39134,7 +39220,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -39972,7 +40060,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -40867,7 +40957,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -41705,7 +41797,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", @@ -42600,7 +42694,9 @@ "conversationBotModeSelectOption_textAdventure", "conversationBotDiscussionZone_title", "conversationBotDiscussionZone_discussionTopicLabel", + "conversationBotDiscussionZone_discussionTopicPlaceholder", "conversationBotDiscussionZone_discussionKeywordsLabel", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder", "conversationBotDiscussionZone_discussionKeywordsHintText", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", From f79203a47ebc4842b53fe5e57109fa4df731754a Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 22 May 2024 16:12:10 -0400 Subject: [PATCH 36/40] Mark chats as read before leaving them --- lib/pages/chat_list/chat_list.dart | 3 +++ lib/pages/chat_list/chat_list_item.dart | 3 +++ lib/pages/chat_list/space_view.dart | 5 ++++- lib/pages/chat_list/utils/on_chat_tap.dart | 13 +++++++------ lib/pangea/utils/archive_space.dart | 6 ++++-- lib/pangea/utils/delete_room.dart | 5 ++++- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index f96baa040..9a6345c6a 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -728,6 +728,9 @@ class ChatListController extends State while (selectedRoomIds.isNotEmpty) { final roomId = selectedRoomIds.first; try { + if (client.getRoomById(roomId)!.isUnread) { + await client.getRoomById(roomId)!.markUnread(false); + } await client.getRoomById(roomId)!.leave(); } finally { toggleSelection(roomId); diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 447b5f6c3..71d5d558b 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -53,6 +53,9 @@ class ChatListItem extends StatelessWidget { message: L10n.of(context)!.archiveRoomDescription, ); if (confirmed == OkCancelResult.cancel) return; + if (room.isUnread) { + await room.markUnread(false); + } await showFutureLoadingDialog( context: context, future: () => room.leave(), diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 348550c65..48be9eb04 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -288,7 +288,10 @@ class _SpaceViewState extends State { // #Pangea // future: room!.leave, future: () async { - await room!.leave(); + if (room!.isUnread) { + await room.markUnread(false); + } + await room.leave(); if (Matrix.of(context).activeRoomId == room.id) { context.go('/rooms'); } diff --git a/lib/pages/chat_list/utils/on_chat_tap.dart b/lib/pages/chat_list/utils/on_chat_tap.dart index d24af1fb4..3869cd60d 100644 --- a/lib/pages/chat_list/utils/on_chat_tap.dart +++ b/lib/pages/chat_list/utils/on_chat_tap.dart @@ -1,15 +1,13 @@ -import 'package:flutter/material.dart'; - import 'package:adaptive_dialog/adaptive_dialog.dart'; +import 'package:fluffychat/pages/chat/send_file_dialog.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; +import 'package:fluffychat/widgets/matrix.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:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; -import 'package:fluffychat/pages/chat/send_file_dialog.dart'; -import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; -import 'package:fluffychat/widgets/matrix.dart'; - void onChatTap(Room room, BuildContext context) async { if (room.membership == Membership.invite) { final inviterId = @@ -47,6 +45,9 @@ void onChatTap(Room room, BuildContext context) async { return; } if (inviteAction == InviteActions.decline) { + if (room.isUnread) { + await room.markUnread(false); + } await showFutureLoadingDialog( context: context, future: room.leave, diff --git a/lib/pangea/utils/archive_space.dart b/lib/pangea/utils/archive_space.dart index 72f10fae4..ac83980fb 100644 --- a/lib/pangea/utils/archive_space.dart +++ b/lib/pangea/utils/archive_space.dart @@ -1,7 +1,6 @@ -import 'package:matrix/matrix.dart'; - import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart'; +import 'package:matrix/matrix.dart'; Future archiveSpace(Room? space, Client client) async { if (space == null) { @@ -14,6 +13,9 @@ Future archiveSpace(Room? space, Client client) async { final List children = await space.getChildRooms(); for (final Room child in children) { + if (child.isUnread) { + await child.markUnread(false); + } await child.leave(); } await space.leave(); diff --git a/lib/pangea/utils/delete_room.dart b/lib/pangea/utils/delete_room.dart index f8e168779..d2a0acae9 100644 --- a/lib/pangea/utils/delete_room.dart +++ b/lib/pangea/utils/delete_room.dart @@ -1,6 +1,6 @@ +import 'package:fluffychat/pangea/constants/class_default_values.dart'; import 'package:matrix/matrix.dart'; -import 'package:fluffychat/pangea/constants/class_default_values.dart'; import 'error_handler.dart'; Future deleteRoom(String? roomID, Client client) async { @@ -79,6 +79,9 @@ Future deleteRoom(String? roomID, Client client) async { } try { + if (room.isUnread) { + await room.markUnread(false); + } await room.leave(); } catch (err) { ErrorHandler.logError( From ceb7fdb24e5a719b6ef4c1455e49bdc58178bdfc Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 22 May 2024 16:21:25 -0400 Subject: [PATCH 37/40] Fixed code in Fluffchat files to match convention --- lib/pages/chat_list/chat_list.dart | 2 ++ lib/pages/chat_list/chat_list_item.dart | 2 ++ lib/pages/chat_list/utils/on_chat_tap.dart | 2 ++ 3 files changed, 6 insertions(+) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 9a6345c6a..c0791c936 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -728,9 +728,11 @@ class ChatListController extends State while (selectedRoomIds.isNotEmpty) { final roomId = selectedRoomIds.first; try { + // #Pangea if (client.getRoomById(roomId)!.isUnread) { await client.getRoomById(roomId)!.markUnread(false); } + // Pangea# await client.getRoomById(roomId)!.leave(); } finally { toggleSelection(roomId); diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 71d5d558b..9775ec624 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -53,9 +53,11 @@ class ChatListItem extends StatelessWidget { message: L10n.of(context)!.archiveRoomDescription, ); if (confirmed == OkCancelResult.cancel) return; + // #Pangea if (room.isUnread) { await room.markUnread(false); } + // Pangea# await showFutureLoadingDialog( context: context, future: () => room.leave(), diff --git a/lib/pages/chat_list/utils/on_chat_tap.dart b/lib/pages/chat_list/utils/on_chat_tap.dart index 3869cd60d..d9f1c8191 100644 --- a/lib/pages/chat_list/utils/on_chat_tap.dart +++ b/lib/pages/chat_list/utils/on_chat_tap.dart @@ -45,9 +45,11 @@ void onChatTap(Room room, BuildContext context) async { return; } if (inviteAction == InviteActions.decline) { + // #Pangea if (room.isUnread) { await room.markUnread(false); } + // Pangea# await showFutureLoadingDialog( context: context, future: room.leave, From c203071a7db3ba6f9937a06f69621f53d075d608 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 22 May 2024 16:39:32 -0400 Subject: [PATCH 38/40] removed unused delete room files --- .../p_class_widgets/delete_class_tile.dart | 149 ------------------ lib/pangea/utils/delete_room.dart | 92 ----------- 2 files changed, 241 deletions(-) delete mode 100644 lib/pangea/pages/class_settings/p_class_widgets/delete_class_tile.dart delete mode 100644 lib/pangea/utils/delete_room.dart diff --git a/lib/pangea/pages/class_settings/p_class_widgets/delete_class_tile.dart b/lib/pangea/pages/class_settings/p_class_widgets/delete_class_tile.dart deleted file mode 100644 index 7e3fc3af6..000000000 --- a/lib/pangea/pages/class_settings/p_class_widgets/delete_class_tile.dart +++ /dev/null @@ -1,149 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:future_loading_dialog/future_loading_dialog.dart'; -import 'package:go_router/go_router.dart'; -import 'package:matrix/matrix.dart'; - -import 'package:fluffychat/pangea/utils/delete_room.dart'; -import 'package:fluffychat/widgets/matrix.dart'; - -class DeleteSpaceTile extends StatelessWidget { - final Room room; - - const DeleteSpaceTile({ - super.key, - required this.room, - }); - - @override - Widget build(BuildContext context) { - bool classNameMatch = true; - final textController = TextEditingController(); - Future deleteSpace() async { - final Client client = Matrix.of(context).client; - final GetSpaceHierarchyResponse spaceHierarchy = - await client.getSpaceHierarchy(room.id); - - if (spaceHierarchy.rooms.isNotEmpty) { - final List spaceChats = spaceHierarchy.rooms - .where((c) => c.roomId != room.id) - .map((e) => Matrix.of(context).client.getRoomById(e.roomId)) - .where((c) => c != null && !c.isSpace && !c.isDirectChat) - .cast() - .toList(); - - await Future.wait( - spaceChats.map((c) => deleteRoom(c.id, client)), - ); - } - deleteRoom(room.id, client); - context.go('/rooms'); - return; - } - - Future deleteChat() { - context.go('/rooms'); - return deleteRoom(room.id, Matrix.of(context).client); - } - - Future deleteChatAction() async { - showDialog( - context: context, - useRootNavigator: false, - builder: (context) { - return StatefulBuilder( - builder: (context, setState) { - return AlertDialog( - title: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - room.isSpace - ? L10n.of(context)!.areYouSureDeleteClass - : L10n.of(context)!.areYouSureDeleteGroup, - style: const TextStyle( - fontSize: 20, - ), - textAlign: TextAlign.center, - ), - const SizedBox(height: 5), - Text( - L10n.of(context)!.cannotBeReversed, - style: const TextStyle( - fontSize: 16, - ), - textAlign: TextAlign.center, - ), - const SizedBox(height: 10), - if (room.isSpace) - Text( - L10n.of(context)!.enterDeletedClassName, - style: const TextStyle( - fontSize: 14, - ), - textAlign: TextAlign.center, - ), - ], - ), - content: room.isSpace - ? TextField( - autofocus: true, - controller: textController, - decoration: InputDecoration( - hintText: room.name, - errorText: !classNameMatch - ? L10n.of(context)!.incorrectClassName - : null, - ), - ) - : null, - actions: [ - TextButton( - child: Text(L10n.of(context)!.ok), - onPressed: () async { - if (room.isSpace) { - setState(() { - classNameMatch = textController.text == room.name; - }); - if (classNameMatch) { - Navigator.of(context).pop(); - await showFutureLoadingDialog( - context: context, - future: () => deleteSpace(), - ); - } - } else { - await showFutureLoadingDialog( - context: context, - future: () => deleteChat(), - ); - } - }, - ), - TextButton( - child: Text(L10n.of(context)!.cancel), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ); - }, - ); - }, - ); - } - - return ListTile( - trailing: const Icon(Icons.delete_outlined), - title: Text( - room.isSpace - ? L10n.of(context)!.deleteSpace - : L10n.of(context)!.deleteGroup, - style: const TextStyle(color: Colors.red), - ), - onTap: () => deleteChatAction(), - ); - } -} diff --git a/lib/pangea/utils/delete_room.dart b/lib/pangea/utils/delete_room.dart deleted file mode 100644 index d2a0acae9..000000000 --- a/lib/pangea/utils/delete_room.dart +++ /dev/null @@ -1,92 +0,0 @@ -import 'package:fluffychat/pangea/constants/class_default_values.dart'; -import 'package:matrix/matrix.dart'; - -import 'error_handler.dart'; - -Future deleteRoom(String? roomID, Client client) async { - if (roomID == null) { - ErrorHandler.logError( - m: "in deleteRoomAction with null pangeaClassRoomID", - s: StackTrace.current, - ); - return; - } - - final Room? room = client.getRoomById(roomID); - if (room == null) { - ErrorHandler.logError( - m: "failed to fetch room with roomID $roomID", - s: StackTrace.current, - ); - return; - } - - try { - await room.join(); - } catch (err) { - ErrorHandler.logError( - m: "failed to join room with roomID $roomID", - s: StackTrace.current, - ); - return; - } - - List members; - try { - members = await room.requestParticipants(); - } catch (err) { - ErrorHandler.logError( - m: "failed to fetch members for room with roomID $roomID", - s: StackTrace.current, - ); - return; - } - - final List otherAdmins = []; - for (final User member in members) { - final String memberID = member.id; - final int memberPowerLevel = room.getPowerLevelByUserId(memberID); - if (memberID == client.userID) continue; - if (memberPowerLevel >= ClassDefaultValues.powerLevelOfAdmin) { - otherAdmins.add(member); - continue; - } - try { - await room.kick(memberID); - } catch (err) { - ErrorHandler.logError( - m: "Failed to kick user $memberID from room with id $roomID. Error: $err", - s: StackTrace.current, - ); - continue; - } - } - - if (otherAdmins.isNotEmpty && room.canSendEvent(EventTypes.RoomJoinRules)) { - try { - await client.setRoomStateWithKey( - roomID, - EventTypes.RoomJoinRules, - "", - {"join_rules": "invite"}, - ); - } catch (err) { - ErrorHandler.logError( - m: "Failed to update student create room permissions. error: $err, roomId: $roomID", - s: StackTrace.current, - ); - } - } - - try { - if (room.isUnread) { - await room.markUnread(false); - } - await room.leave(); - } catch (err) { - ErrorHandler.logError( - m: "Failed to leave room with id $roomID. Error: $err", - s: StackTrace.current, - ); - } -} From 208a5ef09508136eb6d6a107782ef087aecb905a Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 23 May 2024 09:24:54 -0400 Subject: [PATCH 39/40] Spanish translations --- assets/l10n/intl_es.arb | 19 +++++- .../builder.dart | 62 ++++++++++++------- needed-translations.txt | 20 ------ 3 files changed, 59 insertions(+), 42 deletions(-) diff --git a/assets/l10n/intl_es.arb b/assets/l10n/intl_es.arb index 59f5719b0..d463699be 100644 --- a/assets/l10n/intl_es.arb +++ b/assets/l10n/intl_es.arb @@ -4634,5 +4634,22 @@ "points": "Puntos", "noPaymentInfo": "No se necesitan datos de pago.", "updatePhoneOS": "Puede que necesites actualizar la versión del sistema operativo de tu dispositivo.", - "wordsPerMinute": "Palabras por minuto" + "wordsPerMinute": "Palabras por minuto", + "conversationBotModeSelectDescription": "Modo bot", + "conversationBotModeSelectOption_discussion": "Debate", + "conversationBotModeSelectOption_custom": "A medida", + "conversationBotModeSelectOption_conversation": "Conversación", + "conversationBotModeSelectOption_textAdventure": "Aventura textual", + "conversationBotDiscussionZone_title": "Configuración del debate", + "conversationBotDiscussionZone_discussionTopicLabel": "Tema de debate", + "conversationBotDiscussionZone_discussionTopicPlaceholder": "Establecer tema de debate", + "conversationBotDiscussionZone_discussionKeywordsLabel": "Palabras clave del debate", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder": "Establecer palabras clave de debate", + "conversationBotDiscussionZone_discussionKeywordsHintText": "Lista de palabras clave separadas por comas para orientar el debate", + "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel": "Enviar mensajes de debate según un calendario", + "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Horas entre temas de debate", + "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Enviar aviso de discusión cuando el usuario reacciona ⏩ al mensaje del bot.", + "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/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart index 301d0c6ee..e1a8b99d5 100644 --- a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart +++ b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart @@ -1,20 +1,16 @@ import 'dart:io'; +import 'package:fluffychat/pangea/utils/error_handler.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart'; +import 'package:fluffychat/utils/platform_infos.dart'; import 'package:flutter/foundation.dart'; - -import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/matrix.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; import 'package:sqflite_common_ffi/sqflite_ffi.dart'; import 'package:universal_html/html.dart' as html; -import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/utils/client_manager.dart'; -import 'package:fluffychat/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart'; -import 'package:fluffychat/utils/platform_infos.dart'; import 'cipher.dart'; - import 'sqlcipher_stub.dart' if (dart.library.io) 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart'; @@ -24,25 +20,49 @@ Future flutterMatrixSdkDatabaseBuilder(Client client) async { database = await _constructDatabase(client); await database.open(); return database; - } catch (e) { + // #Pangea + // } catch (e) { + } catch (e, s) { + ErrorHandler.logError( + e: e, + s: s, + m: "Failed to open matrix sdk database. Openning fallback database.", + ); + // Pangea# // Try to delete database so that it can created again on next init: database?.delete().catchError( - (e, s) => Logs().w( - 'Unable to delete database, after failed construction', - e, - s, - ), + // #Pangea + // (e, s) => Logs().w( + // 'Unable to delete database, after failed construction', + // e, + // s, + // ), + (e, s) { + Logs().w( + 'Unable to delete database, after failed construction', + e, + s, + ); + ErrorHandler.logError( + e: e, + s: s, + m: "Failed to delete matrix database after failed construction.", + ); + } + // Pangea# ); // Send error notification: - final l10n = lookupL10n(PlatformDispatcher.instance.locale); - ClientManager.sendInitNotification( - l10n.initAppError, - l10n.databaseBuildErrorBody( - AppConfig.newIssueUrl.toString(), - e.toString(), - ), - ); + // #Pangea + // final l10n = lookupL10n(PlatformDispatcher.instance.locale); + // ClientManager.sendInitNotification( + // l10n.initAppError, + // l10n.databaseBuildErrorBody( + // AppConfig.newIssueUrl.toString(), + // e.toString(), + // ), + // ); + // Pangea# return FlutterHiveCollectionsDatabase.databaseBuilder(client); } diff --git a/needed-translations.txt b/needed-translations.txt index af36b97ba..bb967d011 100644 --- a/needed-translations.txt +++ b/needed-translations.txt @@ -8527,26 +8527,6 @@ "wordsPerMinute" ], - "es": [ - "conversationBotModeSelectDescription", - "conversationBotModeSelectOption_discussion", - "conversationBotModeSelectOption_custom", - "conversationBotModeSelectOption_conversation", - "conversationBotModeSelectOption_textAdventure", - "conversationBotDiscussionZone_title", - "conversationBotDiscussionZone_discussionTopicLabel", - "conversationBotDiscussionZone_discussionTopicPlaceholder", - "conversationBotDiscussionZone_discussionKeywordsLabel", - "conversationBotDiscussionZone_discussionKeywordsPlaceholder", - "conversationBotDiscussionZone_discussionKeywordsHintText", - "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel", - "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel", - "conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel", - "conversationBotDiscussionZone_discussionTriggerReactionKeyLabel", - "studentAnalyticsNotAvailable", - "roomDataMissing" - ], - "et": [ "accountInformation", "addGroupDescription", From 340e90ac389ff2c4b6a8249d673d79ac3649e34b Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 23 May 2024 09:39:01 -0400 Subject: [PATCH 40/40] fix for concurrent modification of list error --- lib/pangea/extensions/client_extension.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pangea/extensions/client_extension.dart b/lib/pangea/extensions/client_extension.dart index b259d0c9e..47d67c0b8 100644 --- a/lib/pangea/extensions/client_extension.dart +++ b/lib/pangea/extensions/client_extension.dart @@ -25,7 +25,8 @@ extension PangeaClient on Client { .toList(); Future> get classesAndExchangesImTeaching async { - for (final Room space in rooms.where((room) => room.isSpace)) { + final allSpaces = rooms.where((room) => room.isSpace); + for (final Room space in allSpaces) { if (space.getState(EventTypes.RoomPowerLevels) == null) { await space.postLoad(); }