finished font family changing and sharing on client-side

This commit is contained in:
Kima 2024-02-18 21:12:03 +01:00
parent 4a1aa75cb2
commit 304e0ea877
5 changed files with 12 additions and 2 deletions

View File

@ -13,6 +13,7 @@ class SharedTheme {
SharedGradeColors gradeColors; SharedGradeColors gradeColors;
String displayName; String displayName;
ThemeMode? themeMode; ThemeMode? themeMode;
String fontFamily;
SharedTheme({ SharedTheme({
required this.json, required this.json,
@ -27,6 +28,7 @@ class SharedTheme {
required this.gradeColors, required this.gradeColors,
this.displayName = 'displayName', this.displayName = 'displayName',
this.themeMode, this.themeMode,
required this.fontFamily,
}); });
factory SharedTheme.fromJson(Map json, SharedGradeColors gradeColors) { factory SharedTheme.fromJson(Map json, SharedGradeColors gradeColors) {
@ -45,6 +47,7 @@ class SharedTheme {
themeMode: json['theme_mode'] == 'dark' themeMode: json['theme_mode'] == 'dark'
? ThemeMode.dark ? ThemeMode.dark
: (json['theme_mode'] == 'light' ? ThemeMode.light : null), : (json['theme_mode'] == 'light' ? ThemeMode.light : null),
fontFamily: json['font_family'] ?? '',
); );
} }
} }

View File

@ -49,7 +49,8 @@ class ShareProvider extends ChangeNotifier {
'shadow_effect': settings.shadowEffect, 'shadow_effect': settings.shadowEffect,
'theme_mode': settings.theme == ThemeMode.dark 'theme_mode': settings.theme == ThemeMode.dark
? 'dark' ? 'dark'
: (settings.theme == ThemeMode.light ? 'light' : null) : (settings.theme == ThemeMode.light ? 'light' : null),
'font_family': settings.fontFamily,
}; };
SharedTheme theme = SharedTheme.fromJson(themeJson, gradeColors); SharedTheme theme = SharedTheme.fromJson(themeJson, gradeColors);

View File

@ -98,6 +98,7 @@ extension SettingsLocalization on String {
"rename_teachers": "Rename Teachers", "rename_teachers": "Rename Teachers",
"show_breaks": "Show Breaks", "show_breaks": "Show Breaks",
"fonts": "Fonts", "fonts": "Fonts",
"font_family": "Font Family",
}, },
"hu_hu": { "hu_hu": {
"personal_details": "Személyes információk", "personal_details": "Személyes információk",
@ -194,6 +195,7 @@ extension SettingsLocalization on String {
"rename_teachers": "Tanárok átnevezése", "rename_teachers": "Tanárok átnevezése",
"show_breaks": "Szünetek megjelenítése", "show_breaks": "Szünetek megjelenítése",
"fonts": "Betűk", "fonts": "Betűk",
"font_family": "Betűtípus",
}, },
"de_de": { "de_de": {
"personal_details": "Persönliche Angaben", "personal_details": "Persönliche Angaben",
@ -290,6 +292,7 @@ extension SettingsLocalization on String {
"rename_teachers": "Lehrer umbenennen", "rename_teachers": "Lehrer umbenennen",
"show_breaks": "Pausen anzeigen", "show_breaks": "Pausen anzeigen",
"fonts": "Schriftarten", "fonts": "Schriftarten",
"font_family": "Schriftfamilie",
}, },
}; };

View File

@ -560,6 +560,9 @@ class PaintListScreenState extends State<PaintListScreen>
store: true, store: true,
); );
// changing font family
settingsProvider.update(fontFamily: newThemeByID!.fontFamily);
// seems weird but it works, trust me (idk why) // seems weird but it works, trust me (idk why)
await settingsProvider.update(theme: settingsProvider.theme, store: true); await settingsProvider.update(theme: settingsProvider.theme, store: true);
Provider.of<ThemeModeObserver>(context, listen: false) Provider.of<ThemeModeObserver>(context, listen: false)

View File

@ -802,7 +802,7 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
), ),
), ),
leading: Icon( leading: Icon(
FeatherIcons.globe, FeatherIcons.type,
size: 22.0, size: 22.0,
color: AppColors.of(context).text.withOpacity(.95), color: AppColors.of(context).text.withOpacity(.95),
), ),