* chore: move logic for lastUsedByActivityType into ConstructIdentifier * feat: vocab practice * add vocab activity progress bar * fix: shuffle audio practice choices * update UI of vocab practice Added buttons, increased text size and change position, cards flip over and turn red/green on click and respond to hover input * add xp sparkle, shimmering choice card placeholder * spacing changes fix padding, make choice cards spacing/sizing responsive to screen size, replace shimmer cards with stationary circle indicator * don't include duplicate lemma choices * use constructID and show lemma/emoji on choice cards add method to clear cache in case the results was an error, and add a retry button on error * gain xp immediately and take out continue session also refactor the choice cards to have separate widgets for each type and a parent widget to give each an id for xp sparkle * add practice finished page with analytics * Color tweaks on completed page and time card placeholder * add timer * give XP for bonuses and change timer to use stopwatch * simplify card logic, lock practice when few vocab words * merge analytics changes and fix bugs * reload on language change - derive XP data from new analytics - Don't allow any clicks after correct answer selected * small fixes, added tooltip, added copy to l10 * small tweaks and comments * formatting and import sorting --------- Co-authored-by: avashilling <165050625+avashilling@users.noreply.github.com>
149 lines
5.2 KiB
Dart
149 lines
5.2 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:fluffychat/l10n/l10n.dart';
|
|
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
|
|
enum InstructionsEnum {
|
|
clickMessage,
|
|
speechToText,
|
|
l1Translation,
|
|
translationChoices,
|
|
clickBestOption,
|
|
completeActivitiesToUnlock,
|
|
chooseLemmaMeaning,
|
|
activityPlannerOverview,
|
|
ttsDisabled,
|
|
chooseEmoji,
|
|
chooseWordAudio,
|
|
chooseMorphs,
|
|
analyticsVocabList,
|
|
morphAnalyticsList,
|
|
activityAnalyticsList,
|
|
levelAnalytics,
|
|
readingAssistanceOverview,
|
|
emptyChatWarning,
|
|
activityStatsMenu,
|
|
chatParticipantTooltip,
|
|
courseParticipantTooltip,
|
|
noSavedActivitiesYet,
|
|
setLemmaEmoji,
|
|
disableLanguageTools,
|
|
selectMeaning,
|
|
}
|
|
|
|
extension InstructionsEnumExtension on InstructionsEnum {
|
|
String title(L10n l10n) {
|
|
switch (this) {
|
|
case InstructionsEnum.clickMessage:
|
|
return l10n.clickMessageTitle;
|
|
case InstructionsEnum.ttsDisabled:
|
|
return l10n.ttsDisbledTitle;
|
|
case InstructionsEnum.chooseWordAudio:
|
|
case InstructionsEnum.selectMeaning:
|
|
case InstructionsEnum.chooseEmoji:
|
|
case InstructionsEnum.activityPlannerOverview:
|
|
case InstructionsEnum.speechToText:
|
|
case InstructionsEnum.l1Translation:
|
|
case InstructionsEnum.translationChoices:
|
|
case InstructionsEnum.clickBestOption:
|
|
case InstructionsEnum.completeActivitiesToUnlock:
|
|
case InstructionsEnum.chooseLemmaMeaning:
|
|
case InstructionsEnum.chooseMorphs:
|
|
case InstructionsEnum.analyticsVocabList:
|
|
case InstructionsEnum.morphAnalyticsList:
|
|
case InstructionsEnum.readingAssistanceOverview:
|
|
case InstructionsEnum.activityStatsMenu:
|
|
case InstructionsEnum.chatParticipantTooltip:
|
|
case InstructionsEnum.courseParticipantTooltip:
|
|
case InstructionsEnum.activityAnalyticsList:
|
|
case InstructionsEnum.levelAnalytics:
|
|
case InstructionsEnum.noSavedActivitiesYet:
|
|
case InstructionsEnum.setLemmaEmoji:
|
|
case InstructionsEnum.disableLanguageTools:
|
|
ErrorHandler.logError(
|
|
e: Exception("No title for this instruction"),
|
|
m: 'InstructionsEnumExtension.title',
|
|
data: {
|
|
'this': this,
|
|
},
|
|
);
|
|
debugger(when: kDebugMode);
|
|
return "";
|
|
case InstructionsEnum.emptyChatWarning:
|
|
return l10n.emptyChatWarningTitle;
|
|
}
|
|
}
|
|
|
|
String body(L10n l10n) {
|
|
switch (this) {
|
|
case InstructionsEnum.clickMessage:
|
|
return l10n.clickMessageBody;
|
|
case InstructionsEnum.speechToText:
|
|
return l10n.speechToTextBody;
|
|
case InstructionsEnum.l1Translation:
|
|
return l10n.l1TranslationBody;
|
|
case InstructionsEnum.translationChoices:
|
|
return l10n.translationChoicesBody;
|
|
case InstructionsEnum.clickBestOption:
|
|
return l10n.clickBestOption;
|
|
case InstructionsEnum.completeActivitiesToUnlock:
|
|
return l10n.completeActivitiesToUnlock;
|
|
case InstructionsEnum.chooseLemmaMeaning:
|
|
return l10n.chooseLemmaMeaningInstructionsBody;
|
|
case InstructionsEnum.activityPlannerOverview:
|
|
return l10n.activityPlannerOverviewInstructionsBody;
|
|
case InstructionsEnum.chooseEmoji:
|
|
return l10n.chooseEmojiInstructionsBody;
|
|
case InstructionsEnum.ttsDisabled:
|
|
return l10n.ttsDisabledBody;
|
|
case InstructionsEnum.chooseWordAudio:
|
|
return l10n.chooseWordAudioInstructionsBody;
|
|
case InstructionsEnum.chooseMorphs:
|
|
return l10n.chooseMorphsInstructionsBody;
|
|
case InstructionsEnum.analyticsVocabList:
|
|
return l10n.analyticsVocabListBody;
|
|
case InstructionsEnum.morphAnalyticsList:
|
|
return l10n.morphAnalyticsListBody;
|
|
case InstructionsEnum.activityAnalyticsList:
|
|
return l10n.activityAnalyticsTooltipBody;
|
|
case InstructionsEnum.readingAssistanceOverview:
|
|
return l10n.readingAssistanceOverviewBody;
|
|
case InstructionsEnum.emptyChatWarning:
|
|
return l10n.emptyChatWarningDesc;
|
|
case InstructionsEnum.activityStatsMenu:
|
|
return l10n.activityStatsButtonInstruction;
|
|
case InstructionsEnum.chatParticipantTooltip:
|
|
return l10n.chatParticipantTooltip;
|
|
case InstructionsEnum.courseParticipantTooltip:
|
|
return l10n.courseParticipantTooltip;
|
|
case InstructionsEnum.levelAnalytics:
|
|
return l10n.levelInfoTooltip;
|
|
case InstructionsEnum.noSavedActivitiesYet:
|
|
return l10n.noSavedActivitiesYet;
|
|
case InstructionsEnum.setLemmaEmoji:
|
|
return "";
|
|
case InstructionsEnum.disableLanguageTools:
|
|
return l10n.disableLanguageToolsDesc;
|
|
case InstructionsEnum.selectMeaning:
|
|
return l10n.selectMeaning;
|
|
}
|
|
}
|
|
|
|
bool get isToggledOff =>
|
|
MatrixState.pangeaController.userController.profile.instructionSettings
|
|
.getStatus(this);
|
|
|
|
void setToggledOff(bool value) {
|
|
final userController = MatrixState.pangeaController.userController;
|
|
final instructionSettings = userController.profile.instructionSettings;
|
|
if (instructionSettings.getStatus(this) == value) return;
|
|
|
|
userController.updateProfile((profile) {
|
|
profile.instructionSettings.setStatus(this, value);
|
|
return profile;
|
|
});
|
|
}
|
|
}
|