reorganize files
This commit is contained in:
parent
26317c6f8a
commit
513184e1e1
87 changed files with 572 additions and 613 deletions
|
|
@ -2,23 +2,9 @@ import 'dart:async';
|
|||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
|
|
@ -35,21 +21,18 @@ import 'package:fluffychat/pangea/analytics_misc/construct_type_enum.dart';
|
|||
import 'package:fluffychat/pangea/analytics_misc/constructs_model.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/gain_points_animation.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/level_up/level_up_banner.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/message_analytics_feedback.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/put_analytics_controller.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/chat/utils/unlocked_morphs_snackbar.dart';
|
||||
import 'package:fluffychat/pangea/chat/widgets/event_too_large_dialog.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choregrapher_user_settings_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/pangea_text_controller.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/edit_type.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_record.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_state.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/language_mismatch_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/language_mismatch_popup.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/message_analytics_feedback.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/paywall_card.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choregrapher_user_settings_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_record_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_state_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/text_editing/edit_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/text_editing/pangea_text_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/common/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
|
|
@ -63,9 +46,12 @@ import 'package:fluffychat/pangea/events/models/tokens_event_content_model.dart'
|
|||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/instructions/instructions_enum.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/repo/language_mismatch_repo.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/widgets/language_mismatch_popup.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/widgets/p_language_dialog.dart';
|
||||
import 'package:fluffychat/pangea/message_token_text/tokens_util.dart';
|
||||
import 'package:fluffychat/pangea/spaces/utils/load_participants_util.dart';
|
||||
import 'package:fluffychat/pangea/subscription/widgets/paywall_card.dart';
|
||||
import 'package:fluffychat/pangea/token_info_feedback/token_info_feedback_dialog.dart';
|
||||
import 'package:fluffychat/pangea/token_info_feedback/token_info_feedback_notification.dart';
|
||||
import 'package:fluffychat/pangea/token_info_feedback/token_info_feedback_request.dart';
|
||||
|
|
@ -85,6 +71,19 @@ import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart'
|
|||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/widgets/share_scaffold_dialog.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
import '../../utils/account_bundles.dart';
|
||||
import '../../utils/localized_exception_extension.dart';
|
||||
import 'send_file_dialog.dart';
|
||||
|
|
@ -325,7 +324,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
if (draft != null && draft.isNotEmpty) {
|
||||
// #Pangea
|
||||
// sendController.text = draft;
|
||||
sendController.setSystemText(draft, EditType.other);
|
||||
sendController.setSystemText(draft, EditTypeEnum.other);
|
||||
// Pangea#
|
||||
}
|
||||
}
|
||||
|
|
@ -876,7 +875,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
editEventId: editEvent?.eventId,
|
||||
);
|
||||
inputFocus.unfocus();
|
||||
sendController.setSystemText("", EditType.other);
|
||||
sendController.setSystemText("", EditTypeEnum.other);
|
||||
setState(() => _fakeEventIDs.add(eventID));
|
||||
|
||||
// wait for the next event to come through before clearing any fake event,
|
||||
|
|
@ -916,7 +915,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
PangeaRepresentation? originalWritten,
|
||||
PangeaMessageTokens? tokensSent,
|
||||
PangeaMessageTokens? tokensWritten,
|
||||
ChoreoRecord? choreo,
|
||||
ChoreoRecordModel? choreo,
|
||||
String? tempEventId,
|
||||
}) async {
|
||||
if (message.trim().isEmpty) return;
|
||||
|
|
@ -960,7 +959,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
// typing a new message. We don't want to erase that, so only reset the input
|
||||
// bar text if the message is the same as the sendController text.
|
||||
if (message == sendController.text) {
|
||||
sendController.setSystemText("", EditType.other);
|
||||
sendController.setSystemText("", EditTypeEnum.other);
|
||||
}
|
||||
|
||||
final previousEdit = editEvent;
|
||||
|
|
@ -1964,7 +1963,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
if (editEvent != null) {
|
||||
// #Pangea
|
||||
// sendController.text = pendingText;
|
||||
sendController.setSystemText(pendingText, EditType.other);
|
||||
sendController.setSystemText(pendingText, EditTypeEnum.other);
|
||||
// Pangea#
|
||||
pendingText = '';
|
||||
}
|
||||
|
|
@ -2084,7 +2083,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
String? eventId, {
|
||||
PangeaRepresentation? originalSent,
|
||||
PangeaMessageTokens? tokensSent,
|
||||
ChoreoRecord? choreo,
|
||||
ChoreoRecordModel? choreo,
|
||||
}) {
|
||||
// There's a listen in my_analytics_controller that decides when to auto-update
|
||||
// analytics based on when / how many messages the logged in user send. This
|
||||
|
|
|
|||
|
|
@ -1,21 +1,20 @@
|
|||
import 'package:emojis/emoji.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_state_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/text_editing/pangea_text_controller.dart';
|
||||
import 'package:fluffychat/pangea/subscription/controllers/subscription_controller.dart';
|
||||
import 'package:fluffychat/pangea/subscription/widgets/paywall_card.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/utils/shrinkable_text.dart';
|
||||
import 'package:fluffychat/utils/markdown_context_builder.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:emojis/emoji.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:slugify/slugify.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_state_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/pangea_text_controller.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/paywall_card.dart';
|
||||
import 'package:fluffychat/pangea/subscription/controllers/subscription_controller.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/utils/shrinkable_text.dart';
|
||||
import 'package:fluffychat/utils/markdown_context_builder.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
import '../../widgets/avatar.dart';
|
||||
import '../../widgets/matrix.dart';
|
||||
import 'command_hints.dart';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/has_error_button.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_has_error_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatFloatingActionButton extends StatelessWidget {
|
||||
final ChatController controller;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pages/chat/chat_emoji_picker.dart';
|
||||
import 'package:fluffychat/pages/chat/reply_display.dart';
|
||||
import 'package:fluffychat/pangea/activity_sessions/activity_session_chat/activity_role_tooltip.dart';
|
||||
import 'package:fluffychat/pangea/chat/widgets/pangea_chat_input_row.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/it_bar.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/it_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatInputBar extends StatelessWidget {
|
||||
final ChatController controller;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:animations/animations.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pages/chat/input_bar.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/send_button.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/start_igc_button.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_send_button.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/start_igc_button.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PangeaChatInputRow extends StatelessWidget {
|
||||
final ChatController controller;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@
|
|||
// IGC is running, IGC has run and there are remaining steps (either IT or IGC), or all steps are done
|
||||
// Or user does not have a subscription
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
|
||||
enum AssistanceState {
|
||||
enum AssistanceStateEnum {
|
||||
noSub,
|
||||
noMessage,
|
||||
notFetched,
|
||||
|
|
@ -16,33 +15,33 @@ enum AssistanceState {
|
|||
error,
|
||||
}
|
||||
|
||||
extension AssistanceStateExtension on AssistanceState {
|
||||
extension AssistanceStateExtension on AssistanceStateEnum {
|
||||
Color stateColor(context) {
|
||||
switch (this) {
|
||||
case AssistanceState.noSub:
|
||||
case AssistanceState.noMessage:
|
||||
case AssistanceState.fetched:
|
||||
case AssistanceState.error:
|
||||
case AssistanceStateEnum.noSub:
|
||||
case AssistanceStateEnum.noMessage:
|
||||
case AssistanceStateEnum.fetched:
|
||||
case AssistanceStateEnum.error:
|
||||
return Theme.of(context).disabledColor;
|
||||
case AssistanceState.notFetched:
|
||||
case AssistanceState.fetching:
|
||||
case AssistanceStateEnum.notFetched:
|
||||
case AssistanceStateEnum.fetching:
|
||||
return Theme.of(context).colorScheme.primary;
|
||||
case AssistanceState.complete:
|
||||
case AssistanceStateEnum.complete:
|
||||
return AppConfig.success;
|
||||
}
|
||||
}
|
||||
|
||||
Color sendButtonColor(context) {
|
||||
switch (this) {
|
||||
case AssistanceState.noMessage:
|
||||
case AssistanceState.fetched:
|
||||
case AssistanceStateEnum.noMessage:
|
||||
case AssistanceStateEnum.fetched:
|
||||
return Theme.of(context).disabledColor;
|
||||
case AssistanceState.noSub:
|
||||
case AssistanceState.error:
|
||||
case AssistanceState.notFetched:
|
||||
case AssistanceState.fetching:
|
||||
case AssistanceStateEnum.noSub:
|
||||
case AssistanceStateEnum.error:
|
||||
case AssistanceStateEnum.notFetched:
|
||||
case AssistanceStateEnum.fetching:
|
||||
return Theme.of(context).colorScheme.primary;
|
||||
case AssistanceState.complete:
|
||||
case AssistanceStateEnum.complete:
|
||||
return AppConfig.success;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import 'package:fluffychat/pangea/spaces/models/space_model.dart';
|
||||
|
||||
|
|
@ -3,13 +3,13 @@ import 'dart:math';
|
|||
/// Changes made to previous choreo step's text
|
||||
/// Remove substring of length 'length', starting at position 'offset'
|
||||
/// Then add String 'insert' at that position
|
||||
class ChoreoEdit {
|
||||
class ChoreoEditModel {
|
||||
final int offset;
|
||||
final int length;
|
||||
final String insert;
|
||||
|
||||
/// Normal constructor created from preexisting ChoreoEdit values
|
||||
const ChoreoEdit({
|
||||
const ChoreoEditModel({
|
||||
this.offset = 0,
|
||||
this.length = 0,
|
||||
this.insert = "",
|
||||
|
|
@ -17,28 +17,28 @@ class ChoreoEdit {
|
|||
|
||||
/// Constructor that determines and saves
|
||||
/// edits differentiating originalText and editedText
|
||||
factory ChoreoEdit.fromText({
|
||||
factory ChoreoEditModel.fromText({
|
||||
required String originalText,
|
||||
required String editedText,
|
||||
}) {
|
||||
if (originalText == editedText) {
|
||||
// No changes, return empty edit
|
||||
return const ChoreoEdit();
|
||||
return const ChoreoEditModel();
|
||||
}
|
||||
|
||||
final offset = _firstDifference(originalText, editedText);
|
||||
final length =
|
||||
_lastDifference(originalText, editedText, offset) + 1 - offset;
|
||||
final insert = _insertion(originalText, editedText, offset, length);
|
||||
return ChoreoEdit(
|
||||
return ChoreoEditModel(
|
||||
offset: offset,
|
||||
length: length,
|
||||
insert: insert,
|
||||
);
|
||||
}
|
||||
|
||||
factory ChoreoEdit.fromJson(Map<String, dynamic> json) {
|
||||
return ChoreoEdit(
|
||||
factory ChoreoEditModel.fromJson(Map<String, dynamic> json) {
|
||||
return ChoreoEditModel(
|
||||
offset: json[_offsetKey],
|
||||
length: json[_lengthKey],
|
||||
insert: json[_insertKey],
|
||||
1
lib/pangea/choreographer/choreo_mode_enum.dart
Normal file
1
lib/pangea/choreographer/choreo_mode_enum.dart
Normal file
|
|
@ -0,0 +1 @@
|
|||
enum ChoreoModeEnum { igc, it }
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/enums/pangea_match_status.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_edit.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/span_data.dart';
|
||||
import 'completed_it_step.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_edit_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_status_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_model.dart';
|
||||
|
||||
import 'it/completed_it_step_model.dart';
|
||||
|
||||
/// this class lives within a [PangeaIGCEvent]
|
||||
/// it always has a [RepresentationEvent] parent
|
||||
|
|
@ -13,30 +14,30 @@ import 'completed_it_step.dart';
|
|||
/// It represents the real-time changes to a text
|
||||
/// TODO - start saving senderL2Code in choreoRecord to be able better decide the useType
|
||||
|
||||
class ChoreoRecord {
|
||||
class ChoreoRecordModel {
|
||||
/// ordered versions of the representation, with first being original and last
|
||||
/// being the final sent text
|
||||
/// there is not a 1-to-1 map from steps to matches
|
||||
final List<ChoreoRecordStep> choreoSteps;
|
||||
final List<ChoreoRecordStepModel> choreoSteps;
|
||||
final List<PangeaMatch> openMatches;
|
||||
final String originalText;
|
||||
|
||||
final Set<String> pastedStrings = {};
|
||||
|
||||
ChoreoRecord({
|
||||
ChoreoRecordModel({
|
||||
required this.choreoSteps,
|
||||
required this.openMatches,
|
||||
required this.originalText,
|
||||
});
|
||||
|
||||
factory ChoreoRecord.fromJson(
|
||||
factory ChoreoRecordModel.fromJson(
|
||||
Map<String, dynamic> json, [
|
||||
String? defaultOriginalText,
|
||||
]) {
|
||||
final stepsRaw = json[_stepsKey];
|
||||
String? originalText = json[_originalTextKey];
|
||||
|
||||
List<ChoreoRecordStep> steps = [];
|
||||
List<ChoreoRecordStepModel> steps = [];
|
||||
final stepContent = (jsonDecode(stepsRaw ?? "[]") as Iterable);
|
||||
|
||||
if (stepContent.isNotEmpty &&
|
||||
|
|
@ -47,9 +48,9 @@ class ChoreoRecord {
|
|||
|
||||
if (stepContent.every((step) => step["txt"] is! String)) {
|
||||
steps = stepContent
|
||||
.map((e) => ChoreoRecordStep.fromJson(e))
|
||||
.map((e) => ChoreoRecordStepModel.fromJson(e))
|
||||
.toList()
|
||||
.cast<ChoreoRecordStep>();
|
||||
.cast<ChoreoRecordStepModel>();
|
||||
} else {
|
||||
String? currentEdit = originalText;
|
||||
for (final content in stepContent) {
|
||||
|
|
@ -62,12 +63,12 @@ class ChoreoRecord {
|
|||
// will yield a correct result, but it's possible the user manually changed the text
|
||||
// between steps, so we need handle that by adding an extra step
|
||||
if (textBefore != currentEdit) {
|
||||
final edits = ChoreoEdit.fromText(
|
||||
final edits = ChoreoEditModel.fromText(
|
||||
originalText: currentEdit,
|
||||
editedText: textBefore,
|
||||
);
|
||||
|
||||
steps.add(ChoreoRecordStep(edits: edits));
|
||||
steps.add(ChoreoRecordStepModel(edits: edits));
|
||||
currentEdit = textBefore;
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +76,7 @@ class ChoreoRecord {
|
|||
int length = 0;
|
||||
String insert = "";
|
||||
|
||||
ChoreoRecordStep step = ChoreoRecordStep.fromJson(content);
|
||||
ChoreoRecordStepModel step = ChoreoRecordStepModel.fromJson(content);
|
||||
if (step.acceptedOrIgnoredMatch != null) {
|
||||
final SpanData? match = step.acceptedOrIgnoredMatch?.match;
|
||||
final correction = match?.bestChoice;
|
||||
|
|
@ -102,13 +103,13 @@ class ChoreoRecord {
|
|||
insert,
|
||||
);
|
||||
|
||||
final edits = ChoreoEdit.fromText(
|
||||
final edits = ChoreoEditModel.fromText(
|
||||
originalText: currentEdit,
|
||||
editedText: textAfter,
|
||||
);
|
||||
|
||||
currentEdit = textAfter;
|
||||
step = ChoreoRecordStep(
|
||||
step = ChoreoRecordStepModel(
|
||||
edits: edits,
|
||||
acceptedOrIgnoredMatch: step.acceptedOrIgnoredMatch,
|
||||
itStep: step.itStep,
|
||||
|
|
@ -124,7 +125,7 @@ class ChoreoRecord {
|
|||
);
|
||||
}
|
||||
|
||||
return ChoreoRecord(
|
||||
return ChoreoRecordModel(
|
||||
choreoSteps: steps,
|
||||
originalText: originalText ?? defaultOriginalText!,
|
||||
openMatches: (jsonDecode(json[_openMatchesKey] ?? "[]") as Iterable)
|
||||
|
|
@ -151,13 +152,13 @@ class ChoreoRecord {
|
|||
|
||||
bool get includedIT => choreoSteps.any((step) {
|
||||
return step.acceptedOrIgnoredMatch?.status ==
|
||||
PangeaMatchStatus.accepted &&
|
||||
PangeaMatchStatusEnum.accepted &&
|
||||
(step.acceptedOrIgnoredMatch?.isOutOfTargetMatch ?? false);
|
||||
});
|
||||
|
||||
bool get includedIGC => choreoSteps.any((step) {
|
||||
return step.acceptedOrIgnoredMatch?.status ==
|
||||
PangeaMatchStatus.accepted &&
|
||||
PangeaMatchStatusEnum.accepted &&
|
||||
(step.acceptedOrIgnoredMatch?.isGrammarMatch ?? false);
|
||||
});
|
||||
|
||||
|
|
@ -190,18 +191,22 @@ class ChoreoRecord {
|
|||
return text;
|
||||
}
|
||||
|
||||
void addRecord(String text, {PangeaMatch? match, CompletedITStep? step}) {
|
||||
void addRecord(
|
||||
String text, {
|
||||
PangeaMatch? match,
|
||||
CompletedITStepModel? step,
|
||||
}) {
|
||||
if (match != null && step != null) {
|
||||
throw Exception("match and step should not both be defined");
|
||||
}
|
||||
|
||||
final edit = ChoreoEdit.fromText(
|
||||
final edit = ChoreoEditModel.fromText(
|
||||
originalText: stepText(),
|
||||
editedText: text,
|
||||
);
|
||||
|
||||
choreoSteps.add(
|
||||
ChoreoRecordStep(
|
||||
ChoreoRecordStepModel(
|
||||
edits: edit,
|
||||
acceptedOrIgnoredMatch: match,
|
||||
itStep: step,
|
||||
|
|
@ -231,21 +236,21 @@ class ChoreoRecord {
|
|||
/// the user selects IT and a step is made
|
||||
/// the user chooses "hola" and a step is saved
|
||||
/// adds "amigo" and a step saved
|
||||
class ChoreoRecordStep {
|
||||
class ChoreoRecordStepModel {
|
||||
/// Edits that, when applied to the previous step's text,
|
||||
/// will provide the current step's text
|
||||
/// Should always exist, except when using fromJSON
|
||||
/// on old version of ChoreoRecordStep
|
||||
final ChoreoEdit? edits;
|
||||
final ChoreoEditModel? edits;
|
||||
|
||||
/// all matches throughout edit process,
|
||||
/// including those open, accepted and ignored
|
||||
/// last step in list may contain open
|
||||
final PangeaMatch? acceptedOrIgnoredMatch;
|
||||
|
||||
final CompletedITStep? itStep;
|
||||
final CompletedITStepModel? itStep;
|
||||
|
||||
ChoreoRecordStep({
|
||||
ChoreoRecordStepModel({
|
||||
this.edits,
|
||||
this.acceptedOrIgnoredMatch,
|
||||
this.itStep,
|
||||
|
|
@ -257,15 +262,16 @@ class ChoreoRecordStep {
|
|||
}
|
||||
}
|
||||
|
||||
factory ChoreoRecordStep.fromJson(Map<String, dynamic> json) {
|
||||
return ChoreoRecordStep(
|
||||
edits:
|
||||
json[_editKey] != null ? ChoreoEdit.fromJson(json[_editKey]) : null,
|
||||
factory ChoreoRecordStepModel.fromJson(Map<String, dynamic> json) {
|
||||
return ChoreoRecordStepModel(
|
||||
edits: json[_editKey] != null
|
||||
? ChoreoEditModel.fromJson(json[_editKey])
|
||||
: null,
|
||||
acceptedOrIgnoredMatch: json[_acceptedOrIgnoredMatchKey] != null
|
||||
? PangeaMatch.fromJson(json[_acceptedOrIgnoredMatchKey])
|
||||
: null,
|
||||
itStep: json[_stepKey] != null
|
||||
? CompletedITStep.fromJson(json[_stepKey])
|
||||
? CompletedITStepModel.fromJson(json[_stepKey])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
|
@ -1,21 +1,17 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/constants/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choregrapher_user_settings_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_state_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/igc_controller.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/pangea_text_controller.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/choreo_mode.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/edit_type.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/pangea_match_status.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_record.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_state.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choregrapher_user_settings_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_mode_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_record_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_state_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/igc_controller.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_state_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_status_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/text_editing/edit_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/text_editing/pangea_text_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/models/representation_content_model.dart';
|
||||
|
|
@ -26,9 +22,12 @@ import 'package:fluffychat/pangea/learning_settings/constants/language_constants
|
|||
import 'package:fluffychat/pangea/subscription/controllers/subscription_controller.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/controllers/tts_controller.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import '../../../widgets/matrix.dart';
|
||||
import 'error_service.dart';
|
||||
import 'it_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../../widgets/matrix.dart';
|
||||
import 'choreographer_error_controller.dart';
|
||||
import 'it/it_controller.dart';
|
||||
|
||||
class OpenMatchesException implements Exception {}
|
||||
|
||||
|
|
@ -41,16 +40,16 @@ class Choreographer extends ChangeNotifier {
|
|||
late PangeaTextController textController;
|
||||
late ITController itController;
|
||||
late IgcController igcController;
|
||||
late ErrorService errorService;
|
||||
late ChoreographerErrorController errorService;
|
||||
|
||||
ChoreoRecord? _choreoRecord;
|
||||
ChoreoRecordModel? _choreoRecord;
|
||||
|
||||
final ValueNotifier<bool> _isFetching = ValueNotifier(false);
|
||||
|
||||
int _timesClicked = 0;
|
||||
Timer? _debounceTimer;
|
||||
String? _lastChecked;
|
||||
ChoreoMode _choreoMode = ChoreoMode.igc;
|
||||
ChoreoModeEnum _choreoMode = ChoreoModeEnum.igc;
|
||||
|
||||
StreamSubscription? _languageStream;
|
||||
StreamSubscription? _settingsUpdateStream;
|
||||
|
|
@ -61,14 +60,14 @@ class Choreographer extends ChangeNotifier {
|
|||
|
||||
int get timesClicked => _timesClicked;
|
||||
ValueNotifier<bool> get isFetching => _isFetching;
|
||||
ChoreoMode get choreoMode => _choreoMode;
|
||||
ChoreoModeEnum get choreoMode => _choreoMode;
|
||||
String get currentText => textController.text;
|
||||
|
||||
void _initialize() {
|
||||
textController = PangeaTextController(choreographer: this);
|
||||
textController.addListener(_onChange);
|
||||
|
||||
errorService = ErrorService();
|
||||
errorService = ChoreographerErrorController();
|
||||
errorService.addListener(notifyListeners);
|
||||
|
||||
itController = ITController(
|
||||
|
|
@ -94,7 +93,7 @@ class Choreographer extends ChangeNotifier {
|
|||
}
|
||||
|
||||
void clear() {
|
||||
setChoreoMode(ChoreoMode.igc);
|
||||
setChoreoMode(ChoreoModeEnum.igc);
|
||||
_lastChecked = null;
|
||||
_timesClicked = 0;
|
||||
_isFetching.value = false;
|
||||
|
|
@ -124,7 +123,7 @@ class Choreographer extends ChangeNotifier {
|
|||
}
|
||||
|
||||
void onClickSend() {
|
||||
if (assistanceState == AssistanceState.fetched) {
|
||||
if (assistanceState == AssistanceStateEnum.fetched) {
|
||||
_timesClicked++;
|
||||
|
||||
// if user is doing IT, call closeIT here to
|
||||
|
|
@ -135,7 +134,7 @@ class Choreographer extends ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
void setChoreoMode(ChoreoMode mode) {
|
||||
void setChoreoMode(ChoreoModeEnum mode) {
|
||||
_choreoMode = mode;
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
@ -148,7 +147,7 @@ class Choreographer extends ChangeNotifier {
|
|||
}
|
||||
|
||||
void _initChoreoRecord() {
|
||||
_choreoRecord ??= ChoreoRecord(
|
||||
_choreoRecord ??= ChoreoRecordModel(
|
||||
originalText: textController.text,
|
||||
choreoSteps: [],
|
||||
openMatches: [],
|
||||
|
|
@ -176,13 +175,13 @@ class Choreographer extends ChangeNotifier {
|
|||
}
|
||||
|
||||
_lastChecked = textController.text;
|
||||
if (textController.editType == EditType.it) {
|
||||
if (textController.editType == EditTypeEnum.it) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (textController.editType == EditType.igc ||
|
||||
textController.editType == EditType.itDismissed) {
|
||||
textController.editType = EditType.keyboard;
|
||||
if (textController.editType == EditTypeEnum.igc ||
|
||||
textController.editType == EditTypeEnum.itDismissed) {
|
||||
textController.editType = EditTypeEnum.keyboard;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +190,7 @@ class Choreographer extends ChangeNotifier {
|
|||
if (errorService.isError) return;
|
||||
|
||||
igcController.clear();
|
||||
if (textController.editType == EditType.keyboard) {
|
||||
if (textController.editType == EditTypeEnum.keyboard) {
|
||||
itController.clearSourceText();
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +203,7 @@ class Choreographer extends ChangeNotifier {
|
|||
//Note: we don't set the keyboard type on each keyboard stroke so this is how we default to
|
||||
//a change being from the keyboard unless explicitly set to one of the other
|
||||
//types when that action happens (e.g. an it/igc choice is selected)
|
||||
textController.editType = EditType.keyboard;
|
||||
textController.editType = EditTypeEnum.keyboard;
|
||||
}
|
||||
|
||||
Future<void> _startWritingAssistance({
|
||||
|
|
@ -218,7 +217,7 @@ class Choreographer extends ChangeNotifier {
|
|||
l2Lang == null ||
|
||||
l1Lang == null ||
|
||||
(!igcEnabled && !itEnabled) ||
|
||||
(!isAutoIGCEnabled && !manual && _choreoMode != ChoreoMode.it)) {
|
||||
(!isAutoIGCEnabled && !manual && _choreoMode != ChoreoModeEnum.it)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -357,15 +356,15 @@ class Choreographer extends ChangeNotifier {
|
|||
}
|
||||
|
||||
chatController.inputFocus.unfocus();
|
||||
setChoreoMode(ChoreoMode.it);
|
||||
setChoreoMode(ChoreoModeEnum.it);
|
||||
|
||||
final sourceText = currentText;
|
||||
textController.setSystemText("", EditType.it);
|
||||
textController.setSystemText("", EditTypeEnum.it);
|
||||
itController.openIT(sourceText);
|
||||
igcController.clear();
|
||||
|
||||
_initChoreoRecord();
|
||||
itMatch.setStatus(PangeaMatchStatus.accepted);
|
||||
itMatch.setStatus(PangeaMatchStatusEnum.accepted);
|
||||
_choreoRecord!.addRecord(
|
||||
"",
|
||||
match: itMatch.updatedMatch,
|
||||
|
|
@ -378,17 +377,17 @@ class Choreographer extends ChangeNotifier {
|
|||
if (currentText.isEmpty && itController.sourceText.value != null) {
|
||||
textController.setSystemText(
|
||||
itController.sourceText.value!,
|
||||
EditType.itDismissed,
|
||||
EditTypeEnum.itDismissed,
|
||||
);
|
||||
}
|
||||
|
||||
setChoreoMode(ChoreoMode.igc);
|
||||
setChoreoMode(ChoreoModeEnum.igc);
|
||||
errorService.resetError();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void onSubmitEdits(String text) {
|
||||
textController.setSystemText("", EditType.it);
|
||||
textController.setSystemText("", EditTypeEnum.it);
|
||||
itController.onSubmitEdits(text);
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +395,7 @@ class Choreographer extends ChangeNotifier {
|
|||
final step = itController.onAcceptContinuance(index);
|
||||
textController.setSystemText(
|
||||
textController.text + step.continuances[step.chosen].text,
|
||||
EditType.it,
|
||||
EditTypeEnum.it,
|
||||
);
|
||||
|
||||
_initChoreoRecord();
|
||||
|
|
@ -416,12 +415,12 @@ class Choreographer extends ChangeNotifier {
|
|||
}) {
|
||||
final updatedMatch = igcController.acceptReplacement(
|
||||
match,
|
||||
PangeaMatchStatus.accepted,
|
||||
PangeaMatchStatusEnum.accepted,
|
||||
);
|
||||
|
||||
textController.setSystemText(
|
||||
igcController.currentText!,
|
||||
EditType.igc,
|
||||
EditTypeEnum.igc,
|
||||
);
|
||||
|
||||
if (!updatedMatch.match.isNormalizationError()) {
|
||||
|
|
@ -444,7 +443,7 @@ class Choreographer extends ChangeNotifier {
|
|||
|
||||
textController.setSystemText(
|
||||
igcController.currentText!,
|
||||
EditType.igc,
|
||||
EditTypeEnum.igc,
|
||||
);
|
||||
MatrixState.pAnyState.closeOverlay();
|
||||
chatController.inputFocus.requestFocus();
|
||||
|
|
@ -479,12 +478,12 @@ class Choreographer extends ChangeNotifier {
|
|||
);
|
||||
final updatedMatch = igcController.acceptReplacement(
|
||||
match,
|
||||
PangeaMatchStatus.automatic,
|
||||
PangeaMatchStatusEnum.automatic,
|
||||
);
|
||||
|
||||
textController.setSystemText(
|
||||
igcController.currentText!,
|
||||
EditType.igc,
|
||||
EditTypeEnum.igc,
|
||||
);
|
||||
_choreoRecord!.addRecord(
|
||||
currentText,
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../common/utils/error_handler.dart';
|
||||
import '../common/utils/error_handler.dart';
|
||||
|
||||
class ChoreoError {
|
||||
final Object? raw;
|
||||
|
|
@ -15,11 +15,11 @@ class ChoreoError {
|
|||
IconData get icon => Icons.error_outline;
|
||||
}
|
||||
|
||||
class ErrorService extends ChangeNotifier {
|
||||
class ChoreographerErrorController extends ChangeNotifier {
|
||||
ChoreoError? _error;
|
||||
int coolDownSeconds = 0;
|
||||
|
||||
ErrorService();
|
||||
ChoreographerErrorController();
|
||||
|
||||
bool get isError => _error != null;
|
||||
ChoreoError? get error => _error;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import '../controllers/error_service.dart';
|
||||
import 'choreographer_error_controller.dart';
|
||||
|
||||
class ChoreographerHasErrorButton extends StatelessWidget {
|
||||
final ChoreoError error;
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_state_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_state_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChoreographerSendButton extends StatelessWidget {
|
||||
final ChatController controller;
|
||||
30
lib/pangea/choreographer/choreographer_state_extension.dart
Normal file
30
lib/pangea/choreographer/choreographer_state_extension.dart
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import 'package:fluffychat/pangea/choreographer/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_mode_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||
|
||||
extension ChoregrapherUserSettingsExtension on Choreographer {
|
||||
bool get isRunningIT {
|
||||
return choreoMode == ChoreoModeEnum.it &&
|
||||
itController.currentITStep.value?.isFinal != true;
|
||||
}
|
||||
|
||||
AssistanceStateEnum get assistanceState {
|
||||
final isSubscribed = pangeaController.subscriptionController.isSubscribed;
|
||||
if (isSubscribed == false) return AssistanceStateEnum.noSub;
|
||||
if (currentText.isEmpty && itController.sourceText.value == null) {
|
||||
return AssistanceStateEnum.noMessage;
|
||||
}
|
||||
|
||||
if (errorService.isError) {
|
||||
return AssistanceStateEnum.error;
|
||||
}
|
||||
|
||||
if (igcController.hasOpenMatches || isRunningIT) {
|
||||
return AssistanceStateEnum.fetched;
|
||||
}
|
||||
|
||||
if (isFetching.value) return AssistanceStateEnum.fetching;
|
||||
if (!igcController.hasIGCTextData) return AssistanceStateEnum.notFetched;
|
||||
return AssistanceStateEnum.complete;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/any_state_holder.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/choreo_mode.dart';
|
||||
|
||||
extension ChoregrapherUserSettingsExtension on Choreographer {
|
||||
bool get isRunningIT {
|
||||
return choreoMode == ChoreoMode.it &&
|
||||
itController.currentITStep.value?.isFinal != true;
|
||||
}
|
||||
|
||||
AssistanceState get assistanceState {
|
||||
final isSubscribed = pangeaController.subscriptionController.isSubscribed;
|
||||
if (isSubscribed == false) return AssistanceState.noSub;
|
||||
if (currentText.isEmpty && itController.sourceText.value == null) {
|
||||
return AssistanceState.noMessage;
|
||||
}
|
||||
|
||||
if (errorService.isError) {
|
||||
return AssistanceState.error;
|
||||
}
|
||||
|
||||
if (igcController.hasOpenMatches || isRunningIT) {
|
||||
return AssistanceState.fetched;
|
||||
}
|
||||
|
||||
if (isFetching.value) return AssistanceState.fetching;
|
||||
if (!igcController.hasIGCTextData) return AssistanceState.notFetched;
|
||||
return AssistanceState.complete;
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
enum ChoreoMode { igc, it }
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
enum PangeaMatchStatus {
|
||||
open,
|
||||
ignored,
|
||||
accepted,
|
||||
automatic,
|
||||
unknown;
|
||||
|
||||
static PangeaMatchStatus fromString(String status) {
|
||||
final String lastPart = status.toString().split('.').last;
|
||||
switch (lastPart) {
|
||||
case 'open':
|
||||
return PangeaMatchStatus.open;
|
||||
case 'ignored':
|
||||
return PangeaMatchStatus.ignored;
|
||||
case 'accepted':
|
||||
return PangeaMatchStatus.accepted;
|
||||
case 'automatic':
|
||||
return PangeaMatchStatus.automatic;
|
||||
default:
|
||||
return PangeaMatchStatus.unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/autocorrect_popup.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/autocorrect_popup.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/overlay.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AutocorrectSpan extends WidgetSpan {
|
||||
AutocorrectSpan({
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/enums/pangea_match_status.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/igc_text_data_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_state.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/igc_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/igc_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/span_data_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/span_data_request.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/igc_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/igc_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/igc_text_data_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_state_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_status_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_request.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
|
|
@ -48,7 +47,7 @@ class IgcController {
|
|||
|
||||
PangeaMatch acceptReplacement(
|
||||
PangeaMatchState match,
|
||||
PangeaMatchStatus status,
|
||||
PangeaMatchStatusEnum status,
|
||||
) {
|
||||
if (_igcTextData == null) {
|
||||
throw "acceptReplacement called with null igcTextData";
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/igc_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/igc_response_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/igc_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/igc_response_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/common/config/environment.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../common/network/requests.dart';
|
||||
import '../../common/network/urls.dart';
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
|
||||
class IGCResponseModel {
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/enums/pangea_match_status.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_state.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/span_data.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/igc_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/igc_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_state_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_status_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_model.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A model representing mutable text and match state used by
|
||||
/// Interactive Grammar Correction (IGC).
|
||||
|
|
@ -46,10 +44,10 @@ class IGCTextData {
|
|||
for (final match in matches) {
|
||||
final matchState = PangeaMatchState(
|
||||
match: match.match,
|
||||
status: PangeaMatchStatus.open,
|
||||
status: PangeaMatchStatusEnum.open,
|
||||
original: match,
|
||||
);
|
||||
if (match.status == PangeaMatchStatus.open) {
|
||||
if (match.status == PangeaMatchStatusEnum.open) {
|
||||
_openMatches.add(matchState);
|
||||
} else {
|
||||
_closedMatches.add(matchState);
|
||||
|
|
@ -83,7 +81,7 @@ class IGCTextData {
|
|||
List<PangeaMatchState> get recentAutomaticCorrections =>
|
||||
_closedMatches.reversed
|
||||
.takeWhile(
|
||||
(m) => m.updatedMatch.status == PangeaMatchStatus.automatic,
|
||||
(m) => m.updatedMatch.status == PangeaMatchStatusEnum.automatic,
|
||||
)
|
||||
.toList();
|
||||
|
||||
|
|
@ -156,7 +154,7 @@ class IGCTextData {
|
|||
/// updates offsets for all matches accordingly.
|
||||
PangeaMatch acceptMatch(
|
||||
PangeaMatchState matchState,
|
||||
PangeaMatchStatus status,
|
||||
PangeaMatchStatusEnum status,
|
||||
) {
|
||||
final openMatch = _openMatches.firstWhere(
|
||||
(m) => m.originalMatch == matchState.originalMatch,
|
||||
|
|
@ -196,7 +194,7 @@ class IGCTextData {
|
|||
),
|
||||
);
|
||||
|
||||
matchState.setStatus(PangeaMatchStatus.ignored);
|
||||
matchState.setStatus(PangeaMatchStatusEnum.ignored);
|
||||
_openMatches.remove(openMatch);
|
||||
_closedMatches.add(matchState);
|
||||
return matchState.updatedMatch;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
class MatchRuleIds {
|
||||
class MatchRuleIdModel {
|
||||
static const interactiveTranslation = "interactive_translation";
|
||||
|
||||
/// note these are not currently being passed by the server
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
import 'package:fluffychat/pangea/choreographer/enums/pangea_match_status.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/span_data_type.dart';
|
||||
import '../constants/match_rule_ids.dart';
|
||||
import 'span_data.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_status_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_type_enum.dart';
|
||||
|
||||
import 'match_rule_id_model.dart';
|
||||
import 'span_data_model.dart';
|
||||
|
||||
class PangeaMatch {
|
||||
final SpanData match;
|
||||
final PangeaMatchStatus status;
|
||||
final PangeaMatchStatusEnum status;
|
||||
|
||||
const PangeaMatch({
|
||||
required this.match,
|
||||
|
|
@ -16,8 +17,8 @@ class PangeaMatch {
|
|||
return PangeaMatch(
|
||||
match: SpanData.fromJson(json[_matchKey] as Map<String, dynamic>),
|
||||
status: json[_statusKey] != null
|
||||
? PangeaMatchStatus.fromString(json[_statusKey] as String)
|
||||
: PangeaMatchStatus.open,
|
||||
? PangeaMatchStatusEnum.fromString(json[_statusKey] as String)
|
||||
: PangeaMatchStatusEnum.open,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -30,14 +31,14 @@ class PangeaMatch {
|
|||
static const _statusKey = "status";
|
||||
|
||||
bool get isITStart =>
|
||||
match.rule?.id == MatchRuleIds.interactiveTranslation ||
|
||||
match.rule?.id == MatchRuleIdModel.interactiveTranslation ||
|
||||
[SpanDataTypeEnum.itStart, SpanDataTypeEnum.itStart.name]
|
||||
.contains(match.type.typeName);
|
||||
|
||||
bool get _needsTranslation => match.rule?.id != null
|
||||
? [
|
||||
MatchRuleIds.tokenNeedsTranslation,
|
||||
MatchRuleIds.tokenSpanNeedsTranslation,
|
||||
MatchRuleIdModel.tokenNeedsTranslation,
|
||||
MatchRuleIdModel.tokenSpanNeedsTranslation,
|
||||
].contains(match.rule!.id)
|
||||
: false;
|
||||
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
import 'package:fluffychat/pangea/choreographer/enums/pangea_match_status.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/span_data.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_status_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_model.dart';
|
||||
|
||||
class PangeaMatchState {
|
||||
final PangeaMatch _original;
|
||||
SpanData _match;
|
||||
PangeaMatchStatus _status;
|
||||
PangeaMatchStatusEnum _status;
|
||||
|
||||
PangeaMatchState({
|
||||
required PangeaMatch original,
|
||||
required SpanData match,
|
||||
required PangeaMatchStatus status,
|
||||
required PangeaMatchStatusEnum status,
|
||||
}) : _original = original,
|
||||
_match = match,
|
||||
_status = status;
|
||||
|
|
@ -22,7 +22,7 @@ class PangeaMatchState {
|
|||
status: _status,
|
||||
);
|
||||
|
||||
void setStatus(PangeaMatchStatus status) {
|
||||
void setStatus(PangeaMatchStatusEnum status) {
|
||||
_status = status;
|
||||
}
|
||||
|
||||
23
lib/pangea/choreographer/igc/pangea_match_status_enum.dart
Normal file
23
lib/pangea/choreographer/igc/pangea_match_status_enum.dart
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
enum PangeaMatchStatusEnum {
|
||||
open,
|
||||
ignored,
|
||||
accepted,
|
||||
automatic,
|
||||
unknown;
|
||||
|
||||
static PangeaMatchStatusEnum fromString(String status) {
|
||||
final String lastPart = status.toString().split('.').last;
|
||||
switch (lastPart) {
|
||||
case 'open':
|
||||
return PangeaMatchStatusEnum.open;
|
||||
case 'ignored':
|
||||
return PangeaMatchStatusEnum.ignored;
|
||||
case 'accepted':
|
||||
return PangeaMatchStatusEnum.accepted;
|
||||
case 'automatic':
|
||||
return PangeaMatchStatusEnum.automatic;
|
||||
default:
|
||||
return PangeaMatchStatusEnum.unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,19 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_style.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/span_choice_type.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/span_data_type.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_state.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/span_data.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_state_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_choice_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/feedback_model.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/error_indicator.dart';
|
||||
import '../../../../widgets/matrix.dart';
|
||||
import '../choice_array.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../../../widgets/matrix.dart';
|
||||
import '../../common/widgets/choice_array.dart';
|
||||
import 'why_button.dart';
|
||||
|
||||
class SpanCard extends StatefulWidget {
|
||||
|
|
@ -1,54 +1,53 @@
|
|||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
|
||||
enum SpanChoiceType {
|
||||
enum SpanChoiceTypeEnum {
|
||||
bestCorrection,
|
||||
distractor,
|
||||
bestAnswer,
|
||||
}
|
||||
|
||||
extension SpanChoiceExt on SpanChoiceType {
|
||||
extension SpanChoiceExt on SpanChoiceTypeEnum {
|
||||
String get name {
|
||||
switch (this) {
|
||||
case SpanChoiceType.bestCorrection:
|
||||
case SpanChoiceTypeEnum.bestCorrection:
|
||||
return "bestCorrection";
|
||||
case SpanChoiceType.distractor:
|
||||
case SpanChoiceTypeEnum.distractor:
|
||||
return "distractor";
|
||||
case SpanChoiceType.bestAnswer:
|
||||
case SpanChoiceTypeEnum.bestAnswer:
|
||||
return "bestAnswer";
|
||||
}
|
||||
}
|
||||
|
||||
String defaultFeedback(BuildContext context) {
|
||||
switch (this) {
|
||||
case SpanChoiceType.bestCorrection:
|
||||
case SpanChoiceTypeEnum.bestCorrection:
|
||||
return L10n.of(context).bestCorrectionFeedback;
|
||||
case SpanChoiceType.distractor:
|
||||
case SpanChoiceTypeEnum.distractor:
|
||||
return L10n.of(context).distractorFeedback;
|
||||
case SpanChoiceType.bestAnswer:
|
||||
case SpanChoiceTypeEnum.bestAnswer:
|
||||
return L10n.of(context).bestAnswerFeedback;
|
||||
}
|
||||
}
|
||||
|
||||
IconData get icon {
|
||||
switch (this) {
|
||||
case SpanChoiceType.bestCorrection:
|
||||
case SpanChoiceTypeEnum.bestCorrection:
|
||||
return Icons.check_circle;
|
||||
case SpanChoiceType.distractor:
|
||||
case SpanChoiceTypeEnum.distractor:
|
||||
return Icons.cancel;
|
||||
case SpanChoiceType.bestAnswer:
|
||||
case SpanChoiceTypeEnum.bestAnswer:
|
||||
return Icons.check_circle;
|
||||
}
|
||||
}
|
||||
|
||||
Color get color {
|
||||
switch (this) {
|
||||
case SpanChoiceType.bestCorrection:
|
||||
case SpanChoiceTypeEnum.bestCorrection:
|
||||
return Colors.green;
|
||||
case SpanChoiceType.distractor:
|
||||
case SpanChoiceTypeEnum.distractor:
|
||||
return Colors.red;
|
||||
case SpanChoiceType.bestAnswer:
|
||||
case SpanChoiceTypeEnum.bestAnswer:
|
||||
return Colors.green;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:diacritic/diacritic.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import '../enums/span_choice_type.dart';
|
||||
import '../enums/span_data_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'span_choice_type_enum.dart';
|
||||
import 'span_data_type_enum.dart';
|
||||
|
||||
class SpanData {
|
||||
final String? message;
|
||||
|
|
@ -206,7 +205,7 @@ class SpanData {
|
|||
|
||||
class SpanChoice {
|
||||
final String value;
|
||||
final SpanChoiceType type;
|
||||
final SpanChoiceTypeEnum type;
|
||||
final bool selected;
|
||||
final String? feedback;
|
||||
final DateTime? timestamp;
|
||||
|
|
@ -221,7 +220,7 @@ class SpanChoice {
|
|||
|
||||
SpanChoice copyWith({
|
||||
String? value,
|
||||
SpanChoiceType? type,
|
||||
SpanChoiceTypeEnum? type,
|
||||
String? feedback,
|
||||
bool? selected,
|
||||
DateTime? timestamp,
|
||||
|
|
@ -239,11 +238,11 @@ class SpanChoice {
|
|||
return SpanChoice(
|
||||
value: json['value'] as String,
|
||||
type: json['type'] != null
|
||||
? SpanChoiceType.values.firstWhereOrNull(
|
||||
? SpanChoiceTypeEnum.values.firstWhereOrNull(
|
||||
(element) => element.name == json['type'],
|
||||
) ??
|
||||
SpanChoiceType.bestCorrection
|
||||
: SpanChoiceType.bestCorrection,
|
||||
SpanChoiceTypeEnum.bestCorrection
|
||||
: SpanChoiceTypeEnum.bestCorrection,
|
||||
feedback: json['feedback'],
|
||||
selected: json['selected'] ?? false,
|
||||
timestamp:
|
||||
|
|
@ -266,7 +265,7 @@ class SpanChoice {
|
|||
return feedback!;
|
||||
}
|
||||
|
||||
bool get isBestCorrection => type == SpanChoiceType.bestCorrection;
|
||||
bool get isBestCorrection => type == SpanChoiceTypeEnum.bestCorrection;
|
||||
|
||||
Color get color => type.color;
|
||||
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/repo/span_data_request.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/span_data_response.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_request.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_response.dart';
|
||||
import 'package:fluffychat/pangea/common/config/environment.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../common/network/requests.dart';
|
||||
import '../../common/network/urls.dart';
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:fluffychat/pangea/choreographer/models/span_data.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_model.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
|
||||
class SpanDetailsRequest {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:fluffychat/pangea/choreographer/models/span_data.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_data_model.dart';
|
||||
|
||||
class SpanDetailsResponse {
|
||||
final String userL1;
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_state_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_state_extension.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../pages/chat/chat.dart';
|
||||
|
||||
class StartIGCButton extends StatefulWidget {
|
||||
|
|
@ -24,10 +24,10 @@ class StartIGCButton extends StatefulWidget {
|
|||
|
||||
class StartIGCButtonState extends State<StartIGCButton>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AssistanceState get assistanceState =>
|
||||
AssistanceStateEnum get assistanceState =>
|
||||
widget.controller.choreographer.assistanceState;
|
||||
AnimationController? _controller;
|
||||
AssistanceState? _prevState;
|
||||
AssistanceStateEnum? _prevState;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -46,11 +46,11 @@ class StartIGCButtonState extends State<StartIGCButton>
|
|||
}
|
||||
|
||||
void _updateSpinnerState() {
|
||||
if (_prevState != AssistanceState.fetching &&
|
||||
assistanceState == AssistanceState.fetching) {
|
||||
if (_prevState != AssistanceStateEnum.fetching &&
|
||||
assistanceState == AssistanceStateEnum.fetching) {
|
||||
_controller?.repeat();
|
||||
} else if (_prevState == AssistanceState.fetching &&
|
||||
assistanceState != AssistanceState.fetching) {
|
||||
} else if (_prevState == AssistanceStateEnum.fetching &&
|
||||
assistanceState != AssistanceStateEnum.fetching) {
|
||||
_controller?.reset();
|
||||
}
|
||||
if (mounted) {
|
||||
|
|
@ -60,12 +60,12 @@ class StartIGCButtonState extends State<StartIGCButton>
|
|||
|
||||
bool get _enableFeedback {
|
||||
return ![
|
||||
AssistanceState.fetching,
|
||||
AssistanceState.fetched,
|
||||
AssistanceState.complete,
|
||||
AssistanceState.noMessage,
|
||||
AssistanceState.noSub,
|
||||
AssistanceState.error,
|
||||
AssistanceStateEnum.fetching,
|
||||
AssistanceStateEnum.fetched,
|
||||
AssistanceStateEnum.complete,
|
||||
AssistanceStateEnum.noMessage,
|
||||
AssistanceStateEnum.noSub,
|
||||
AssistanceStateEnum.error,
|
||||
].contains(assistanceState);
|
||||
}
|
||||
|
||||
|
|
@ -83,14 +83,14 @@ class StartIGCButtonState extends State<StartIGCButton>
|
|||
|
||||
Color get _backgroundColor {
|
||||
switch (assistanceState) {
|
||||
case AssistanceState.noSub:
|
||||
case AssistanceState.noMessage:
|
||||
case AssistanceState.fetched:
|
||||
case AssistanceState.complete:
|
||||
case AssistanceState.error:
|
||||
case AssistanceStateEnum.noSub:
|
||||
case AssistanceStateEnum.noMessage:
|
||||
case AssistanceStateEnum.fetched:
|
||||
case AssistanceStateEnum.complete:
|
||||
case AssistanceStateEnum.error:
|
||||
return Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
case AssistanceState.notFetched:
|
||||
case AssistanceState.fetching:
|
||||
case AssistanceStateEnum.notFetched:
|
||||
case AssistanceStateEnum.fetching:
|
||||
return Theme.of(context).colorScheme.primaryContainer;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import '../constants/choreo_constants.dart';
|
||||
import '../choreo_constants.dart';
|
||||
|
||||
class CompletedITStep {
|
||||
final List<Continuance> continuances;
|
||||
class CompletedITStepModel {
|
||||
final List<ContinuanceModel> continuances;
|
||||
final int chosen;
|
||||
|
||||
const CompletedITStep(
|
||||
const CompletedITStepModel(
|
||||
this.continuances, {
|
||||
required this.chosen,
|
||||
});
|
||||
|
|
@ -19,23 +19,23 @@ class CompletedITStep {
|
|||
return data;
|
||||
}
|
||||
|
||||
factory CompletedITStep.fromJson(Map<String, dynamic> json) {
|
||||
final List<Continuance> continuances = <Continuance>[];
|
||||
factory CompletedITStepModel.fromJson(Map<String, dynamic> json) {
|
||||
final List<ContinuanceModel> continuances = <ContinuanceModel>[];
|
||||
for (final Map<String, dynamic> continuance in json['continuances']) {
|
||||
continuances.add(Continuance.fromJson(continuance));
|
||||
continuances.add(ContinuanceModel.fromJson(continuance));
|
||||
}
|
||||
return CompletedITStep(
|
||||
return CompletedITStepModel(
|
||||
continuances,
|
||||
chosen: json['chosen'],
|
||||
);
|
||||
}
|
||||
|
||||
Continuance? get chosenContinuance {
|
||||
ContinuanceModel? get chosenContinuance {
|
||||
return continuances[chosen];
|
||||
}
|
||||
}
|
||||
|
||||
class Continuance {
|
||||
class ContinuanceModel {
|
||||
final double probability;
|
||||
final int level;
|
||||
final String text;
|
||||
|
|
@ -47,7 +47,7 @@ class Continuance {
|
|||
final bool hasInfo;
|
||||
final bool gold;
|
||||
|
||||
const Continuance({
|
||||
const ContinuanceModel({
|
||||
required this.probability,
|
||||
required this.level,
|
||||
required this.text,
|
||||
|
|
@ -59,8 +59,8 @@ class Continuance {
|
|||
required this.gold,
|
||||
});
|
||||
|
||||
factory Continuance.fromJson(Map<String, dynamic> json) {
|
||||
return Continuance(
|
||||
factory ContinuanceModel.fromJson(Map<String, dynamic> json) {
|
||||
return ContinuanceModel(
|
||||
probability: json['probability'].toDouble(),
|
||||
level: json['level'],
|
||||
text: json['text'],
|
||||
|
|
@ -90,7 +90,7 @@ class Continuance {
|
|||
return data;
|
||||
}
|
||||
|
||||
Continuance copyWith({
|
||||
ContinuanceModel copyWith({
|
||||
double? probability,
|
||||
int? level,
|
||||
String? text,
|
||||
|
|
@ -101,7 +101,7 @@ class Continuance {
|
|||
bool? hasInfo,
|
||||
bool? gold,
|
||||
}) {
|
||||
return Continuance(
|
||||
return ContinuanceModel(
|
||||
probability: probability ?? this.probability,
|
||||
level: level ?? this.level,
|
||||
text: text ?? this.text,
|
||||
|
|
@ -145,7 +145,7 @@ class Continuance {
|
|||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is Continuance &&
|
||||
other is ContinuanceModel &&
|
||||
runtimeType == other.runtimeType &&
|
||||
probability == other.probability &&
|
||||
level == other.level &&
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/repo/contextual_definition_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/contextual_definition_response_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/contextual_definition_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/contextual_definition_response_model.dart';
|
||||
import 'package:fluffychat/pangea/common/config/environment.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../common/network/requests.dart';
|
||||
import '../../common/network/urls.dart';
|
||||
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import 'package:fluffychat/pangea/choreographer/models/completed_it_step.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/completed_it_step_model.dart';
|
||||
|
||||
class GoldRouteTracker {
|
||||
class GoldRouteTrackerModel {
|
||||
final String _originalText;
|
||||
final List<Continuance> continuances;
|
||||
final List<ContinuanceModel> continuances;
|
||||
|
||||
const GoldRouteTracker(this.continuances, String originalText)
|
||||
const GoldRouteTrackerModel(this.continuances, String originalText)
|
||||
: _originalText = originalText;
|
||||
|
||||
Continuance? currentContinuance({
|
||||
ContinuanceModel? currentContinuance({
|
||||
required String currentText,
|
||||
required String sourceText,
|
||||
}) {
|
||||
|
|
@ -1,26 +1,25 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/constants/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choregrapher_user_settings_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/completed_it_step.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/word_data_card.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/it_feedback_card.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choregrapher_user_settings_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/completed_it_step_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/it_feedback_card.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/word_data_card.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/error_indicator.dart';
|
||||
import 'package:fluffychat/pangea/instructions/instructions_enum.dart';
|
||||
import 'package:fluffychat/pangea/instructions/instructions_inline_tooltip.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../../common/utils/overlay.dart';
|
||||
import 'choice_array.dart';
|
||||
import '../../common/widgets/choice_array.dart';
|
||||
|
||||
class ITBar extends StatefulWidget {
|
||||
final Choreographer choreographer;
|
||||
|
|
@ -131,7 +130,7 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
|||
|
||||
void _selectContinuance(int index) {
|
||||
MatrixState.pAnyState.closeOverlay("it_feedback_card");
|
||||
Continuance continuance;
|
||||
ContinuanceModel continuance;
|
||||
try {
|
||||
continuance =
|
||||
widget.choreographer.itController.onSelectContinuance(index);
|
||||
|
|
@ -386,7 +385,7 @@ class _ITBarHeader extends StatelessWidget {
|
|||
}
|
||||
|
||||
class _ITChoices extends StatelessWidget {
|
||||
final List<Continuance> continuances;
|
||||
final List<ContinuanceModel> continuances;
|
||||
final Function(int) onPressed;
|
||||
final Function(int) onLongPressed;
|
||||
|
||||
|
|
@ -1,27 +1,26 @@
|
|||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/models/gold_route_tracker.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/it_step.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/it_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/it_response_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/gold_route_tracker_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/it_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/it_response_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/it_step_model.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../models/completed_it_step.dart';
|
||||
import '../repo/it_request_model.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'completed_it_step_model.dart';
|
||||
import 'it_request_model.dart';
|
||||
|
||||
class ITController {
|
||||
final Function(Object) onError;
|
||||
|
||||
final Queue<Completer<ITStep>> _queue = Queue();
|
||||
GoldRouteTracker? _goldRouteTracker;
|
||||
final Queue<Completer<ITStepModel>> _queue = Queue();
|
||||
GoldRouteTrackerModel? _goldRouteTracker;
|
||||
|
||||
final ValueNotifier<String?> _sourceText = ValueNotifier(null);
|
||||
final ValueNotifier<ITStep?> _currentITStep = ValueNotifier(null);
|
||||
final ValueNotifier<ITStepModel?> _currentITStep = ValueNotifier(null);
|
||||
final ValueNotifier<bool> _open = ValueNotifier(false);
|
||||
final ValueNotifier<bool> _editing = ValueNotifier(false);
|
||||
bool _dismissed = false;
|
||||
|
|
@ -30,7 +29,7 @@ class ITController {
|
|||
|
||||
ValueNotifier<bool> get open => _open;
|
||||
ValueNotifier<bool> get editing => _editing;
|
||||
ValueNotifier<ITStep?> get currentITStep => _currentITStep;
|
||||
ValueNotifier<ITStepModel?> get currentITStep => _currentITStep;
|
||||
ValueNotifier<String?> get sourceText => _sourceText;
|
||||
bool get dismissed => _dismissed;
|
||||
|
||||
|
|
@ -100,7 +99,7 @@ class ITController {
|
|||
continueIT();
|
||||
}
|
||||
|
||||
Continuance onSelectContinuance(int index) {
|
||||
ContinuanceModel onSelectContinuance(int index) {
|
||||
if (_currentITStep.value == null) {
|
||||
throw "onSelectContinuance called when _currentITStep is null";
|
||||
}
|
||||
|
|
@ -119,7 +118,7 @@ class ITController {
|
|||
return _currentITStep.value!.continuances[index];
|
||||
}
|
||||
|
||||
CompletedITStep onAcceptContinuance(int chosenIndex) {
|
||||
CompletedITStepModel onAcceptContinuance(int chosenIndex) {
|
||||
if (_currentITStep.value == null) {
|
||||
throw "onAcceptContinuance called when _currentITStep is null";
|
||||
}
|
||||
|
|
@ -129,7 +128,7 @@ class ITController {
|
|||
throw "onAcceptContinuance called with invalid index $chosenIndex";
|
||||
}
|
||||
|
||||
final completedStep = CompletedITStep(
|
||||
final completedStep = CompletedITStepModel(
|
||||
_currentITStep.value!.continuances,
|
||||
chosen: chosenIndex,
|
||||
);
|
||||
|
|
@ -168,12 +167,12 @@ class ITController {
|
|||
}
|
||||
|
||||
final result = res.result!;
|
||||
_goldRouteTracker = GoldRouteTracker(
|
||||
_goldRouteTracker = GoldRouteTrackerModel(
|
||||
result.goldContinuances!,
|
||||
_sourceText.value!,
|
||||
);
|
||||
|
||||
_currentITStep.value = ITStep.fromResponse(
|
||||
_currentITStep.value = ITStepModel.fromResponse(
|
||||
sourceText: _sourceText.value!,
|
||||
currentText: "",
|
||||
responseModel: res.result!,
|
||||
|
|
@ -193,14 +192,14 @@ class ITController {
|
|||
final goldContinuances = _goldRouteTracker!.continuances;
|
||||
String currentText = goldContinuances[0].text;
|
||||
for (int i = 1; i < goldContinuances.length; i++) {
|
||||
final completer = Completer<ITStep>();
|
||||
final completer = Completer<ITStepModel>();
|
||||
_queue.add(completer);
|
||||
final resp = await _safeRequest(currentText);
|
||||
if (resp.isError) {
|
||||
completer.completeError(resp.asError!);
|
||||
break;
|
||||
} else {
|
||||
final step = ITStep.fromResponse(
|
||||
final step = ITStepModel.fromResponse(
|
||||
sourceText: sourceText,
|
||||
currentText: currentText,
|
||||
responseModel: resp.result!,
|
||||
|
|
@ -1,18 +1,17 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/text_loading_shimmer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/feedback_model.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_repo.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../widgets/matrix.dart';
|
||||
import '../../bot/utils/bot_style.dart';
|
||||
import 'igc/card_error_widget.dart';
|
||||
import '../../common/widgets/card_error_widget.dart';
|
||||
|
||||
class ITFeedbackCard extends StatefulWidget {
|
||||
final FullTextTranslationRequestModel req;
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/models/completed_it_step.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/completed_it_step_model.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class ITRequestModel {
|
||||
final String text;
|
||||
|
|
@ -10,7 +9,7 @@ class ITRequestModel {
|
|||
final String targetLangCode;
|
||||
|
||||
final String? goldTranslation;
|
||||
final List<Continuance>? goldContinuances;
|
||||
final List<ContinuanceModel>? goldContinuances;
|
||||
|
||||
const ITRequestModel({
|
||||
required this.text,
|
||||
|
|
@ -29,7 +28,7 @@ class ITRequestModel {
|
|||
goldTranslation: json['gold_translation'],
|
||||
goldContinuances: json['gold_continuances'] != null
|
||||
? (json['gold_continuances'])
|
||||
.map((e) => Continuance.fromJson(e))
|
||||
.map((e) => ContinuanceModel.fromJson(e))
|
||||
.toList()
|
||||
: null,
|
||||
);
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/constants/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/completed_it_step.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/completed_it_step_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ITResponseModel {
|
||||
final String fullTextTranslation;
|
||||
final List<Continuance> continuances;
|
||||
final List<Continuance>? goldContinuances;
|
||||
final List<ContinuanceModel> continuances;
|
||||
final List<ContinuanceModel>? goldContinuances;
|
||||
final bool isFinal;
|
||||
final String? translationId;
|
||||
final int payloadId;
|
||||
|
|
@ -30,15 +28,15 @@ class ITResponseModel {
|
|||
json['finished'] = true;
|
||||
}
|
||||
|
||||
final List<Continuance> interimCont = (json['continuances'] as List)
|
||||
final List<ContinuanceModel> interimCont = (json['continuances'] as List)
|
||||
.mapIndexed((index, e) {
|
||||
e["index"] = index;
|
||||
return Continuance.fromJson(e);
|
||||
return ContinuanceModel.fromJson(e);
|
||||
})
|
||||
.toList()
|
||||
.take(ChoreoConstants.numberOfITChoices)
|
||||
.toList()
|
||||
.cast<Continuance>()
|
||||
.cast<ContinuanceModel>()
|
||||
//can't do this on the backend because step translation can't filter them out
|
||||
.where((element) => element.inDictionary)
|
||||
.toList();
|
||||
|
|
@ -54,7 +52,7 @@ class ITResponseModel {
|
|||
goldContinuances: json['gold_continuances'] != null
|
||||
? (json['gold_continuances'] as Iterable).map((e) {
|
||||
e["gold"] = true;
|
||||
return Continuance.fromJson(e);
|
||||
return ContinuanceModel.fromJson(e);
|
||||
}).toList()
|
||||
: null,
|
||||
);
|
||||
|
|
@ -1,30 +1,30 @@
|
|||
import 'package:fluffychat/pangea/choreographer/constants/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/completed_it_step.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/gold_route_tracker.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/it_response_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/completed_it_step_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/gold_route_tracker_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/it_response_model.dart';
|
||||
|
||||
class ITStep {
|
||||
late List<Continuance> continuances;
|
||||
class ITStepModel {
|
||||
late List<ContinuanceModel> continuances;
|
||||
late bool isFinal;
|
||||
|
||||
ITStep({this.continuances = const [], this.isFinal = false});
|
||||
ITStepModel({this.continuances = const [], this.isFinal = false});
|
||||
|
||||
factory ITStep.fromResponse({
|
||||
factory ITStepModel.fromResponse({
|
||||
required String sourceText,
|
||||
required String currentText,
|
||||
required ITResponseModel responseModel,
|
||||
required List<Continuance>? storedGoldContinuances,
|
||||
required List<ContinuanceModel>? storedGoldContinuances,
|
||||
}) {
|
||||
final List<Continuance> gold =
|
||||
final List<ContinuanceModel> gold =
|
||||
storedGoldContinuances ?? responseModel.goldContinuances ?? [];
|
||||
final goldTracker = GoldRouteTracker(gold, sourceText);
|
||||
final goldTracker = GoldRouteTrackerModel(gold, sourceText);
|
||||
|
||||
final isFinal = responseModel.isFinal;
|
||||
List<Continuance> continuances;
|
||||
List<ContinuanceModel> continuances;
|
||||
if (responseModel.continuances.isEmpty) {
|
||||
continuances = [];
|
||||
} else {
|
||||
final Continuance? goldCont = goldTracker.currentContinuance(
|
||||
final ContinuanceModel? goldCont = goldTracker.currentContinuance(
|
||||
currentText: currentText,
|
||||
sourceText: sourceText,
|
||||
);
|
||||
|
|
@ -45,21 +45,21 @@ class ITStep {
|
|||
];
|
||||
continuances.shuffle();
|
||||
} else {
|
||||
continuances = List<Continuance>.from(responseModel.continuances);
|
||||
continuances = List<ContinuanceModel>.from(responseModel.continuances);
|
||||
}
|
||||
}
|
||||
|
||||
return ITStep(
|
||||
return ITStepModel(
|
||||
continuances: continuances,
|
||||
isFinal: isFinal,
|
||||
);
|
||||
}
|
||||
|
||||
ITStep copyWith({
|
||||
List<Continuance>? continuances,
|
||||
ITStepModel copyWith({
|
||||
List<ContinuanceModel>? continuances,
|
||||
bool? isFinal,
|
||||
}) {
|
||||
return ITStep(
|
||||
return ITStepModel(
|
||||
continuances: continuances ?? this.continuances,
|
||||
isFinal: isFinal ?? this.isFinal,
|
||||
);
|
||||
|
|
@ -1,17 +1,15 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_style.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/contextual_definition_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/contextual_definition_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/contextual_definition_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/it/contextual_definition_request_model.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/feedback_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/toolbar_content_loading_indicator.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WordDataCard extends StatefulWidget {
|
||||
final String word;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
enum EditType {
|
||||
enum EditTypeEnum {
|
||||
igc,
|
||||
it,
|
||||
itDismissed,
|
||||
|
|
@ -1,22 +1,21 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/constants/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/constants/match_rule_ids.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/pangea_match_status.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_state.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/autocorrect_span.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_constants.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/autocorrect_span.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/match_rule_id_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_state_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_status_enum.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/subscription/controllers/subscription_controller.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../enums/edit_type.dart';
|
||||
import 'choreographer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../choreographer.dart';
|
||||
import 'edit_type_enum.dart';
|
||||
|
||||
class PangeaTextController extends TextEditingController {
|
||||
final Choreographer choreographer;
|
||||
EditType editType = EditType.keyboard;
|
||||
EditTypeEnum editType = EditTypeEnum.keyboard;
|
||||
String _currentText = '';
|
||||
|
||||
PangeaTextController({
|
||||
|
|
@ -34,15 +33,15 @@ class PangeaTextController extends TextEditingController {
|
|||
);
|
||||
|
||||
Color _underlineColor(PangeaMatch match) {
|
||||
if (match.status == PangeaMatchStatus.automatic) {
|
||||
if (match.status == PangeaMatchStatusEnum.automatic) {
|
||||
return const Color.fromARGB(187, 132, 96, 224);
|
||||
}
|
||||
|
||||
switch (match.match.rule?.id ?? "unknown") {
|
||||
case MatchRuleIds.interactiveTranslation:
|
||||
case MatchRuleIdModel.interactiveTranslation:
|
||||
return const Color.fromARGB(187, 132, 96, 224);
|
||||
case MatchRuleIds.tokenNeedsTranslation:
|
||||
case MatchRuleIds.tokenSpanNeedsTranslation:
|
||||
case MatchRuleIdModel.tokenNeedsTranslation:
|
||||
case MatchRuleIdModel.tokenSpanNeedsTranslation:
|
||||
return const Color.fromARGB(186, 255, 132, 0);
|
||||
default:
|
||||
return const Color.fromARGB(149, 255, 17, 0);
|
||||
|
|
@ -64,14 +63,14 @@ class PangeaTextController extends TextEditingController {
|
|||
return existingStyle?.merge(style) ?? style;
|
||||
}
|
||||
|
||||
void setSystemText(String text, EditType type) {
|
||||
void setSystemText(String text, EditTypeEnum type) {
|
||||
editType = type;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
void _onTextChanged() {
|
||||
final diff = text.characters.length - _currentText.characters.length;
|
||||
if (diff > 1 && editType == EditType.keyboard) {
|
||||
if (diff > 1 && editType == EditTypeEnum.keyboard) {
|
||||
final pastedText = text.characters
|
||||
.skip(_currentText.characters.length)
|
||||
.take(diff)
|
||||
|
|
@ -147,7 +146,7 @@ class PangeaTextController extends TextEditingController {
|
|||
)
|
||||
.toString();
|
||||
|
||||
if (match.updatedMatch.status == PangeaMatchStatus.automatic) {
|
||||
if (match.updatedMatch.status == PangeaMatchStatusEnum.automatic) {
|
||||
final originalText = match.originalMatch.match.fullText.characters
|
||||
.getRange(
|
||||
match.originalMatch.match.offset,
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/extensions/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/pangea_match_state.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/span_card.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreographer_ui_extension.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_state_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/span_card.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/any_state_holder.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/anchored_overlay_widget.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/overlay_container.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/transparent_backdrop.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../config/themes.dart';
|
||||
import '../../../widgets/matrix.dart';
|
||||
import 'error_handler.dart';
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_style.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../../bot/widgets/bot_face_svg.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../bot/widgets/bot_face_svg.dart';
|
||||
|
||||
class CardHeader extends StatelessWidget {
|
||||
const CardHeader(
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/choice_animation.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/choice_animation.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/controllers/tts_controller.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../bot/utils/bot_style.dart';
|
||||
import 'it_shimmer.dart';
|
||||
import '../../choreographer/it/it_shimmer.dart';
|
||||
|
||||
typedef ChoiceCallback = void Function(String value, int index);
|
||||
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:matrix/matrix.dart' hide Result;
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_repo.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/pangea/common/controllers/base_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
|
|
@ -16,8 +12,11 @@ import 'package:fluffychat/pangea/events/models/tokens_event_content_model.dart'
|
|||
import 'package:fluffychat/pangea/events/repo/token_api_models.dart';
|
||||
import 'package:fluffychat/pangea/events/repo/tokens_repo.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_repo.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:matrix/matrix.dart' hide Result;
|
||||
|
||||
// TODO - make this static and take it out of the _pangeaController
|
||||
// will need to pass accessToken to the requests
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/extensions/pangea_event_extension.dart';
|
||||
import '../../choreographer/models/choreo_record.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import '../../choreographer/choreo_record_model.dart';
|
||||
import '../constants/pangea_event_types.dart';
|
||||
|
||||
class ChoreoEvent {
|
||||
Event event;
|
||||
ChoreoRecord? _content;
|
||||
ChoreoRecordModel? _content;
|
||||
|
||||
ChoreoEvent({required this.event}) {
|
||||
if (event.type != PangeaEventTypes.choreoRecord) {
|
||||
|
|
@ -21,9 +20,9 @@ class ChoreoEvent {
|
|||
}
|
||||
}
|
||||
|
||||
ChoreoRecord? get content {
|
||||
ChoreoRecordModel? get content {
|
||||
try {
|
||||
_content ??= event.getPangeaContent<ChoreoRecord>();
|
||||
_content ??= event.getPangeaContent<ChoreoRecordModel>();
|
||||
return _content;
|
||||
} catch (err, s) {
|
||||
debugger(when: kDebugMode);
|
||||
|
|
|
|||
|
|
@ -2,14 +2,8 @@ import 'dart:convert';
|
|||
import 'dart:developer';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_record.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_record_model.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/events/event_wrappers/pangea_representation_event.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
|
|
@ -28,7 +22,12 @@ import 'package:fluffychat/pangea/toolbar/enums/audio_encoding_enum.dart';
|
|||
import 'package:fluffychat/pangea/toolbar/event_wrappers/practice_activity_event.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/models/speech_to_text_models.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_audio_card.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../../../widgets/matrix.dart';
|
||||
import '../../common/utils/error_handler.dart';
|
||||
import '../../learning_settings/constants/language_constants.dart';
|
||||
|
|
@ -399,10 +398,10 @@ class PangeaMessageEvent {
|
|||
}
|
||||
}
|
||||
|
||||
ChoreoRecord? get _embeddedChoreo {
|
||||
ChoreoRecordModel? get _embeddedChoreo {
|
||||
try {
|
||||
if (_latestEdit.content[ModelKey.choreoRecord] == null) return null;
|
||||
return ChoreoRecord.fromJson(
|
||||
return ChoreoRecordModel.fromJson(
|
||||
_latestEdit.content[ModelKey.choreoRecord] as Map<String, dynamic>,
|
||||
originalWrittenContent,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,22 +2,15 @@
|
|||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:matrix/matrix.dart' hide Result;
|
||||
import 'package:matrix/src/utils/markdown.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/analytics_misc/constructs_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_record.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/language_detection_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_record_model.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/events/event_wrappers/pangea_choreo_event.dart';
|
||||
import 'package:fluffychat/pangea/events/extensions/pangea_event_extension.dart';
|
||||
import 'package:fluffychat/pangea/events/models/language_detection_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/representation_content_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/stt_translation_model.dart';
|
||||
|
|
@ -27,14 +20,19 @@ import 'package:fluffychat/pangea/learning_settings/constants/language_constants
|
|||
import 'package:fluffychat/pangea/morphs/morph_features_enum.dart';
|
||||
import 'package:fluffychat/pangea/morphs/parts_of_speech_enum.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/activity_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:matrix/matrix.dart' hide Result;
|
||||
import 'package:matrix/src/utils/markdown.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
class RepresentationEvent {
|
||||
Event? _event;
|
||||
PangeaRepresentation? _content;
|
||||
PangeaMessageTokens? _tokens;
|
||||
ChoreoRecord? _choreo;
|
||||
ChoreoRecordModel? _choreo;
|
||||
Timeline timeline;
|
||||
Event parentMessageEvent;
|
||||
|
||||
|
|
@ -44,7 +42,7 @@ class RepresentationEvent {
|
|||
Event? event,
|
||||
PangeaRepresentation? content,
|
||||
PangeaMessageTokens? tokens,
|
||||
ChoreoRecord? choreo,
|
||||
ChoreoRecordModel? choreo,
|
||||
}) {
|
||||
if (event != null && event.type != PangeaEventTypes.representation) {
|
||||
throw Exception(
|
||||
|
|
@ -75,7 +73,7 @@ class RepresentationEvent {
|
|||
bool get botAuthored =>
|
||||
content.originalSent == false && content.originalWritten == false;
|
||||
|
||||
List<LanguageDetection>? get detections => _tokens?.detections;
|
||||
List<LanguageDetectionModel>? get detections => _tokens?.detections;
|
||||
|
||||
List<PangeaToken>? get tokens {
|
||||
if (_tokens != null) return _tokens!.tokens;
|
||||
|
|
@ -228,7 +226,7 @@ class RepresentationEvent {
|
|||
);
|
||||
}
|
||||
|
||||
ChoreoRecord? get choreo {
|
||||
ChoreoRecordModel? get choreo {
|
||||
if (_choreo != null) return _choreo;
|
||||
|
||||
if (_event == null) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_record.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_record_model.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
|
|
@ -14,6 +10,8 @@ import 'package:fluffychat/pangea/practice_activities/practice_activity_model.da
|
|||
import 'package:fluffychat/pangea/practice_activities/practice_record.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/controllers/text_to_speech_controller.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_audio_card.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
extension PangeaEvent on Event {
|
||||
V getPangeaContent<V>() {
|
||||
|
|
@ -33,7 +31,7 @@ extension PangeaEvent on Event {
|
|||
case PangeaEventTypes.representation:
|
||||
return PangeaRepresentation.fromJson(json) as V;
|
||||
case PangeaEventTypes.choreoRecord:
|
||||
return ChoreoRecord.fromJson(json) as V;
|
||||
return ChoreoRecordModel.fromJson(json) as V;
|
||||
case PangeaEventTypes.pangeaActivity:
|
||||
return PracticeActivityModel.fromJson(json) as V;
|
||||
case PangeaEventTypes.activityRecord:
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
|
||||
class LanguageDetection {
|
||||
class LanguageDetectionModel {
|
||||
final String langCode;
|
||||
final double confidence;
|
||||
|
||||
const LanguageDetection({
|
||||
const LanguageDetectionModel({
|
||||
required this.langCode,
|
||||
required this.confidence,
|
||||
});
|
||||
|
||||
factory LanguageDetection.fromJson(Map<String, dynamic> json) {
|
||||
factory LanguageDetectionModel.fromJson(Map<String, dynamic> json) {
|
||||
final dynamic confValue = json[ModelKey.confidence];
|
||||
double confidence;
|
||||
if (confValue is String) {
|
||||
|
|
@ -21,7 +21,7 @@ class LanguageDetection {
|
|||
} else {
|
||||
throw TypeError();
|
||||
}
|
||||
return LanguageDetection(
|
||||
return LanguageDetectionModel(
|
||||
langCode: json[ModelKey.langCode],
|
||||
confidence: confidence,
|
||||
);
|
||||
|
|
@ -1,20 +1,19 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/analytics_misc/construct_use_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/constructs_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/enums/pangea_match_status.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_record.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_record_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/pangea_match_status_enum.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/models/speech_to_text_models.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
/// this class is contained within a [RepresentationEvent]
|
||||
/// this event is the child of a [EventTypes.Message]
|
||||
/// the event has two potential children events -
|
||||
/// [PangeaTokensEvent] and [PangeaIGCEvent]
|
||||
/// these events contain [PangeaMessageTokens] and [ChoreoRecord], respectively.
|
||||
/// these events contain [PangeaMessageTokens] and [ChoreoRecordModel], respectively.
|
||||
class PangeaRepresentation {
|
||||
/// system-detected language, possibly condensed from a list,
|
||||
/// but only with high certainty
|
||||
|
|
@ -101,7 +100,7 @@ class PangeaRepresentation {
|
|||
required List<PangeaToken> tokens,
|
||||
Event? event,
|
||||
ConstructUseMetaData? metadata,
|
||||
ChoreoRecord? choreo,
|
||||
ChoreoRecordModel? choreo,
|
||||
}) {
|
||||
final List<OneConstructUse> uses = [];
|
||||
|
||||
|
|
@ -147,7 +146,7 @@ class PangeaRepresentation {
|
|||
}
|
||||
|
||||
for (final token in tokensToSave) {
|
||||
ChoreoRecordStep? tokenStep;
|
||||
ChoreoRecordStepModel? tokenStep;
|
||||
for (final step in choreo.choreoSteps) {
|
||||
final igcMatch = step.acceptedOrIgnoredMatch;
|
||||
final itStep = step.itStep;
|
||||
|
|
@ -176,7 +175,7 @@ class PangeaRepresentation {
|
|||
|
||||
if (tokenStep == null ||
|
||||
tokenStep.acceptedOrIgnoredMatch?.status ==
|
||||
PangeaMatchStatus.automatic) {
|
||||
PangeaMatchStatusEnum.automatic) {
|
||||
// if the token wasn't found in any IT or IGC step, so it was wa
|
||||
uses.addAll(
|
||||
token.allUses(
|
||||
|
|
@ -190,7 +189,7 @@ class PangeaRepresentation {
|
|||
|
||||
if (tokenStep.acceptedOrIgnoredMatch != null &&
|
||||
tokenStep.acceptedOrIgnoredMatch?.status !=
|
||||
PangeaMatchStatus.accepted) {
|
||||
PangeaMatchStatusEnum.accepted) {
|
||||
uses.addAll(
|
||||
token.allUses(
|
||||
ConstructUseTypeEnum.ga,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/models/language_detection_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/language_detection_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
|
||||
/// this class lives within a [PangeaTokensEvent]
|
||||
|
|
@ -9,7 +9,7 @@ import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
|||
/// representation
|
||||
class PangeaMessageTokens {
|
||||
List<PangeaToken> tokens;
|
||||
List<LanguageDetection>? detections;
|
||||
List<LanguageDetectionModel>? detections;
|
||||
|
||||
PangeaMessageTokens({
|
||||
required this.tokens,
|
||||
|
|
@ -38,9 +38,9 @@ class PangeaMessageTokens {
|
|||
.toList()
|
||||
.cast<PangeaToken>(),
|
||||
detections: detectionsIterable
|
||||
?.map((e) => LanguageDetection.fromJson(e))
|
||||
?.map((e) => LanguageDetectionModel.fromJson(e))
|
||||
.toList()
|
||||
.cast<LanguageDetection>(),
|
||||
.cast<LanguageDetectionModel>(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:fluffychat/pangea/choreographer/models/language_detection_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/language_detection_model.dart';
|
||||
|
||||
class LanguageDetectionResponse {
|
||||
List<LanguageDetection> detections;
|
||||
List<LanguageDetectionModel> detections;
|
||||
String fullText;
|
||||
|
||||
LanguageDetectionResponse({
|
||||
|
|
@ -11,9 +11,9 @@ class LanguageDetectionResponse {
|
|||
|
||||
factory LanguageDetectionResponse.fromJson(Map<String, dynamic> json) {
|
||||
return LanguageDetectionResponse(
|
||||
detections: List<LanguageDetection>.from(
|
||||
detections: List<LanguageDetectionModel>.from(
|
||||
(json['detections'] as Iterable).map(
|
||||
(e) => LanguageDetection.fromJson(e),
|
||||
(e) => LanguageDetectionModel.fromJson(e),
|
||||
),
|
||||
),
|
||||
fullText: json['full_text'],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:fluffychat/pangea/choreographer/models/language_detection_model.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/events/models/language_detection_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class TokensRequestModel {
|
|||
class TokensResponseModel {
|
||||
List<PangeaToken> tokens;
|
||||
String lang;
|
||||
List<LanguageDetection> detections;
|
||||
List<LanguageDetectionModel> detections;
|
||||
|
||||
TokensResponseModel({
|
||||
required this.tokens,
|
||||
|
|
@ -75,10 +75,10 @@ class TokensResponseModel {
|
|||
.cast<PangeaToken>(),
|
||||
lang: json[ModelKey.lang],
|
||||
detections: (json[ModelKey.allDetections] as Iterable)
|
||||
.map<LanguageDetection>(
|
||||
(e) => LanguageDetection.fromJson(e as Map<String, dynamic>),
|
||||
.map<LanguageDetectionModel>(
|
||||
(e) => LanguageDetectionModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList()
|
||||
.cast<LanguageDetection>(),
|
||||
.cast<LanguageDetectionModel>(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,7 @@ import 'dart:async';
|
|||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:html_unescape/html_unescape.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:matrix/src/utils/markdown.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/activity_sessions/activity_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/constructs_event.dart';
|
||||
|
|
@ -22,7 +14,7 @@ import 'package:fluffychat/pangea/bot/utils/bot_room_extension.dart';
|
|||
import 'package:fluffychat/pangea/chat/constants/default_power_level.dart';
|
||||
import 'package:fluffychat/pangea/chat_settings/constants/bot_mode.dart';
|
||||
import 'package:fluffychat/pangea/chat_settings/constants/pangea_room_types.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/igc_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/igc/igc_request_model.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/constructs/construct_identifier.dart';
|
||||
|
|
@ -34,7 +26,14 @@ import 'package:fluffychat/pangea/lemmas/user_set_lemma_info.dart';
|
|||
import 'package:fluffychat/pangea/spaces/constants/space_constants.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import '../choreographer/models/choreo_record.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:html_unescape/html_unescape.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:matrix/src/utils/markdown.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../choreographer/choreo_record_model.dart';
|
||||
import '../events/constants/pangea_event_types.dart';
|
||||
import '../events/models/representation_content_model.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ extension EventsRoomExtension on Room {
|
|||
PangeaRepresentation? originalWritten,
|
||||
PangeaMessageTokens? tokensSent,
|
||||
PangeaMessageTokens? tokensWritten,
|
||||
ChoreoRecord? choreo,
|
||||
ChoreoRecordModel? choreo,
|
||||
String? messageTag,
|
||||
String? tempEventId,
|
||||
}) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:fluffychat/pangea/choreographer/models/language_detection_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/language_detection_model.dart';
|
||||
|
||||
class LanguageKeys {
|
||||
static const unknownLanguage = "unk";
|
||||
|
|
@ -12,7 +12,7 @@ class PrefKey {
|
|||
static const languagesKey = 'p_lang_flag';
|
||||
}
|
||||
|
||||
const LanguageDetection unknownLanguageDetection = LanguageDetection(
|
||||
const LanguageDetectionModel unknownLanguageDetection = LanguageDetectionModel(
|
||||
langCode: LanguageKeys.unknownLanguage,
|
||||
confidence: 0.5,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_style.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/card_header.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/card_header.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LanguageMismatchPopup extends StatelessWidget {
|
||||
final Future<void> Function() onConfirm;
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_style.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/card_header.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/overlay.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/card_header.dart';
|
||||
import 'package:fluffychat/pangea/subscription/repo/subscription_management_repo.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PaywallCard extends StatelessWidget {
|
||||
const PaywallCard({super.key});
|
||||
|
|
@ -2,29 +2,26 @@ import 'dart:async';
|
|||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter_tts/flutter_tts.dart' as flutter_tts;
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pages/chat/events/audio_player.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_style.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/card_header.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart'
|
||||
as error_handler;
|
||||
import 'package:fluffychat/pangea/common/utils/overlay.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/card_header.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_text_model.dart';
|
||||
import 'package:fluffychat/pangea/instructions/instructions_enum.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/controllers/text_to_speech_controller.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart'
|
||||
as error_handler;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_tts/flutter_tts.dart' as flutter_tts;
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
class TtsController {
|
||||
static List<String> _availableLangCodes = [];
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/analytics_details_popup/morph_meaning_widget.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/construct_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/choice_animation.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/choice_animation.dart';
|
||||
import 'package:fluffychat/pangea/constructs/construct_form.dart';
|
||||
import 'package:fluffychat/pangea/constructs/construct_identifier.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
|
|
@ -15,6 +12,7 @@ import 'package:fluffychat/pangea/practice_activities/practice_activity_model.da
|
|||
import 'package:fluffychat/pangea/practice_activities/practice_choice.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/message_morph_choice_item.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// this widget will handle the content of the input bar when mode == MessageMode.wordMorph
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/choice_animation.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/choice_animation.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/activity_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/practice_activity_model.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/practice_choice.dart';
|
||||
|
|
@ -14,6 +10,8 @@ import 'package:fluffychat/pangea/toolbar/enums/message_mode_enum.dart';
|
|||
import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/practice_match_item.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_audio_card.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MatchActivityCard extends StatelessWidget {
|
||||
final PracticeActivityModel currentActivity;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/put_analytics_controller.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/choice_array.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/choice_array.dart';
|
||||
import 'package:fluffychat/pangea/morphs/get_grammar_copy.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/activity_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/practice_activity_model.dart';
|
||||
|
|
@ -16,6 +13,8 @@ import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart
|
|||
import 'package:fluffychat/pangea/toolbar/widgets/practice_activity/practice_activity_card.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/practice_activity/word_audio_button.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The multiple choice activity view
|
||||
class MultipleChoiceActivity extends StatefulWidget {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/constructs_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/card_error_widget.dart';
|
||||
import 'package:fluffychat/pangea/common/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/card_error_widget.dart';
|
||||
import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/activity_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/message_activity_request.dart';
|
||||
|
|
@ -24,6 +21,8 @@ import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart
|
|||
import 'package:fluffychat/pangea/toolbar/widgets/practice_activity/multiple_choice_activity.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/toolbar_content_loading_indicator.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The wrapper for practice activity content.
|
||||
/// Handles the activities associated with a message,
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ import 'dart:async';
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/pangea/translation/full_text_translation_response_model.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_request_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_response_model.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import '../../common/config/environment.dart';
|
||||
import '../../common/network/requests.dart';
|
||||
import '../../common/network/urls.dart';
|
||||
import '../common/config/environment.dart';
|
||||
import '../common/network/requests.dart';
|
||||
import '../common/network/urls.dart';
|
||||
|
||||
class _TranslateCacheItem {
|
||||
final Future<FullTextTranslationResponseModel> response;
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
import 'package:fluffychat/pangea/choreographer/choreo_edit_model.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/choreo_record_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_edit.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/models/choreo_record.dart';
|
||||
|
||||
void main() async {
|
||||
group("Optimized choreo record tests", () {
|
||||
test("Test that choreo_edit parameters are accurately calculated", () {
|
||||
const String originalText = "Parameter";
|
||||
const String editedText = "Perrimeter";
|
||||
|
||||
final ChoreoEdit edits = ChoreoEdit.fromText(
|
||||
final ChoreoEditModel edits = ChoreoEditModel.fromText(
|
||||
originalText: originalText,
|
||||
editedText: editedText,
|
||||
);
|
||||
|
|
@ -23,7 +22,7 @@ void main() async {
|
|||
const String originalText = "step";
|
||||
const String editedText = "steps";
|
||||
|
||||
final ChoreoEdit edits = ChoreoEdit.fromText(
|
||||
final ChoreoEditModel edits = ChoreoEditModel.fromText(
|
||||
originalText: originalText,
|
||||
editedText: editedText,
|
||||
);
|
||||
|
|
@ -41,7 +40,7 @@ void main() async {
|
|||
steps.add("");
|
||||
steps.add("Si");
|
||||
|
||||
final record = ChoreoRecord(
|
||||
final record = ChoreoRecordModel(
|
||||
originalText: "Yes",
|
||||
choreoSteps: [],
|
||||
openMatches: [],
|
||||
|
|
@ -64,7 +63,7 @@ void main() async {
|
|||
steps.add("");
|
||||
steps.add("Si");
|
||||
|
||||
final record = ChoreoRecord(
|
||||
final record = ChoreoRecordModel(
|
||||
originalText: "Yes",
|
||||
choreoSteps: [],
|
||||
openMatches: [],
|
||||
|
|
@ -75,7 +74,7 @@ void main() async {
|
|||
}
|
||||
|
||||
final json = record.toJson();
|
||||
final received = ChoreoRecord.fromJson(json);
|
||||
final received = ChoreoRecordModel.fromJson(json);
|
||||
|
||||
assert(
|
||||
received.choreoSteps[0].edits != null &&
|
||||
|
|
@ -94,7 +93,7 @@ void main() async {
|
|||
steps.add("Cinco");
|
||||
steps.add("Cincai");
|
||||
|
||||
final record = ChoreoRecord(
|
||||
final record = ChoreoRecordModel(
|
||||
originalText: "One",
|
||||
choreoSteps: [],
|
||||
openMatches: [],
|
||||
|
|
@ -105,7 +104,7 @@ void main() async {
|
|||
}
|
||||
|
||||
final json = record.toJson();
|
||||
final received = ChoreoRecord.fromJson(json);
|
||||
final received = ChoreoRecordModel.fromJson(json);
|
||||
|
||||
// Initial step and steps following empty strings
|
||||
// will have text instead of edits
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue