You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.7 KiB
Dart
82 lines
2.7 KiB
Dart
import 'package:country_picker/country_picker.dart';
|
|
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
|
|
import 'package:fluffychat/pangea/models/space_model.dart';
|
|
import 'package:fluffychat/pangea/models/user_model.dart';
|
|
import 'package:fluffychat/pangea/pages/settings_learning/settings_learning_view.dart';
|
|
import 'package:fluffychat/pangea/widgets/user_settings/p_language_dialog.dart';
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class SettingsLearning extends StatefulWidget {
|
|
final bool isPopup;
|
|
const SettingsLearning({
|
|
this.isPopup = false,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
SettingsLearningController createState() => SettingsLearningController();
|
|
}
|
|
|
|
class SettingsLearningController extends State<SettingsLearning> {
|
|
PangeaController pangeaController = MatrixState.pangeaController;
|
|
|
|
setPublicProfile(bool isPublic) {
|
|
pangeaController.userController.updateProfile((profile) {
|
|
profile.userSettings.publicProfile = isPublic;
|
|
return profile;
|
|
});
|
|
setState(() {});
|
|
}
|
|
|
|
void changeLanguage() {
|
|
pLanguageDialog(context, () {}).then((_) => setState(() {}));
|
|
}
|
|
|
|
void changeCountry(Country country) {
|
|
pangeaController.userController.updateProfile((Profile profile) {
|
|
profile.userSettings.country = country.displayNameNoCountryCode;
|
|
return profile;
|
|
});
|
|
setState(() {});
|
|
}
|
|
|
|
void updateToolSetting(ToolSetting toolSetting, bool value) {
|
|
pangeaController.userController.updateProfile((Profile profile) {
|
|
switch (toolSetting) {
|
|
case ToolSetting.interactiveTranslator:
|
|
return profile..toolSettings.interactiveTranslator = value;
|
|
case ToolSetting.interactiveGrammar:
|
|
return profile..toolSettings.interactiveGrammar = value;
|
|
case ToolSetting.immersionMode:
|
|
return profile..toolSettings.immersionMode = value;
|
|
case ToolSetting.definitions:
|
|
return profile..toolSettings.definitions = value;
|
|
case ToolSetting.autoIGC:
|
|
return profile..toolSettings.autoIGC = value;
|
|
}
|
|
});
|
|
}
|
|
|
|
bool getToolSetting(ToolSetting toolSetting) {
|
|
final toolSettings = pangeaController.userController.profile.toolSettings;
|
|
switch (toolSetting) {
|
|
case ToolSetting.interactiveTranslator:
|
|
return toolSettings.interactiveTranslator;
|
|
case ToolSetting.interactiveGrammar:
|
|
return toolSettings.interactiveGrammar;
|
|
case ToolSetting.immersionMode:
|
|
return toolSettings.immersionMode;
|
|
case ToolSetting.definitions:
|
|
return toolSettings.definitions;
|
|
case ToolSetting.autoIGC:
|
|
return toolSettings.autoIGC;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SettingsLearningView(this);
|
|
}
|
|
}
|