custom font improvements

This commit is contained in:
Kima 2024-05-15 20:21:07 +02:00
parent 8c118eedc1
commit 30f24d5d33
12 changed files with 221 additions and 40 deletions

View File

@ -45,6 +45,7 @@ const settingsDB = DatabaseStruct("settings", {
// more // more
"show_breaks": int, "show_breaks": int,
"font_family": String, "font_family": String,
"title_only_font": int,
"plus_session_id": String, "plus_session_id": String,
"cal_sync_room_location": String, "cal_sync_show_exams": int, "cal_sync_room_location": String, "cal_sync_show_exams": int,
"cal_sync_show_teacher": int, "cal_sync_renamed": int, "cal_sync_show_teacher": int, "cal_sync_renamed": int,

View File

@ -96,6 +96,7 @@ class SettingsProvider extends ChangeNotifier {
// more // more
bool _showBreaks; bool _showBreaks;
String _fontFamily; String _fontFamily;
bool _titleOnlyFont;
String _plusSessionId; String _plusSessionId;
String _calSyncRoomLocation; String _calSyncRoomLocation;
bool _calSyncShowExams; bool _calSyncShowExams;
@ -167,6 +168,7 @@ class SettingsProvider extends ChangeNotifier {
required String pinSetNotify, required String pinSetNotify,
required String pinSetExtras, required String pinSetExtras,
required String fontFamily, required String fontFamily,
required bool titleOnlyFont,
required String plusSessionId, required String plusSessionId,
required String calSyncRoomLocation, required String calSyncRoomLocation,
required bool calSyncShowExams, required bool calSyncShowExams,
@ -235,6 +237,7 @@ class SettingsProvider extends ChangeNotifier {
_pinSetNotify = pinSetNotify, _pinSetNotify = pinSetNotify,
_pinSetExtras = pinSetExtras, _pinSetExtras = pinSetExtras,
_fontFamily = fontFamily, _fontFamily = fontFamily,
_titleOnlyFont = titleOnlyFont,
_plusSessionId = plusSessionId, _plusSessionId = plusSessionId,
_calSyncRoomLocation = calSyncRoomLocation, _calSyncRoomLocation = calSyncRoomLocation,
_calSyncShowExams = calSyncShowExams, _calSyncShowExams = calSyncShowExams,
@ -322,6 +325,7 @@ class SettingsProvider extends ChangeNotifier {
pinSetNotify: map['notify_s_pin'], pinSetNotify: map['notify_s_pin'],
pinSetExtras: map['extras_s_pin'], pinSetExtras: map['extras_s_pin'],
fontFamily: map['font_family'], fontFamily: map['font_family'],
titleOnlyFont: map['title_only_font'] == 1,
plusSessionId: map['plus_session_id'], plusSessionId: map['plus_session_id'],
calSyncRoomLocation: map['cal_sync_room_location'], calSyncRoomLocation: map['cal_sync_room_location'],
calSyncShowExams: map['cal_sync_show_exams'] == 1, calSyncShowExams: map['cal_sync_show_exams'] == 1,
@ -397,6 +401,7 @@ class SettingsProvider extends ChangeNotifier {
"notify_s_pin": _pinSetNotify, "notify_s_pin": _pinSetNotify,
"extras_s_pin": _pinSetExtras, "extras_s_pin": _pinSetExtras,
"font_family": _fontFamily, "font_family": _fontFamily,
"title_only_font": _titleOnlyFont ? 1 : 0,
"plus_session_id": _plusSessionId, "plus_session_id": _plusSessionId,
"cal_sync_room_location": _calSyncRoomLocation, "cal_sync_room_location": _calSyncRoomLocation,
"cal_sync_show_exams": _calSyncShowExams ? 1 : 0, "cal_sync_show_exams": _calSyncShowExams ? 1 : 0,
@ -476,6 +481,7 @@ class SettingsProvider extends ChangeNotifier {
pinSetNotify: '', pinSetNotify: '',
pinSetExtras: '', pinSetExtras: '',
fontFamily: '', fontFamily: '',
titleOnlyFont: false,
plusSessionId: '', plusSessionId: '',
calSyncRoomLocation: 'location', calSyncRoomLocation: 'location',
calSyncShowExams: true, calSyncShowExams: true,
@ -546,6 +552,7 @@ class SettingsProvider extends ChangeNotifier {
String get currentThemeCreator => _currentThemeCreator; String get currentThemeCreator => _currentThemeCreator;
bool get showBreaks => _showBreaks; bool get showBreaks => _showBreaks;
String get fontFamily => _fontFamily; String get fontFamily => _fontFamily;
bool get titleOnlyFont => _titleOnlyFont;
String get plusSessionId => _plusSessionId; String get plusSessionId => _plusSessionId;
String get calSyncRoomLocation => _calSyncRoomLocation; String get calSyncRoomLocation => _calSyncRoomLocation;
bool get calSyncShowExams => _calSyncShowExams; bool get calSyncShowExams => _calSyncShowExams;
@ -612,6 +619,7 @@ class SettingsProvider extends ChangeNotifier {
String? currentThemeCreator, String? currentThemeCreator,
bool? showBreaks, bool? showBreaks,
String? fontFamily, String? fontFamily,
bool? titleOnlyFont,
String? plusSessionId, String? plusSessionId,
String? calSyncRoomLocation, String? calSyncRoomLocation,
bool? calSyncShowExams, bool? calSyncShowExams,
@ -777,6 +785,9 @@ class SettingsProvider extends ChangeNotifier {
if (fontFamily != null && fontFamily != _fontFamily) { if (fontFamily != null && fontFamily != _fontFamily) {
_fontFamily = fontFamily; _fontFamily = fontFamily;
} }
if (titleOnlyFont != null && titleOnlyFont != _titleOnlyFont) {
_titleOnlyFont = titleOnlyFont;
}
if (plusSessionId != null && plusSessionId != _plusSessionId) { if (plusSessionId != null && plusSessionId != _plusSessionId) {
_plusSessionId = plusSessionId; _plusSessionId = plusSessionId;
} }

View File

@ -104,9 +104,10 @@ class AppTheme {
brightness: Brightness.light, brightness: Brightness.light,
useMaterial3: true, useMaterial3: true,
fontFamily: _defaultFontFamily, fontFamily: _defaultFontFamily,
textTheme: textTheme: !settings.titleOnlyFont
googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor) ?? ? (googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor) ??
const TextTheme().apply(bodyColor: textColor), const TextTheme().apply(bodyColor: textColor))
: null,
scaffoldBackgroundColor: backgroundColor, scaffoldBackgroundColor: backgroundColor,
primaryColor: lightColors.filc, primaryColor: lightColors.filc,
dividerColor: const Color(0x00000000), dividerColor: const Color(0x00000000),
@ -229,8 +230,9 @@ class AppTheme {
brightness: Brightness.dark, brightness: Brightness.dark,
useMaterial3: true, useMaterial3: true,
fontFamily: _defaultFontFamily, fontFamily: _defaultFontFamily,
textTheme: textTheme: !settings.titleOnlyFont
googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor), ? (googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor))
: null,
scaffoldBackgroundColor: backgroundColor, scaffoldBackgroundColor: backgroundColor,
primaryColor: darkColors.filc, primaryColor: darkColors.filc,
dividerColor: const Color(0x00000000), dividerColor: const Color(0x00000000),

View File

@ -4,7 +4,9 @@ import 'dart:math';
import 'package:animations/animations.dart'; import 'package:animations/animations.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:refilc/api/providers/update_provider.dart'; import 'package:refilc/api/providers/update_provider.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/theme/colors/utils.dart'; import 'package:refilc/theme/colors/utils.dart';
import 'package:refilc/ui/date_widget.dart'; import 'package:refilc/ui/date_widget.dart';
import 'package:refilc_kreta_api/models/absence.dart'; import 'package:refilc_kreta_api/models/absence.dart';
@ -180,10 +182,22 @@ class AbsencesPageState extends State<AbsencesPage>
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: Text( child: Text(
"Absences".i18n, "Absences".i18n,
style: TextStyle( style: Provider.of<SettingsProvider>(context).fontFamily !=
color: AppColors.of(context).text, '' &&
fontSize: 32.0, Provider.of<SettingsProvider>(context).titleOnlyFont
fontWeight: FontWeight.bold), ? GoogleFonts.getFont(
Provider.of<SettingsProvider>(context).fontFamily,
textStyle: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold,
),
)
: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold,
),
), ),
), ),
bottom: FilterBar( bottom: FilterBar(

View File

@ -4,6 +4,7 @@ import 'dart:math';
import 'package:auto_size_text/auto_size_text.dart'; import 'package:auto_size_text/auto_size_text.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:refilc/api/providers/update_provider.dart'; import 'package:refilc/api/providers/update_provider.dart';
import 'package:refilc/models/settings.dart'; import 'package:refilc/models/settings.dart';
import 'package:refilc/ui/widgets/grade/grade_tile.dart'; import 'package:refilc/ui/widgets/grade/grade_tile.dart';
@ -576,10 +577,20 @@ class GradesPageState extends State<GradesPage> {
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: Text( child: Text(
"Grades".i18n, "Grades".i18n,
style: TextStyle( style: Provider.of<SettingsProvider>(context).fontFamily !=
color: AppColors.of(context).text, '' &&
fontSize: 32.0, Provider.of<SettingsProvider>(context).titleOnlyFont
fontWeight: FontWeight.bold), ? GoogleFonts.getFont(
Provider.of<SettingsProvider>(context).fontFamily,
textStyle: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
)
: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
), ),
), ),
shadowColor: Theme.of(context).shadowColor, shadowColor: Theme.of(context).shadowColor,

View File

@ -3,6 +3,7 @@ import 'dart:math';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart'; import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:refilc/api/providers/live_card_provider.dart'; import 'package:refilc/api/providers/live_card_provider.dart';
import 'package:refilc/theme/colors/colors.dart'; import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc/ui/date_widget.dart'; import 'package:refilc/ui/date_widget.dart';
@ -244,14 +245,34 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
greeting, greeting,
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
textAlign: TextAlign.start, textAlign: TextAlign.start,
style: TextStyle( style:
fontWeight: FontWeight.bold, Provider.of<SettingsProvider>(context)
fontSize: 18.0, .fontFamily !=
color: Theme.of(context) '' &&
.textTheme Provider.of<SettingsProvider>(
.bodyMedium context)
?.color, .titleOnlyFont
), ? GoogleFonts.getFont(
Provider.of<SettingsProvider>(
context)
.fontFamily,
textStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18.0,
color: Theme.of(context)
.textTheme
.bodyMedium
?.color,
),
)
: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18.0,
color: Theme.of(context)
.textTheme
.bodyMedium
?.color,
),
), ),
Text( Text(
DateFormat('EEEE, MMM d', DateFormat('EEEE, MMM d',

View File

@ -1,6 +1,8 @@
import 'dart:math'; import 'dart:math';
import 'package:google_fonts/google_fonts.dart';
import 'package:refilc/api/providers/update_provider.dart'; import 'package:refilc/api/providers/update_provider.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/ui/date_widget.dart'; import 'package:refilc/ui/date_widget.dart';
import 'package:refilc_kreta_api/providers/message_provider.dart'; import 'package:refilc_kreta_api/providers/message_provider.dart';
import 'package:refilc/api/providers/user_provider.dart'; import 'package:refilc/api/providers/user_provider.dart';
@ -129,10 +131,22 @@ class MessagesPageState extends State<MessagesPage>
), ),
Text( Text(
"Messages".i18n, "Messages".i18n,
style: TextStyle( style: Provider.of<SettingsProvider>(context)
color: AppColors.of(context).text, .fontFamily !=
fontSize: 32.0, '' &&
fontWeight: FontWeight.bold), Provider.of<SettingsProvider>(context)
.titleOnlyFont
? GoogleFonts.getFont(
Provider.of<SettingsProvider>(context).fontFamily,
textStyle: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
)
: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
), ),
], ],
), ),

View File

@ -5,6 +5,7 @@ import 'dart:math';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart'; import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:refilc/api/providers/database_provider.dart'; import 'package:refilc/api/providers/database_provider.dart';
import 'package:refilc/api/providers/self_note_provider.dart'; import 'package:refilc/api/providers/self_note_provider.dart';
import 'package:refilc/api/providers/update_provider.dart'; import 'package:refilc/api/providers/update_provider.dart';
@ -326,10 +327,20 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: Text( child: Text(
"notes".i18n, "notes".i18n,
style: TextStyle( style: Provider.of<SettingsProvider>(context).fontFamily !=
color: AppColors.of(context).text, '' &&
fontSize: 32.0, Provider.of<SettingsProvider>(context).titleOnlyFont
fontWeight: FontWeight.bold), ? GoogleFonts.getFont(
Provider.of<SettingsProvider>(context).fontFamily,
textStyle: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
)
: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
), ),
), ),
), ),

View File

@ -1,3 +1,6 @@
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/theme/colors/colors.dart'; import 'package:refilc/theme/colors/colors.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:refilc/utils/format.dart'; import 'package:refilc/utils/format.dart';
@ -50,11 +53,26 @@ class _DayTitleState extends State<DayTitle> {
width: MediaQuery.of(context).size.width / 1.5, width: MediaQuery.of(context).size.width / 1.5,
child: Text( child: Text(
widget.dayTitle(index).capital(), widget.dayTitle(index).capital(),
style: TextStyle( style: Provider.of<SettingsProvider>(context)
color: .fontFamily !=
AppColors.of(context).text.withOpacity(opacity), '' &&
fontSize: 32.0, Provider.of<SettingsProvider>(context)
fontWeight: FontWeight.bold), .titleOnlyFont
? GoogleFonts.getFont(
Provider.of<SettingsProvider>(context).fontFamily,
textStyle: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(opacity),
fontSize: 32.0,
fontWeight: FontWeight.bold),
)
: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(opacity),
fontSize: 32.0,
fontWeight: FontWeight.bold),
), ),
); );
}, },

View File

@ -1,5 +1,6 @@
import 'dart:math'; import 'dart:math';
import 'package:animations/animations.dart'; import 'package:animations/animations.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:i18n_extension/i18n_extension.dart'; import 'package:i18n_extension/i18n_extension.dart';
import 'package:refilc/api/providers/database_provider.dart'; import 'package:refilc/api/providers/database_provider.dart';
import 'package:refilc/api/providers/update_provider.dart'; import 'package:refilc/api/providers/update_provider.dart';
@ -375,11 +376,25 @@ class TimetablePageState extends State<TimetablePage>
} else { } else {
return Text( return Text(
"timetable".i18n, "timetable".i18n,
style: TextStyle( style: Provider.of<SettingsProvider>(context)
fontSize: 32.0, .fontFamily !=
fontWeight: FontWeight.bold, '' &&
color: AppColors.of(context).text, Provider.of<SettingsProvider>(context)
), .titleOnlyFont
? GoogleFonts.getFont(
Provider.of<SettingsProvider>(context)
.fontFamily,
textStyle: TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.bold,
color: AppColors.of(context).text,
),
)
: TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.bold,
color: AppColors.of(context).text,
),
); );
} }
}(), }(),

View File

@ -119,6 +119,8 @@ extension SettingsLocalization on String {
// grade streak // grade streak
"grade_streak": "Grade 5 Streak", "grade_streak": "Grade 5 Streak",
"grade_streak_subtitle": "So many 5s in a row?!", "grade_streak_subtitle": "So many 5s in a row?!",
// other
"only_ch_title_font": "Font Only for Titles",
}, },
"hu_hu": { "hu_hu": {
"personal_details": "Személyes információk", "personal_details": "Személyes információk",
@ -236,6 +238,8 @@ extension SettingsLocalization on String {
// grade streak // grade streak
"grade_streak": "5-ös sorozat", "grade_streak": "5-ös sorozat",
"grade_streak_subtitle": "Egymás után ennyi 5-ös?!", "grade_streak_subtitle": "Egymás után ennyi 5-ös?!",
// other
"only_ch_title_font": "Betűtípus csak címekre",
}, },
"de_de": { "de_de": {
"personal_details": "Persönliche Angaben", "personal_details": "Persönliche Angaben",
@ -353,6 +357,8 @@ extension SettingsLocalization on String {
// grade streak // grade streak
"grade_streak": "5er-Streak", "grade_streak": "5er-Streak",
"grade_streak_subtitle": "So viele 5er in Folge?!", "grade_streak_subtitle": "So viele 5er in Folge?!",
// other
"only_ch_title_font": "Schriftart nur für Titel",
}, },
}; };

View File

@ -890,7 +890,7 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
title: Text('fonts'.i18n), title: Text('fonts'.i18n),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0), cardPadding: const EdgeInsets.all(4.0),
isSeparated: true, isSeparated: false,
children: [ children: [
PanelButton( PanelButton(
onPressed: () { onPressed: () {
@ -928,6 +928,63 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
), ),
borderRadius: const BorderRadius.vertical( borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0), top: Radius.circular(12.0),
bottom: Radius.circular(6.0),
),
),
PanelButton(
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
onPressed: () async {
if (!Provider.of<PlusProvider>(context, listen: false)
.hasScope(PremiumScopes.customFont)) {
PlusLockedFeaturePopup.show(
context: context,
feature: PremiumFeature.fontChange);
return;
}
settingsProvider.update(
titleOnlyFont: !settingsProvider.titleOnlyFont);
Provider.of<ThemeModeObserver>(context, listen: false)
.changeTheme(settingsProvider.theme,
updateNavbarColor: false);
setState(() {});
},
title: Text(
"only_ch_title_font".i18n,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(
settingsProvider.titleOnlyFont ? .95 : .25),
),
),
leading: Icon(
Icons.text_increase_rounded,
size: 22.0,
color: AppColors.of(context).text.withOpacity(
settingsProvider.titleOnlyFont ? .95 : .25),
),
trailing: Switch(
onChanged: (v) async {
if (!Provider.of<PlusProvider>(context,
listen: false)
.hasScope(PremiumScopes.customFont)) {
PlusLockedFeaturePopup.show(
context: context,
feature: PremiumFeature.fontChange);
return;
}
settingsProvider.update(titleOnlyFont: v);
Provider.of<ThemeModeObserver>(context,
listen: false)
.changeTheme(settingsProvider.theme,
updateNavbarColor: false);
setState(() {});
},
value: settingsProvider.titleOnlyFont,
activeColor: Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(4.0),
bottom: Radius.circular(12.0), bottom: Radius.circular(12.0),
), ),
), ),