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
"show_breaks": int,
"font_family": String,
"title_only_font": int,
"plus_session_id": String,
"cal_sync_room_location": String, "cal_sync_show_exams": int,
"cal_sync_show_teacher": int, "cal_sync_renamed": int,

View File

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

View File

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

View File

@ -4,7 +4,9 @@ import 'dart:math';
import 'package:animations/animations.dart';
import 'package:collection/collection.dart';
import 'package:google_fonts/google_fonts.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/ui/date_widget.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),
child: Text(
"Absences".i18n,
style: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
style: Provider.of<SettingsProvider>(context).fontFamily !=
'' &&
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,
),
),
),
bottom: FilterBar(

View File

@ -4,6 +4,7 @@ import 'dart:math';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:collection/collection.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:refilc/api/providers/update_provider.dart';
import 'package:refilc/models/settings.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),
child: Text(
"Grades".i18n,
style: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
style: Provider.of<SettingsProvider>(context).fontFamily !=
'' &&
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),
),
),
shadowColor: Theme.of(context).shadowColor,

View File

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

View File

@ -1,6 +1,8 @@
import 'dart:math';
import 'package:google_fonts/google_fonts.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_kreta_api/providers/message_provider.dart';
import 'package:refilc/api/providers/user_provider.dart';
@ -129,10 +131,22 @@ class MessagesPageState extends State<MessagesPage>
),
Text(
"Messages".i18n,
style: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
style: Provider.of<SettingsProvider>(context)
.fontFamily !=
'' &&
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_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/self_note_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),
child: Text(
"notes".i18n,
style: TextStyle(
color: AppColors.of(context).text,
fontSize: 32.0,
fontWeight: FontWeight.bold),
style: Provider.of<SettingsProvider>(context).fontFamily !=
'' &&
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

@ -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:flutter/material.dart';
import 'package:refilc/utils/format.dart';
@ -50,11 +53,26 @@ class _DayTitleState extends State<DayTitle> {
width: MediaQuery.of(context).size.width / 1.5,
child: Text(
widget.dayTitle(index).capital(),
style: TextStyle(
color:
AppColors.of(context).text.withOpacity(opacity),
fontSize: 32.0,
fontWeight: FontWeight.bold),
style: Provider.of<SettingsProvider>(context)
.fontFamily !=
'' &&
Provider.of<SettingsProvider>(context)
.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 'package:animations/animations.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:i18n_extension/i18n_extension.dart';
import 'package:refilc/api/providers/database_provider.dart';
import 'package:refilc/api/providers/update_provider.dart';
@ -375,11 +376,25 @@ class TimetablePageState extends State<TimetablePage>
} else {
return Text(
"timetable".i18n,
style: TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.bold,
color: AppColors.of(context).text,
),
style: Provider.of<SettingsProvider>(context)
.fontFamily !=
'' &&
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 5 Streak",
"grade_streak_subtitle": "So many 5s in a row?!",
// other
"only_ch_title_font": "Font Only for Titles",
},
"hu_hu": {
"personal_details": "Személyes információk",
@ -236,6 +238,8 @@ extension SettingsLocalization on String {
// grade streak
"grade_streak": "5-ös sorozat",
"grade_streak_subtitle": "Egymás után ennyi 5-ös?!",
// other
"only_ch_title_font": "Betűtípus csak címekre",
},
"de_de": {
"personal_details": "Persönliche Angaben",
@ -353,6 +357,8 @@ extension SettingsLocalization on String {
// grade streak
"grade_streak": "5er-Streak",
"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),
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0),
isSeparated: true,
isSeparated: false,
children: [
PanelButton(
onPressed: () {
@ -928,6 +928,63 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
),
borderRadius: const BorderRadius.vertical(
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),
),
),