move language settings getter into user controller
This commit is contained in:
parent
97bfdb2603
commit
16fe7f28e3
67 changed files with 243 additions and 396 deletions
|
|
@ -59,6 +59,7 @@ 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/controllers/language_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/repo/language_mismatch_repo.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/widgets/p_language_dialog.dart';
|
||||
import 'package:fluffychat/pangea/message_token_text/tokens_util.dart';
|
||||
|
|
@ -532,7 +533,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
if (!mounted) return;
|
||||
pangeaController.languageController.showDialogOnEmptyLanguage(
|
||||
LanguageController.showDialogOnEmptyLanguage(
|
||||
context,
|
||||
() => () => setState(() {}),
|
||||
);
|
||||
|
|
@ -1153,8 +1154,8 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
'waveform': result.waveform,
|
||||
},
|
||||
// #Pangea
|
||||
'speaker_l1': pangeaController.languageController.activeL1Code(),
|
||||
'speaker_l2': pangeaController.languageController.activeL2Code(),
|
||||
'speaker_l1': pangeaController.userController.userL1Code,
|
||||
'speaker_l2': pangeaController.userController.userL2Code,
|
||||
// Pangea#
|
||||
},
|
||||
// #Pangea
|
||||
|
|
@ -1990,7 +1991,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
}
|
||||
|
||||
// Check if the user has set their languages. If not, prompt them to do so.
|
||||
if (!MatrixState.pangeaController.languageController.languagesSet) {
|
||||
if (!MatrixState.pangeaController.userController.languagesSet) {
|
||||
pLanguageDialog(context, () {});
|
||||
return;
|
||||
}
|
||||
|
|
@ -2150,9 +2151,9 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
);
|
||||
|
||||
final stt = await messageEvent.requestSpeechToText(
|
||||
MatrixState.pangeaController.languageController.userL1?.langCodeShort ??
|
||||
MatrixState.pangeaController.userController.userL1?.langCodeShort ??
|
||||
LanguageKeys.unknownLanguage,
|
||||
MatrixState.pangeaController.languageController.userL2?.langCodeShort ??
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort ??
|
||||
LanguageKeys.unknownLanguage,
|
||||
);
|
||||
if (stt.transcript.sttTokens.isEmpty) return;
|
||||
|
|
|
|||
|
|
@ -401,11 +401,10 @@ class InputBar extends StatelessWidget {
|
|||
MatrixState.pangeaController.subscriptionController.subscriptionStatus;
|
||||
|
||||
String _defaultHintText(BuildContext context) {
|
||||
final lang = MatrixState.pangeaController.languageController;
|
||||
return lang.languagesSet
|
||||
return MatrixState.pangeaController.userController.languagesSet
|
||||
? L10n.of(context).writeAMessageLangCodes(
|
||||
lang.userL1!.displayName,
|
||||
lang.userL2!.displayName,
|
||||
MatrixState.pangeaController.userController.userL1!.displayName,
|
||||
MatrixState.pangeaController.userController.userL2!.displayName,
|
||||
)
|
||||
: L10n.of(context).writeAMessage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import '../../widgets/matrix.dart';
|
|||
import 'package:fluffychat/utils/tor_stub.dart'
|
||||
if (dart.library.html) 'package:tor_detector_web/tor_detector_web.dart';
|
||||
|
||||
|
||||
enum PopupMenuAction {
|
||||
settings,
|
||||
invite,
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@
|
|||
// super.initState();
|
||||
|
||||
// selectedLanguageOfInstructions =
|
||||
// MatrixState.pangeaController.languageController.userL1?.langCode;
|
||||
// MatrixState.pangeaController.userController.userL1?.langCode;
|
||||
// selectedTargetLanguage =
|
||||
// MatrixState.pangeaController.languageController.userL2?.langCode;
|
||||
// MatrixState.pangeaController.userController.userL2?.langCode;
|
||||
// selectedCefrLevel = LanguageLevelTypeEnum.a1;
|
||||
// selectedNumberOfParticipants = 3;
|
||||
// _setMode();
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
|
||||
// ActivitySettingRequestSchema get req => ActivitySettingRequestSchema(
|
||||
// langCode:
|
||||
// MatrixState.pangeaController.languageController.userL1?.langCode ??
|
||||
// MatrixState.pangeaController.userController.userL1?.langCode ??
|
||||
// LanguageKeys.defaultLanguage,
|
||||
// );
|
||||
|
||||
|
|
@ -139,9 +139,9 @@
|
|||
// modeController.clear();
|
||||
// selectedMedia = MediaEnum.nan;
|
||||
// selectedLanguageOfInstructions =
|
||||
// MatrixState.pangeaController.languageController.userL1?.langCode;
|
||||
// MatrixState.pangeaController.userController.userL1?.langCode;
|
||||
// selectedTargetLanguage =
|
||||
// MatrixState.pangeaController.languageController.userL2?.langCode;
|
||||
// MatrixState.pangeaController.userController.userL2?.langCode;
|
||||
// selectedCefrLevel = LanguageLevelTypeEnum.a1;
|
||||
// selectedNumberOfParticipants = 3;
|
||||
// });
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@
|
|||
// controller.selectedLanguageOfInstructions!,
|
||||
// )
|
||||
// : MatrixState
|
||||
// .pangeaController.languageController.userL1,
|
||||
// .pangeaController.userController.userL1,
|
||||
// isL2List: false,
|
||||
// decorationText:
|
||||
// L10n.of(context).languageOfInstructionsLabel,
|
||||
|
|
@ -174,7 +174,7 @@
|
|||
// controller.selectedTargetLanguage!,
|
||||
// )
|
||||
// : MatrixState
|
||||
// .pangeaController.languageController.userL2,
|
||||
// .pangeaController.userController.userL2,
|
||||
// decorationText: L10n.of(context).targetLanguageLabel,
|
||||
// isL2List: true,
|
||||
// ),
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ extension ActivityMenuLogic on ChatController {
|
|||
}
|
||||
|
||||
final l1 =
|
||||
MatrixState.pangeaController.languageController.userL1?.langCodeShort;
|
||||
MatrixState.pangeaController.userController.userL1?.langCodeShort;
|
||||
final l2 =
|
||||
MatrixState.pangeaController.languageController.userL2?.langCodeShort;
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort;
|
||||
final activityLang = room.activityPlan?.req.targetLanguage.split('-').first;
|
||||
|
||||
return activityLang != null &&
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ class ActivitySessionStartController extends State<ActivitySessionStartPage>
|
|||
final activitiesResponse = await CourseActivityRepo.get(
|
||||
TranslateActivityRequest(
|
||||
activityIds: [widget.activityId],
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
widget.activityId,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -106,10 +106,10 @@ class ActivitySessionStartView extends StatelessWidget {
|
|||
activityId: controller.widget.activityId,
|
||||
feedbackText: feedback,
|
||||
userId: Matrix.of(context).client.userID!,
|
||||
userL1: MatrixState.pangeaController.languageController
|
||||
.activeL1Code()!,
|
||||
userL2: MatrixState.pangeaController.languageController
|
||||
.activeL2Code()!,
|
||||
userL1: MatrixState
|
||||
.pangeaController.userController.userL1Code!,
|
||||
userL2: MatrixState
|
||||
.pangeaController.userController.userL2Code!,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -120,8 +120,7 @@ class ActivitySessionStartView extends StatelessWidget {
|
|||
|
||||
CourseActivityRepo.setSentFeedback(
|
||||
controller.widget.activityId,
|
||||
MatrixState.pangeaController.languageController
|
||||
.activeL1Code()!,
|
||||
MatrixState.pangeaController.userController.userL1Code!,
|
||||
);
|
||||
|
||||
await showDialog(
|
||||
|
|
|
|||
|
|
@ -75,10 +75,10 @@
|
|||
// double get cardWidth => _isColumnMode ? 225.0 : 150.0;
|
||||
|
||||
// String get instructionLanguage =>
|
||||
// MatrixState.pangeaController.languageController.userL1?.langCode ??
|
||||
// MatrixState.pangeaController.userController.userL1?.langCode ??
|
||||
// LanguageKeys.defaultLanguage;
|
||||
// String get targetLanguage =>
|
||||
// MatrixState.pangeaController.languageController.userL2?.langCode ??
|
||||
// MatrixState.pangeaController.userController.userL2?.langCode ??
|
||||
// LanguageKeys.defaultLanguage;
|
||||
|
||||
// ActivityPlanRequest get _request {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class ConstructAnalyticsViewState extends State<ConstructAnalyticsView> {
|
|||
ErrorHandler.logError(
|
||||
e: e,
|
||||
s: s,
|
||||
data: {"l2": MatrixState.pangeaController.languageController.userL2},
|
||||
data: {"l2": MatrixState.pangeaController.userController.userL2},
|
||||
);
|
||||
} finally {
|
||||
features.sort(
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class VocabDetailsView extends StatelessWidget {
|
|||
|
||||
/// Get the language code for the current lemma
|
||||
String? get _userL2 =>
|
||||
MatrixState.pangeaController.languageController.userL2?.langCode;
|
||||
MatrixState.pangeaController.userController.userL2?.langCode;
|
||||
|
||||
List<String> get forms =>
|
||||
MatrixState.pangeaController.getAnalytics.constructListModel
|
||||
|
|
@ -69,14 +69,13 @@ class VocabDetailsView extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
),
|
||||
if (MatrixState
|
||||
.pangeaController.languageController.showTranscription)
|
||||
if (MatrixState.pangeaController.userController.showTranscription)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: PhoneticTranscriptionWidget(
|
||||
text: _construct.lemma,
|
||||
textLanguage:
|
||||
MatrixState.pangeaController.languageController.userL2!,
|
||||
MatrixState.pangeaController.userController.userL2!,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: textColor.withAlpha((0.7 * 255).toInt()),
|
||||
fontSize: 18,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ extension AnalyticsClientExtension on Client {
|
|||
/// optional userId (if not specified, uses current user).
|
||||
/// If user is invited to the room, joins the room.
|
||||
Room? analyticsRoomLocal([LanguageModel? lang, String? userIdParam]) {
|
||||
lang ??= MatrixState.pangeaController.languageController.userL2;
|
||||
lang ??= MatrixState.pangeaController.userController.userL2;
|
||||
|
||||
if (lang == null) {
|
||||
debugger(when: kDebugMode);
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ class GetAnalyticsController extends BaseController {
|
|||
_pangeaController = pangeaController;
|
||||
}
|
||||
|
||||
LanguageModel? get _l1 => _pangeaController.languageController.userL1;
|
||||
LanguageModel? get _l2 => _pangeaController.languageController.userL2;
|
||||
LanguageModel? get _l1 => _pangeaController.userController.userL1;
|
||||
LanguageModel? get _l2 => _pangeaController.userController.userL2;
|
||||
|
||||
Client get _client => _pangeaController.matrixState.client;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class LevelUpManager {
|
|||
.numConstructs(ConstructTypeEnum.vocab);
|
||||
|
||||
final LanguageModel? l2 =
|
||||
MatrixState.pangeaController.languageController.userL2;
|
||||
MatrixState.pangeaController.userController.userL2;
|
||||
final Room? analyticsRoom =
|
||||
MatrixState.pangeaController.matrixState.client.analyticsRoomLocal(l2!);
|
||||
|
||||
|
|
|
|||
|
|
@ -107,10 +107,9 @@ class _LevelUpPopupContentState extends State<LevelUpPopupContent>
|
|||
Uri? avatarUrl;
|
||||
final bool _hasBlastedConfetti = false;
|
||||
|
||||
String language = MatrixState.pangeaController.languageController
|
||||
.activeL2Code()
|
||||
?.toUpperCase() ??
|
||||
LanguageKeys.unknownLanguage;
|
||||
String language =
|
||||
MatrixState.pangeaController.userController.userL2Code?.toUpperCase() ??
|
||||
LanguageKeys.unknownLanguage;
|
||||
|
||||
ConstructSummary? _constructSummary;
|
||||
Object? _error;
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ class PutAnalyticsController extends BaseController<AnalyticsStream> {
|
|||
if (cachedConstructs.isEmpty || onlyDraft) return;
|
||||
|
||||
// if missing important info, don't send analytics. Could happen if user just signed up.
|
||||
final l2 = l2Override ?? _pangeaController.languageController.userL2;
|
||||
final l2 = l2Override ?? _pangeaController.userController.userL2;
|
||||
if (l2 == null || _client.userID == null) return;
|
||||
|
||||
// analytics room for the user and current target language
|
||||
|
|
@ -418,10 +418,10 @@ class PutAnalyticsController extends BaseController<AnalyticsStream> {
|
|||
|
||||
Future<void> sendActivityAnalytics(String roomId) async {
|
||||
if (_pangeaController.matrixState.client.userID == null) return;
|
||||
if (_pangeaController.languageController.userL2 == null) return;
|
||||
if (_pangeaController.userController.userL2 == null) return;
|
||||
|
||||
final Room? analyticsRoom = await _client.getMyAnalyticsRoom(
|
||||
_pangeaController.languageController.userL2!,
|
||||
_pangeaController.userController.userL2!,
|
||||
);
|
||||
if (analyticsRoom == null) return;
|
||||
await analyticsRoom.addActivityRoomId(roomId);
|
||||
|
|
@ -436,10 +436,10 @@ class PutAnalyticsController extends BaseController<AnalyticsStream> {
|
|||
|
||||
Future<void> removeActivityAnalytics(String roomId) async {
|
||||
if (_pangeaController.matrixState.client.userID == null) return;
|
||||
if (_pangeaController.languageController.userL2 == null) return;
|
||||
if (_pangeaController.userController.userL2 == null) return;
|
||||
|
||||
final Room? analyticsRoom = await _client.getMyAnalyticsRoom(
|
||||
_pangeaController.languageController.userL2!,
|
||||
_pangeaController.userController.userL2!,
|
||||
);
|
||||
if (analyticsRoom == null) return;
|
||||
await analyticsRoom.removeActivityRoomId(roomId);
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ class LearningProgressIndicatorsState
|
|||
return const SizedBox();
|
||||
}
|
||||
|
||||
final userL1 = MatrixState.pangeaController.languageController.userL1;
|
||||
final userL2 = MatrixState.pangeaController.languageController.userL2;
|
||||
final userL1 = MatrixState.pangeaController.userController.userL1;
|
||||
final userL2 = MatrixState.pangeaController.userController.userL2;
|
||||
|
||||
final isColumnMode = FluffyThemes.isColumnMode(context);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ class PangeaChatInputRow extends StatelessWidget {
|
|||
});
|
||||
|
||||
LanguageModel? get activel1 =>
|
||||
controller.pangeaController.languageController.activeL1Model();
|
||||
controller.pangeaController.userController.userL1;
|
||||
LanguageModel? get activel2 =>
|
||||
controller.pangeaController.languageController.activeL2Model();
|
||||
controller.pangeaController.userController.userL2;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class ChatListItemSubtitle extends StatelessWidget {
|
|||
});
|
||||
|
||||
bool _showPangeaContent(Event event) {
|
||||
return MatrixState.pangeaController.languageController.languagesSet &&
|
||||
return MatrixState.pangeaController.userController.languagesSet &&
|
||||
!event.redacted &&
|
||||
event.type == EventTypes.Message &&
|
||||
event.messageType == MessageTypes.Text &&
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ extension BotClientExtension on Client {
|
|||
StateEvent(
|
||||
content: BotOptionsModel(
|
||||
mode: BotMode.directChat,
|
||||
targetLanguage: MatrixState
|
||||
.pangeaController.languageController.userL2?.langCode,
|
||||
targetLanguage:
|
||||
MatrixState.pangeaController.userController.userL2?.langCode,
|
||||
languageLevel: MatrixState.pangeaController.userController.profile
|
||||
.userSettings.cefrLevel,
|
||||
).toJson(),
|
||||
|
|
|
|||
|
|
@ -223,8 +223,8 @@ class Choreographer extends ChangeNotifier {
|
|||
MatrixState.pangeaController.subscriptionController.subscriptionStatus;
|
||||
|
||||
if (canSendStatus != SubscriptionStatus.subscribed ||
|
||||
MatrixState.pangeaController.languageController.userL2 == null ||
|
||||
MatrixState.pangeaController.languageController.userL1 == null ||
|
||||
MatrixState.pangeaController.userController.userL2 == null ||
|
||||
MatrixState.pangeaController.userController.userL1 == null ||
|
||||
(!ToolSetting.interactiveGrammar.enabled &&
|
||||
!ToolSetting.interactiveTranslator.enabled) ||
|
||||
(!ToolSetting.autoIGC.enabled &&
|
||||
|
|
@ -261,9 +261,9 @@ class Choreographer extends ChangeNotifier {
|
|||
Future<PangeaMessageContentModel> getMessageContent(String message) async {
|
||||
TokensResponseModel? tokensResp;
|
||||
final l2LangCode =
|
||||
MatrixState.pangeaController.languageController.userL2?.langCode;
|
||||
MatrixState.pangeaController.userController.userL2?.langCode;
|
||||
final l1LangCode =
|
||||
MatrixState.pangeaController.languageController.userL1?.langCode;
|
||||
MatrixState.pangeaController.userController.userL1?.langCode;
|
||||
if (l1LangCode != null && l2LangCode != null) {
|
||||
final res = await TokensRepo.get(
|
||||
MatrixState.pangeaController.userController.accessToken,
|
||||
|
|
|
|||
|
|
@ -69,16 +69,16 @@ class IgcController {
|
|||
IGCRequestModel(
|
||||
fullText: text,
|
||||
userId: MatrixState.pangeaController.userController.userId!,
|
||||
userL1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
userL2: MatrixState.pangeaController.languageController.activeL2Code()!,
|
||||
userL1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
userL2: MatrixState.pangeaController.userController.userL2Code!,
|
||||
enableIGC: true,
|
||||
enableIT: true,
|
||||
prevMessages: prevMessages,
|
||||
);
|
||||
|
||||
SpanDetailsRequest _spanDetailsRequest(SpanData span) => SpanDetailsRequest(
|
||||
userL1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
userL2: MatrixState.pangeaController.languageController.activeL2Code()!,
|
||||
userL1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
userL2: MatrixState.pangeaController.userController.userL2Code!,
|
||||
enableIGC: true,
|
||||
enableIT: true,
|
||||
span: span,
|
||||
|
|
|
|||
|
|
@ -177,8 +177,7 @@ class SpanCardState extends State<SpanCard> {
|
|||
widget.match.updatedMatch.match.selectedChoiceIndex,
|
||||
id: widget.match.hashCode.toString(),
|
||||
langCode: MatrixState
|
||||
.pangeaController.languageController
|
||||
.activeL2Code(),
|
||||
.pangeaController.userController.userL2Code!,
|
||||
),
|
||||
_SpanCardFeedback(
|
||||
_selectedChoice != null,
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class SpanData {
|
|||
final errorSpan = fullText.characters.skip(offset).take(length).toString();
|
||||
|
||||
final l2Code =
|
||||
MatrixState.pangeaController.languageController.userL2?.langCodeShort;
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort;
|
||||
|
||||
return correctChoice != null &&
|
||||
l2Code != null &&
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ extension SpanDataTypeEnumExt on SpanDataTypeEnum {
|
|||
return L10n.of(context).correctionDefaultPrompt;
|
||||
case SpanDataTypeEnum.itStart:
|
||||
return L10n.of(context).needsItMessage(
|
||||
MatrixState.pangeaController.languageController.userL2
|
||||
MatrixState.pangeaController.userController.userL2
|
||||
?.getDisplayName(context) ??
|
||||
L10n.of(context).targetLanguage,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -62,12 +62,9 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
|||
FullTextTranslationRequestModel _translationRequest(String text) =>
|
||||
FullTextTranslationRequestModel(
|
||||
text: text,
|
||||
tgtLang:
|
||||
MatrixState.pangeaController.languageController.userL1!.langCode,
|
||||
userL1:
|
||||
MatrixState.pangeaController.languageController.userL1!.langCode,
|
||||
userL2:
|
||||
MatrixState.pangeaController.languageController.userL2!.langCode,
|
||||
tgtLang: MatrixState.pangeaController.userController.userL1!.langCode,
|
||||
userL1: MatrixState.pangeaController.userController.userL1!.langCode,
|
||||
userL2: MatrixState.pangeaController.userController.userL2!.langCode,
|
||||
);
|
||||
|
||||
void _openListener() {
|
||||
|
|
@ -105,8 +102,8 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
|||
cardToShow: selected
|
||||
? WordDataCard(
|
||||
word: text,
|
||||
langCode: MatrixState
|
||||
.pangeaController.languageController.userL2!.langCode,
|
||||
langCode:
|
||||
MatrixState.pangeaController.userController.userL2!.langCode,
|
||||
fullText: _sourceText.value ?? widget.choreographer.currentText,
|
||||
)
|
||||
: ITFeedbackCard(_translationRequest(text)),
|
||||
|
|
@ -394,7 +391,7 @@ class _ITChoices extends StatelessWidget {
|
|||
onPressed: (value, index) => onPressed(index),
|
||||
onLongPress: (value, index) => onLongPressed(continuances[index]),
|
||||
selectedChoiceIndex: null,
|
||||
langCode: MatrixState.pangeaController.languageController.activeL2Code(),
|
||||
langCode: MatrixState.pangeaController.userController.userL2Code!,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,8 @@ class ITController {
|
|||
return ITRequestModel(
|
||||
text: _sourceText.value!,
|
||||
customInput: textInput,
|
||||
sourceLangCode:
|
||||
MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
targetLangCode:
|
||||
MatrixState.pangeaController.languageController.activeL2Code()!,
|
||||
sourceLangCode: MatrixState.pangeaController.userController.userL1Code!,
|
||||
targetLangCode: MatrixState.pangeaController.userController.userL2Code!,
|
||||
goldTranslation: _goldRouteTracker?.fullTranslation,
|
||||
goldContinuances: _goldRouteTracker?.continuances,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@ class WordDataCard extends StatelessWidget {
|
|||
word: word,
|
||||
fullTextLang: langCode,
|
||||
wordLang: langCode,
|
||||
feedbackLang:
|
||||
MatrixState.pangeaController.languageController.activeL1Code() ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
feedbackLang: MatrixState.pangeaController.userController.userL1Code ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
);
|
||||
|
||||
Future<Result<String>> _fetchDefinition() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
|
@ -17,12 +16,10 @@ import 'package:fluffychat/pangea/chat_settings/utils/bot_client_extension.dart'
|
|||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/guard/p_vguard.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/controllers/language_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/utils/locale_provider.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/utils/p_language_store.dart';
|
||||
import 'package:fluffychat/pangea/subscription/controllers/subscription_controller.dart';
|
||||
import 'package:fluffychat/pangea/text_to_speech/tts_controller.dart';
|
||||
import 'package:fluffychat/pangea/user/controllers/permissions_controller.dart';
|
||||
import 'package:fluffychat/pangea/user/controllers/user_controller.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../utils/firebase_analytics.dart';
|
||||
|
|
@ -30,8 +27,6 @@ import '../utils/firebase_analytics.dart';
|
|||
class PangeaController {
|
||||
///pangeaControllers
|
||||
late UserController userController;
|
||||
late LanguageController languageController;
|
||||
late PermissionsController permissionsController;
|
||||
late GetAnalyticsController getAnalytics;
|
||||
late PutAnalyticsController putAnalytics;
|
||||
late SubscriptionController subscriptionController;
|
||||
|
|
@ -46,16 +41,13 @@ class PangeaController {
|
|||
MatrixState matrixState;
|
||||
Matrix matrix;
|
||||
|
||||
int? randomint;
|
||||
PangeaController({required this.matrix, required this.matrixState}) {
|
||||
_setup();
|
||||
userController = UserController(this);
|
||||
getAnalytics = GetAnalyticsController(this);
|
||||
putAnalytics = PutAnalyticsController(this);
|
||||
subscriptionController = SubscriptionController(this);
|
||||
PAuthGaurd.pController = this;
|
||||
_setSettingsSubscriptions();
|
||||
randomint = Random().nextInt(2000);
|
||||
}
|
||||
|
||||
/// Pangea Initialization
|
||||
void _setup() {
|
||||
_addRefInObjects();
|
||||
}
|
||||
|
||||
/// Initializes various controllers and settings.
|
||||
|
|
@ -69,18 +61,7 @@ class PangeaController {
|
|||
TtsController.setAvailableLanguages();
|
||||
}
|
||||
|
||||
/// Initialize controllers
|
||||
_addRefInObjects() {
|
||||
userController = UserController(this);
|
||||
languageController = LanguageController(this);
|
||||
permissionsController = PermissionsController(this);
|
||||
getAnalytics = GetAnalyticsController(this);
|
||||
putAnalytics = PutAnalyticsController(this);
|
||||
subscriptionController = SubscriptionController(this);
|
||||
PAuthGaurd.pController = this;
|
||||
}
|
||||
|
||||
_logOutfromPangea(BuildContext context) {
|
||||
void _logOutfromPangea(BuildContext context) {
|
||||
debugPrint("Pangea logout");
|
||||
GoogleAnalytics.logout();
|
||||
clearCache();
|
||||
|
|
@ -243,7 +224,7 @@ class PangeaController {
|
|||
return;
|
||||
}
|
||||
|
||||
final targetLanguage = languageController.userL2?.langCode;
|
||||
final targetLanguage = userController.userL2?.langCode;
|
||||
final cefrLevel = userController.profile.userSettings.cefrLevel;
|
||||
final updateBotOptions = botDM.botOptions ?? BotOptionsModel();
|
||||
|
||||
|
|
|
|||
|
|
@ -152,12 +152,12 @@ class ConstructIdentifier {
|
|||
|
||||
LemmaInfoRequest get _lemmaInfoRequest => LemmaInfoRequest(
|
||||
partOfSpeech: category,
|
||||
lemmaLang: MatrixState
|
||||
.pangeaController.languageController.userL2?.langCodeShort ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
userL1: MatrixState
|
||||
.pangeaController.languageController.userL1?.langCodeShort ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
lemmaLang:
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
userL1:
|
||||
MatrixState.pangeaController.userController.userL1?.langCodeShort ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
lemma: lemma,
|
||||
);
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ class ConstructIdentifier {
|
|||
|
||||
Future<void> setUserLemmaInfo(UserSetLemmaInfo newLemmaInfo) async {
|
||||
final client = MatrixState.pangeaController.matrixState.client;
|
||||
final l2 = MatrixState.pangeaController.languageController.userL2;
|
||||
final l2 = MatrixState.pangeaController.userController.userL2;
|
||||
if (l2 == null) return;
|
||||
|
||||
final analyticsRoom = await client.getMyAnalyticsRoom(l2);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class CourseTopicModel {
|
|||
CourseActivityRepo.getCached(
|
||||
TranslateActivityRequest(
|
||||
activityIds: activityIds,
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
).plans;
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ class CourseTopicModel {
|
|||
final resp = await CourseActivityRepo.get(
|
||||
TranslateActivityRequest(
|
||||
activityIds: activityIds,
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
uuid,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ mixin CoursePlanProvider<T extends StatefulWidget> on State<T> {
|
|||
course = await CoursePlansRepo.get(
|
||||
GetLocalizedCoursesRequest(
|
||||
coursePlanIds: [courseId],
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class CoursePlanModel {
|
|||
Map<String, CourseTopicModel> get loadedTopics => CourseTopicRepo.getCached(
|
||||
TranslateTopicRequest(
|
||||
topicIds: topicIds,
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
).topics;
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ class CoursePlanModel {
|
|||
final resp = await CourseTopicRepo.get(
|
||||
TranslateTopicRequest(
|
||||
topicIds: topicIds,
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
uuid,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ class CoursePlansRepo {
|
|||
return search(
|
||||
GetLocalizedCoursesRequest(
|
||||
coursePlanIds: result.docs,
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,10 @@ class PangeaMessageEvent {
|
|||
|
||||
bool get isAudioMessage => _event.messageType == MessageTypes.Audio;
|
||||
|
||||
String? get _l2Code =>
|
||||
MatrixState.pangeaController.languageController.activeL2Code();
|
||||
String? get _l2Code => MatrixState.pangeaController.userController.userL2Code;
|
||||
|
||||
String? get _l1Code =>
|
||||
MatrixState.pangeaController.languageController.userL1?.langCode;
|
||||
MatrixState.pangeaController.userController.userL1?.langCode;
|
||||
|
||||
Event? _latestEditCache;
|
||||
Event get _latestEdit => _latestEditCache ??= _event
|
||||
|
|
@ -255,8 +254,7 @@ class PangeaMessageEvent {
|
|||
return stt.langCode;
|
||||
}
|
||||
|
||||
final bool immersionMode = MatrixState
|
||||
.pangeaController.permissionsController
|
||||
final bool immersionMode = MatrixState.pangeaController.userController
|
||||
.isToolEnabled(ToolSetting.immersionMode);
|
||||
|
||||
final String? originalLangCode = originalSent?.langCode;
|
||||
|
|
|
|||
|
|
@ -228,10 +228,10 @@ class RepresentationEvent {
|
|||
fullText: text,
|
||||
langCode: langCode,
|
||||
senderL1:
|
||||
MatrixState.pangeaController.languageController.userL1?.langCode ??
|
||||
MatrixState.pangeaController.userController.userL1?.langCode ??
|
||||
LanguageKeys.unknownLanguage,
|
||||
senderL2:
|
||||
MatrixState.pangeaController.languageController.userL2?.langCode ??
|
||||
MatrixState.pangeaController.userController.userL2?.langCode ??
|
||||
LanguageKeys.unknownLanguage,
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class PangeaRepresentation {
|
|||
|
||||
bool get langCodeMatchesL2 =>
|
||||
langCode.split("-").first ==
|
||||
MatrixState.pangeaController.languageController.userL2?.langCodeShort;
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort;
|
||||
|
||||
/// Get construct uses for the message that weren't captured during language assistance.
|
||||
/// Takes a list of tokens and a choreo record, which is searched
|
||||
|
|
|
|||
|
|
@ -4,122 +4,24 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import 'package:universal_io/io.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/common/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/utils/p_language_store.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../widgets/p_language_dialog.dart';
|
||||
|
||||
class LanguageController {
|
||||
late PangeaController _pangeaController;
|
||||
|
||||
LanguageController(PangeaController pangeaController) {
|
||||
_pangeaController = pangeaController;
|
||||
}
|
||||
//show diloag when user does not have languages selected
|
||||
showDialogOnEmptyLanguage(BuildContext context, Function callback) {
|
||||
if (!languagesSet) {
|
||||
static void showDialogOnEmptyLanguage(
|
||||
BuildContext context,
|
||||
Function callback,
|
||||
) {
|
||||
if (!MatrixState.pangeaController.userController.languagesSet) {
|
||||
pLanguageDialog(context, callback);
|
||||
}
|
||||
}
|
||||
|
||||
bool get languagesSet =>
|
||||
_userL1Code != null &&
|
||||
_userL2Code != null &&
|
||||
_userL1Code!.isNotEmpty &&
|
||||
_userL2Code!.isNotEmpty &&
|
||||
_userL1Code != LanguageKeys.unknownLanguage &&
|
||||
_userL2Code != LanguageKeys.unknownLanguage;
|
||||
|
||||
LanguageModel? get systemLanguage {
|
||||
static LanguageModel? get systemLanguage {
|
||||
if (Platform.localeName.length < 2) return null;
|
||||
final String systemLang = Platform.localeName.substring(0, 2);
|
||||
return PLanguageStore.byLangCode(systemLang);
|
||||
}
|
||||
|
||||
String? get _userL1Code {
|
||||
final source =
|
||||
_pangeaController.userController.profile.userSettings.sourceLanguage;
|
||||
return source == null || source.isEmpty ? systemLanguage?.langCode : source;
|
||||
}
|
||||
|
||||
String? get _userL2Code {
|
||||
final target =
|
||||
_pangeaController.userController.profile.userSettings.targetLanguage;
|
||||
return target == null || target.isEmpty ? null : target;
|
||||
}
|
||||
|
||||
LanguageModel? get userL1 {
|
||||
if (_userL1Code == null) return null;
|
||||
final langModel = PLanguageStore.byLangCode(_userL1Code!);
|
||||
return langModel?.langCode == LanguageKeys.unknownLanguage
|
||||
? null
|
||||
: langModel;
|
||||
}
|
||||
|
||||
LanguageModel? get userL2 {
|
||||
if (_userL2Code == null) return null;
|
||||
final langModel = PLanguageStore.byLangCode(_userL2Code!);
|
||||
return langModel?.langCode == LanguageKeys.unknownLanguage
|
||||
? null
|
||||
: langModel;
|
||||
}
|
||||
|
||||
String? activeL1Code() {
|
||||
return _userL1Code;
|
||||
// final String? activeL2 = activeL2Code(roomID: roomID);
|
||||
// if (roomID == null || activeL2 != _userL1Code) {
|
||||
// return _userL1Code;
|
||||
// }
|
||||
// final LanguageSettingsModel? classContext = _pangeaController
|
||||
// .matrixState.client
|
||||
// .getRoomById(roomID)
|
||||
// ?.firstLanguageSettings;
|
||||
// final String? classL1 = classContext?.dominantLanguage;
|
||||
// if (classL1 == LanguageKeys.mixedLanguage ||
|
||||
// classL1 == LanguageKeys.multiLanguage ||
|
||||
// classL1 == null) {
|
||||
// if (_userL2Code != _userL1Code) {
|
||||
// return _userL2Code;
|
||||
// }
|
||||
// return LanguageKeys.unknownLanguage;
|
||||
// }
|
||||
// return classL1;
|
||||
}
|
||||
|
||||
/// Class languages override user languages within a class context
|
||||
String? activeL2Code() {
|
||||
return _userL2Code;
|
||||
// if (roomID == null) {
|
||||
// return _userL2Code;
|
||||
// }
|
||||
// final LanguageSettingsModel? classContext = _pangeaController
|
||||
// .matrixState.client
|
||||
// .getRoomById(roomID)
|
||||
// ?.firstLanguageSettings;
|
||||
// return classContext?.targetLanguage ?? _userL2Code;
|
||||
}
|
||||
|
||||
LanguageModel? activeL1Model() {
|
||||
return userL1;
|
||||
// final activeL1 = activeL1Code(roomID: roomID);
|
||||
// return activeL1 != null ? PangeaLanguage.byLangCode(activeL1) : null;
|
||||
}
|
||||
|
||||
LanguageModel? activeL2Model() {
|
||||
return userL2;
|
||||
// final activeL2 = activeL2Code(roomID: roomID);
|
||||
// final model = activeL2 != null ? PangeaLanguage.byLangCode(activeL2) : null;
|
||||
// return model;
|
||||
}
|
||||
|
||||
bool get showTranscription =>
|
||||
(_pangeaController.languageController.userL1 != null &&
|
||||
_pangeaController.languageController.userL2 != null &&
|
||||
_pangeaController.languageController.userL1?.script !=
|
||||
_pangeaController.languageController.userL2?.script) ||
|
||||
(_pangeaController.languageController.userL1?.script !=
|
||||
LanguageKeys.unknownLanguage ||
|
||||
_pangeaController.languageController.userL2?.script ==
|
||||
LanguageKeys.unknownLanguage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,5 +66,5 @@ enum ToolSetting {
|
|||
}
|
||||
|
||||
bool get enabled =>
|
||||
MatrixState.pangeaController.permissionsController.isToolEnabled(this);
|
||||
MatrixState.pangeaController.userController.isToolEnabled(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import 'package:fluffychat/l10n/l10n.dart';
|
|||
import 'package:fluffychat/pangea/common/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/instructions/instruction_settings.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/controllers/language_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/enums/language_level_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/enums/tool_settings_enum.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
|
|
@ -234,8 +235,7 @@ class SettingsLearningController extends State<SettingsLearning> {
|
|||
_profile.userSettings.targetLanguage != null && _targetLanguage != null;
|
||||
|
||||
LanguageModel? get selectedSourceLanguage {
|
||||
return _selectedBaseLanguage ??
|
||||
pangeaController.languageController.systemLanguage;
|
||||
return _selectedBaseLanguage ?? LanguageController.systemLanguage;
|
||||
}
|
||||
|
||||
LanguageModel? get selectedTargetLanguage {
|
||||
|
|
@ -255,8 +255,8 @@ class SettingsLearningController extends State<SettingsLearning> {
|
|||
? PLanguageStore.byLangCode(_profile.userSettings.targetLanguage!)
|
||||
: null;
|
||||
|
||||
LanguageModel? get userL1 => pangeaController.languageController.userL1;
|
||||
LanguageModel? get userL2 => pangeaController.languageController.userL2;
|
||||
LanguageModel? get userL1 => pangeaController.userController.userL1;
|
||||
LanguageModel? get userL2 => pangeaController.userController.userL2;
|
||||
|
||||
bool get publicProfile => _profile.userSettings.publicProfile ?? false;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:fluffychat/l10n/l10n.dart';
|
|||
import 'package:fluffychat/pangea/common/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/controllers/language_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/utils/p_language_store.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
|
|
@ -21,10 +22,9 @@ Future<void> pLanguageDialog(
|
|||
) async {
|
||||
final PangeaController pangeaController = MatrixState.pangeaController;
|
||||
//PTODO: if source language not set by user, default to languge from device settings
|
||||
final LanguageModel? userL1 = pangeaController.languageController.userL1;
|
||||
final LanguageModel? userL2 = pangeaController.languageController.userL2;
|
||||
final LanguageModel? systemLanguage =
|
||||
pangeaController.languageController.systemLanguage;
|
||||
final LanguageModel? userL1 = pangeaController.userController.userL1;
|
||||
final LanguageModel? userL2 = pangeaController.userController.userL2;
|
||||
final LanguageModel? systemLanguage = LanguageController.systemLanguage;
|
||||
|
||||
LanguageModel? selectedSourceLanguage = systemLanguage;
|
||||
if (userL1 != null && userL1.langCode != LanguageKeys.unknownLanguage) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import 'package:fluffychat/pangea/common/widgets/error_indicator.dart';
|
|||
import 'package:fluffychat/pangea/course_plans/courses/course_plan_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/course_plans/courses/course_plans_repo.dart';
|
||||
import 'package:fluffychat/pangea/course_plans/courses/get_localized_courses_request.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/controllers/language_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/utils/p_language_store.dart';
|
||||
import 'package:fluffychat/pangea/login/utils/lang_code_repo.dart';
|
||||
import 'package:fluffychat/pangea/spaces/space_code_controller.dart';
|
||||
|
|
@ -52,7 +53,7 @@ class CreatePangeaAccountPageState extends State<CreatePangeaAccountPage> {
|
|||
|
||||
Future<String?> get _baseLangCode async =>
|
||||
(await _cachedLangCode)?.baseLangCode ??
|
||||
MatrixState.pangeaController.languageController.systemLanguage?.langCode;
|
||||
LanguageController.systemLanguage?.langCode;
|
||||
|
||||
String? get _cachedSpaceCode => SpaceCodeRepo.spaceCode;
|
||||
|
||||
|
|
@ -99,7 +100,7 @@ class CreatePangeaAccountPageState extends State<CreatePangeaAccountPage> {
|
|||
final course = await CoursePlansRepo.get(
|
||||
GetLocalizedCoursesRequest(
|
||||
coursePlanIds: [courseId],
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -187,8 +188,7 @@ class CreatePangeaAccountPageState extends State<CreatePangeaAccountPage> {
|
|||
if (targetLangCode != null)
|
||||
MatrixState.pangeaController.userController.updateAnalyticsProfile(
|
||||
targetLanguage: PLanguageStore.byLangCode(targetLangCode),
|
||||
baseLanguage:
|
||||
MatrixState.pangeaController.languageController.systemLanguage,
|
||||
baseLanguage: LanguageController.systemLanguage,
|
||||
level: 1,
|
||||
),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
|||
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/controllers/language_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/utils/p_language_store.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/widgets/p_language_dropdown.dart';
|
||||
|
|
@ -30,9 +31,7 @@ class LanguageSelectionPageState extends State<LanguageSelectionPage> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_baseLanguage =
|
||||
MatrixState.pangeaController.languageController.systemLanguage;
|
||||
|
||||
_baseLanguage = LanguageController.systemLanguage;
|
||||
_setFromCache();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class NewCoursePageState extends State<NewCoursePage> {
|
|||
super.initState();
|
||||
|
||||
_targetLanguageFilter.value =
|
||||
MatrixState.pangeaController.languageController.userL2;
|
||||
MatrixState.pangeaController.userController.userL2;
|
||||
|
||||
_loadCourses();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class PublicCoursesPageState extends State<PublicCoursesPage> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
final target = MatrixState.pangeaController.languageController.userL2;
|
||||
final target = MatrixState.pangeaController.userController.userL2;
|
||||
if (target != null) {
|
||||
setTargetLanguageFilter(target);
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ class PublicCoursesPageState extends State<PublicCoursesPage> {
|
|||
GetLocalizedCoursesRequest(
|
||||
coursePlanIds:
|
||||
discoveredCourses.map((c) => c.courseId).toSet().toList(),
|
||||
l1: MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
l1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
),
|
||||
);
|
||||
final searchResult = resp.coursePlans;
|
||||
|
|
|
|||
|
|
@ -100,8 +100,7 @@ class TokenEmojiButtonState extends State<TokenEmojiButton>
|
|||
overlayKey: "overlay_emoji_selector",
|
||||
context: context,
|
||||
cardToShow: LemmaMeaningBuilder(
|
||||
langCode:
|
||||
MatrixState.pangeaController.languageController.activeL2Code()!,
|
||||
langCode: MatrixState.pangeaController.userController.userL2Code!,
|
||||
constructId: widget.token!.vocabConstructID,
|
||||
builder: (context, controller) {
|
||||
return Material(
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class TokensUtil {
|
|||
}
|
||||
|
||||
final messageInUserL2 = event.messageDisplayLangCode.split("-")[0] ==
|
||||
MatrixState.pangeaController.languageController.userL2?.langCodeShort;
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort;
|
||||
|
||||
final cached = _getCachedNewTokens(event.eventId);
|
||||
if (cached != null) {
|
||||
|
|
|
|||
|
|
@ -86,12 +86,10 @@ class MorphInfoRepo {
|
|||
}) async {
|
||||
final res = await _get(
|
||||
MorphInfoRequest(
|
||||
userL1:
|
||||
MatrixState.pangeaController.languageController.userL1?.langCode ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
userL2:
|
||||
MatrixState.pangeaController.languageController.userL2?.langCode ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
userL1: MatrixState.pangeaController.userController.userL1?.langCode ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
userL2: MatrixState.pangeaController.userController.userL2?.langCode ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
),
|
||||
);
|
||||
final morph = res.getFeatureByCode(feature.name);
|
||||
|
|
@ -107,10 +105,10 @@ class MorphInfoRepo {
|
|||
required String defintion,
|
||||
}) async {
|
||||
final userL1 =
|
||||
MatrixState.pangeaController.languageController.userL1?.langCode ??
|
||||
MatrixState.pangeaController.userController.userL1?.langCode ??
|
||||
LanguageKeys.defaultLanguage;
|
||||
final userL2 =
|
||||
MatrixState.pangeaController.languageController.userL2?.langCode ??
|
||||
MatrixState.pangeaController.userController.userL2?.langCode ??
|
||||
LanguageKeys.defaultLanguage;
|
||||
final userL1Short = userL1.split('-').first;
|
||||
final userL2Short = userL2.split('-').first;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class MorphsRepo {
|
|||
/// if not, we can make it async and update uses of this function
|
||||
/// to be async as well
|
||||
static Future<MorphFeaturesAndTags> get([LanguageModel? language]) async {
|
||||
language ??= MatrixState.pangeaController.languageController.userL2;
|
||||
language ??= MatrixState.pangeaController.userController.userL2;
|
||||
|
||||
if (language == null) {
|
||||
return defaultMorphMapping;
|
||||
|
|
@ -111,12 +111,12 @@ class MorphsRepo {
|
|||
}
|
||||
|
||||
static MorphFeaturesAndTags get cached {
|
||||
if (MatrixState.pangeaController.languageController.userL2?.langCodeShort ==
|
||||
if (MatrixState.pangeaController.userController.userL2?.langCodeShort ==
|
||||
null) {
|
||||
return defaultMorphMapping;
|
||||
}
|
||||
final cachedJson = _morphsStorage.read(
|
||||
MatrixState.pangeaController.languageController.userL2!.langCodeShort,
|
||||
MatrixState.pangeaController.userController.userL2!.langCodeShort,
|
||||
);
|
||||
if (cachedJson != null) {
|
||||
return MorphsRepo.fromJson(cachedJson);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class _PhoneticTranscriptionWidgetState
|
|||
_transcription = null;
|
||||
});
|
||||
|
||||
if (MatrixState.pangeaController.languageController.userL1 == null) {
|
||||
if (MatrixState.pangeaController.userController.userL1 == null) {
|
||||
ErrorHandler.logError(
|
||||
e: Exception('User L1 is not set'),
|
||||
data: {
|
||||
|
|
@ -85,7 +85,7 @@ class _PhoneticTranscriptionWidgetState
|
|||
}
|
||||
final req = PhoneticTranscriptionRequest(
|
||||
arc: LanguageArc(
|
||||
l1: MatrixState.pangeaController.languageController.userL1!,
|
||||
l1: MatrixState.pangeaController.userController.userL1!,
|
||||
l2: widget.textLanguage,
|
||||
),
|
||||
content: PangeaTokenText.fromString(widget.text),
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class PracticeSelectionRepo {
|
|||
String messageLanguage,
|
||||
List<PangeaToken> tokens,
|
||||
) {
|
||||
final userL2 = MatrixState.pangeaController.languageController.userL2;
|
||||
final userL2 = MatrixState.pangeaController.userController.userL2;
|
||||
if (userL2?.langCodeShort != messageLanguage.split("-").first) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ class PracticeSelectionRepo {
|
|||
required String langCode,
|
||||
}) {
|
||||
if (langCode.split("-")[0] !=
|
||||
MatrixState.pangeaController.languageController.userL2?.langCodeShort) {
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort) {
|
||||
return PracticeSelection({});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class DownloadAnalyticsDialogState extends State<DownloadAnalyticsDialog> {
|
|||
}
|
||||
|
||||
String? get userL2 =>
|
||||
MatrixState.pangeaController.languageController.userL2?.langCode;
|
||||
MatrixState.pangeaController.userController.userL2?.langCode;
|
||||
|
||||
Future<void> _runDownload() async {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class SpaceAnalyticsState extends State<SpaceAnalytics> {
|
|||
Room? get room => Matrix.of(context).client.getRoomById(widget.roomId);
|
||||
|
||||
LanguageModel? get _userL2 {
|
||||
final l2 = MatrixState.pangeaController.languageController.userL2;
|
||||
final l2 = MatrixState.pangeaController.userController.userL2;
|
||||
if (l2 == null) return null;
|
||||
|
||||
// Attempt to find the language model by its short code, since analytics
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/spaces/space_code_controller.dart';
|
||||
import 'package:fluffychat/pangea/spaces/space_code_repo.dart';
|
||||
|
||||
//if on home with classcode in url and not logged in, then save it soemhow and after llogin, join class automatically
|
||||
//if on home with classcode in url and logged in, then join class automatically
|
||||
|
|
@ -33,7 +33,7 @@ class _JoinClassWithLinkState extends State<JoinClassWithLink> {
|
|||
}
|
||||
|
||||
if (widget.classCode != null) {
|
||||
await SpaceCodeController.cacheSpaceCode(widget.classCode!);
|
||||
await SpaceCodeRepo.setSpaceCode(widget.classCode!);
|
||||
}
|
||||
context.push("/home");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -275,12 +275,10 @@ class TtsController {
|
|||
text: text,
|
||||
langCode: langCode,
|
||||
tokens: tokens,
|
||||
userL1:
|
||||
MatrixState.pangeaController.languageController.activeL1Code() ??
|
||||
LanguageKeys.unknownLanguage,
|
||||
userL2:
|
||||
MatrixState.pangeaController.languageController.activeL2Code() ??
|
||||
LanguageKeys.unknownLanguage,
|
||||
userL1: MatrixState.pangeaController.userController.userL1Code ??
|
||||
LanguageKeys.unknownLanguage,
|
||||
userL2: MatrixState.pangeaController.userController.userL2Code ??
|
||||
LanguageKeys.unknownLanguage,
|
||||
),
|
||||
);
|
||||
loadingChoreoStream.add(false);
|
||||
|
|
|
|||
|
|
@ -135,9 +135,9 @@ class TokenInfoFeedbackDialog extends StatelessWidget {
|
|||
final req = PhoneticTranscriptionRequest(
|
||||
arc: LanguageArc(
|
||||
l1: PLanguageStore.byLangCode(requestData.wordCardL1) ??
|
||||
MatrixState.pangeaController.languageController.userL1!,
|
||||
MatrixState.pangeaController.userController.userL1!,
|
||||
l2: PLanguageStore.byLangCode(langCode) ??
|
||||
MatrixState.pangeaController.languageController.userL2!,
|
||||
MatrixState.pangeaController.userController.userL2!,
|
||||
),
|
||||
content: response.content,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ class PracticeMatchItemState extends State<PracticeMatchItem> {
|
|||
setState(() => _isPlaying = true);
|
||||
}
|
||||
try {
|
||||
final l2 =
|
||||
MatrixState.pangeaController.languageController.activeL2Code();
|
||||
final l2 = MatrixState.pangeaController.userController.userL2Code;
|
||||
if (l2 != null) {
|
||||
await TtsController.tryToSpeak(
|
||||
widget.audioContent!,
|
||||
|
|
|
|||
|
|
@ -494,8 +494,8 @@ class _MessageBubbleTranscription extends StatelessWidget {
|
|||
onClick: onTokenSelected,
|
||||
isSelected: isTokenSelected,
|
||||
),
|
||||
if (MatrixState.pangeaController.languageController
|
||||
.showTranscription)
|
||||
if (MatrixState
|
||||
.pangeaController.userController.showTranscription)
|
||||
PhoneticTranscriptionWidget(
|
||||
text: transcription.transcript.text,
|
||||
textLanguage: PLanguageStore.byLangCode(
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class PracticeActivityCardState extends State<PracticeActivityCard> {
|
|||
|
||||
Future<void> _fetchActivity() async {
|
||||
_activityState.value = const AsyncState.loading();
|
||||
if (!MatrixState.pangeaController.languageController.languagesSet) {
|
||||
if (!MatrixState.pangeaController.userController.languagesSet) {
|
||||
_activityState.value = const AsyncState.error("Error fetching activity");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ class PracticeController with ChangeNotifier {
|
|||
PracticeTarget target,
|
||||
) async {
|
||||
final req = MessageActivityRequest(
|
||||
userL1: MatrixState.pangeaController.languageController.userL1!.langCode,
|
||||
userL2: MatrixState.pangeaController.languageController.userL2!.langCode,
|
||||
userL1: MatrixState.pangeaController.userController.userL1!.langCode,
|
||||
userL2: MatrixState.pangeaController.userController.userL2!.langCode,
|
||||
messageText: pangeaMessageEvent.messageDisplayText,
|
||||
messageTokens:
|
||||
pangeaMessageEvent.messageDisplayRepresentation?.tokens ?? [],
|
||||
|
|
|
|||
|
|
@ -60,8 +60,7 @@ class ReadingAssistanceContent extends StatelessWidget {
|
|||
overlayController.pangeaMessageEvent.messageDisplayLangCode,
|
||||
tokens: tokens ?? [],
|
||||
selectedToken: selectedTokenIndex,
|
||||
wordCardL1:
|
||||
MatrixState.pangeaController.languageController.activeL1Code()!,
|
||||
wordCardL1: MatrixState.pangeaController.userController.userL1Code!,
|
||||
);
|
||||
overlayController.widget.chatController.showTokenFeedbackDialog(
|
||||
requestData,
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ class _TranscriptionLoader extends AsyncLoader<SpeechToTextResponseModel> {
|
|||
|
||||
@override
|
||||
Future<SpeechToTextResponseModel> fetch() => messageEvent.requestSpeechToText(
|
||||
MatrixState.pangeaController.languageController.userL1!.langCodeShort,
|
||||
MatrixState.pangeaController.languageController.userL2!.langCodeShort,
|
||||
MatrixState.pangeaController.userController.userL1!.langCodeShort,
|
||||
MatrixState.pangeaController.userController.userL2!.langCodeShort,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -30,12 +30,12 @@ class _STTTranslationLoader extends AsyncLoader<String> {
|
|||
|
||||
@override
|
||||
Future<String> fetch() => messageEvent.requestSttTranslation(
|
||||
langCode: MatrixState
|
||||
.pangeaController.languageController.userL1!.langCodeShort,
|
||||
l1Code: MatrixState
|
||||
.pangeaController.languageController.userL1!.langCodeShort,
|
||||
l2Code: MatrixState
|
||||
.pangeaController.languageController.userL2!.langCodeShort,
|
||||
langCode:
|
||||
MatrixState.pangeaController.userController.userL1!.langCodeShort,
|
||||
l1Code:
|
||||
MatrixState.pangeaController.userController.userL1!.langCodeShort,
|
||||
l2Code:
|
||||
MatrixState.pangeaController.userController.userL2!.langCodeShort,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ class SelectModeController {
|
|||
|
||||
if (messageEvent.event.messageType == MessageTypes.Text) {
|
||||
final matchesL2 = messageEvent.messageDisplayLangCode.split("-").first ==
|
||||
MatrixState.pangeaController.languageController.userL2!.langCodeShort;
|
||||
MatrixState.pangeaController.userController.userL2!.langCodeShort;
|
||||
|
||||
return matchesL2 ? textModes : [SelectMode.translate];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,9 +50,8 @@ class LemmaMeaningBuilderState extends State<LemmaMeaningBuilder> {
|
|||
lemma: widget.constructId.lemma,
|
||||
partOfSpeech: widget.constructId.category,
|
||||
lemmaLang: widget.langCode,
|
||||
userL1:
|
||||
MatrixState.pangeaController.languageController.userL1?.langCode ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
userL1: MatrixState.pangeaController.userController.userL1?.langCode ??
|
||||
LanguageKeys.defaultLanguage,
|
||||
);
|
||||
|
||||
Future<void> _fetchLemmaMeaning() async {
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ class WordZoomWidget extends StatelessWidget {
|
|||
spacing: 12.0,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (MatrixState.pangeaController
|
||||
.languageController.showTranscription)
|
||||
if (MatrixState.pangeaController.userController
|
||||
.showTranscription)
|
||||
PhoneticTranscriptionWidget(
|
||||
text: token.content,
|
||||
textLanguage: PLanguageStore.byLangCode(
|
||||
|
|
|
|||
|
|
@ -1,78 +0,0 @@
|
|||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/common/controllers/base_controller.dart';
|
||||
import 'package:fluffychat/pangea/common/controllers/pangea_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/enums/tool_settings_enum.dart';
|
||||
|
||||
class PermissionsController extends BaseController {
|
||||
late PangeaController _pangeaController;
|
||||
|
||||
PermissionsController(PangeaController pangeaController) : super() {
|
||||
_pangeaController = pangeaController;
|
||||
}
|
||||
|
||||
/// Returns false if user is null
|
||||
bool isUser18() {
|
||||
final DateTime? dob =
|
||||
_pangeaController.userController.profile.userSettings.dateOfBirth;
|
||||
if (dob == null) return false;
|
||||
final today = DateTime.now();
|
||||
final age = today.year - dob.year;
|
||||
|
||||
// Check if the birthday has occurred yet this year
|
||||
final hasHadBirthdayThisYear = (today.month > dob.month) ||
|
||||
(today.month == dob.month && today.day >= dob.day);
|
||||
|
||||
// Return true if they are 18 or older
|
||||
return age > 18 || (age == 18 && hasHadBirthdayThisYear);
|
||||
}
|
||||
|
||||
bool canShareVideo(String? roomID) => isUser18();
|
||||
|
||||
bool canSharePhoto(String? roomID) => true;
|
||||
|
||||
bool canShareFile(String? roomID) => true;
|
||||
|
||||
bool canShareLocation(String? roomID) => isUser18();
|
||||
|
||||
bool userToolSetting(ToolSetting setting) {
|
||||
switch (setting) {
|
||||
case ToolSetting.interactiveTranslator:
|
||||
return _pangeaController
|
||||
.userController.profile.toolSettings.interactiveTranslator;
|
||||
case ToolSetting.interactiveGrammar:
|
||||
return _pangeaController
|
||||
.userController.profile.toolSettings.interactiveGrammar;
|
||||
case ToolSetting.immersionMode:
|
||||
return _pangeaController
|
||||
.userController.profile.toolSettings.immersionMode;
|
||||
case ToolSetting.definitions:
|
||||
return _pangeaController
|
||||
.userController.profile.toolSettings.definitions;
|
||||
case ToolSetting.autoIGC:
|
||||
return _pangeaController.userController.profile.toolSettings.autoIGC;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isToolEnabled(ToolSetting setting) {
|
||||
// Rules can't be edited; default to true
|
||||
return userToolSetting(setting);
|
||||
// if (room?.isSpaceAdmin ?? false) {
|
||||
// return userToolSetting(setting);
|
||||
// }
|
||||
// final int? classPermission =
|
||||
// room != null ? classLanguageToolPermission(room, setting) : 1;
|
||||
// if (classPermission == 0) return false;
|
||||
// if (classPermission == 2) return true;
|
||||
// return userToolSetting(setting);
|
||||
}
|
||||
|
||||
bool isWritingAssistanceEnabled(Room? room) {
|
||||
// Rules can't be edited; default to true
|
||||
return true;
|
||||
// return isToolEnabled(ToolSetting.interactiveTranslator, room) &&
|
||||
// isToolEnabled(ToolSetting.interactiveGrammar, room);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,8 @@ import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
|||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/controllers/language_controller.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/enums/tool_settings_enum.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/utils/p_language_store.dart';
|
||||
import 'package:fluffychat/pangea/user/models/activities_profile_model.dart';
|
||||
|
|
@ -107,8 +109,8 @@ class UserController {
|
|||
waitForDataInSync = false,
|
||||
}) async {
|
||||
await initialize();
|
||||
final prevTargetLang = _pangeaController.languageController.userL2;
|
||||
final prevBaseLang = _pangeaController.languageController.userL1;
|
||||
final prevTargetLang = _pangeaController.userController.userL2;
|
||||
final prevBaseLang = _pangeaController.userController.userL1;
|
||||
final prevHash = profile.hashCode;
|
||||
|
||||
final Profile updatedProfile = update(profile);
|
||||
|
|
@ -119,12 +121,12 @@ class UserController {
|
|||
|
||||
await updatedProfile.saveProfileData(waitForDataInSync: waitForDataInSync);
|
||||
|
||||
if ((prevTargetLang != _pangeaController.languageController.userL2) ||
|
||||
(prevBaseLang != _pangeaController.languageController.userL1)) {
|
||||
if ((prevTargetLang != _pangeaController.userController.userL2) ||
|
||||
(prevBaseLang != _pangeaController.userController.userL1)) {
|
||||
languageStream.add(
|
||||
LanguageUpdate(
|
||||
baseLang: _pangeaController.languageController.userL1!,
|
||||
targetLang: _pangeaController.languageController.userL2!,
|
||||
baseLang: _pangeaController.userController.userL1!,
|
||||
targetLang: _pangeaController.userController.userL2!,
|
||||
prevBaseLang: prevBaseLang,
|
||||
prevTargetLang: prevTargetLang,
|
||||
),
|
||||
|
|
@ -155,7 +157,7 @@ class UserController {
|
|||
|
||||
if (profile.userSettings.targetLanguage != null &&
|
||||
profile.userSettings.targetLanguage!.isNotEmpty &&
|
||||
_pangeaController.languageController.userL2 == null) {
|
||||
_pangeaController.userController.userL2 == null) {
|
||||
// update the language list and send an update to refresh analytics summary
|
||||
await PLanguageStore.initialize(forceRefresh: true);
|
||||
}
|
||||
|
|
@ -364,8 +366,8 @@ class UserController {
|
|||
LanguageModel? baseLanguage,
|
||||
LanguageModel? targetLanguage,
|
||||
}) async {
|
||||
targetLanguage ??= _pangeaController.languageController.userL2;
|
||||
baseLanguage ??= _pangeaController.languageController.userL1;
|
||||
targetLanguage ??= _pangeaController.userController.userL2;
|
||||
baseLanguage ??= _pangeaController.userController.userL1;
|
||||
if (targetLanguage == null || analyticsProfile == null) return;
|
||||
|
||||
final analyticsRoom =
|
||||
|
|
@ -426,7 +428,7 @@ class UserController {
|
|||
}
|
||||
|
||||
Future<void> addXPOffset(int offset) async {
|
||||
final targetLanguage = _pangeaController.languageController.userL2;
|
||||
final targetLanguage = _pangeaController.userController.userL2;
|
||||
if (targetLanguage == null || analyticsProfile == null) return;
|
||||
|
||||
analyticsProfile!.addXPOffset(
|
||||
|
|
@ -525,4 +527,66 @@ class UserController {
|
|||
return AnalyticsProfileModel();
|
||||
}
|
||||
}
|
||||
|
||||
bool isToolEnabled(ToolSetting setting) {
|
||||
return userToolSetting(setting);
|
||||
}
|
||||
|
||||
bool userToolSetting(ToolSetting setting) {
|
||||
switch (setting) {
|
||||
case ToolSetting.interactiveTranslator:
|
||||
return profile.toolSettings.interactiveTranslator;
|
||||
case ToolSetting.interactiveGrammar:
|
||||
return profile.toolSettings.interactiveGrammar;
|
||||
case ToolSetting.immersionMode:
|
||||
return profile.toolSettings.immersionMode;
|
||||
case ToolSetting.definitions:
|
||||
return profile.toolSettings.definitions;
|
||||
case ToolSetting.autoIGC:
|
||||
return profile.toolSettings.autoIGC;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String? get userL1Code {
|
||||
final source = profile.userSettings.sourceLanguage;
|
||||
return source == null || source.isEmpty
|
||||
? LanguageController.systemLanguage?.langCode
|
||||
: source;
|
||||
}
|
||||
|
||||
String? get userL2Code {
|
||||
final target = profile.userSettings.targetLanguage;
|
||||
return target == null || target.isEmpty ? null : target;
|
||||
}
|
||||
|
||||
LanguageModel? get userL1 {
|
||||
if (userL1Code == null) return null;
|
||||
final langModel = PLanguageStore.byLangCode(userL1Code!);
|
||||
return langModel?.langCode == LanguageKeys.unknownLanguage
|
||||
? null
|
||||
: langModel;
|
||||
}
|
||||
|
||||
LanguageModel? get userL2 {
|
||||
if (userL2Code == null) return null;
|
||||
final langModel = PLanguageStore.byLangCode(userL2Code!);
|
||||
return langModel?.langCode == LanguageKeys.unknownLanguage
|
||||
? null
|
||||
: langModel;
|
||||
}
|
||||
|
||||
bool get languagesSet =>
|
||||
userL1Code != null &&
|
||||
userL2Code != null &&
|
||||
userL1Code!.isNotEmpty &&
|
||||
userL2Code!.isNotEmpty &&
|
||||
userL1Code != LanguageKeys.unknownLanguage &&
|
||||
userL2Code != LanguageKeys.unknownLanguage;
|
||||
|
||||
bool get showTranscription =>
|
||||
(userL1 != null && userL2 != null && userL1?.script != userL2?.script) ||
|
||||
(userL1?.script != LanguageKeys.unknownLanguage ||
|
||||
userL2?.script == LanguageKeys.unknownLanguage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,9 +162,9 @@ class VocabRepo {
|
|||
}
|
||||
|
||||
static VocabResponse placeholderData([LanguageModel? language]) {
|
||||
language ??= MatrixState.pangeaController.languageController.userL2 == null
|
||||
language ??= MatrixState.pangeaController.userController.userL2 == null
|
||||
? PLanguageStore.byLangCode(LanguageKeys.defaultLanguage)
|
||||
: MatrixState.pangeaController.languageController.userL2!;
|
||||
: MatrixState.pangeaController.userController.userL2!;
|
||||
|
||||
//TODO - move this to the server and fill out all our languages
|
||||
final Map<String, VocabResponse> placeholder = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue