Merge branch 'main' into igc-button
This commit is contained in:
commit
36bc156837
60 changed files with 2087 additions and 630 deletions
66
README.md
66
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 <DEVICE_NAME>`
|
||||
|
||||

|
||||
|
||||
[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)
|
||||
|
||||
<a href='https://ko-fi.com/C1C86VN53' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi5.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
||||
|
||||
### Screenshots:
|
||||
|
||||

|
||||
|
||||
# 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)
|
||||
|
||||
* <a href="https://github.com/fabiyamada">Fabiyamada</a> is a graphics designer and has made the fluffychat logo and the banner. Big thanks for her great designs.
|
||||
|
||||
* <a href="https://github.com/advocatux">Advocatux</a> has made the Spanish translation with great love and care. He always stands by my side and supports my work with great commitment.
|
||||
|
|
|
|||
|
|
@ -3945,6 +3945,21 @@
|
|||
"accuracy": "Accuracy",
|
||||
"points": "Points",
|
||||
"noPaymentInfo": "No payment info necessary!",
|
||||
"conversationBotModeSelectDescription": "Bot mode",
|
||||
"conversationBotModeSelectOption_discussion": "Discussion",
|
||||
"conversationBotModeSelectOption_custom": "Custom",
|
||||
"conversationBotModeSelectOption_conversation": "Conversation",
|
||||
"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",
|
||||
"conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Send discussion prompt when user reacts ⏩ to bot message",
|
||||
"conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reaction to send discussion prompt",
|
||||
"studentAnalyticsNotAvailable": "Student data not currently available",
|
||||
"roomDataMissing": "Some data may be missing from rooms in which you are not a member.",
|
||||
"updatePhoneOS": "You may need to update your device's OS version.",
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
}
|
||||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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,12 @@ class ArchiveController extends State<Archive> {
|
|||
|
||||
Future<List<Room>> 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();
|
||||
return archive = (await Matrix.of(context).client.loadArchive())
|
||||
.where((e) => (!e.isSpace && !e.isAnalyticsRoom))
|
||||
.toList();
|
||||
// Pangea#
|
||||
}
|
||||
|
||||
void forgetRoomAction(int i) async {
|
||||
|
|
|
|||
|
|
@ -1078,6 +1078,9 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
bool get canEditSelectedEvents {
|
||||
if (isArchived ||
|
||||
selectedEvents.length != 1 ||
|
||||
// #Pangea
|
||||
selectedEvents.single.messageType != MessageTypes.Text ||
|
||||
// Pangea#
|
||||
!selectedEvents.first.status.isSent) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,8 @@ class ChatView extends StatelessWidget {
|
|||
// #Pangea
|
||||
} else {
|
||||
return [
|
||||
ChatSettingsPopupMenu(controller.room, !controller.room.isDirectChat),
|
||||
ChatSettingsPopupMenu(controller.room,
|
||||
(!controller.room.isDirectChat && !controller.room.isArchived)),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -728,6 +728,11 @@ class ChatListController extends State<ChatList>
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -53,6 +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(),
|
||||
|
|
|
|||
|
|
@ -237,6 +237,10 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
icon: Icons.send_outlined,
|
||||
),
|
||||
if (spaceChild != null &&
|
||||
// #Pangea
|
||||
room != null &&
|
||||
room.ownPowerLevel >= ClassDefaultValues.powerLevelOfAdmin &&
|
||||
// Pangea#
|
||||
(activeSpace?.canChangeStateEvent(EventTypes.spaceChild) ?? false))
|
||||
SheetAction(
|
||||
key: SpaceChildContextAction.removeFromSpace,
|
||||
|
|
@ -284,7 +288,10 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
// #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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ 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 != 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/${controller.activeSpaceId ?? ''}');
|
||||
context.go(
|
||||
'/rooms/newgroup${controller.activeSpaceId != null ? '?spaceId=${controller.activeSpaceId}' : ''}',
|
||||
);
|
||||
// Pangea#
|
||||
break;
|
||||
case ActiveFilter.spaces:
|
||||
|
|
|
|||
|
|
@ -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,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,
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -50,7 +57,7 @@ class NewGroupController extends State<NewGroup> {
|
|||
void setVocab(List<Lemma> 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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ class SettingsController extends State<Settings> {
|
|||
cancelLabel: L10n.of(context)!.cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
// #Pangea
|
||||
maxLength: 32,
|
||||
// Pangea#
|
||||
initialText: profile?.displayName ??
|
||||
Matrix.of(context).client.userID!.localpart,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -96,7 +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";
|
||||
}
|
||||
|
|
|
|||
138
lib/pangea/controllers/language_detection_controller.dart
Normal file
138
lib/pangea/controllers/language_detection_controller.dart
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
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 {
|
||||
/// The full text from which to detect the language.
|
||||
String fullText;
|
||||
|
||||
/// 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,
|
||||
this.userL1 = "",
|
||||
required this.userL2,
|
||||
});
|
||||
|
||||
Map<String, dynamic> 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<Map<String, dynamic>> detections;
|
||||
String fullText;
|
||||
|
||||
LanguageDetectionResponse({
|
||||
required this.detections,
|
||||
required this.fullText,
|
||||
});
|
||||
|
||||
factory LanguageDetectionResponse.fromJson(Map<String, dynamic> json) {
|
||||
return LanguageDetectionResponse(
|
||||
detections: List<Map<String, dynamic>>.from(json['detections']),
|
||||
fullText: json['full_text'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'detections': detections,
|
||||
'full_text': fullText,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class _LanguageDetectionCacheItem {
|
||||
Future<LanguageDetectionResponse> data;
|
||||
|
||||
_LanguageDetectionCacheItem({
|
||||
required this.data,
|
||||
});
|
||||
}
|
||||
|
||||
class LanguageDetectionController {
|
||||
static final Map<LanguageDetectionRequest, _LanguageDetectionCacheItem>
|
||||
_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<LanguageDetectionResponse> get(
|
||||
LanguageDetectionRequest params,
|
||||
) async {
|
||||
if (_cache.containsKey(params)) {
|
||||
return _cache[params]!.data;
|
||||
} else {
|
||||
final Future<LanguageDetectionResponse> response = _fetchResponse(
|
||||
await _pangeaController.userController.accessToken,
|
||||
params,
|
||||
);
|
||||
_cache[params] = _LanguageDetectionCacheItem(data: response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LanguageDetectionResponse> _fetchResponse(
|
||||
String accessToken,
|
||||
LanguageDetectionRequest params,
|
||||
) async {
|
||||
final Requests request = Requests(
|
||||
choreoApiKey: Environment.choreoApiKey,
|
||||
accessToken: accessToken,
|
||||
);
|
||||
|
||||
final http.Response res = await request.post(
|
||||
url: PApiUrls.languageDetection,
|
||||
body: params.toJson(),
|
||||
);
|
||||
|
||||
final Map<String, dynamic> json = jsonDecode(res.body);
|
||||
return LanguageDetectionResponse.fromJson(json);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ extension PangeaClient on Client {
|
|||
.toList();
|
||||
|
||||
Future<List<Room>> 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -815,6 +815,9 @@ extension PangeaRoom on Room {
|
|||
);
|
||||
return false;
|
||||
}
|
||||
if (room != null && !room.isRoomAdmin) {
|
||||
return false;
|
||||
}
|
||||
if (!pangeaCanSendEvent(EventTypes.spaceChild) && !isRoomAdmin) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,18 +80,26 @@ class PangeaMessageEvent {
|
|||
return _latestEdit;
|
||||
}
|
||||
|
||||
bool showRichText(bool selected, bool highlighted) {
|
||||
bool showRichText(
|
||||
bool selected, {
|
||||
bool highlighted = false,
|
||||
bool isOverlay = false,
|
||||
}) {
|
||||
if (!_isValidPangeaMessageEvent) {
|
||||
return false;
|
||||
}
|
||||
// if (URLFinder.getMatches(event.body).isNotEmpty) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if ([EventStatus.error, EventStatus.sending].contains(_event.status)) {
|
||||
return false;
|
||||
}
|
||||
if (ownMessage && !selected && !highlighted) return false;
|
||||
|
||||
if (isOverlay) return true;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
@ -346,6 +354,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;
|
||||
}
|
||||
|
||||
|
|
@ -564,17 +585,20 @@ class PangeaMessageEvent {
|
|||
return langCode ?? LanguageKeys.unknownLanguage;
|
||||
}
|
||||
|
||||
PangeaMatch? firstErrorStep(String lemma) {
|
||||
List<PangeaMatch>? 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<PangeaMatch> steps = repEvent!.choreo!.choreoSteps
|
||||
.where(
|
||||
(choreoStep) =>
|
||||
choreoStep.acceptedOrIgnoredMatch != null &&
|
||||
choreoStep.acceptedOrIgnoredMatch?.match.shortMessage == lemma,
|
||||
)
|
||||
?.acceptedOrIgnoredMatch;
|
||||
return step;
|
||||
.map((element) => element.acceptedOrIgnoredMatch)
|
||||
.cast<PangeaMatch>()
|
||||
.toList();
|
||||
return steps;
|
||||
}
|
||||
|
||||
// List<SpanData> get activities =>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -12,20 +12,45 @@ class BotOptionsModel {
|
|||
String topic;
|
||||
List<String> keywords;
|
||||
bool safetyModeration;
|
||||
String mode;
|
||||
String? custom;
|
||||
String? discussionTopic;
|
||||
String? discussionKeywords;
|
||||
bool? discussionTriggerScheduleEnabled;
|
||||
int? discussionTriggerScheduleHourInterval;
|
||||
bool? discussionTriggerReactionEnabled;
|
||||
String? discussionTriggerReactionKey;
|
||||
|
||||
BotOptionsModel({
|
||||
this.languageLevel,
|
||||
this.topic = "General Conversation",
|
||||
this.keywords = const [],
|
||||
this.safetyModeration = true,
|
||||
this.mode = "discussion",
|
||||
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<String>(),
|
||||
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],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -34,9 +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);
|
||||
|
|
@ -51,15 +86,33 @@ 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;
|
||||
case ModelKey.mode:
|
||||
mode = value;
|
||||
break;
|
||||
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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -248,6 +248,38 @@ class ConstructListViewState extends State<ConstructListView> {
|
|||
(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<MessageEventMatch> getMessageEventMatches() {
|
||||
if (widget.controller.currentLemma == null) return [];
|
||||
final List<MessageEventMatch> 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<PangeaMatch>? 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<ConstructListView> {
|
|||
);
|
||||
}
|
||||
|
||||
final msgEventMatches = getMessageEventMatches();
|
||||
|
||||
return widget.controller.currentLemma == null
|
||||
? Expanded(
|
||||
child: ListView.builder(
|
||||
|
|
@ -299,11 +333,12 @@ class ConstructListViewState extends State<ConstructListView> {
|
|||
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<ConstructListView> {
|
|||
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<void> deleteSpace() async {
|
||||
final Client client = Matrix.of(context).client;
|
||||
final GetSpaceHierarchyResponse spaceHierarchy =
|
||||
await client.getSpaceHierarchy(room.id);
|
||||
|
||||
if (spaceHierarchy.rooms.isNotEmpty) {
|
||||
final List<Room> 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<Room>()
|
||||
.toList();
|
||||
|
||||
await Future.wait(
|
||||
spaceChats.map((c) => deleteRoom(c.id, client)),
|
||||
);
|
||||
}
|
||||
deleteRoom(room.id, client);
|
||||
context.go('/rooms');
|
||||
return;
|
||||
}
|
||||
|
||||
Future<void> deleteChat() {
|
||||
context.go('/rooms');
|
||||
return deleteRoom(room.id, Matrix.of(context).client);
|
||||
}
|
||||
|
||||
Future<void> 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: <Widget>[
|
||||
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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
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/pangea/widgets/user_settings/p_language_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SettingsLearning extends StatefulWidget {
|
||||
const SettingsLearning({super.key});
|
||||
|
|
@ -32,6 +32,11 @@ class SettingsLearningController extends State<SettingsLearning> {
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> changeLanguage() async {
|
||||
await pLanguageDialog(context, () {});
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
import '../config/environment.dart';
|
||||
import '../network/requests.dart';
|
||||
import '../network/urls.dart';
|
||||
|
||||
class MessageServiceRepo {
|
||||
static Future<void> 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<int> 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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -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<void> archiveSpace(Room? space, Client client) async {
|
||||
if (space == null) {
|
||||
|
|
@ -14,6 +13,9 @@ Future<void> archiveSpace(Room? space, Client client) async {
|
|||
|
||||
final List<Room> children = await space.getChildRooms();
|
||||
for (final Room child in children) {
|
||||
if (child.isUnread) {
|
||||
await child.markUnread(false);
|
||||
}
|
||||
await child.leave();
|
||||
}
|
||||
await space.leave();
|
||||
|
|
|
|||
|
|
@ -1,89 +0,0 @@
|
|||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/constants/class_default_values.dart';
|
||||
import 'error_handler.dart';
|
||||
|
||||
Future<void> 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<User> 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<User> 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 {
|
||||
await room.leave();
|
||||
} catch (err) {
|
||||
ErrorHandler.logError(
|
||||
m: "Failed to leave room with id $roomID. Error: $err",
|
||||
s: StackTrace.current,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,7 @@ class GetChatListItemSubtitle {
|
|||
}
|
||||
|
||||
if (!pangeaController.languageController.languagesSet ||
|
||||
event.redacted ||
|
||||
event.type != EventTypes.Message ||
|
||||
event.messageType != MessageTypes.Text ||
|
||||
!pangeaController.permissionsController
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ void setClassDisplayname(BuildContext context, String? roomId) async {
|
|||
: L10n.of(context)!.changeTheNameOfTheChat,
|
||||
),
|
||||
content: TextField(
|
||||
maxLength: 32,
|
||||
controller: textFieldController,
|
||||
),
|
||||
actions: [
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ class MessageSpeechToTextCardState extends State<MessageSpeechToTextCard> {
|
|||
}
|
||||
|
||||
String? get wordsPerMinuteString =>
|
||||
speechToTextResponse?.transcript.wordsPerMinute?.toString();
|
||||
speechToTextResponse?.transcript.wordsPerMinute?.toStringAsFixed(2);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -172,6 +175,19 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
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 +290,14 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
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);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ class OverlayMessage extends StatelessWidget {
|
|||
pangeaMessageEvent: pangeaMessageEvent,
|
||||
immersionMode: immersionMode,
|
||||
toolbarController: toolbarController,
|
||||
isOverlay: true,
|
||||
),
|
||||
if (event.hasAggregatedEvents(
|
||||
timeline,
|
||||
|
|
|
|||
|
|
@ -235,8 +235,13 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
|
|||
),
|
||||
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(),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
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;
|
||||
|
||||
const ConversationBotDiscussionZone({
|
||||
super.key,
|
||||
required this.initialBotOptions,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String discussionTopic = initialBotOptions.discussionTopic ?? "";
|
||||
final String discussionKeywords =
|
||||
initialBotOptions.discussionKeywords ?? "";
|
||||
// int discussionTriggerScheduleHourInterval =
|
||||
// initialBotOptions.discussionTriggerScheduleHourInterval ?? 24;
|
||||
// String discussionTriggerReactionKey =
|
||||
// initialBotOptions.discussionTriggerReactionKey ?? "⏩";
|
||||
// List<String> reactionKeyOptions = ["⏩"];
|
||||
return Column(
|
||||
children: [
|
||||
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),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 0, 0),
|
||||
child: Text(
|
||||
L10n.of(context)!
|
||||
.conversationBotDiscussionZone_discussionTopicLabel,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
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,
|
||||
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(
|
||||
// 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;
|
||||
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,
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_conversation_zone.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'conversation_bot_discussion_zone.dart';
|
||||
|
||||
class ConversationBotModeDynamicZone extends StatelessWidget {
|
||||
final BotOptionsModel initialBotOptions;
|
||||
final void Function(BotOptionsModel) onChanged;
|
||||
|
||||
const ConversationBotModeDynamicZone({
|
||||
super.key,
|
||||
required this.initialBotOptions,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final zoneMap = {
|
||||
'discussion': ConversationBotDiscussionZone(
|
||||
initialBotOptions: initialBotOptions,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
"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[initialBotOptions.mode],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class ConversationBotModeSelect extends StatelessWidget {
|
||||
final String? initialMode;
|
||||
final void Function(String?)? onChanged;
|
||||
|
||||
const ConversationBotModeSelect({
|
||||
super.key,
|
||||
this.initialMode,
|
||||
this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Map<String, String> 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,
|
||||
};
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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_dynamic_zone.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<ConversationBotSettings> {
|
|||
),
|
||||
),
|
||||
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,41 @@ class ConversationBotSettingsState extends State<ConversationBotSettings> {
|
|||
}),
|
||||
),
|
||||
),
|
||||
// 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(
|
||||
initialBotOptions: botOptions,
|
||||
onChanged: (BotOptionsModel? newOptions) {
|
||||
updateBotOption(() {
|
||||
if (newOptions != null) {
|
||||
botOptions = newOptions;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -48,28 +48,33 @@ class PangeaRichTextState extends State<PangeaRichText> {
|
|||
@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<PangeaRichText> {
|
|||
|
||||
if (repEvent == null) {
|
||||
setState(() => _fetchingRepresentation = true);
|
||||
|
||||
widget.pangeaMessageEvent
|
||||
.representationByLanguageGlobal(
|
||||
langCode: widget.pangeaMessageEvent.messageDisplayLangCode,
|
||||
|
|
@ -95,23 +99,17 @@ class PangeaRichTextState extends State<PangeaRichText> {
|
|||
)
|
||||
.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<PangeaRichText> {
|
|||
|
||||
return blur > 0
|
||||
? ImageFiltered(
|
||||
imageFilter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
|
||||
imageFilter: ImageFilter.blur(
|
||||
sigmaX: blur,
|
||||
sigmaY: blur,
|
||||
),
|
||||
child: richText,
|
||||
)
|
||||
: richText;
|
||||
|
|
|
|||
|
|
@ -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>[
|
||||
TextSpan(
|
||||
text: "${L10n.of(context)!.definition}: ",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
TextSpan(text: definition),
|
||||
],
|
||||
),
|
||||
children: <TextSpan>[
|
||||
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>[
|
||||
TextSpan(
|
||||
text: "${L10n.of(context)!.exampleSentence}: ",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
TextSpan(text: exampleSentence),
|
||||
],
|
||||
),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "${L10n.of(context)!.exampleSentence}: ",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
TextSpan(
|
||||
text: languageType == LanguageType.target
|
||||
? wordData.targetExampleSentence
|
||||
: wordData.baseExampleSentence,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
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 +81,9 @@ class LanguageTile extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
trailing: const Icon(Icons.edit_outlined),
|
||||
onTap: () => pLanguageDialog(context, () {}),
|
||||
onTap: () async {
|
||||
learningController.changeLanguage();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<DatabaseApi> 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,19 +83,22 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
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 (!widget.room.isArchived)
|
||||
// Pangea#
|
||||
PopupMenuItem<String>(
|
||||
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<String>(
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue