mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-24 22:57:12 -04:00
Added language options to Appearance Model
This commit is contained in:
parent
6ea43cd5e5
commit
578bf963f7
1 changed files with 13 additions and 4 deletions
|
@ -1,15 +1,21 @@
|
|||
import 'package:app_flowy/user/infrastructure/repos/user_setting_repo.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flowy_infra/theme.dart';
|
||||
import 'package:flowy_infra/language.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_setting.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
|
||||
AppearanceSettings setting;
|
||||
AppTheme _theme;
|
||||
AppLanguage _language;
|
||||
|
||||
AppearanceSettingModel(this.setting)
|
||||
: _theme = AppTheme.fromName(name: setting.theme),
|
||||
_language = AppLanguage.fromName(name: setting.language);
|
||||
|
||||
AppearanceSettingModel(this.setting) : _theme = AppTheme.fromName(name: setting.theme);
|
||||
AppTheme get theme => _theme;
|
||||
AppLanguage get language => _language;
|
||||
|
||||
Future<void> save() async {
|
||||
await UserSettingReppsitory().setAppearanceSettings(setting);
|
||||
|
@ -31,9 +37,12 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
|
|||
}
|
||||
}
|
||||
|
||||
void setLanguage(String language) {
|
||||
if (setting.language != language) {
|
||||
setting.language = language;
|
||||
void setLanguage(Language language) {
|
||||
String langaugeString = stringFromLanguageName(language);
|
||||
|
||||
if (setting.language != langaugeString) {
|
||||
_language = AppLanguage.fromLanguage(language: language);
|
||||
setting.language = langaugeString;
|
||||
notifyListeners();
|
||||
save();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue