drafted - need and correctly assembling records and unsaved msgs - need to confirm that constructs are being assembled
This commit is contained in:
commit
923d39eab6
56 changed files with 1633 additions and 55528 deletions
|
|
@ -2894,21 +2894,23 @@
|
|||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"helpMeTranslate": "Help me translate!",
|
||||
"helpMeTranslate": "Yes!",
|
||||
"@helpMeTranslate": {
|
||||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"needsItShortMessage": "Try interactive translation!",
|
||||
"needsItShortMessage": "Out of target",
|
||||
"needsIGCShortMessage": "Try interactive grammar assistance!",
|
||||
"@needsItShortMessage": {
|
||||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"needsItMessage": "This message has too many words in your base language.",
|
||||
"needsItMessage": "Wait, that's not {targetLanguage}! Do you need help translating?",
|
||||
"@needsItMessage": {
|
||||
"type": "text",
|
||||
"placeholders": {}
|
||||
"placeholders": {
|
||||
"targetLanguage": {}
|
||||
}
|
||||
},
|
||||
"needsIgcMessage": "This message has a grammar error.",
|
||||
"tokenTranslationTitle": "A word is in your base language.",
|
||||
|
|
@ -3998,6 +4000,10 @@
|
|||
"conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Hours between discussion prompts",
|
||||
"conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Responds on ⏩ reaction",
|
||||
"conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reaction to send discussion prompt",
|
||||
"conversationBotCustomZone_title": "Custom Settings",
|
||||
"conversationBotCustomZone_customSystemPromptLabel": "System prompt",
|
||||
"conversationBotCustomZone_customSystemPromptPlaceholder": "Set custom system prompt",
|
||||
"conversationBotCustomZone_customTriggerReactionEnabledLabel": "Responds on ⏩ reaction",
|
||||
"addConversationBotDialogTitleInvite": "Confirm inviting conversation bot",
|
||||
"addConversationBotButtonInvite": "Invite",
|
||||
"addConversationBotDialogInviteConfirmation": "Invite",
|
||||
|
|
@ -4059,11 +4065,22 @@
|
|||
"practice": "Practice",
|
||||
"noLanguagesSet": "No languages set",
|
||||
"noActivitiesFound": "No practice activities found for this message",
|
||||
"previous": "Previous",
|
||||
"languageButtonLabel": "Language: {currentLanguage}",
|
||||
"@languageButtonLabel": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"currentLanguage": {}
|
||||
}
|
||||
},
|
||||
"interactiveTranslatorAutoPlaySliderHeader": "Autoplay translation",
|
||||
"@interactiveTranslatorAutoPlaySliderHeader": {
|
||||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"interactiveTranslatorAutoPlayDesc": "Launches the interactive translator without asking.",
|
||||
"@interactiveTranslatorAutoPlayDesc": {
|
||||
"type": "text",
|
||||
"placeholders": {}
|
||||
}
|
||||
}
|
||||
|
|
@ -3064,6 +3064,17 @@
|
|||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"interactiveTranslatorAutoPlaySliderHeader": "Traducción de reproducción automática",
|
||||
"interactiveTranslatorAutoPlay": "Traductora interactiva de reproducción automática",
|
||||
"@interactiveTranslatorAutoPlay": {
|
||||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"interactiveTranslatorAutoPlayDesc": "Inicia el traductor interactivo sin preguntar.",
|
||||
"@interactiveTranslatorAutoPlayDesc": {
|
||||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"grammarAssistance": "Asistencia gramatical",
|
||||
"@grammarAssistance": {
|
||||
"type": "text",
|
||||
|
|
@ -3126,10 +3137,16 @@
|
|||
"translationSeemsFinished": "La traducción parece estar terminada.",
|
||||
"needsItShortMessage": "¡Pruebe la traducción interactiva!",
|
||||
"needsIGCShortMessage": "¡Pruebe el corrector gramatical interactivo!",
|
||||
"needsItMessage": "Este mensaje tiene demasiadas palabras en su idioma base.",
|
||||
"needsItMessage": "Espera, ¡ese no es {targetLanguage}! ¿Necesitas ayuda para traducir?",
|
||||
"@needsItMessage": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"targetLanguage": {}
|
||||
}
|
||||
},
|
||||
"needsIgcMessage": "Este mensaje tiene un error gramatical.",
|
||||
"tokenTranslationTitle": "Una palabra está en su idioma base.",
|
||||
"helpMeTranslate": "¡Ayúdeme a traducir!",
|
||||
"helpMeTranslate": "¡Sí!",
|
||||
"setToPublicSettingsTitle": "¿Quiere encontrar un compañero de conversación?",
|
||||
"setToPublicSettingsDesc": "Antes de que pueda buscar un compañero de conversación, debe configurar la visibilidad de su perfil como pública.",
|
||||
"publicProfileTitle": "Perfil público",
|
||||
|
|
|
|||
BIN
assets/pangea/bot_faces/pangea_bot.riv
Normal file
BIN
assets/pangea/bot_faces/pangea_bot.riv
Normal file
Binary file not shown.
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:animations/animations.dart';
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/it_bar.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/send_button.dart';
|
||||
import 'package:fluffychat/pangea/constants/language_constants.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
|
|
@ -55,9 +54,6 @@ class ChatInputRow extends StatelessWidget {
|
|||
|
||||
return Column(
|
||||
children: [
|
||||
ITBar(
|
||||
choreographer: controller.choreographer,
|
||||
),
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import '../../pangea/choreographer/widgets/it_bar.dart';
|
||||
import '../../utils/stream_extension.dart';
|
||||
import 'chat_emoji_picker.dart';
|
||||
import 'chat_input_row.dart';
|
||||
|
|
@ -440,6 +441,9 @@ class ChatView extends StatelessWidget {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const ConnectionStatusHeader(),
|
||||
ITBar(
|
||||
choreographer: controller.choreographer,
|
||||
),
|
||||
ReactionsPicker(controller),
|
||||
ReplyDisplay(controller),
|
||||
ChatInputRow(controller),
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -14,6 +14,7 @@ import 'package:fluffychat/pangea/models/it_step.dart';
|
|||
import 'package:fluffychat/pangea/models/representation_content_model.dart';
|
||||
import 'package:fluffychat/pangea/models/space_model.dart';
|
||||
import 'package:fluffychat/pangea/models/tokens_event_content_model.dart';
|
||||
import 'package:fluffychat/pangea/models/user_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/any_state_holder.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/utils/overlay.dart';
|
||||
|
|
@ -532,6 +533,10 @@ class Choreographer {
|
|||
chatController.room,
|
||||
);
|
||||
|
||||
bool get itAutoPlayEnabled => pangeaController.pStoreService.read(
|
||||
MatrixProfile.itAutoPlay.title,
|
||||
) ?? false;
|
||||
|
||||
bool get definitionsEnabled =>
|
||||
pangeaController.permissionsController.isToolEnabled(
|
||||
ToolSetting.definitions,
|
||||
|
|
|
|||
|
|
@ -170,6 +170,15 @@ class IgcController {
|
|||
const int firstMatchIndex = 0;
|
||||
final PangeaMatch match = igcTextData!.matches[firstMatchIndex];
|
||||
|
||||
if (
|
||||
match.isITStart &&
|
||||
choreographer.itAutoPlayEnabled &&
|
||||
igcTextData != null
|
||||
) {
|
||||
choreographer.onITStart(igcTextData!.matches[firstMatchIndex]);
|
||||
return;
|
||||
}
|
||||
|
||||
OverlayUtil.showPositionedCard(
|
||||
context: context,
|
||||
cardToShow: SpanCard(
|
||||
|
|
@ -189,7 +198,7 @@ class IgcController {
|
|||
),
|
||||
roomId: choreographer.roomId,
|
||||
),
|
||||
cardSize: match.isITStart ? const Size(350, 220) : const Size(350, 400),
|
||||
cardSize: match.isITStart ? const Size(350, 260) : const Size(350, 400),
|
||||
transformTargetId: choreographer.inputTransformTargetKey,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class ITController {
|
|||
Choreographer choreographer;
|
||||
|
||||
bool _isOpen = false;
|
||||
bool _willOpen = false;
|
||||
bool _isEditingSourceText = false;
|
||||
bool showChoiceFeedback = false;
|
||||
|
||||
|
|
@ -36,6 +37,7 @@ class ITController {
|
|||
|
||||
void clear() {
|
||||
_isOpen = false;
|
||||
_willOpen = false;
|
||||
showChoiceFeedback = false;
|
||||
_isEditingSourceText = false;
|
||||
|
||||
|
|
@ -54,6 +56,7 @@ class ITController {
|
|||
}
|
||||
|
||||
Future<void> initializeIT(ITStartData itStartData) async {
|
||||
_willOpen = true;
|
||||
Future.delayed(const Duration(microseconds: 100), () {
|
||||
_isOpen = true;
|
||||
});
|
||||
|
|
@ -61,11 +64,9 @@ class ITController {
|
|||
}
|
||||
|
||||
void closeIT() {
|
||||
//if they close it before choosing anything, just put their text back
|
||||
//if they close it before completing, just put their text back
|
||||
//PTODO - explore using last itStep
|
||||
if (choreographer.currentText.isEmpty) {
|
||||
choreographer.textController.text = sourceText ?? "";
|
||||
}
|
||||
choreographer.textController.text = sourceText ?? "";
|
||||
clear();
|
||||
}
|
||||
|
||||
|
|
@ -217,31 +218,19 @@ class ITController {
|
|||
|
||||
Future<void> onEditSourceTextSubmit(String newSourceText) async {
|
||||
try {
|
||||
sourceText = newSourceText;
|
||||
|
||||
_isOpen = true;
|
||||
_isEditingSourceText = false;
|
||||
final String currentText = choreographer.currentText;
|
||||
_itStartData = ITStartData(newSourceText, choreographer.l1LangCode);
|
||||
completedITSteps = [];
|
||||
currentITStep = null;
|
||||
nextITStep = null;
|
||||
goldRouteTracker = GoldRouteTracker.defaultTracker;
|
||||
payLoadIds = [];
|
||||
|
||||
choreographer.startLoading();
|
||||
_setSourceText();
|
||||
getTranslationData(false);
|
||||
|
||||
final List<ITResponseModel> responses = await Future.wait([
|
||||
_customInputTranslation(""),
|
||||
_customInputTranslation(choreographer.currentText),
|
||||
]);
|
||||
if (responses[0].goldContinuances != null &&
|
||||
responses[0].goldContinuances!.isNotEmpty) {
|
||||
goldRouteTracker = GoldRouteTracker(
|
||||
responses[0].goldContinuances!,
|
||||
sourceText!,
|
||||
);
|
||||
}
|
||||
currentITStep = CurrentITStep(
|
||||
sourceText: sourceText!,
|
||||
currentText: currentText,
|
||||
responseModel: responses[1],
|
||||
storedGoldContinuances: goldRouteTracker.continuances,
|
||||
);
|
||||
|
||||
_addPayloadId(responses[1]);
|
||||
} catch (err, stack) {
|
||||
debugger(when: kDebugMode);
|
||||
if (err is! http.Response) {
|
||||
|
|
@ -252,6 +241,7 @@ class ITController {
|
|||
);
|
||||
} finally {
|
||||
choreographer.stopLoading();
|
||||
choreographer.textController.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -334,6 +324,8 @@ class ITController {
|
|||
|
||||
bool get isOpen => _isOpen;
|
||||
|
||||
bool get willOpen => _willOpen;
|
||||
|
||||
String get targetLangCode => choreographer.l2LangCode!;
|
||||
|
||||
String get sourceLangCode => choreographer.l1LangCode!;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|||
import '../../utils/bot_style.dart';
|
||||
import 'it_shimmer.dart';
|
||||
|
||||
class ChoicesArray extends StatelessWidget {
|
||||
class ChoicesArray extends StatefulWidget {
|
||||
final bool isLoading;
|
||||
final List<Choice>? choices;
|
||||
final void Function(int) onPressed;
|
||||
|
|
@ -32,23 +32,51 @@ class ChoicesArray extends StatelessWidget {
|
|||
this.onLongPress,
|
||||
});
|
||||
|
||||
@override
|
||||
ChoicesArrayState createState() => ChoicesArrayState();
|
||||
}
|
||||
|
||||
class ChoicesArrayState extends State<ChoicesArray> {
|
||||
bool interactionDisabled = false;
|
||||
|
||||
void disableInteraction() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
interactionDisabled = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void enableInteractions() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
interactionDisabled = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return isLoading && (choices == null || choices!.length <= 1)
|
||||
? ItShimmer(originalSpan: originalSpan)
|
||||
return widget.isLoading &&
|
||||
(widget.choices == null || widget.choices!.length <= 1)
|
||||
? ItShimmer(originalSpan: widget.originalSpan)
|
||||
: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
children: choices
|
||||
children: widget.choices
|
||||
?.asMap()
|
||||
.entries
|
||||
.map(
|
||||
(entry) => ChoiceItem(
|
||||
theme: theme,
|
||||
onLongPress: isActive ? onLongPress : null,
|
||||
onPressed: isActive ? onPressed : (_) {},
|
||||
onLongPress:
|
||||
widget.isActive ? widget.onLongPress : null,
|
||||
onPressed: widget.isActive ? widget.onPressed : (_) {},
|
||||
entry: entry,
|
||||
isSelected: selectedChoiceIndex == entry.key,
|
||||
interactionDisabled: interactionDisabled,
|
||||
enableInteraction: enableInteractions,
|
||||
disableInteraction: disableInteraction,
|
||||
isSelected: widget.selectedChoiceIndex == entry.key,
|
||||
),
|
||||
)
|
||||
.toList() ??
|
||||
|
|
@ -77,6 +105,9 @@ class ChoiceItem extends StatelessWidget {
|
|||
required this.onPressed,
|
||||
required this.entry,
|
||||
required this.isSelected,
|
||||
required this.interactionDisabled,
|
||||
required this.enableInteraction,
|
||||
required this.disableInteraction,
|
||||
});
|
||||
|
||||
final MapEntry<int, Choice> entry;
|
||||
|
|
@ -84,6 +115,9 @@ class ChoiceItem extends StatelessWidget {
|
|||
final void Function(int p1)? onLongPress;
|
||||
final void Function(int p1) onPressed;
|
||||
final bool isSelected;
|
||||
final bool interactionDisabled;
|
||||
final VoidCallback enableInteraction;
|
||||
final VoidCallback disableInteraction;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -97,6 +131,8 @@ class ChoiceItem extends StatelessWidget {
|
|||
key: ValueKey(entry.value.text),
|
||||
selected: entry.value.color != null,
|
||||
isGold: entry.value.isGold,
|
||||
enableInteraction: enableInteraction,
|
||||
disableInteraction: disableInteraction,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: EdgeInsets.zero,
|
||||
|
|
@ -130,9 +166,11 @@ class ChoiceItem extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
onLongPress:
|
||||
onLongPress != null ? () => onLongPress!(entry.key) : null,
|
||||
onPressed: () => onPressed(entry.key),
|
||||
onLongPress: onLongPress != null && !interactionDisabled
|
||||
? () => onLongPress!(entry.key)
|
||||
: null,
|
||||
onPressed:
|
||||
interactionDisabled ? null : () => onPressed(entry.key),
|
||||
child: Text(
|
||||
entry.value.text,
|
||||
style: BotStyle.text(context),
|
||||
|
|
@ -152,11 +190,15 @@ class ChoiceAnimationWidget extends StatefulWidget {
|
|||
final Widget child;
|
||||
final bool selected;
|
||||
final bool isGold;
|
||||
final VoidCallback enableInteraction;
|
||||
final VoidCallback disableInteraction;
|
||||
|
||||
const ChoiceAnimationWidget({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.selected,
|
||||
required this.enableInteraction,
|
||||
required this.disableInteraction,
|
||||
this.isGold = false,
|
||||
});
|
||||
|
||||
|
|
@ -164,11 +206,13 @@ class ChoiceAnimationWidget extends StatefulWidget {
|
|||
ChoiceAnimationWidgetState createState() => ChoiceAnimationWidgetState();
|
||||
}
|
||||
|
||||
enum AnimationState { ready, forward, reverse, finished }
|
||||
|
||||
class ChoiceAnimationWidgetState extends State<ChoiceAnimationWidget>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
late final Animation<double> _animation;
|
||||
bool animationPlayed = false;
|
||||
AnimationState animationState = AnimationState.ready;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -196,17 +240,29 @@ class ChoiceAnimationWidgetState extends State<ChoiceAnimationWidget>
|
|||
),
|
||||
]).animate(_controller);
|
||||
|
||||
if (widget.selected && !animationPlayed) {
|
||||
widget.enableInteraction();
|
||||
|
||||
if (widget.selected && animationState == AnimationState.ready) {
|
||||
widget.disableInteraction();
|
||||
_controller.forward();
|
||||
animationPlayed = true;
|
||||
setState(() {});
|
||||
setState(() {
|
||||
animationState = AnimationState.forward;
|
||||
});
|
||||
}
|
||||
_controller.addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
if (status == AnimationStatus.completed &&
|
||||
animationState == AnimationState.forward) {
|
||||
_controller.reverse();
|
||||
} else if (status == AnimationStatus.dismissed) {
|
||||
_controller.stop();
|
||||
_controller.reset();
|
||||
setState(() {
|
||||
animationState = AnimationState.reverse;
|
||||
});
|
||||
}
|
||||
if (status == AnimationStatus.dismissed &&
|
||||
animationState == AnimationState.reverse) {
|
||||
widget.enableInteraction();
|
||||
setState(() {
|
||||
animationState = AnimationState.finished;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -214,10 +270,12 @@ class ChoiceAnimationWidgetState extends State<ChoiceAnimationWidget>
|
|||
@override
|
||||
void didUpdateWidget(ChoiceAnimationWidget oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.selected && !animationPlayed) {
|
||||
if (widget.selected && animationState == AnimationState.ready) {
|
||||
widget.disableInteraction();
|
||||
_controller.forward();
|
||||
animationPlayed = true;
|
||||
setState(() {});
|
||||
setState(() {
|
||||
animationState = AnimationState.forward;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:fluffychat/pangea/choreographer/widgets/it_feedback_card.dart';
|
|||
import 'package:fluffychat/pangea/choreographer/widgets/translation_finished_flow.dart';
|
||||
import 'package:fluffychat/pangea/constants/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
|
@ -21,93 +22,107 @@ class ITBar extends StatelessWidget {
|
|||
final Choreographer choreographer;
|
||||
const ITBar({super.key, required this.choreographer});
|
||||
|
||||
ITController get controller => choreographer.itController;
|
||||
ITController get itController => choreographer.itController;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!controller.isOpen) return const SizedBox();
|
||||
|
||||
return CompositedTransformTarget(
|
||||
link: choreographer.itBarLinkAndKey.link,
|
||||
child: Container(
|
||||
key: choreographer.itBarLinkAndKey.key,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).brightness == Brightness.light
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(AppConfig.borderRadius),
|
||||
topRight: Radius.circular(AppConfig.borderRadius),
|
||||
),
|
||||
),
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(0, 3, 3, 3),
|
||||
child: Stack(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
return AnimatedSize(
|
||||
duration: itController.willOpen
|
||||
? const Duration(milliseconds: 2000)
|
||||
: const Duration(milliseconds: 500),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
clipBehavior: Clip.none,
|
||||
child: !itController.willOpen
|
||||
? const SizedBox()
|
||||
: CompositedTransformTarget(
|
||||
link: choreographer.itBarLinkAndKey.link,
|
||||
child: AnimatedOpacity(
|
||||
duration: itController.willOpen
|
||||
? const Duration(milliseconds: 2000)
|
||||
: const Duration(milliseconds: 500),
|
||||
opacity: itController.willOpen ? 1.0 : 0.0,
|
||||
child: Container(
|
||||
key: choreographer.itBarLinkAndKey.key,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).brightness == Brightness.light
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(AppConfig.borderRadius),
|
||||
topRight: Radius.circular(AppConfig.borderRadius),
|
||||
),
|
||||
),
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(0, 3, 3, 3),
|
||||
child: Stack(
|
||||
children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// // Row(
|
||||
// // mainAxisAlignment: MainAxisAlignment.start,
|
||||
// // crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// // children: [
|
||||
// // CounterDisplay(
|
||||
// // correct: controller.correctChoices,
|
||||
// // custom: controller.customChoices,
|
||||
// // incorrect: controller.incorrectChoices,
|
||||
// // yellow: controller.wildcardChoices,
|
||||
// // ),
|
||||
// // CompositedTransformTarget(
|
||||
// // link: choreographer.itBotLayerLinkAndKey.link,
|
||||
// // child: ITBotButton(
|
||||
// // key: choreographer.itBotLayerLinkAndKey.key,
|
||||
// // choreographer: choreographer,
|
||||
// // ),
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// ITCloseButton(choreographer: choreographer),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(height: 40.0),
|
||||
OriginalText(controller: controller),
|
||||
const SizedBox(height: 7.0),
|
||||
IntrinsicHeight(
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(minHeight: 80),
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: Center(
|
||||
child: controller.choreographer.errorService.isError
|
||||
? ITError(
|
||||
error: controller
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// // Row(
|
||||
// // mainAxisAlignment: MainAxisAlignment.start,
|
||||
// // crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// // children: [
|
||||
// // CounterDisplay(
|
||||
// // correct: controller.correctChoices,
|
||||
// // custom: controller.customChoices,
|
||||
// // incorrect: controller.incorrectChoices,
|
||||
// // yellow: controller.wildcardChoices,
|
||||
// // ),
|
||||
// // CompositedTransformTarget(
|
||||
// // link: choreographer.itBotLayerLinkAndKey.link,
|
||||
// // child: ITBotButton(
|
||||
// // key: choreographer.itBotLayerLinkAndKey.key,
|
||||
// // choreographer: choreographer,
|
||||
// // ),
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// ITCloseButton(choreographer: choreographer),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(height: 40.0),
|
||||
OriginalText(controller: itController),
|
||||
const SizedBox(height: 7.0),
|
||||
IntrinsicHeight(
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(minHeight: 80),
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: Center(
|
||||
child: itController.choreographer.errorService.isError
|
||||
? ITError(
|
||||
error: itController
|
||||
.choreographer.errorService.error!,
|
||||
controller: controller,
|
||||
controller: itController,
|
||||
)
|
||||
: controller.showChoiceFeedback
|
||||
? ChoiceFeedbackText(controller: controller)
|
||||
: controller.isTranslationDone
|
||||
? TranslationFeedback(
|
||||
controller: controller,
|
||||
)
|
||||
: ITChoices(controller: controller),
|
||||
),
|
||||
: itController.showChoiceFeedback
|
||||
? ChoiceFeedbackText(controller: itController)
|
||||
: itController.isTranslationDone
|
||||
? TranslationFeedback(
|
||||
controller: itController,
|
||||
)
|
||||
: ITChoices(controller: itController),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 0.0,
|
||||
right: 0.0,
|
||||
child: ITCloseButton(choreographer: choreographer),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 0.0,
|
||||
right: 0.0,
|
||||
child: ITCloseButton(choreographer: choreographer),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -184,10 +199,23 @@ class OriginalText extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (!controller.isEditingSourceText && controller.sourceText != null)
|
||||
IconButton(
|
||||
onPressed: () => controller.setIsEditingSourceText(true),
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
if (
|
||||
!controller.isEditingSourceText
|
||||
&& controller.sourceText != null
|
||||
)
|
||||
AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
opacity: controller.nextITStep != null
|
||||
? 1.0
|
||||
: 0.0,
|
||||
child: IconButton(
|
||||
onPressed: () => {
|
||||
if (controller.nextITStep != null) {
|
||||
controller.setIsEditingSourceText(true),
|
||||
},
|
||||
},
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class ITBotButton extends StatelessWidget {
|
|||
);
|
||||
|
||||
return IconButton(
|
||||
icon: const BotFace(width: 40.0, expression: BotExpression.right),
|
||||
icon: const BotFace(width: 40.0, expression: BotExpression.idle),
|
||||
onPressed: () => choreographer.pangeaController.instructions.show(
|
||||
context,
|
||||
InstructionsEnum.itInstructions,
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class ITFeedbackCardView extends StatelessWidget {
|
|||
children: [
|
||||
CardHeader(
|
||||
text: controller.widget.req.chosenContinuance,
|
||||
botExpression: BotExpression.down,
|
||||
botExpression: BotExpression.nonGold,
|
||||
),
|
||||
Text(
|
||||
controller.widget.choiceFeedback,
|
||||
|
|
|
|||
|
|
@ -11,5 +11,6 @@ class PLocalKey {
|
|||
static const String dismissedPaywall = 'dismissedPaywall';
|
||||
static const String paywallBackoff = 'paywallBackoff';
|
||||
static const String autoPlayMessages = 'autoPlayMessages';
|
||||
static const String itAutoPlay = 'itAutoPlay';
|
||||
static const String messagesSinceUpdate = 'messagesSinceLastUpdate';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,17 +95,16 @@ class ModelKey {
|
|||
static const String languageLevel = "difficulty";
|
||||
static const String safetyModeration = "safety_moderation";
|
||||
static const String mode = "mode";
|
||||
static const String custom = "custom";
|
||||
static const String discussionTopic = "discussion_topic";
|
||||
static const String discussionKeywords = "discussion_keywords";
|
||||
static const String discussionTriggerScheduleEnabled =
|
||||
"discussion_trigger_schedule_enabled";
|
||||
static const String discussionTriggerScheduleHourInterval =
|
||||
"discussion_trigger_schedule_hour_interval";
|
||||
static const String discussionTriggerReactionEnabled =
|
||||
"discussion_trigger_reaction_enabled";
|
||||
static const String discussionTriggerReactionKey =
|
||||
"discussion_trigger_reaction_key";
|
||||
static const String customSystemPrompt = "custom_system_prompt";
|
||||
static const String customTriggerReactionEnabled =
|
||||
"custom_trigger_reaction_enabled";
|
||||
static const String customTriggerReactionKey = "custom_trigger_reaction_key";
|
||||
|
||||
static const String prevEventId = "prev_event_id";
|
||||
static const String prevLastUpdated = "prev_last_updated";
|
||||
|
|
|
|||
|
|
@ -26,7 +26,13 @@ class PangeaEventTypes {
|
|||
static const String report = 'm.report';
|
||||
static const textToSpeechRule = "p.rule.text_to_speech";
|
||||
|
||||
static const pangeaActivityRes = "pangea.activity_res";
|
||||
static const acitivtyRequest = "pangea.activity_req";
|
||||
/// A request to the server to generate activities
|
||||
static const activityRequest = "pangea.activity_req";
|
||||
|
||||
/// A practice activity that is related to a message
|
||||
static const pangeaActivity = "pangea.activity_res";
|
||||
|
||||
/// A record of completion of an activity. There
|
||||
/// can be one per user per activity.
|
||||
static const activityRecord = "pangea.activity_completion";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class MyAnalyticsController {
|
|||
|
||||
/// the max number of messages that will be cached before
|
||||
/// an automatic update is triggered
|
||||
final int _maxMessagesCached = 10;
|
||||
final int _maxMessagesCached = 1;
|
||||
|
||||
/// the number of minutes before an automatic update is triggered
|
||||
final int _minutesBeforeUpdate = 5;
|
||||
|
|
@ -212,16 +212,22 @@ class MyAnalyticsController {
|
|||
);
|
||||
|
||||
// all chats in which user is a student
|
||||
final List<Room> chats = await _client.chatsImAStudentIn;
|
||||
final List<Room> chats = _client.rooms
|
||||
.where((room) => !room.isSpace && !room.isAnalyticsRoom)
|
||||
.toList();
|
||||
|
||||
final DateTime now = DateTime.now();
|
||||
|
||||
// get the recent message events and activity records for each chat
|
||||
final List<Future<List<Event>>> recentMsgFutures = [];
|
||||
final List<Future<List<Event>>> recentActivityFutures = [];
|
||||
for (final Room chat in chats) {
|
||||
chat.getEventsBySender(
|
||||
type: EventTypes.Message,
|
||||
sender: _client.userID!,
|
||||
since: l2AnalyticsLastUpdated,
|
||||
recentMsgFutures.add(
|
||||
chat.getEventsBySender(
|
||||
type: EventTypes.Message,
|
||||
sender: _client.userID!,
|
||||
since: l2AnalyticsLastUpdated,
|
||||
),
|
||||
);
|
||||
recentActivityFutures.add(
|
||||
chat.getEventsBySender(
|
||||
|
|
@ -302,6 +308,7 @@ class MyAnalyticsController {
|
|||
|
||||
constructContent.addAll(constructLists.expand((e) => e));
|
||||
|
||||
//TODO - confirm that this is the correct construct content
|
||||
debugger(when: kDebugMode);
|
||||
|
||||
await analyticsRoom.sendConstructsEvent(
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class PracticeGenerationController {
|
|||
final Event? activityEvent = await pangeaMessageEvent.room.sendPangeaEvent(
|
||||
content: model.toJson(),
|
||||
parentEventId: pangeaMessageEvent.eventId,
|
||||
type: PangeaEventTypes.pangeaActivityRes,
|
||||
type: PangeaEventTypes.pangeaActivity,
|
||||
);
|
||||
|
||||
if (activityEvent == null) {
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ class UserController extends BaseController {
|
|||
: null;
|
||||
|
||||
final bool? autoPlay = migratedProfileInfo(MatrixProfile.autoPlayMessages);
|
||||
final bool? itAutoPlay = migratedProfileInfo(MatrixProfile.itAutoPlay);
|
||||
final bool? trial = migratedProfileInfo(MatrixProfile.activatedFreeTrial);
|
||||
final bool? interactiveTranslator =
|
||||
migratedProfileInfo(MatrixProfile.interactiveTranslator);
|
||||
|
|
@ -142,6 +143,7 @@ class UserController extends BaseController {
|
|||
await updateMatrixProfile(
|
||||
dateOfBirth: dob,
|
||||
autoPlayMessages: autoPlay,
|
||||
itAutoPlay: itAutoPlay,
|
||||
activatedFreeTrial: trial,
|
||||
interactiveTranslator: interactiveTranslator,
|
||||
interactiveGrammar: interactiveGrammar,
|
||||
|
|
@ -223,6 +225,7 @@ class UserController extends BaseController {
|
|||
Future<void> updateMatrixProfile({
|
||||
String? dateOfBirth,
|
||||
bool? autoPlayMessages,
|
||||
bool? itAutoPlay,
|
||||
bool? activatedFreeTrial,
|
||||
bool? interactiveTranslator,
|
||||
bool? interactiveGrammar,
|
||||
|
|
@ -251,6 +254,12 @@ class UserController extends BaseController {
|
|||
autoPlayMessages,
|
||||
);
|
||||
}
|
||||
if (itAutoPlay != null) {
|
||||
await _pangeaController.pStoreService.save(
|
||||
MatrixProfile.itAutoPlay.title,
|
||||
itAutoPlay,
|
||||
);
|
||||
}
|
||||
if (activatedFreeTrial != null) {
|
||||
await _pangeaController.pStoreService.save(
|
||||
MatrixProfile.activatedFreeTrial.title,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
enum SpanDataTypeEnum {
|
||||
|
|
@ -32,7 +32,10 @@ extension SpanDataTypeEnumExt on SpanDataTypeEnum {
|
|||
case SpanDataTypeEnum.correction:
|
||||
return L10n.of(context)!.correctionDefaultPrompt;
|
||||
case SpanDataTypeEnum.itStart:
|
||||
return L10n.of(context)!.needsItMessage;
|
||||
return L10n.of(context)!.needsItMessage(
|
||||
MatrixState.pangeaController.languageController.userL2?.displayName ??
|
||||
L10n.of(context)!.targetLanguage,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ extension PangeaEvent on Event {
|
|||
return PangeaRepresentation.fromJson(json) as V;
|
||||
case PangeaEventTypes.choreoRecord:
|
||||
return ChoreoRecord.fromJson(json) as V;
|
||||
case PangeaEventTypes.pangeaActivityRes:
|
||||
case PangeaEventTypes.pangeaActivity:
|
||||
return PracticeActivityModel.fromJson(json) as V;
|
||||
case PangeaEventTypes.activityRecord:
|
||||
return PracticeActivityRecordModel.fromJson(json) as V;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ extension AnalyticsRoomExtension on Room {
|
|||
final List<Event> events = await getEventsBySender(
|
||||
type: type,
|
||||
sender: userId,
|
||||
count: 1,
|
||||
count: 10,
|
||||
);
|
||||
if (events.isEmpty) return null;
|
||||
final Event event = events.first;
|
||||
|
|
|
|||
|
|
@ -572,18 +572,8 @@ class PangeaMessageEvent {
|
|||
/// If any activity is not complete, it returns true, indicating that the activity icon should be shown.
|
||||
/// Otherwise, it returns false.
|
||||
bool get hasUncompletedActivity {
|
||||
if (l2Code == null) return false;
|
||||
final List<PracticeActivityEvent> activities = practiceActivities(l2Code!);
|
||||
if (activities.isEmpty) return false;
|
||||
|
||||
// for now, only show the button if the event has no completed activities
|
||||
// TODO - revert this after adding logic to show next activity
|
||||
for (final activity in activities) {
|
||||
if (activity.isComplete) return false;
|
||||
}
|
||||
return true;
|
||||
// if (activities.isEmpty) return false;
|
||||
// return !activities.every((activity) => activity.isComplete);
|
||||
if (practiceActivities.isEmpty) return false;
|
||||
return practiceActivities.any((activity) => !(activity.isComplete));
|
||||
}
|
||||
|
||||
String? get l2Code =>
|
||||
|
|
@ -617,34 +607,36 @@ class PangeaMessageEvent {
|
|||
return steps;
|
||||
}
|
||||
|
||||
List<PracticeActivityEvent> get _practiceActivityEvents => _latestEdit
|
||||
.aggregatedEvents(
|
||||
timeline,
|
||||
PangeaEventTypes.pangeaActivityRes,
|
||||
)
|
||||
.map(
|
||||
(e) => PracticeActivityEvent(
|
||||
timeline: timeline,
|
||||
event: e,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
/// Returns a list of all [PracticeActivityEvent] objects
|
||||
/// associated with this message event.
|
||||
List<PracticeActivityEvent> get _practiceActivityEvents {
|
||||
return _latestEdit
|
||||
.aggregatedEvents(
|
||||
timeline,
|
||||
PangeaEventTypes.pangeaActivity,
|
||||
)
|
||||
.map(
|
||||
(e) => PracticeActivityEvent(
|
||||
timeline: timeline,
|
||||
event: e,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// Returns a boolean value indicating whether there are any
|
||||
/// activities associated with this message event for the user's active l2
|
||||
bool get hasActivities {
|
||||
try {
|
||||
final String? l2code =
|
||||
MatrixState.pangeaController.languageController.activeL2Code();
|
||||
|
||||
if (l2code == null) return false;
|
||||
|
||||
return practiceActivities(l2code).isNotEmpty;
|
||||
return practiceActivities.isNotEmpty;
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(e: e, s: s);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
List<PracticeActivityEvent> practiceActivities(
|
||||
/// Returns a list of [PracticeActivityEvent] objects for the given [langCode].
|
||||
List<PracticeActivityEvent> practiceActivitiesByLangCode(
|
||||
String langCode, {
|
||||
bool debug = false,
|
||||
}) {
|
||||
|
|
@ -667,6 +659,19 @@ class PangeaMessageEvent {
|
|||
List<OneConstructUse> get allConstructUses =>
|
||||
[...grammarConstructUses, ..._vocabUses];
|
||||
|
||||
/// Returns a list of [PracticeActivityEvent] for the user's active l2.
|
||||
List<PracticeActivityEvent> get practiceActivities {
|
||||
final String? l2code =
|
||||
MatrixState.pangeaController.languageController.activeL2Code();
|
||||
if (l2code == null) return [];
|
||||
return practiceActivitiesByLangCode(l2code);
|
||||
}
|
||||
|
||||
// List<SpanData> get activities =>
|
||||
//each match is turned into an activity that other students can access
|
||||
//they're not told the answer but have to find it themselves
|
||||
//the message has a blank piece which they fill in themselves
|
||||
|
||||
/// [tokens] is the final list of tokens that were sent
|
||||
/// if no ga or ta,
|
||||
/// make wa use for each and return
|
||||
|
|
@ -716,6 +721,7 @@ class PangeaMessageEvent {
|
|||
);
|
||||
}
|
||||
|
||||
//
|
||||
for (final step in originalSent!.choreo!.choreoSteps) {
|
||||
/// if 1) accepted match 2) token is in the replacement and 3) replacement
|
||||
/// is in the overall step text, then token was a ga
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class PracticeActivityEvent {
|
|||
_content = content;
|
||||
}
|
||||
}
|
||||
if (event.type != PangeaEventTypes.pangeaActivityRes) {
|
||||
if (event.type != PangeaEventTypes.pangeaActivity) {
|
||||
throw Exception(
|
||||
"${event.type} should not be used to make a PracticeActivityEvent",
|
||||
);
|
||||
|
|
@ -39,7 +39,7 @@ class PracticeActivityEvent {
|
|||
return _content!;
|
||||
}
|
||||
|
||||
//in aggregatedEvents for the event, find all practiceActivityRecordEvents whose sender matches the client's userId
|
||||
/// All completion records assosiated with this activity
|
||||
List<PracticeActivityRecordEvent> get allRecords {
|
||||
if (timeline == null) {
|
||||
debugger(when: kDebugMode);
|
||||
|
|
@ -54,16 +54,26 @@ class PracticeActivityEvent {
|
|||
.toList();
|
||||
}
|
||||
|
||||
List<PracticeActivityRecordEvent> get userRecords => allRecords
|
||||
.where(
|
||||
(recordEvent) =>
|
||||
recordEvent.event.senderId == recordEvent.event.room.client.userID,
|
||||
)
|
||||
.toList();
|
||||
/// Completion record assosiated with this activity
|
||||
/// for the logged in user, null if there is none
|
||||
PracticeActivityRecordEvent? get userRecord {
|
||||
final List<PracticeActivityRecordEvent> records = allRecords
|
||||
.where(
|
||||
(recordEvent) =>
|
||||
recordEvent.event.senderId ==
|
||||
recordEvent.event.room.client.userID,
|
||||
)
|
||||
.toList();
|
||||
if (records.length > 1) {
|
||||
debugPrint("There should only be one record per user per activity");
|
||||
debugger(when: kDebugMode);
|
||||
}
|
||||
return records.firstOrNull;
|
||||
}
|
||||
|
||||
String get parentMessageId => event.relationshipEventId!;
|
||||
|
||||
/// Checks if there are any user records in the list for this activity,
|
||||
/// and, if so, then the activity is complete
|
||||
bool get isComplete => userRecords.isNotEmpty;
|
||||
bool get isComplete => userRecord != null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,44 +13,66 @@ class BotOptionsModel {
|
|||
List<String> keywords;
|
||||
bool safetyModeration;
|
||||
String mode;
|
||||
String? custom;
|
||||
String? discussionTopic;
|
||||
String? discussionKeywords;
|
||||
bool? discussionTriggerScheduleEnabled;
|
||||
int? discussionTriggerScheduleHourInterval;
|
||||
bool? discussionTriggerReactionEnabled;
|
||||
String? discussionTriggerReactionKey;
|
||||
String? customSystemPrompt;
|
||||
bool? customTriggerReactionEnabled;
|
||||
String? customTriggerReactionKey;
|
||||
|
||||
BotOptionsModel({
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// General Bot Options
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
this.languageLevel,
|
||||
this.topic = "General Conversation",
|
||||
this.keywords = const [],
|
||||
this.safetyModeration = true,
|
||||
this.mode = "discussion",
|
||||
this.custom = "",
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Discussion Mode Options
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
this.discussionTopic,
|
||||
this.discussionKeywords,
|
||||
this.discussionTriggerScheduleEnabled,
|
||||
this.discussionTriggerScheduleHourInterval,
|
||||
this.discussionTriggerReactionEnabled = true,
|
||||
this.discussionTriggerReactionKey,
|
||||
this.discussionTriggerReactionKey = "⏩",
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Custom Mode Options
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
this.customSystemPrompt,
|
||||
this.customTriggerReactionEnabled = true,
|
||||
this.customTriggerReactionKey = "⏩",
|
||||
});
|
||||
|
||||
factory BotOptionsModel.fromJson(json) {
|
||||
return BotOptionsModel(
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// General Bot Options
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
languageLevel: json[ModelKey.languageLevel],
|
||||
safetyModeration: json[ModelKey.safetyModeration] ?? true,
|
||||
mode: json[ModelKey.mode] ?? "discussion",
|
||||
custom: json[ModelKey.custom],
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Discussion Mode Options
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
discussionTopic: json[ModelKey.discussionTopic],
|
||||
discussionKeywords: json[ModelKey.discussionKeywords],
|
||||
discussionTriggerScheduleEnabled:
|
||||
json[ModelKey.discussionTriggerScheduleEnabled],
|
||||
discussionTriggerScheduleHourInterval:
|
||||
json[ModelKey.discussionTriggerScheduleHourInterval],
|
||||
discussionTriggerReactionEnabled:
|
||||
json[ModelKey.discussionTriggerReactionEnabled],
|
||||
discussionTriggerReactionKey: json[ModelKey.discussionTriggerReactionKey],
|
||||
json[ModelKey.discussionTriggerReactionEnabled] ?? true,
|
||||
discussionTriggerReactionKey:
|
||||
json[ModelKey.discussionTriggerReactionKey] ?? "⏩",
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Custom Mode Options
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
customSystemPrompt: json[ModelKey.customSystemPrompt],
|
||||
customTriggerReactionEnabled:
|
||||
json[ModelKey.customTriggerReactionEnabled] ?? true,
|
||||
customTriggerReactionKey: json[ModelKey.customTriggerReactionKey] ?? "⏩",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -61,17 +83,16 @@ class BotOptionsModel {
|
|||
data[ModelKey.languageLevel] = languageLevel;
|
||||
data[ModelKey.safetyModeration] = safetyModeration;
|
||||
data[ModelKey.mode] = mode;
|
||||
data[ModelKey.custom] = custom;
|
||||
data[ModelKey.discussionTopic] = discussionTopic;
|
||||
data[ModelKey.discussionKeywords] = discussionKeywords;
|
||||
data[ModelKey.discussionTriggerScheduleEnabled] =
|
||||
discussionTriggerScheduleEnabled;
|
||||
data[ModelKey.discussionTriggerScheduleHourInterval] =
|
||||
discussionTriggerScheduleHourInterval;
|
||||
data[ModelKey.discussionTriggerReactionEnabled] =
|
||||
discussionTriggerReactionEnabled;
|
||||
discussionTriggerReactionEnabled ?? true;
|
||||
data[ModelKey.discussionTriggerReactionKey] =
|
||||
discussionTriggerReactionKey;
|
||||
discussionTriggerReactionKey ?? "⏩";
|
||||
data[ModelKey.customSystemPrompt] = customSystemPrompt;
|
||||
data[ModelKey.customTriggerReactionEnabled] =
|
||||
customTriggerReactionEnabled ?? true;
|
||||
data[ModelKey.customTriggerReactionKey] = customTriggerReactionKey ?? "⏩";
|
||||
return data;
|
||||
} catch (e, s) {
|
||||
debugger(when: kDebugMode);
|
||||
|
|
@ -92,27 +113,27 @@ class BotOptionsModel {
|
|||
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;
|
||||
case ModelKey.customSystemPrompt:
|
||||
customSystemPrompt = value;
|
||||
break;
|
||||
case ModelKey.customTriggerReactionEnabled:
|
||||
customTriggerReactionEnabled = value;
|
||||
break;
|
||||
case ModelKey.customTriggerReactionKey:
|
||||
customTriggerReactionKey = value;
|
||||
break;
|
||||
default:
|
||||
throw Exception('Invalid key for bot options - $key');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class MultipleChoice {
|
|||
return MultipleChoice(
|
||||
question: json['question'] as String,
|
||||
choices: (json['choices'] as List).map((e) => e as String).toList(),
|
||||
answer: json['answer'] as String,
|
||||
answer: json['answer'] ?? json['correct_answer'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -243,9 +243,11 @@ class PracticeActivityModel {
|
|||
.toList(),
|
||||
langCode: json['lang_code'] as String,
|
||||
msgId: json['msg_id'] as String,
|
||||
activityType: ActivityTypeEnum.values.firstWhere(
|
||||
(e) => e.string == json['activity_type'],
|
||||
),
|
||||
activityType: json['activity_type'] == "multipleChoice"
|
||||
? ActivityTypeEnum.multipleChoice
|
||||
: ActivityTypeEnum.values.firstWhere(
|
||||
(e) => e.string == json['activity_type'],
|
||||
),
|
||||
multipleChoice: json['multiple_choice'] != null
|
||||
? MultipleChoice.fromJson(
|
||||
json['multiple_choice'] as Map<String, dynamic>,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ class PUserModel {
|
|||
enum MatrixProfile {
|
||||
dateOfBirth,
|
||||
autoPlayMessages,
|
||||
itAutoPlay,
|
||||
activatedFreeTrial,
|
||||
interactiveTranslator,
|
||||
interactiveGrammar,
|
||||
|
|
@ -79,6 +80,8 @@ extension MatrixProfileExtension on MatrixProfile {
|
|||
return ModelKey.userDateOfBirth;
|
||||
case MatrixProfile.autoPlayMessages:
|
||||
return PLocalKey.autoPlayMessages;
|
||||
case MatrixProfile.itAutoPlay:
|
||||
return PLocalKey.itAutoPlay;
|
||||
case MatrixProfile.activatedFreeTrial:
|
||||
return PLocalKey.activatedTrialKey;
|
||||
case MatrixProfile.interactiveTranslator:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class ClassDescriptionButton extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final iconColor = Theme.of(context).textTheme.bodyLarge!.color;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
|
|
@ -26,14 +27,27 @@ class ClassDescriptionButton extends StatelessWidget {
|
|||
foregroundColor: iconColor,
|
||||
child: const Icon(Icons.topic_outlined),
|
||||
),
|
||||
subtitle: Text(
|
||||
room.topic.isEmpty
|
||||
? (room.isRoomAdmin
|
||||
? (room.isSpace
|
||||
? L10n.of(context)!.classDescriptionDesc
|
||||
: L10n.of(context)!.chatTopicDesc)
|
||||
: L10n.of(context)!.topicNotSet)
|
||||
: room.topic,
|
||||
subtitle: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 190,
|
||||
),
|
||||
child: Scrollbar(
|
||||
controller: scrollController,
|
||||
interactive: true,
|
||||
child: SingleChildScrollView(
|
||||
controller: scrollController,
|
||||
primary: false,
|
||||
child: Text(
|
||||
room.topic.isEmpty
|
||||
? (room.isRoomAdmin
|
||||
? (room.isSpace
|
||||
? L10n.of(context)!.classDescriptionDesc
|
||||
: L10n.of(context)!.chatTopicDesc)
|
||||
: L10n.of(context)!.topicNotSet)
|
||||
: room.topic,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
room.isSpace
|
||||
|
|
|
|||
|
|
@ -61,6 +61,16 @@ class SettingsLearningView extends StatelessWidget {
|
|||
pStoreKey: setting.toString(),
|
||||
local: false,
|
||||
),
|
||||
PSettingsSwitchListTile.adaptive(
|
||||
defaultValue: controller.pangeaController.pStoreService.read(
|
||||
PLocalKey.itAutoPlay,
|
||||
) ??
|
||||
false,
|
||||
title: L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader,
|
||||
subtitle: L10n.of(context)!.interactiveTranslatorAutoPlayDesc,
|
||||
pStoreKey: PLocalKey.itAutoPlay,
|
||||
local: false,
|
||||
),
|
||||
PSettingsSwitchListTile.adaptive(
|
||||
defaultValue: controller.pangeaController.pStoreService.read(
|
||||
PLocalKey.autoPlayMessages,
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@ class InstructionsController {
|
|||
String transformTargetKey, [
|
||||
bool showToggle = true,
|
||||
]) async {
|
||||
if (_instructionsShown[key] ?? false) {
|
||||
return;
|
||||
}
|
||||
_instructionsShown[key] = true;
|
||||
|
||||
if (wereInstructionsTurnedOff(key)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -51,9 +56,6 @@ class InstructionsController {
|
|||
);
|
||||
return;
|
||||
}
|
||||
if (_instructionsShown[key] ?? false) {
|
||||
return;
|
||||
}
|
||||
|
||||
final bool userLangsSet =
|
||||
await _pangeaController.userController.areUserLanguagesSet;
|
||||
|
|
@ -61,8 +63,6 @@ class InstructionsController {
|
|||
return;
|
||||
}
|
||||
|
||||
_instructionsShown[key] = true;
|
||||
|
||||
final botStyle = BotStyle.text(context);
|
||||
Future.delayed(
|
||||
const Duration(seconds: 1),
|
||||
|
|
@ -74,7 +74,7 @@ class InstructionsController {
|
|||
children: [
|
||||
CardHeader(
|
||||
text: key.title(context),
|
||||
botExpression: BotExpression.surprised,
|
||||
botExpression: BotExpression.idle,
|
||||
onClose: () => {_instructionsClosed[key] = true},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/enum/span_data_type.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../constants/match_rule_ids.dart';
|
||||
import '../models/pangea_match_model.dart';
|
||||
|
||||
|
|
@ -96,7 +96,11 @@ class MatchCopy {
|
|||
switch (afterColon) {
|
||||
case MatchRuleIds.interactiveTranslation:
|
||||
title = l10n.needsItShortMessage;
|
||||
description = l10n.needsItMessage;
|
||||
description = l10n.needsItMessage(
|
||||
MatrixState
|
||||
.pangeaController.languageController.userL2?.displayName ??
|
||||
"target language",
|
||||
);
|
||||
break;
|
||||
case MatchRuleIds.tokenNeedsTranslation:
|
||||
title = l10n.tokenTranslationTitle;
|
||||
|
|
|
|||
|
|
@ -94,59 +94,62 @@ class ToolbarDisplayController {
|
|||
previousEvent: previousEvent,
|
||||
);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
Widget overlayEntry;
|
||||
if (toolbar == null) return;
|
||||
try {
|
||||
overlayEntry = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: pangeaMessageEvent.ownMessage
|
||||
? CrossAxisAlignment.end
|
||||
: CrossAxisAlignment.start,
|
||||
children: [
|
||||
toolbarUp ? toolbar! : overlayMessage,
|
||||
const SizedBox(height: 6),
|
||||
toolbarUp ? overlayMessage : toolbar!,
|
||||
],
|
||||
);
|
||||
} catch (err) {
|
||||
debugger(when: kDebugMode);
|
||||
ErrorHandler.logError(e: err, s: StackTrace.current);
|
||||
return;
|
||||
}
|
||||
|
||||
OverlayUtil.showOverlay(
|
||||
context: context,
|
||||
child: overlayEntry,
|
||||
transformTargetId: targetId,
|
||||
targetAnchor: pangeaMessageEvent.ownMessage
|
||||
? toolbarUp
|
||||
? Alignment.bottomRight
|
||||
: Alignment.topRight
|
||||
: toolbarUp
|
||||
? Alignment.bottomLeft
|
||||
: Alignment.topLeft,
|
||||
followerAnchor: pangeaMessageEvent.ownMessage
|
||||
? toolbarUp
|
||||
? Alignment.bottomRight
|
||||
: Alignment.topRight
|
||||
: toolbarUp
|
||||
? Alignment.bottomLeft
|
||||
: Alignment.topLeft,
|
||||
backgroundColor: const Color.fromRGBO(0, 0, 0, 1).withAlpha(100),
|
||||
// I'm not sure why I put this here, but it causes the toolbar
|
||||
// not to open immediately after clicking (user has to scroll or move their cursor)
|
||||
// so I'm commenting it out for now
|
||||
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
Widget overlayEntry;
|
||||
if (toolbar == null) return;
|
||||
try {
|
||||
overlayEntry = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: pangeaMessageEvent.ownMessage
|
||||
? CrossAxisAlignment.end
|
||||
: CrossAxisAlignment.start,
|
||||
children: [
|
||||
toolbarUp ? toolbar! : overlayMessage,
|
||||
const SizedBox(height: 6),
|
||||
toolbarUp ? overlayMessage : toolbar!,
|
||||
],
|
||||
);
|
||||
} catch (err) {
|
||||
debugger(when: kDebugMode);
|
||||
ErrorHandler.logError(e: err, s: StackTrace.current);
|
||||
return;
|
||||
}
|
||||
|
||||
if (MatrixState.pAnyState.entries.isNotEmpty) {
|
||||
overlayId = MatrixState.pAnyState.entries.last.hashCode.toString();
|
||||
}
|
||||
OverlayUtil.showOverlay(
|
||||
context: context,
|
||||
child: overlayEntry,
|
||||
transformTargetId: targetId,
|
||||
targetAnchor: pangeaMessageEvent.ownMessage
|
||||
? toolbarUp
|
||||
? Alignment.bottomRight
|
||||
: Alignment.topRight
|
||||
: toolbarUp
|
||||
? Alignment.bottomLeft
|
||||
: Alignment.topLeft,
|
||||
followerAnchor: pangeaMessageEvent.ownMessage
|
||||
? toolbarUp
|
||||
? Alignment.bottomRight
|
||||
: Alignment.topRight
|
||||
: toolbarUp
|
||||
? Alignment.bottomLeft
|
||||
: Alignment.topLeft,
|
||||
backgroundColor: const Color.fromRGBO(0, 0, 0, 1).withAlpha(100),
|
||||
);
|
||||
|
||||
if (mode != null) {
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 100),
|
||||
() => toolbarModeStream.add(mode),
|
||||
);
|
||||
}
|
||||
});
|
||||
if (MatrixState.pAnyState.entries.isNotEmpty) {
|
||||
overlayId = MatrixState.pAnyState.entries.last.hashCode.toString();
|
||||
}
|
||||
|
||||
if (mode != null) {
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 100),
|
||||
() => toolbarModeStream.add(mode),
|
||||
);
|
||||
}
|
||||
// });
|
||||
}
|
||||
|
||||
bool get highlighted {
|
||||
|
|
@ -302,7 +305,6 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
void showPracticeActivity() {
|
||||
toolbarContent = PracticeActivityCard(
|
||||
pangeaMessageEvent: widget.pangeaMessageEvent,
|
||||
controller: this,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ class MessageTranslationCardState extends State<MessageTranslationCard> {
|
|||
|
||||
String? translationLangCode() {
|
||||
if (widget.immersionMode) return l1Code;
|
||||
final String? originalWrittenCode =
|
||||
widget.messageEvent.originalWritten?.content.langCode;
|
||||
return (l1Code == originalWrittenCode || originalWrittenCode == null)
|
||||
final String? originalSentCode =
|
||||
widget.messageEvent.originalSent?.content.langCode;
|
||||
return (l1Code == originalSentCode || originalSentCode == null)
|
||||
? l2Code
|
||||
: l1Code;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
enum BotExpression { surprised, right, addled, left, down, shocked }
|
||||
enum BotExpression { gold, nonGold, addled, idle, surprised }
|
||||
|
||||
class BotFace extends StatefulWidget {
|
||||
final double width;
|
||||
final Color? forceColor;
|
||||
final BotExpression expression;
|
||||
|
||||
class BotFace extends StatelessWidget {
|
||||
const BotFace({
|
||||
super.key,
|
||||
required this.width,
|
||||
|
|
@ -10,23 +15,80 @@ class BotFace extends StatelessWidget {
|
|||
this.forceColor,
|
||||
});
|
||||
|
||||
final double width;
|
||||
final Color? forceColor;
|
||||
final BotExpression expression;
|
||||
@override
|
||||
BotFaceState createState() => BotFaceState();
|
||||
}
|
||||
|
||||
class BotFaceState extends State<BotFace> {
|
||||
Artboard? _artboard;
|
||||
StateMachineController? _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadRiveFile();
|
||||
}
|
||||
|
||||
double mapExpressionToInput(BotExpression expression) {
|
||||
switch (expression) {
|
||||
case BotExpression.gold:
|
||||
return 1.0;
|
||||
case BotExpression.nonGold:
|
||||
return 2.0;
|
||||
case BotExpression.surprised:
|
||||
return 3.0;
|
||||
case BotExpression.addled:
|
||||
return 4.0;
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadRiveFile() async {
|
||||
final riveFile = await RiveFile.asset('assets/pangea/bot_faces/pangea_bot.riv');
|
||||
|
||||
final artboard = riveFile.mainArtboard;
|
||||
_controller = StateMachineController
|
||||
.fromArtboard(artboard, 'BotIconStateMachine');
|
||||
|
||||
if (_controller != null) {
|
||||
artboard.addController(_controller!);
|
||||
_controller!.setInputValue(
|
||||
_controller!.stateMachine.inputs[0].id,
|
||||
mapExpressionToInput(widget.expression),
|
||||
);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_artboard = artboard;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Image.asset(
|
||||
'assets/pangea/bot_faces/${expression.toString().split('.').last}.png',
|
||||
// 'assets/pangea/bot_faces/surprised.png',
|
||||
width: width,
|
||||
height: width,
|
||||
// color: forceColor ??
|
||||
// (Theme.of(context).brightness == Brightness.light
|
||||
// ? Theme.of(context).colorScheme.primary
|
||||
// : Theme.of(context).colorScheme.primary),
|
||||
|
||||
return SizedBox(
|
||||
width: widget.width,
|
||||
height: widget.width,
|
||||
child: _artboard != null
|
||||
? Rive(
|
||||
artboard: _artboard!,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Container(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(BotFace oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.expression != widget.expression) {
|
||||
_controller!.setInputValue(
|
||||
_controller!.stateMachine.inputs[0].id,
|
||||
mapExpressionToInput(widget.expression),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// extension ParseToString on BotExpressions {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class ConversationBotCustomSystemPromptInput extends StatelessWidget {
|
||||
final BotOptionsModel initialBotOptions;
|
||||
// call this to update propagate changes to parents
|
||||
final void Function(BotOptionsModel) onChanged;
|
||||
|
||||
const ConversationBotCustomSystemPromptInput({
|
||||
super.key,
|
||||
required this.initialBotOptions,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String customSystemPrompt = initialBotOptions.customSystemPrompt ?? "";
|
||||
|
||||
final TextEditingController textFieldController =
|
||||
TextEditingController(text: customSystemPrompt);
|
||||
|
||||
void setBotCustomSystemPromptAction() async {
|
||||
showDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: Text(
|
||||
L10n.of(context)!.conversationBotCustomZone_customSystemPromptLabel,
|
||||
),
|
||||
content: TextField(
|
||||
minLines: 1,
|
||||
maxLines: 10,
|
||||
maxLength: 1000,
|
||||
controller: textFieldController,
|
||||
onChanged: (value) {
|
||||
customSystemPrompt = value;
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(L10n.of(context)!.cancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(L10n.of(context)!.ok),
|
||||
onPressed: () {
|
||||
if (customSystemPrompt == "") return;
|
||||
if (customSystemPrompt !=
|
||||
initialBotOptions.customSystemPrompt) {
|
||||
initialBotOptions.customSystemPrompt = customSystemPrompt;
|
||||
onChanged.call(initialBotOptions);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
onTap: setBotCustomSystemPromptAction,
|
||||
title: Text(
|
||||
initialBotOptions.customSystemPrompt ??
|
||||
L10n.of(context)!
|
||||
.conversationBotCustomZone_customSystemPromptPlaceholder,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,75 @@
|
|||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_custom_system_prompt_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class ConversationBotCustomZone extends StatelessWidget {
|
||||
final BotOptionsModel initialBotOptions;
|
||||
// call this to update propagate changes to parents
|
||||
final void Function(BotOptionsModel) onChanged;
|
||||
|
||||
const ConversationBotCustomZone({
|
||||
super.key,
|
||||
required this.initialBotOptions,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Column(
|
||||
print(initialBotOptions.toJson());
|
||||
return Column(
|
||||
children: [
|
||||
Text('Custom Zone'),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
L10n.of(context)!.conversationBotCustomZone_title,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
color: Colors.grey,
|
||||
thickness: 1,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 0, 0),
|
||||
child: Text(
|
||||
L10n.of(context)!
|
||||
.conversationBotCustomZone_customSystemPromptLabel,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: ConversationBotCustomSystemPromptInput(
|
||||
initialBotOptions: initialBotOptions,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
CheckboxListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!
|
||||
.conversationBotCustomZone_customTriggerReactionEnabledLabel,
|
||||
),
|
||||
enabled: false,
|
||||
value: initialBotOptions.customTriggerReactionEnabled ?? true,
|
||||
onChanged: (value) {
|
||||
initialBotOptions.customTriggerReactionEnabled = value ?? true;
|
||||
initialBotOptions.customTriggerReactionKey =
|
||||
"⏩"; // hard code this for now
|
||||
onChanged.call(initialBotOptions);
|
||||
},
|
||||
// make this input disabled always
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ class ConversationBotDiscussionZone extends StatelessWidget {
|
|||
.conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel,
|
||||
),
|
||||
enabled: false,
|
||||
value: initialBotOptions.discussionTriggerReactionEnabled ?? false,
|
||||
value: initialBotOptions.discussionTriggerReactionEnabled ?? true,
|
||||
onChanged: (value) {
|
||||
initialBotOptions.discussionTriggerReactionEnabled = value ?? false;
|
||||
initialBotOptions.discussionTriggerReactionEnabled = value ?? true;
|
||||
initialBotOptions.discussionTriggerReactionKey =
|
||||
"⏩"; // hard code this for now
|
||||
onChanged.call(initialBotOptions);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_conversation_zone.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'conversation_bot_discussion_zone.dart';
|
||||
|
|
@ -23,9 +21,12 @@ class ConversationBotModeDynamicZone extends StatelessWidget {
|
|||
initialBotOptions: initialBotOptions,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
"custom": const ConversationBotCustomZone(),
|
||||
"conversation": const ConversationBotConversationZone(),
|
||||
"text_adventure": const ConversationBotTextAdventureZone(),
|
||||
"custom": ConversationBotCustomZone(
|
||||
initialBotOptions: initialBotOptions,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
// "conversation": const ConversationBotConversationZone(),
|
||||
// "text_adventure": const ConversationBotTextAdventureZone(),
|
||||
};
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class ConversationBotModeSelect extends StatelessWidget {
|
|||
final Map<String, String> options = {
|
||||
"discussion":
|
||||
L10n.of(context)!.conversationBotModeSelectOption_discussion,
|
||||
// "custom": L10n.of(context)!.conversationBotModeSelectOption_custom,
|
||||
"custom": L10n.of(context)!.conversationBotModeSelectOption_custom,
|
||||
// "conversation":
|
||||
// L10n.of(context)!.conversationBotModeSelectOption_conversation,
|
||||
// "text_adventure":
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
|||
import 'package:fluffychat/pangea/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/widgets/common/bot_face_svg.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart';
|
||||
import 'package:fluffychat/pangea/widgets/space/language_level_dropdown.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -44,7 +45,9 @@ class ConversationBotSettingsState extends State<ConversationBotSettings> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
isOpen = widget.startOpen;
|
||||
botOptions = widget.room?.botOptions ?? BotOptionsModel();
|
||||
botOptions = widget.room?.botOptions != null
|
||||
? BotOptionsModel.fromJson(widget.room?.botOptions?.toJson())
|
||||
: BotOptionsModel();
|
||||
widget.room?.isBotRoom.then((bool isBotRoom) {
|
||||
setState(() {
|
||||
addBot = isBotRoom;
|
||||
|
|
@ -136,7 +139,7 @@ class ConversationBotSettingsState extends State<ConversationBotSettings> {
|
|||
Theme.of(context).textTheme.bodyLarge!.color,
|
||||
child: const BotFace(
|
||||
width: 30.0,
|
||||
expression: BotExpression.right,
|
||||
expression: BotExpression.idle,
|
||||
),
|
||||
),
|
||||
trailing: ElevatedButton(
|
||||
|
|
@ -221,28 +224,28 @@ 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(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(
|
||||
|
|
|
|||
|
|
@ -71,6 +71,16 @@ class PangeaTextController extends TextEditingController {
|
|||
choreographer.igc.igcTextData!.getTopMatchIndexForOffset(
|
||||
selection.baseOffset,
|
||||
);
|
||||
|
||||
// if autoplay on and it start then just start it
|
||||
if (matchIndex != -1 &&
|
||||
choreographer.itAutoPlayEnabled &&
|
||||
choreographer.igc.igcTextData!.matches[matchIndex].isITStart) {
|
||||
return choreographer.onITStart(
|
||||
choreographer.igc.igcTextData!.matches[matchIndex],
|
||||
);
|
||||
}
|
||||
|
||||
final Widget? cardToShow = matchIndex != -1
|
||||
? SpanCard(
|
||||
scm: SpanCardModel(
|
||||
|
|
@ -100,7 +110,7 @@ class PangeaTextController extends TextEditingController {
|
|||
context: context,
|
||||
cardSize: matchIndex != -1 &&
|
||||
choreographer.igc.igcTextData!.matches[matchIndex].isITStart
|
||||
? const Size(350, 220)
|
||||
? const Size(350, 260)
|
||||
: const Size(350, 400),
|
||||
cardToShow: cardToShow,
|
||||
transformTargetId: choreographer.inputTransformTargetKey,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/constants/local.key.dart';
|
||||
import 'package:fluffychat/pangea/enum/span_data_type.dart';
|
||||
import 'package:fluffychat/pangea/models/span_data.dart';
|
||||
import 'package:fluffychat/pangea/utils/bot_style.dart';
|
||||
|
|
@ -49,6 +50,8 @@ class SpanCardState extends State<SpanCard> {
|
|||
bool fetchingData = false;
|
||||
int? selectedChoiceIndex;
|
||||
|
||||
BotExpression currentExpression = BotExpression.nonGold;
|
||||
|
||||
//on initState, get SpanDetails
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -150,7 +153,23 @@ class WordMatchContent extends StatelessWidget {
|
|||
.choices?[index]
|
||||
.selected = true;
|
||||
|
||||
controller.setState(() => ());
|
||||
controller.setState(
|
||||
() => (
|
||||
controller.currentExpression =
|
||||
controller
|
||||
.widget
|
||||
.scm
|
||||
.choreographer
|
||||
.igc
|
||||
.igcTextData
|
||||
!.matches[controller.widget.scm.matchIndex]
|
||||
.match
|
||||
.choices![index]
|
||||
.isBestCorrection
|
||||
? BotExpression.gold
|
||||
: BotExpression.surprised
|
||||
),
|
||||
);
|
||||
// if (controller.widget.scm.pangeaMatch.match.choices![index].type ==
|
||||
// SpanChoiceType.distractor) {
|
||||
// await controller.getSpanDetails();
|
||||
|
|
@ -192,10 +211,11 @@ class WordMatchContent extends StatelessWidget {
|
|||
try {
|
||||
return Column(
|
||||
children: [
|
||||
// if (!controller.widget.scm.pangeaMatch!.isITStart)
|
||||
CardHeader(
|
||||
text: controller.error?.toString() ?? matchCopy.title,
|
||||
botExpression: controller.error == null
|
||||
? BotExpression.right
|
||||
? controller.currentExpression
|
||||
: BotExpression.addled,
|
||||
),
|
||||
Expanded(
|
||||
|
|
@ -321,6 +341,10 @@ class WordMatchContent extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
if (controller.widget.scm.pangeaMatch!.isITStart)
|
||||
DontShowSwitchListTile(
|
||||
controller: pangeaController,
|
||||
),
|
||||
],
|
||||
);
|
||||
} on Exception catch (e) {
|
||||
|
|
@ -459,3 +483,40 @@ class StartITButton extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DontShowSwitchListTile extends StatefulWidget {
|
||||
final PangeaController controller;
|
||||
|
||||
const DontShowSwitchListTile({
|
||||
super.key,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
@override
|
||||
DontShowSwitchListTileState createState() => DontShowSwitchListTileState();
|
||||
}
|
||||
|
||||
class DontShowSwitchListTileState extends State<DontShowSwitchListTile> {
|
||||
bool switchValue = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SwitchListTile.adaptive(
|
||||
activeColor: AppConfig.activeToggleColor,
|
||||
title: Text(L10n.of(context)!.interactiveTranslatorAutoPlaySliderHeader),
|
||||
value: switchValue,
|
||||
onChanged: (value) => {
|
||||
widget.controller.pStoreService.save(
|
||||
PLocalKey.itAutoPlay.toString(),
|
||||
value,
|
||||
),
|
||||
setState(() => switchValue = value),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ class GenerateVocabButtonState extends State<GenerateVocabButton> {
|
|||
ElevatedButton.icon(
|
||||
icon: const BotFace(
|
||||
width: 50.0,
|
||||
expression: BotExpression.right,
|
||||
expression: BotExpression.idle,
|
||||
),
|
||||
label: Text(L10n.of(context)!.generateVocabulary),
|
||||
onPressed: () async {
|
||||
|
|
@ -464,9 +464,9 @@ class PromptsFieldState extends State<PromptsField> {
|
|||
|
||||
// button to call API
|
||||
ElevatedButton.icon(
|
||||
icon: const BotFace(
|
||||
icon: BotFace(
|
||||
width: 50.0,
|
||||
expression: BotExpression.right,
|
||||
expression: BotExpression.idle,
|
||||
),
|
||||
label: Text(L10n.of(context)!.generatePrompts),
|
||||
onPressed: () async {
|
||||
|
|
|
|||
|
|
@ -2,31 +2,93 @@ import 'package:collection/collection.dart';
|
|||
import 'package:fluffychat/pangea/choreographer/widgets/choice_array.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/practice_activity_event.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart';
|
||||
import 'package:fluffychat/pangea/widgets/practice_activity/practice_activity_content.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_record_model.dart';
|
||||
import 'package:fluffychat/pangea/widgets/practice_activity/practice_activity_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MultipleChoiceActivity extends StatelessWidget {
|
||||
final MessagePracticeActivityContentState card;
|
||||
final Function(int) updateChoice;
|
||||
final bool isActive;
|
||||
/// The multiple choice activity view
|
||||
class MultipleChoiceActivity extends StatefulWidget {
|
||||
final MessagePracticeActivityCardState controller;
|
||||
final PracticeActivityEvent? currentActivity;
|
||||
|
||||
const MultipleChoiceActivity({
|
||||
super.key,
|
||||
required this.card,
|
||||
required this.updateChoice,
|
||||
required this.isActive,
|
||||
required this.controller,
|
||||
required this.currentActivity,
|
||||
});
|
||||
|
||||
PracticeActivityEvent get practiceEvent => card.practiceEvent;
|
||||
@override
|
||||
MultipleChoiceActivityState createState() => MultipleChoiceActivityState();
|
||||
}
|
||||
|
||||
int? get selectedChoiceIndex => card.selectedChoiceIndex;
|
||||
class MultipleChoiceActivityState extends State<MultipleChoiceActivity> {
|
||||
int? selectedChoiceIndex;
|
||||
|
||||
bool get submitted => card.recordSubmittedThisSession;
|
||||
PracticeActivityRecordModel? get currentRecordModel =>
|
||||
widget.controller.currentRecordModel;
|
||||
|
||||
bool get isSubmitted =>
|
||||
widget.currentActivity?.userRecord?.record.latestResponse != null;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
setCompletionRecord();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant MultipleChoiceActivity oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.currentActivity?.event.eventId !=
|
||||
widget.currentActivity?.event.eventId) {
|
||||
setCompletionRecord();
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the completion record for the multiple choice activity.
|
||||
/// If the user record is null, it creates a new record model with the question
|
||||
/// from the current activity and sets the selected choice index to null.
|
||||
/// Otherwise, it sets the current model to the user record's record and
|
||||
/// determines the selected choice index.
|
||||
void setCompletionRecord() {
|
||||
if (widget.currentActivity?.userRecord?.record == null) {
|
||||
widget.controller.setCurrentModel(
|
||||
PracticeActivityRecordModel(
|
||||
question:
|
||||
widget.currentActivity?.practiceActivity.multipleChoice!.question,
|
||||
),
|
||||
);
|
||||
selectedChoiceIndex = null;
|
||||
} else {
|
||||
widget.controller
|
||||
.setCurrentModel(widget.currentActivity!.userRecord!.record);
|
||||
selectedChoiceIndex = widget
|
||||
.currentActivity?.practiceActivity.multipleChoice!
|
||||
.choiceIndex(currentRecordModel!.latestResponse!.text!);
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void updateChoice(int index) {
|
||||
currentRecordModel?.addResponse(
|
||||
text: widget.controller.currentActivity!.practiceActivity.multipleChoice!
|
||||
.choices[index],
|
||||
score: widget.controller.currentActivity!.practiceActivity.multipleChoice!
|
||||
.isCorrect(index)
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
setState(() => selectedChoiceIndex = index);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final PracticeActivityModel practiceActivity =
|
||||
practiceEvent.practiceActivity;
|
||||
final PracticeActivityModel? practiceActivity =
|
||||
widget.currentActivity?.practiceActivity;
|
||||
|
||||
if (practiceActivity == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
|
|
@ -50,17 +112,14 @@ class MultipleChoiceActivity extends StatelessWidget {
|
|||
.mapIndexed(
|
||||
(index, value) => Choice(
|
||||
text: value,
|
||||
color: (selectedChoiceIndex == index ||
|
||||
practiceActivity.multipleChoice!
|
||||
.isCorrect(index)) &&
|
||||
submitted
|
||||
color: selectedChoiceIndex == index
|
||||
? practiceActivity.multipleChoice!.choiceColor(index)
|
||||
: null,
|
||||
isGold: practiceActivity.multipleChoice!.isCorrect(index),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
isActive: isActive,
|
||||
isActive: !isSubmitted,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:fluffychat/pangea/enum/message_mode_enum.dart';
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/practice_activity_event.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_record_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/bot_style.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/message_toolbar.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/widgets/practice_activity/practice_activity_content.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
/// The wrapper for practice activity content.
|
||||
/// Handles the activities assosiated with a message,
|
||||
/// their navigation, and the management of completion records
|
||||
class PracticeActivityCard extends StatefulWidget {
|
||||
final PangeaMessageEvent pangeaMessageEvent;
|
||||
final MessageToolbarState controller;
|
||||
|
||||
const PracticeActivityCard({
|
||||
super.key,
|
||||
required this.pangeaMessageEvent,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -27,69 +27,129 @@ class PracticeActivityCard extends StatefulWidget {
|
|||
}
|
||||
|
||||
class MessagePracticeActivityCardState extends State<PracticeActivityCard> {
|
||||
PracticeActivityEvent? practiceEvent;
|
||||
PracticeActivityEvent? currentActivity;
|
||||
PracticeActivityRecordModel? currentRecordModel;
|
||||
bool sending = false;
|
||||
|
||||
List<PracticeActivityEvent> get practiceActivities =>
|
||||
widget.pangeaMessageEvent.practiceActivities;
|
||||
|
||||
int get practiceEventIndex => practiceActivities.indexWhere(
|
||||
(activity) => activity.event.eventId == currentActivity?.event.eventId,
|
||||
);
|
||||
|
||||
bool get isPrevEnabled =>
|
||||
practiceEventIndex > 0 &&
|
||||
practiceActivities.length > (practiceEventIndex - 1);
|
||||
|
||||
bool get isNextEnabled =>
|
||||
practiceEventIndex >= 0 &&
|
||||
practiceEventIndex < practiceActivities.length - 1;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loadInitialData();
|
||||
setCurrentActivity();
|
||||
}
|
||||
|
||||
String? get langCode {
|
||||
final String? langCode = MatrixState.pangeaController.languageController
|
||||
.activeL2Model()
|
||||
?.langCode;
|
||||
|
||||
if (langCode == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(L10n.of(context)!.noLanguagesSet)),
|
||||
);
|
||||
debugger(when: kDebugMode);
|
||||
return null;
|
||||
}
|
||||
return langCode;
|
||||
}
|
||||
|
||||
void loadInitialData() {
|
||||
if (langCode == null) return;
|
||||
updatePracticeActivity();
|
||||
if (practiceEvent == null) {
|
||||
debugger(when: kDebugMode);
|
||||
}
|
||||
}
|
||||
|
||||
void updatePracticeActivity() {
|
||||
if (langCode == null) return;
|
||||
final List<PracticeActivityEvent> activities =
|
||||
widget.pangeaMessageEvent.practiceActivities(langCode!);
|
||||
if (activities.isEmpty) return;
|
||||
/// Initalizes the current activity.
|
||||
/// If the current activity hasn't been set yet, show the first
|
||||
/// uncompleted activity if there is one.
|
||||
/// If not, show the first activity
|
||||
void setCurrentActivity() {
|
||||
if (practiceActivities.isEmpty) return;
|
||||
final List<PracticeActivityEvent> incompleteActivities =
|
||||
activities.where((element) => !element.isComplete).toList();
|
||||
debugPrint("total events: ${activities.length}");
|
||||
debugPrint("incomplete practice events: ${incompleteActivities.length}");
|
||||
|
||||
// TODO update to show next activity
|
||||
practiceEvent = activities.first;
|
||||
// // if an incomplete activity is found, show that
|
||||
// if (incompleteActivities.isNotEmpty) {
|
||||
// practiceEvent = incompleteActivities.first;
|
||||
// }
|
||||
// // if no incomplete activity is found, show the last activity
|
||||
// else if (activities.isNotEmpty) {
|
||||
// practiceEvent = activities.last;
|
||||
// }
|
||||
practiceActivities.where((element) => !element.isComplete).toList();
|
||||
currentActivity ??= incompleteActivities.isNotEmpty
|
||||
? incompleteActivities.first
|
||||
: practiceActivities.first;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void showNextActivity() {
|
||||
if (langCode == null) return;
|
||||
updatePracticeActivity();
|
||||
widget.controller.updateMode(MessageMode.practiceActivity);
|
||||
void setCurrentModel(PracticeActivityRecordModel? recordModel) {
|
||||
currentRecordModel = recordModel;
|
||||
}
|
||||
|
||||
/// Sets the current acitivity based on the given [direction].
|
||||
void navigateActivities(Direction direction) {
|
||||
final bool enableNavigation = (direction == Direction.f && isNextEnabled) ||
|
||||
(direction == Direction.b && isPrevEnabled);
|
||||
if (enableNavigation) {
|
||||
currentActivity = practiceActivities[direction == Direction.f
|
||||
? practiceEventIndex + 1
|
||||
: practiceEventIndex - 1];
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends the current record model and activity to the server.
|
||||
/// If either the currentRecordModel or currentActivity is null, the method returns early.
|
||||
/// Sets the [sending] flag to true before sending the record and activity.
|
||||
/// Logs any errors that occur during the send operation.
|
||||
/// Sets the [sending] flag to false when the send operation is complete.
|
||||
void sendRecord() {
|
||||
if (currentRecordModel == null || currentActivity == null) return;
|
||||
setState(() => sending = true);
|
||||
MatrixState.pangeaController.activityRecordController
|
||||
.send(currentRecordModel!, currentActivity!)
|
||||
.catchError((error) {
|
||||
ErrorHandler.logError(
|
||||
e: error,
|
||||
s: StackTrace.current,
|
||||
data: {
|
||||
'recordModel': currentRecordModel?.toJson(),
|
||||
'practiceEvent': currentActivity?.event.toJson(),
|
||||
},
|
||||
);
|
||||
return null;
|
||||
}).whenComplete(() => setState(() => sending = false));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (practiceEvent == null) {
|
||||
final Widget navigationButtons = Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Opacity(
|
||||
opacity: isPrevEnabled ? 1.0 : 0,
|
||||
child: IconButton(
|
||||
onPressed:
|
||||
isPrevEnabled ? () => navigateActivities(Direction.b) : null,
|
||||
icon: const Icon(Icons.keyboard_arrow_left_outlined),
|
||||
tooltip: L10n.of(context)!.previous,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Opacity(
|
||||
opacity: currentActivity?.userRecord == null ? 1.0 : 0.5,
|
||||
child: sending
|
||||
? const CircularProgressIndicator.adaptive()
|
||||
: TextButton(
|
||||
onPressed:
|
||||
currentActivity?.userRecord == null ? sendRecord : null,
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
AppConfig.primaryColor,
|
||||
),
|
||||
),
|
||||
child: Text(L10n.of(context)!.submit),
|
||||
),
|
||||
),
|
||||
),
|
||||
Opacity(
|
||||
opacity: isNextEnabled ? 1.0 : 0,
|
||||
child: IconButton(
|
||||
onPressed:
|
||||
isNextEnabled ? () => navigateActivities(Direction.f) : null,
|
||||
icon: const Icon(Icons.keyboard_arrow_right_outlined),
|
||||
tooltip: L10n.of(context)!.next,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
if (currentActivity == null || practiceActivities.isEmpty) {
|
||||
return Text(
|
||||
L10n.of(context)!.noActivitiesFound,
|
||||
style: BotStyle.text(context),
|
||||
|
|
@ -99,10 +159,14 @@ class MessagePracticeActivityCardState extends State<PracticeActivityCard> {
|
|||
// onActivityGenerated: updatePracticeActivity,
|
||||
// );
|
||||
}
|
||||
return PracticeActivityContent(
|
||||
practiceEvent: practiceEvent!,
|
||||
pangeaMessageEvent: widget.pangeaMessageEvent,
|
||||
controller: this,
|
||||
return Column(
|
||||
children: [
|
||||
PracticeActivity(
|
||||
practiceEvent: currentActivity!,
|
||||
controller: this,
|
||||
),
|
||||
navigationButtons,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,19 @@
|
|||
import 'package:collection/collection.dart';
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/enum/activity_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/practice_activity_record_event.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/practice_activity_event.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/practice_activity_record_event.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_record_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/widgets/practice_activity/multiple_choice_activity.dart';
|
||||
import 'package:fluffychat/pangea/widgets/practice_activity/practice_activity_card.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
class PracticeActivityContent extends StatefulWidget {
|
||||
/// Practice activity content
|
||||
class PracticeActivity extends StatefulWidget {
|
||||
final PracticeActivityEvent practiceEvent;
|
||||
final PangeaMessageEvent pangeaMessageEvent;
|
||||
final MessagePracticeActivityCardState controller;
|
||||
|
||||
const PracticeActivityContent({
|
||||
const PracticeActivity({
|
||||
super.key,
|
||||
required this.practiceEvent,
|
||||
required this.pangeaMessageEvent,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
|
|
@ -30,8 +22,7 @@ class PracticeActivityContent extends StatefulWidget {
|
|||
MessagePracticeActivityContentState();
|
||||
}
|
||||
|
||||
class MessagePracticeActivityContentState
|
||||
extends State<PracticeActivityContent> {
|
||||
class MessagePracticeActivityContentState extends State<PracticeActivity> {
|
||||
int? selectedChoiceIndex;
|
||||
PracticeActivityRecordModel? recordModel;
|
||||
bool recordSubmittedThisSession = false;
|
||||
|
|
@ -46,7 +37,7 @@ class MessagePracticeActivityContentState
|
|||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant PracticeActivityContent oldWidget) {
|
||||
void didUpdateWidget(covariant PracticeActivity oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.practiceEvent.event.eventId !=
|
||||
widget.practiceEvent.event.eventId) {
|
||||
|
|
@ -56,7 +47,7 @@ class MessagePracticeActivityContentState
|
|||
|
||||
void initalizeActivity() {
|
||||
final PracticeActivityRecordEvent? recordEvent =
|
||||
widget.practiceEvent.userRecords.firstOrNull;
|
||||
widget.practiceEvent.userRecord;
|
||||
if (recordEvent?.record == null) {
|
||||
recordModel = PracticeActivityRecordModel(
|
||||
question:
|
||||
|
|
@ -95,75 +86,20 @@ class MessagePracticeActivityContentState
|
|||
switch (widget.practiceEvent.practiceActivity.activityType) {
|
||||
case ActivityTypeEnum.multipleChoice:
|
||||
return MultipleChoiceActivity(
|
||||
card: this,
|
||||
updateChoice: updateChoice,
|
||||
isActive:
|
||||
!recordSubmittedPreviousSession && !recordSubmittedThisSession,
|
||||
controller: widget.controller,
|
||||
currentActivity: widget.practiceEvent,
|
||||
);
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
|
||||
void sendRecord() {
|
||||
MatrixState.pangeaController.activityRecordController
|
||||
.send(
|
||||
recordModel!,
|
||||
widget.practiceEvent,
|
||||
)
|
||||
.catchError((error) {
|
||||
ErrorHandler.logError(
|
||||
e: error,
|
||||
s: StackTrace.current,
|
||||
data: {
|
||||
'recordModel': recordModel?.toJson(),
|
||||
'practiceEvent': widget.practiceEvent.event.toJson(),
|
||||
},
|
||||
);
|
||||
return null;
|
||||
}).then((_) => widget.controller.showNextActivity());
|
||||
|
||||
setState(() {
|
||||
recordSubmittedThisSession = true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint(
|
||||
"MessagePracticeActivityContentState.build with selectedChoiceIndex: $selectedChoiceIndex",
|
||||
);
|
||||
return Column(
|
||||
children: [
|
||||
activityWidget,
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Opacity(
|
||||
opacity: selectedChoiceIndex != null &&
|
||||
!recordSubmittedThisSession &&
|
||||
!recordSubmittedPreviousSession
|
||||
? 1.0
|
||||
: 0.5,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
if (recordSubmittedThisSession ||
|
||||
recordSubmittedPreviousSession) {
|
||||
return;
|
||||
}
|
||||
selectedChoiceIndex != null ? sendRecord() : null;
|
||||
},
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
AppConfig.primaryColor,
|
||||
),
|
||||
),
|
||||
child: Text(L10n.of(context)!.submit),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import pasteboard
|
|||
import path_provider_foundation
|
||||
import purchases_flutter
|
||||
import record_darwin
|
||||
import rive_common
|
||||
import sentry_flutter
|
||||
import share_plus
|
||||
import shared_preferences_foundation
|
||||
|
|
@ -65,6 +66,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
PurchasesFlutterPlugin.register(with: registry.registrar(forPlugin: "PurchasesFlutterPlugin"))
|
||||
RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin"))
|
||||
RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin"))
|
||||
SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin"))
|
||||
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
|
|
|
|||
54496
needed-translations.txt
54496
needed-translations.txt
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
24
pubspec.lock
24
pubspec.lock
|
|
@ -999,6 +999,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
graphs:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: graphs
|
||||
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
highlighter:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1925,6 +1933,22 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
rive:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: rive
|
||||
sha256: "166019487e8bfa6525d4537bfd494deb4f306e32f97a7f50ff452b44ab6b72ea"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.11.11"
|
||||
rive_common:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rive_common
|
||||
sha256: "83af8b500ad4d23930397229c7ed520e266eb851690a8621afa6cbd782aeac87"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.3"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ dependencies:
|
|||
sentry_flutter: ^8.2.0
|
||||
shimmer: ^3.0.0
|
||||
syncfusion_flutter_xlsio: ^25.1.40
|
||||
rive: 0.11.11
|
||||
# Pangea#
|
||||
|
||||
dev_dependencies:
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <pasteboard/pasteboard_plugin.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <record_windows/record_windows_plugin_c_api.h>
|
||||
#include <rive_common/rive_plugin.h>
|
||||
#include <sentry_flutter/sentry_flutter_plugin.h>
|
||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||
#include <sqlcipher_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
|
|
@ -40,6 +41,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
|||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
RecordWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("RecordWindowsPluginCApi"));
|
||||
RivePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("RivePlugin"));
|
||||
SentryFlutterPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SentryFlutterPlugin"));
|
||||
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||
pasteboard
|
||||
permission_handler_windows
|
||||
record_windows
|
||||
rive_common
|
||||
sentry_flutter
|
||||
share_plus
|
||||
sqlcipher_flutter_libs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue