diff --git a/firka/assets/fonts/FiraCode-VariableFont_wght.ttf b/firka/assets/fonts/FiraCode-VariableFont_wght.ttf new file mode 100644 index 00000000..83f2b387 Binary files /dev/null and b/firka/assets/fonts/FiraCode-VariableFont_wght.ttf differ diff --git a/firka/assets/fonts/JustMeAgainDownHere.ttf b/firka/assets/fonts/JustMeAgainDownHere.ttf new file mode 100644 index 00000000..10a4a549 Binary files /dev/null and b/firka/assets/fonts/JustMeAgainDownHere.ttf differ diff --git a/firka/assets/fonts/Monoton-Regular.ttf b/firka/assets/fonts/Monoton-Regular.ttf new file mode 100644 index 00000000..944605ab Binary files /dev/null and b/firka/assets/fonts/Monoton-Regular.ttf differ diff --git a/firka/assets/fonts/PirataOne-Regular.ttf b/firka/assets/fonts/PirataOne-Regular.ttf new file mode 100644 index 00000000..fadd34f3 Binary files /dev/null and b/firka/assets/fonts/PirataOne-Regular.ttf differ diff --git a/firka/assets/fonts/Vollkorn-VariableFont_wght.ttf b/firka/assets/fonts/Vollkorn-VariableFont_wght.ttf new file mode 100644 index 00000000..ca6291a8 Binary files /dev/null and b/firka/assets/fonts/Vollkorn-VariableFont_wght.ttf differ diff --git a/firka/codegen-lock.yaml b/firka/codegen-lock.yaml index d593ac38..b7b476d8 100644 --- a/firka/codegen-lock.yaml +++ b/firka/codegen-lock.yaml @@ -1,15 +1,16 @@ icons: "flutter_launcher_icons.yaml": "c600507ca0df7cebd0f708124842512a14ed3d597b779176200d6ba25b1335b1" - "pubspec.yaml": "a6ae0bd67a2b6226bec2dfd55437b3db2b7ca4a03f315c1a0a8c2f4b505c7c87" + "pubspec.yaml": "d0f795bcffd597e260202b29476fc99caa3bb4aac5abd48a210cadb9f45c19e7" "assets/images/logos/colored_logo.webp": "4b4fa99d144fe6694aa4487ba1b26aeecafae41e3c877836cd7da28d61a77983" "assets/images/logos/monochrome_logo.png": "188d2b0a64c70323b09bcee721663d6698fb557066f20ddaec97bba6869c1c6c" "assets/images/logos/colored_logo_without_mustache.png": "d11cff9f38985885873bfdd2d84e61f8fab03803eada94d4caac1545ef3685f3" "assets/images/logos/colored_logo_only_mustache.png": "bad6220c11bdfb1dfe04e5173bd2ebedd3999689d4b3a68fc63dc520c96dd33b" l10n: "l10n.yml": "a57bc304cac4a2b0235593586f17f400a5165d67fc9aadeaa11893cfa36ee082" - "lib/l10n/app_de.arb": "c6a12eaadf03b012a6a377b3efa4e606bd985355e76e6351956a017f4cfdadc1" - "lib/l10n/app_hu.arb": "a63aace8d129dbc054c4996dd9ef7d54aad96888241ce1310518b10a9a7b561d" - "lib/l10n/app_en.arb": "b2d72778fedb46155f41eb210906ed8ffba8b12744a2800b039951e0a2a88133" + "lib/l10n/app_hu.arb": "e11b8fe4d4fd239584792971c341f1e329fb91f5f49fa6baa664c98b06fc5176" + "lib/l10n/app_de.arb": "5114c70b506f290217161881336d6118c975d59f32347bbdc94a51c1a25293e7" + "lib/l10n/app_en.arb": "a5417b2de058a67db40fa7bfb3526d800fd2f82349dfbc895cff8b298069e707" + "lib/l10n/app_pl.arb": "36cad0796cf8bd20fe969d5fd8443430d25fa932028c0177917ecef6964a08dd" isar: "lib/data/models/app_settings_model.dart": "5eb5af345f1347f104257f0999763650fe2673f9da1754bd12d3f756fe5c9723" "lib/data/models/token_model.dart": "8c957cd07e473827d78fd8fd4fb6c1336b636a69c25c93618e1e7f94b7cf0683" diff --git a/firka/lib/app/initialization.dart b/firka/lib/app/initialization.dart index 52aed18a..55602296 100644 --- a/firka/lib/app/initialization.dart +++ b/firka/lib/app/initialization.dart @@ -12,6 +12,7 @@ import 'package:firka/services/live_activity_service.dart'; import 'package:firka/core/settings/settings_effects.dart'; import 'package:firka/core/settings/settings_repository.dart'; import 'package:firka/core/settings/settings_schema.dart'; +import 'package:firka/core/settings/title_font.dart'; import 'package:firka/services/watch_sync_helper.dart'; import 'package:firka/l10n/app_localizations_de.dart'; import 'package:firka/l10n/app_localizations_en.dart'; @@ -80,24 +81,45 @@ void initTheme(AppInitialization data) { final brightness = SchedulerBinding.instance.platformDispatcher.platformBrightness; + final titleFont = Settings.titleFont.value; + final titleWeight = Settings.titleWeight.value; + final fonts = buildAppFonts( + headingFamily: titleFont.fontFamily, + headingWeight: titleWeight, + supportsWeight: titleFont.supportsWeight, + ); + + appHeadingTextCase = switch (Settings.titleCapitalization.value) { + TitleCapitalization.lower => HeadingTextCase.lower, + TitleCapitalization.upper => HeadingTextCase.upper, + TitleCapitalization.normal => HeadingTextCase.normal, + }; + + FirkaStyle baseStyle; switch (Settings.themeBrightness.value) { case ThemeBrightness.light: - appStyle = lightStyle; + baseStyle = lightStyle; themeCubit.setLightMode(true); break; case ThemeBrightness.dark: - appStyle = darkStyle; + baseStyle = darkStyle; themeCubit.setLightMode(false); break; case ThemeBrightness.auto: if (brightness == Brightness.dark) { - appStyle = darkStyle; + baseStyle = darkStyle; themeCubit.setLightMode(false); } else { - appStyle = lightStyle; + baseStyle = lightStyle; themeCubit.setLightMode(true); } } + + appStyle = FirkaStyle( + isLight: baseStyle.isLight, + colors: baseStyle.colors, + fonts: fonts, + ); } Future _initData(AppInitialization init) async { diff --git a/firka/lib/core/settings.dart b/firka/lib/core/settings.dart index dbe8ab23..d3f1a124 100644 --- a/firka/lib/core/settings.dart +++ b/firka/lib/core/settings.dart @@ -131,6 +131,68 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) { never, ); + final appIconPickerTree = [ + SettingsUiHeader(l10n.s_ci_icon_header, always), + SettingsUiHeader(l10n.s_ci_warning_header, isDebug), + // s_ci_icon_subtitle is intentionally unrendered: the original renderer + // never had a case for SettingsSubtitle either, so this was already dead. + SettingsUiPadding(24, always), + SettingsUiAppIconPreview(always), + SettingsUiPadding(24, always), + childProtection, + SettingsUiAppIconPicker( + { + l10n.s_ci_icon_g1: const ["original", "proto", "pride"], + l10n.s_ci_icon_g2: const ["pixel", "galaxy", "cactus"], + l10n.s_ci_icon_g3: const ["old", "refilc", "filc", "szivacs"], + l10n.s_ci_icon_g4: const [ + "modern", + "cc", + "paper", + "filco", + "o1g", + "pear", + "half_firka_2", + "nuke", + "refulc", + ], + l10n.s_ci_icon_g5: const [ + "kreta", + "cc", + "repont", + "void_icon", + "pixelized", + "mkkp", + "fidesz", + "tisza", + ], + l10n.s_ci_icon_g6: const ["xmas1", "xmas2", "xmas3"], + l10n.s_ci_icon_g7: const [ + "lgbtq", + "lgbtqp", + "trans", + "enby", + "ace", + "gay", + "lesb", + "bi", + ], + l10n.s_ci_icon_g8: const [ + "lgbtq_f", + "lgbtqp_f", + "trans_f", + "enby_f", + "ace_f", + "gay_f", + "lesb_f", + "bi_f", + ], + }, + childProtection, + always, + ), + ]; + return SettingsUiGroup([ SettingsUiBackHeader(l10n.s_a, always), SettingsUiHeader(l10n.s_settings, always), @@ -224,79 +286,7 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) { Majesticon.flower2Solid, l10n.s_c, [ - SettingsUiBackHeader(l10n.s_settings, always), - SettingsUiHeader(l10n.s_customization, always), - SettingsUiHeaderSmall(l10n.s_c_icon_header, always), - SettingsUiPadding(16, always), - SettingsUiAppIconPreview(always), - SettingsUiSubGroup(null, null, l10n.s_c_replace_icon, [ - SettingsUiHeader(l10n.s_ci_icon_header, always), - SettingsUiHeader(l10n.s_ci_warning_header, isDebug), - // s_ci_icon_subtitle is intentionally unrendered: the original renderer - // never had a case for SettingsSubtitle either, so this was already dead. - SettingsUiPadding(24, always), - SettingsUiAppIconPreview(always), - SettingsUiPadding(24, always), - childProtection, - SettingsUiAppIconPicker( - { - l10n.s_ci_icon_g1: const ["original", "proto", "pride"], - l10n.s_ci_icon_g2: const ["pixel", "galaxy", "cactus"], - l10n.s_ci_icon_g3: const ["old", "refilc", "filc", "szivacs"], - l10n.s_ci_icon_g4: const [ - "modern", - "cc", - "paper", - "filco", - "o1g", - "pear", - "half_firka_2", - "nuke", - "refulc", - ], - l10n.s_ci_icon_g5: const [ - "kreta", - "cc", - "repont", - "void_icon", - "pixelized", - "mkkp", - "fidesz", - "tisza", - ], - l10n.s_ci_icon_g6: const ["xmas1", "xmas2", "xmas3"], - l10n.s_ci_icon_g7: const [ - "lgbtq", - "lgbtqp", - "trans", - "enby", - "ace", - "gay", - "lesb", - "bi", - ], - l10n.s_ci_icon_g8: const [ - "lgbtq_f", - "lgbtqp_f", - "trans_f", - "enby_f", - "ace_f", - "gay_f", - "lesb_f", - "bi_f", - ], - }, - childProtection, - always, - ), - ], isAndroid), - SettingsUiPadding(16, always), - SettingsUiHeaderSmall(l10n.s_c_theme_header, always), - SettingsUiEnum(SettingsRegistry.themeBrightness, [ - l10n.s_c_theme_auto, - l10n.s_c_theme_light, - l10n.s_c_theme_dark, - ], always), + SettingsUiPersonalization(appIconPickerTree, always), ], always, ), diff --git a/firka/lib/core/settings/settings_effects.dart b/firka/lib/core/settings/settings_effects.dart index 3ff60d6a..1eaf2312 100644 --- a/firka/lib/core/settings/settings_effects.dart +++ b/firka/lib/core/settings/settings_effects.dart @@ -23,9 +23,20 @@ void registerSettingsEffects( repo.onChange(SettingsRegistry.themeBrightness, (_) async { initTheme(initData); + initData.themeCubit.refresh(); initData.homeRefreshCubit.requestRefresh(); }); + Future refreshTitleStyle(_) async { + initTheme(initData); + initData.themeCubit.refresh(); + initData.homeRefreshCubit.requestRefresh(); + } + + repo.onChange(SettingsRegistry.titleFont, refreshTitleStyle); + repo.onChange(SettingsRegistry.titleWeight, refreshTitleStyle); + repo.onChange(SettingsRegistry.titleCapitalization, refreshTitleStyle); + repo.onChange(SettingsRegistry.wearOsSupport, (enabled) async { if (!Platform.isAndroid) return; if (enabled && initDone) { diff --git a/firka/lib/core/settings/settings_schema.dart b/firka/lib/core/settings/settings_schema.dart index 81b5dc89..dfe0d454 100644 --- a/firka/lib/core/settings/settings_schema.dart +++ b/firka/lib/core/settings/settings_schema.dart @@ -7,6 +7,18 @@ enum AppLanguage { auto, hu, en, de } enum ThemeBrightness { auto, light, dark } +enum TitleFont { + montserrat, + monoton, + pirataOne, + justMeAgainDownHere, + figtree, + firaCode, + vollkorn, +} + +enum TitleCapitalization { lower, normal, upper } + abstract class SettingsSchema { @DoubleSetting(id: 1001, defaultValue: 0, min: 0, max: 120) double get bellDelay; @@ -96,4 +108,29 @@ abstract class SettingsSchema { @BoolSetting(id: 1024, defaultValue: false) bool get wearOsSupport; + + // 1025 is reserved for the selected Kréta account outside SettingsRegistry. + @EnumSetting( + id: 1026, + defaultValue: TitleFont.montserrat, + values: TitleFont.values, + ) + TitleFont get titleFont; + + @DoubleSetting( + id: 1027, + defaultValue: 700, + min: 100, + max: 900, + precision: 0, + step: 100, + ) + double get titleWeight; + + @EnumSetting( + id: 1028, + defaultValue: TitleCapitalization.normal, + values: TitleCapitalization.values, + ) + TitleCapitalization get titleCapitalization; } diff --git a/firka/lib/core/settings/settings_schema.gen.dart b/firka/lib/core/settings/settings_schema.gen.dart index 3396c2e1..a05196fb 100644 --- a/firka/lib/core/settings/settings_schema.gen.dart +++ b/firka/lib/core/settings/settings_schema.gen.dart @@ -3,47 +3,14 @@ part of "settings_schema.dart"; class SettingsRegistry { - static const bellDelay = DoubleSetting( - id: 1001, - defaultValue: 0, - min: 0, - max: 120, - ); - static const rounding1 = DoubleSetting( - id: 1002, - defaultValue: 0.5, - min: 0.1, - max: 0.99, - precision: 2, - ); - static const rounding2 = DoubleSetting( - id: 1003, - defaultValue: 0.5, - min: 0.1, - max: 0.99, - precision: 2, - ); - static const rounding3 = DoubleSetting( - id: 1004, - defaultValue: 0.5, - min: 0.1, - max: 0.99, - precision: 2, - ); - static const rounding4 = DoubleSetting( - id: 1005, - defaultValue: 0.5, - min: 0.1, - max: 0.99, - precision: 2, - ); + static const bellDelay = DoubleSetting(id: 1001, defaultValue: 0, min: 0, max: 120); + static const rounding1 = DoubleSetting(id: 1002, defaultValue: 0.5, min: 0.1, max: 0.99, precision: 2); + static const rounding2 = DoubleSetting(id: 1003, defaultValue: 0.5, min: 0.1, max: 0.99, precision: 2); + static const rounding3 = DoubleSetting(id: 1004, defaultValue: 0.5, min: 0.1, max: 0.99, precision: 2); + static const rounding4 = DoubleSetting(id: 1005, defaultValue: 0.5, min: 0.1, max: 0.99, precision: 2); static const classAvgOnGraph = BoolSetting(id: 1006, defaultValue: true); static const leftHandedMode = BoolSetting(id: 1007, defaultValue: false); - static const language = EnumSetting( - id: 1008, - defaultValue: AppLanguage.auto, - values: AppLanguage.values, - ); + static const language = EnumSetting(id: 1008, defaultValue: AppLanguage.auto, values: AppLanguage.values); static const appIcon = StringSetting(id: 0, defaultValue: "original"); static const childProtection = BoolSetting(id: 1010, defaultValue: true); static const betaWarning = BoolSetting(id: 1011, defaultValue: false); @@ -51,111 +18,50 @@ class SettingsRegistry { static const ttToastTestsAndHw = BoolSetting(id: 1013, defaultValue: true); static const ttToastBreaks = BoolSetting(id: 1014, defaultValue: true); static const statsForNerds = BoolSetting(id: 1015, defaultValue: false); - static const developerOptsEnabled = BoolSetting( - id: 1016, - defaultValue: false, - ); - static const themeBrightness = EnumSetting( - id: 1017, - defaultValue: ThemeBrightness.auto, - values: ThemeBrightness.values, - ); + static const developerOptsEnabled = BoolSetting(id: 1016, defaultValue: false); + static const themeBrightness = EnumSetting(id: 1017, defaultValue: ThemeBrightness.auto, values: ThemeBrightness.values); static const ttToastSubstitution = BoolSetting(id: 1018, defaultValue: true); static const liveActivityEnabled = BoolSetting(id: 1019, defaultValue: false); - static const liveActivityPrivacyEverDeclined = BoolSetting( - id: 1020, - defaultValue: false, - ); - static const morningNotificationEnabled = BoolSetting( - id: 1021, - defaultValue: true, - ); - static const morningNotificationTime = DoubleSetting( - id: 1022, - defaultValue: 120, - min: 30, - max: 240, - precision: 0, - step: 15, - ); + static const liveActivityPrivacyEverDeclined = BoolSetting(id: 1020, defaultValue: false); + static const morningNotificationEnabled = BoolSetting(id: 1021, defaultValue: true); + static const morningNotificationTime = DoubleSetting(id: 1022, defaultValue: 120, min: 30, max: 240, precision: 0, step: 15); static const ttToastABTimetable = BoolSetting(id: 1023, defaultValue: true); static const wearOsSupport = BoolSetting(id: 1024, defaultValue: false); + static const titleFont = EnumSetting(id: 1026, defaultValue: TitleFont.montserrat, values: TitleFont.values); + static const titleWeight = DoubleSetting(id: 1027, defaultValue: 700, min: 100, max: 900, precision: 0, step: 100); + static const titleCapitalization = EnumSetting(id: 1028, defaultValue: TitleCapitalization.normal, values: TitleCapitalization.values); static const all = [ - bellDelay, - rounding1, - rounding2, - rounding3, - rounding4, - classAvgOnGraph, - leftHandedMode, - language, - appIcon, - childProtection, - betaWarning, - ttToastLessonNo, - ttToastTestsAndHw, - ttToastBreaks, - statsForNerds, - developerOptsEnabled, - themeBrightness, - ttToastSubstitution, - liveActivityEnabled, - liveActivityPrivacyEverDeclined, - morningNotificationEnabled, - morningNotificationTime, - ttToastABTimetable, - wearOsSupport, + bellDelay, rounding1, rounding2, rounding3, rounding4, classAvgOnGraph, leftHandedMode, language, appIcon, childProtection, betaWarning, ttToastLessonNo, ttToastTestsAndHw, ttToastBreaks, statsForNerds, developerOptsEnabled, themeBrightness, ttToastSubstitution, liveActivityEnabled, liveActivityPrivacyEverDeclined, morningNotificationEnabled, morningNotificationTime, ttToastABTimetable, wearOsSupport, titleFont, titleWeight, titleCapitalization, ]; } extension SettingsAccessors on SettingsRepository { - SilentlySettable get bellDelay => - SilentlySettable(this, SettingsRegistry.bellDelay); - SilentlySettable get rounding1 => - SilentlySettable(this, SettingsRegistry.rounding1); - SilentlySettable get rounding2 => - SilentlySettable(this, SettingsRegistry.rounding2); - SilentlySettable get rounding3 => - SilentlySettable(this, SettingsRegistry.rounding3); - SilentlySettable get rounding4 => - SilentlySettable(this, SettingsRegistry.rounding4); - SilentlySettable get classAvgOnGraph => - SilentlySettable(this, SettingsRegistry.classAvgOnGraph); - SilentlySettable get leftHandedMode => - SilentlySettable(this, SettingsRegistry.leftHandedMode); - SilentlySettable get language => - SilentlySettable(this, SettingsRegistry.language); - SilentlySettable get appIcon => - SilentlySettable(this, SettingsRegistry.appIcon); - SilentlySettable get childProtection => - SilentlySettable(this, SettingsRegistry.childProtection); - SilentlySettable get betaWarning => - SilentlySettable(this, SettingsRegistry.betaWarning); - SilentlySettable get ttToastLessonNo => - SilentlySettable(this, SettingsRegistry.ttToastLessonNo); - SilentlySettable get ttToastTestsAndHw => - SilentlySettable(this, SettingsRegistry.ttToastTestsAndHw); - SilentlySettable get ttToastBreaks => - SilentlySettable(this, SettingsRegistry.ttToastBreaks); - SilentlySettable get statsForNerds => - SilentlySettable(this, SettingsRegistry.statsForNerds); - SilentlySettable get developerOptsEnabled => - SilentlySettable(this, SettingsRegistry.developerOptsEnabled); - SilentlySettable get themeBrightness => - SilentlySettable(this, SettingsRegistry.themeBrightness); - SilentlySettable get ttToastSubstitution => - SilentlySettable(this, SettingsRegistry.ttToastSubstitution); - SilentlySettable get liveActivityEnabled => - SilentlySettable(this, SettingsRegistry.liveActivityEnabled); - SilentlySettable get liveActivityPrivacyEverDeclined => - SilentlySettable(this, SettingsRegistry.liveActivityPrivacyEverDeclined); - SilentlySettable get morningNotificationEnabled => - SilentlySettable(this, SettingsRegistry.morningNotificationEnabled); - SilentlySettable get morningNotificationTime => - SilentlySettable(this, SettingsRegistry.morningNotificationTime); - SilentlySettable get ttToastABTimetable => - SilentlySettable(this, SettingsRegistry.ttToastABTimetable); - SilentlySettable get wearOsSupport => - SilentlySettable(this, SettingsRegistry.wearOsSupport); + SilentlySettable get bellDelay => SilentlySettable(this, SettingsRegistry.bellDelay); + SilentlySettable get rounding1 => SilentlySettable(this, SettingsRegistry.rounding1); + SilentlySettable get rounding2 => SilentlySettable(this, SettingsRegistry.rounding2); + SilentlySettable get rounding3 => SilentlySettable(this, SettingsRegistry.rounding3); + SilentlySettable get rounding4 => SilentlySettable(this, SettingsRegistry.rounding4); + SilentlySettable get classAvgOnGraph => SilentlySettable(this, SettingsRegistry.classAvgOnGraph); + SilentlySettable get leftHandedMode => SilentlySettable(this, SettingsRegistry.leftHandedMode); + SilentlySettable get language => SilentlySettable(this, SettingsRegistry.language); + SilentlySettable get appIcon => SilentlySettable(this, SettingsRegistry.appIcon); + SilentlySettable get childProtection => SilentlySettable(this, SettingsRegistry.childProtection); + SilentlySettable get betaWarning => SilentlySettable(this, SettingsRegistry.betaWarning); + SilentlySettable get ttToastLessonNo => SilentlySettable(this, SettingsRegistry.ttToastLessonNo); + SilentlySettable get ttToastTestsAndHw => SilentlySettable(this, SettingsRegistry.ttToastTestsAndHw); + SilentlySettable get ttToastBreaks => SilentlySettable(this, SettingsRegistry.ttToastBreaks); + SilentlySettable get statsForNerds => SilentlySettable(this, SettingsRegistry.statsForNerds); + SilentlySettable get developerOptsEnabled => SilentlySettable(this, SettingsRegistry.developerOptsEnabled); + SilentlySettable get themeBrightness => SilentlySettable(this, SettingsRegistry.themeBrightness); + SilentlySettable get ttToastSubstitution => SilentlySettable(this, SettingsRegistry.ttToastSubstitution); + SilentlySettable get liveActivityEnabled => SilentlySettable(this, SettingsRegistry.liveActivityEnabled); + SilentlySettable get liveActivityPrivacyEverDeclined => SilentlySettable(this, SettingsRegistry.liveActivityPrivacyEverDeclined); + SilentlySettable get morningNotificationEnabled => SilentlySettable(this, SettingsRegistry.morningNotificationEnabled); + SilentlySettable get morningNotificationTime => SilentlySettable(this, SettingsRegistry.morningNotificationTime); + SilentlySettable get ttToastABTimetable => SilentlySettable(this, SettingsRegistry.ttToastABTimetable); + SilentlySettable get wearOsSupport => SilentlySettable(this, SettingsRegistry.wearOsSupport); + SilentlySettable get titleFont => SilentlySettable(this, SettingsRegistry.titleFont); + SilentlySettable get titleWeight => SilentlySettable(this, SettingsRegistry.titleWeight); + SilentlySettable get titleCapitalization => SilentlySettable(this, SettingsRegistry.titleCapitalization); } diff --git a/firka/lib/core/settings/settings_ui.dart b/firka/lib/core/settings/settings_ui.dart index cd44f279..963098df 100644 --- a/firka/lib/core/settings/settings_ui.dart +++ b/firka/lib/core/settings/settings_ui.dart @@ -127,6 +127,15 @@ class SettingsUiAppIconPreview extends SettingsUiNode { const SettingsUiAppIconPreview(super.visible); } +class SettingsUiPersonalization extends SettingsUiNode { + final List appIconPickerChildren; + + const SettingsUiPersonalization( + this.appIconPickerChildren, + bool Function() visible, + ) : super(visible); +} + class SettingsUiAppIconPicker extends SettingsUiNode { final Map> iconGroups; final SettingsUiBoolean childProtection; diff --git a/firka/lib/core/settings/title_font.dart b/firka/lib/core/settings/title_font.dart new file mode 100644 index 00000000..3d0c3ac0 --- /dev/null +++ b/firka/lib/core/settings/title_font.dart @@ -0,0 +1,25 @@ +import "package:firka/core/settings/settings_schema.dart"; + +extension TitleFontInfo on TitleFont { + String get fontFamily => switch (this) { + TitleFont.montserrat => "Montserrat", + TitleFont.monoton => "Monoton", + TitleFont.pirataOne => "Pirata One", + TitleFont.justMeAgainDownHere => "Just Me Again Down Here", + TitleFont.figtree => "Figtree", + TitleFont.firaCode => "Fira Code", + TitleFont.vollkorn => "Vollkorn", + }; + + String get displayName => fontFamily; + + bool get supportsWeight => switch (this) { + TitleFont.montserrat || + TitleFont.figtree || + TitleFont.firaCode || + TitleFont.vollkorn => true, + TitleFont.monoton || + TitleFont.pirataOne || + TitleFont.justMeAgainDownHere => false, + }; +} diff --git a/firka/lib/ui/phone/pages/home/home_grades.dart b/firka/lib/ui/phone/pages/home/home_grades.dart index c93a1751..94ec10df 100644 --- a/firka/lib/ui/phone/pages/home/home_grades.dart +++ b/firka/lib/ui/phone/pages/home/home_grades.dart @@ -80,7 +80,7 @@ class _HomeGradesScreen extends FirkaState { Row( children: [ Text( - widget.data.l10n.subjects, + headingText(widget.data.l10n.subjects), style: appStyle.fonts.H_H2.apply( color: appStyle.colors.textPrimary, ), diff --git a/firka/lib/ui/phone/pages/home/home_omissions.dart b/firka/lib/ui/phone/pages/home/home_omissions.dart index 6aa423c9..f9586061 100644 --- a/firka/lib/ui/phone/pages/home/home_omissions.dart +++ b/firka/lib/ui/phone/pages/home/home_omissions.dart @@ -63,7 +63,7 @@ class _HomeOmissionsScreen extends FirkaState { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.data.l10n.omissions, + headingText(widget.data.l10n.omissions), style: appStyle.fonts.H_H2.apply( color: appStyle.colors.textPrimary, ), diff --git a/firka/lib/ui/phone/pages/home/home_timetable.dart b/firka/lib/ui/phone/pages/home/home_timetable.dart index 28f34972..abe6d939 100644 --- a/firka/lib/ui/phone/pages/home/home_timetable.dart +++ b/firka/lib/ui/phone/pages/home/home_timetable.dart @@ -411,7 +411,7 @@ class _HomeTimetableScreen extends FirkaState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - widget.data.l10n.timetable, + headingText(widget.data.l10n.timetable), style: appStyle.fonts.H_H2.apply( color: appStyle.colors.textPrimary, ), diff --git a/firka/lib/ui/phone/pages/home/home_timetable_mo.dart b/firka/lib/ui/phone/pages/home/home_timetable_mo.dart index fc1b2abe..b7b4f952 100644 --- a/firka/lib/ui/phone/pages/home/home_timetable_mo.dart +++ b/firka/lib/ui/phone/pages/home/home_timetable_mo.dart @@ -254,7 +254,7 @@ class _HomeTimetableMonthlyScreen mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - widget.data.l10n.timetable, + headingText(widget.data.l10n.timetable), style: appStyle.fonts.H_H2.apply( color: appStyle.colors.textPrimary, ), diff --git a/firka/lib/ui/phone/screens/settings/settings_personalization_view.dart b/firka/lib/ui/phone/screens/settings/settings_personalization_view.dart new file mode 100644 index 00000000..1babb99b --- /dev/null +++ b/firka/lib/ui/phone/screens/settings/settings_personalization_view.dart @@ -0,0 +1,600 @@ +import "dart:io"; + +import "package:firka/app/app_state.dart"; +import "package:firka/core/bloc/theme_cubit.dart"; +import "package:firka/core/settings/settings_repository.dart"; +import "package:firka/core/settings/settings_schema.dart"; +import "package:firka/core/settings/settings_ui.dart"; +import "package:firka/core/settings/title_font.dart"; +import "package:firka/l10n/app_localizations.dart"; +import "package:firka/ui/shared/firka_icon.dart"; +import "package:firka/ui/theme/style.dart"; +import "package:firka_common/ui/components/firka_card.dart"; +import "package:flutter/material.dart"; +import "package:flutter_bloc/flutter_bloc.dart"; +import "package:go_router/go_router.dart"; +import "package:majesticons_flutter/majesticons_flutter.dart"; + +class SettingsPersonalizationView extends StatefulWidget { + final AppInitialization data; + final SettingsUiPersonalization item; + + const SettingsPersonalizationView({ + required this.data, + required this.item, + super.key, + }); + + @override + State createState() => + _SettingsPersonalizationViewState(); +} + +class _SettingsPersonalizationViewState + extends State { + bool _fontPickerExpanded = false; + + SettingsRepository get _settings => widget.data.settings; + AppLocalizations get _l10n => widget.data.l10n; + + Color get _mutedCardColor => appStyle.isLight + ? const Color(0xFFE4EBC8) + : appStyle.colors.buttonSecondaryFill; + + Color get _selectedSurface => appStyle.colors.buttonSecondaryFill; + + Widget _sectionLabel(String text) { + return Padding( + padding: const EdgeInsets.only(left: 4, bottom: 8, top: 16), + child: Text( + text, + style: appStyle.fonts.B_16R.apply( + color: appStyle.colors.textPrimary, + ), + ), + ); + } + + Widget _externalArrow() { + return RotationTransition( + turns: const AlwaysStoppedAnimation(-45 / 360), + child: FirkaIconWidget( + FirkaIconType.majesticons, + Majesticon.arrowRightLine, + size: 20, + color: appStyle.colors.textSecondary, + ), + ); + } + + Widget _shortcutRow({ + required String title, + FirkaIconType? iconType, + Object? iconData, + VoidCallback? onTap, + }) { + final left = []; + if (iconType != null && iconData != null) { + left.add( + FirkaIconWidget( + iconType, + iconData, + color: appStyle.colors.accent, + ), + ); + left.add(const SizedBox(width: 8)); + } + left.add( + Text( + title, + style: appStyle.fonts.B_16SB.apply( + color: appStyle.colors.textPrimary, + ), + ), + ); + + return GestureDetector( + onTap: onTap, + child: FirkaCard( + left: left, + right: [_externalArrow()], + ), + ); + } + + Widget _chip(String label, {required bool selected}) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), + decoration: BoxDecoration( + color: selected ? _selectedSurface : appStyle.colors.card, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: appStyle.colors.shadowColor, + offset: const Offset(0, 1), + blurRadius: appStyle.isLight ? 2 : 0, + ), + ], + ), + child: Text( + label, + style: (selected ? appStyle.fonts.B_16SB : appStyle.fonts.B_16R).apply( + color: appStyle.colors.textPrimary, + ), + ), + ); + } + + Widget _swatchPreview(List colors) { + return FirkaCard.single( + width: double.infinity, + padding: EdgeInsets.zero, + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: SizedBox( + height: 88, + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + for (final color in colors) + Expanded(child: ColoredBox(color: color)), + ], + ), + ), + ), + ); + } + + Widget _stubCustomizeButton() { + return FirkaCard( + left: [ + Text( + _l10n.s_c_customize, + style: appStyle.fonts.B_16SB.apply( + color: appStyle.colors.textPrimary, + ), + ), + ], + ); + } + + Widget _checkMark() { + return SizedBox( + width: 16, + height: 16, + child: Checkbox( + value: true, + fillColor: WidgetStateProperty.resolveWith((_) { + return appStyle.colors.secondary; + }), + onChanged: (_) {}, + ), + ); + } + + Widget _themeOption(String label, ThemeBrightness value) { + final selected = _settings.get(SettingsRegistry.themeBrightness) == value; + + final card = FirkaCard( + height: 52 + 12, + left: [ + Text( + label, + style: appStyle.fonts.B_16R.apply( + color: appStyle.colors.textPrimary, + ), + ), + ], + right: selected + ? [_checkMark(), const SizedBox(width: 8)] + : [const SizedBox(height: 16 + 8)], + ); + + if (selected) return card; + + return GestureDetector( + onTap: () async { + await _settings.set(SettingsRegistry.themeBrightness, value); + setState(() {}); + }, + child: card, + ); + } + + Widget _fontCard(TitleFont font, {required bool selected}) { + final style = TextStyle( + fontFamily: font.fontFamily, + fontSize: 16, + fontVariations: font.supportsWeight + ? [FontVariation("wght", _settings.get(SettingsRegistry.titleWeight))] + : null, + color: appStyle.colors.textPrimary, + ); + + return GestureDetector( + onTap: selected + ? null + : () async { + await _settings.set(SettingsRegistry.titleFont, font); + setState(() {}); + }, + child: FirkaCard( + color: selected ? _selectedSurface : _mutedCardColor, + left: [ + Text(font.displayName, style: style), + ], + right: selected + ? [_checkMark(), const SizedBox(width: 8)] + : const [], + ), + ); + } + + Widget _changeRow() { + return GestureDetector( + onTap: () { + setState(() => _fontPickerExpanded = !_fontPickerExpanded); + }, + child: FirkaCard( + left: [ + Text( + _l10n.s_c_change, + style: appStyle.fonts.B_16SB.apply( + color: appStyle.colors.textPrimary, + ), + ), + ], + right: [ + FirkaIconWidget( + FirkaIconType.majesticons, + _fontPickerExpanded + ? Majesticon.chevronUpLine + : Majesticon.chevronDownLine, + size: 24, + color: appStyle.colors.textSecondary, + ), + ], + ), + ); + } + + Widget _fontPicker(TitleFont selected) { + if (!_fontPickerExpanded) { + return Column( + children: [ + _fontCard(selected, selected: true), + _changeRow(), + ], + ); + } + + return Column( + children: [ + for (final font in TitleFont.values) + _fontCard(font, selected: font == selected), + _changeRow(), + ], + ); + } + + double _textWidth(String text, TextStyle style) { + final painter = TextPainter( + text: TextSpan(text: text, style: style), + textDirection: TextDirection.ltr, + maxLines: 1, + )..layout(); + return painter.width; + } + + Widget _weightEndDot() { + return Container( + width: 12, + height: 12, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: appStyle.colors.textTertiary.withValues(alpha: 0.22), + ), + ); + } + + Widget _weightThumb({required double size}) { + return Container( + width: size, + height: size, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: appStyle.colors.accent, + border: Border.all( + color: appStyle.colors.buttonSecondaryFill, + width: 3, + ), + boxShadow: [ + BoxShadow( + color: appStyle.colors.shadowColor, + offset: const Offset(0, 1), + blurRadius: appStyle.isLight ? 3 : 0, + ), + ], + ), + ); + } + + Widget _weightSlider() { + final setting = SettingsRegistry.titleWeight; + final value = _settings.get(setting); + const trackHeight = 52.0; + const thumbSize = 28.0; + const thumbRadius = thumbSize / 2; + const edgePad = 16.0; + const gap = 8.0; + const endDotSize = 12.0; + + final labelStyle = appStyle.fonts.B_14R.apply( + color: appStyle.colors.textSecondary, + ); + final thinLabel = _l10n.s_c_title_weight_thin; + final thickLabel = _l10n.s_c_title_weight_thick; + final thinWidth = _textWidth(thinLabel, labelStyle); + final thickWidth = _textWidth(thickLabel, labelStyle); + + Future setFromLocalX(double localX, double width) async { + final start = edgePad + thumbRadius; + final end = width - edgePad - thumbRadius; + if (end <= start) return; + + final t = ((localX - start) / (end - start)).clamp(0.0, 1.0); + final raw = setting.min + t * (setting.max - setting.min); + final stepped = (raw / setting.step!).round() * setting.step!; + final clamped = stepped.clamp(setting.min, setting.max).toDouble(); + if (clamped == value) return; + + await _settings.set(setting, clamped); + setState(() {}); + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _sectionLabel(_l10n.s_c_title_weight_header), + Padding( + padding: const EdgeInsets.only(left: 4, bottom: 8), + child: Text( + _l10n.s_c_title_weight_subtitle, + style: appStyle.fonts.B_14R.apply( + color: appStyle.colors.textSecondary, + ), + ), + ), + FirkaCard.single( + width: double.infinity, + height: trackHeight, + padding: EdgeInsets.zero, + child: LayoutBuilder( + builder: (context, constraints) { + final width = constraints.maxWidth; + final start = edgePad + thumbRadius; + final end = width - edgePad - thumbRadius; + final t = ((value - setting.min) / (setting.max - setting.min)) + .clamp(0.0, 1.0); + final thumbCenterX = start + t * (end - start); + final thumbLeft = thumbCenterX - thumbRadius; + final thumbRight = thumbCenterX + thumbRadius; + + final thinLeft = edgePad + endDotSize + gap; + final thinRight = thinLeft + thinWidth; + final thickRight = width - edgePad - endDotSize - gap; + final thickLeft = thickRight - thickWidth; + + final showThin = thumbRight < thinLeft || thumbLeft > thinRight; + final showThick = thumbRight < thickLeft || thumbLeft > thickRight; + + return GestureDetector( + behavior: HitTestBehavior.opaque, + onTapDown: (details) { + setFromLocalX(details.localPosition.dx, width); + }, + onHorizontalDragUpdate: (details) { + setFromLocalX(details.localPosition.dx, width); + }, + child: Stack( + alignment: Alignment.center, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: edgePad), + child: Row( + children: [ + _weightEndDot(), + const SizedBox(width: gap), + Opacity( + opacity: showThin ? 1 : 0, + child: Text(thinLabel, style: labelStyle), + ), + const Spacer(), + Opacity( + opacity: showThick ? 1 : 0, + child: Text(thickLabel, style: labelStyle), + ), + const SizedBox(width: gap), + _weightEndDot(), + ], + ), + ), + Positioned( + left: thumbLeft, + child: _weightThumb(size: thumbSize), + ), + ], + ), + ); + }, + ), + ), + ], + ); + } + + Widget _capitalizationControl() { + final selected = _settings.get(SettingsRegistry.titleCapitalization); + final options = [ + (TitleCapitalization.lower, _l10n.s_c_capitalization_lower), + (TitleCapitalization.normal, _l10n.s_c_capitalization_normal), + (TitleCapitalization.upper, _l10n.s_c_capitalization_upper), + ]; + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _sectionLabel(_l10n.s_c_capitalization_header), + FirkaCard.single( + width: double.infinity, + color: appStyle.colors.card, + padding: const EdgeInsets.all(4), + child: Row( + children: [ + for (final (value, label) in options) + Expanded( + child: GestureDetector( + onTap: () async { + await _settings.set( + SettingsRegistry.titleCapitalization, + value, + ); + setState(() {}); + }, + child: AnimatedContainer( + duration: const Duration(milliseconds: 150), + padding: const EdgeInsets.symmetric(vertical: 10), + decoration: BoxDecoration( + color: selected == value + ? _selectedSurface + : Colors.transparent, + borderRadius: BorderRadius.circular(14), + boxShadow: selected == value + ? [ + BoxShadow( + color: appStyle.colors.shadowColor, + offset: const Offset(0, 1), + blurRadius: appStyle.isLight ? 2 : 0, + ), + ] + : null, + ), + child: Text( + label, + textAlign: TextAlign.center, + style: appStyle.fonts.B_14R.apply( + color: appStyle.colors.textPrimary, + ), + ), + ), + ), + ), + ], + ), + ), + ], + ); + } + + @override + Widget build(BuildContext context) { + return BlocProvider.value( + value: widget.data.themeCubit, + child: BlocBuilder( + builder: (context, _) { + final selectedFont = _settings.get(SettingsRegistry.titleFont); + + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + Transform.translate( + offset: const Offset(-4, 0), + child: GestureDetector( + onTap: () => Navigator.of(context).pop(), + child: FirkaIconWidget( + FirkaIconType.majesticons, + Majesticon.chevronLeftLine, + color: appStyle.colors.textSecondary, + ), + ), + ), + Transform.translate( + offset: const Offset(-4, 1), + child: Text( + headingText(_l10n.s_customization), + style: appStyle.fonts.H_H2.apply( + color: appStyle.colors.textPrimary, + ), + ), + ), + ], + ), + const SizedBox(height: 16), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + _chip(_l10n.s_c_tab_appearance, selected: true), + const SizedBox(width: 8), + _chip(_l10n.s_c_tab_subjects, selected: false), + const SizedBox(width: 8), + _chip(_l10n.s_c_tab_fonts, selected: false), + ], + ), + ), + const SizedBox(height: 16), + _shortcutRow( + title: _l10n.s_c_my_themes, + iconType: FirkaIconType.majesticons, + iconData: Majesticon.editPen4Solid, + ), + _shortcutRow( + title: _l10n.s_c_manage_subjects, + iconType: FirkaIconType.majesticons, + iconData: Majesticon.bookmarkSolid, + ), + if (Platform.isAndroid) + _shortcutRow( + title: _l10n.s_c_change_app_icon, + onTap: () { + context.push("/settings", extra: [ + SettingsUiBackHeader(_l10n.s_customization, () => true), + ...widget.item.appIconPickerChildren, + ]); + }, + ), + _sectionLabel(_l10n.s_c_colors_header), + _swatchPreview([ + appStyle.colors.secondary, + appStyle.colors.accent, + appStyle.colors.background, + appStyle.colors.card, + ]), + _stubCustomizeButton(), + _sectionLabel(_l10n.s_c_theme_header), + _themeOption(_l10n.s_c_theme_auto, ThemeBrightness.auto), + _themeOption(_l10n.s_c_theme_light, ThemeBrightness.light), + _themeOption(_l10n.s_c_theme_dark, ThemeBrightness.dark), + _sectionLabel(_l10n.s_c_grade_colors_header), + _swatchPreview([ + appStyle.colors.grade5, + appStyle.colors.grade4, + appStyle.colors.grade3, + appStyle.colors.grade2, + appStyle.colors.grade1, + ]), + _stubCustomizeButton(), + _sectionLabel(_l10n.s_c_title_style_header), + _fontPicker(selectedFont), + _weightSlider(), + _capitalizationControl(), + const SizedBox(height: 24), + ], + ); + }, + ), + ); + } +} diff --git a/firka/lib/ui/phone/screens/settings/settings_screen.dart b/firka/lib/ui/phone/screens/settings/settings_screen.dart index 919f141f..ce3dbd88 100644 --- a/firka/lib/ui/phone/screens/settings/settings_screen.dart +++ b/firka/lib/ui/phone/screens/settings/settings_screen.dart @@ -1,6 +1,9 @@ +import 'dart:async'; + import 'package:firka_common/data/database.dart'; import 'package:firka_common/data/models/token_model.dart'; import 'package:firka/core/bloc/app_icon_picker_cubit.dart'; +import 'package:firka/core/bloc/theme_cubit.dart'; import 'package:firka/core/settings/setting.dart'; import 'package:firka/core/settings/settings_repository.dart'; import 'package:firka/core/settings/settings_schema.dart'; @@ -23,6 +26,7 @@ import 'settings_app_icon_picker.dart'; import 'settings_bool_row.dart'; import 'settings_license_page.dart'; import 'settings_logs.dart'; +import 'settings_personalization_view.dart'; class SettingsScreen extends StatefulWidget { final AppInitialization data; @@ -39,6 +43,7 @@ class _SettingsScreenState extends FirkaState { late List tokens; late final AppIconPickerCubit appIconPickerCubit; + StreamSubscription? _themeSub; @override void initState() { @@ -46,10 +51,14 @@ class _SettingsScreenState extends FirkaState { tokens = isarInit.tokenModels.where().sortByUpdatedAtMsDesc().findAllSync(); appIconPickerCubit = AppIconPickerCubit(Settings.appIcon.value); + _themeSub = widget.data.themeCubit.stream.listen((_) { + if (mounted) setState(() {}); + }); } @override void dispose() { + _themeSub?.cancel(); appIconPickerCubit.close(); super.dispose(); } @@ -121,7 +130,7 @@ class _SettingsScreenState extends FirkaState { if (item is SettingsUiHeader) { widgets.add( Text( - item.title, + headingText(item.title), style: appStyle.fonts.H_H1.apply( color: appStyle.colors.textPrimary, ), @@ -133,7 +142,7 @@ class _SettingsScreenState extends FirkaState { if (item is SettingsUiMediumHeader) { widgets.add( Text( - item.title, + headingText(item.title), style: appStyle.fonts.H_H2.apply( color: appStyle.colors.textPrimary, ), @@ -343,6 +352,16 @@ class _SettingsScreenState extends FirkaState { continue; } + if (item is SettingsUiPersonalization) { + widgets.add( + SettingsPersonalizationView( + data: widget.data, + item: item, + ), + ); + + continue; + } if (item is SettingsUiAppIconPicker) { widgets.add( SettingsAppIconPickerView( diff --git a/firka/lib/ui/phone/widgets/home_main_welcome.dart b/firka/lib/ui/phone/widgets/home_main_welcome.dart index 3c64b09c..1250c1cb 100644 --- a/firka/lib/ui/phone/widgets/home_main_welcome.dart +++ b/firka/lib/ui/phone/widgets/home_main_welcome.dart @@ -160,7 +160,7 @@ class _WelcomeWidgetState extends State { getIconForCycle(dayCycle), const SizedBox(height: 16.0), Text( - getTitle(dayCycle), + headingText(getTitle(dayCycle)), style: appStyle.fonts.H_H2.copyWith( color: appStyle.colors.textPrimary, ), diff --git a/firka/pubspec.yaml b/firka/pubspec.yaml index a231a65d..88bef0ea 100644 --- a/firka/pubspec.yaml +++ b/firka/pubspec.yaml @@ -110,6 +110,26 @@ flutter: fonts: - asset: assets/fonts/RobotoMono-VariableFont_wght.ttf style: normal + - family: Monoton + fonts: + - asset: assets/fonts/Monoton-Regular.ttf + style: normal + - family: Pirata One + fonts: + - asset: assets/fonts/PirataOne-Regular.ttf + style: normal + - family: Just Me Again Down Here + fonts: + - asset: assets/fonts/JustMeAgainDownHere.ttf + style: normal + - family: Fira Code + fonts: + - asset: assets/fonts/FiraCode-VariableFont_wght.ttf + style: normal + - family: Vollkorn + fonts: + - asset: assets/fonts/Vollkorn-VariableFont_wght.ttf + style: normal dependency_overrides: vector_math: ^2.2.0 diff --git a/firka_common/lib/ui/theme/style.dart b/firka_common/lib/ui/theme/style.dart index f07f7ff6..723ab501 100644 --- a/firka_common/lib/ui/theme/style.dart +++ b/firka_common/lib/ui/theme/style.dart @@ -140,96 +140,129 @@ class FirkaStyle { }); } -final _defaultFonts = FirkaFonts( - H_H1: TextStyle( - fontSize: 30, - fontFamily: 'Montserrat', - fontVariations: [FontVariation("wght", 700)], - ), - H_18px: TextStyle( - fontSize: 18, - fontFamily: 'Montserrat', - fontVariations: [FontVariation("wght", 700)], - ), - H_H2: TextStyle( - fontSize: 20, - fontFamily: 'Montserrat', - fontVariations: [FontVariation("wght", 700)], - ), - H_16px: TextStyle( - fontSize: 16, - fontFamily: 'Montserrat', - fontVariations: [FontVariation("wght", 600)], - ), - H_14px: TextStyle( - fontSize: 14, - fontFamily: 'Montserrat', - fontVariations: [FontVariation("wght", 600)], - ), - H_12px: TextStyle( - fontSize: 12, - fontFamily: 'Montserrat', - fontVariations: [FontVariation("wght", 600)], - ), - H_16px_trimmed: TextStyle( - fontSize: 16, - fontFamily: 'Montserrat', - fontVariations: [FontVariation("wght", 600)], - height: 1.3, - ), - B_16R: TextStyle( - fontSize: 16, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 500)], - height: 1.3, - ), - B_16SB: TextStyle( - fontSize: 16, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 600)], - height: 1.3, - ), - B_14R: TextStyle( - fontSize: 14, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 500)], - height: 1.3, - ), - B_14SB: TextStyle( - fontSize: 14, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 600)], - height: 1.3, - ), - B_15SB: TextStyle( - fontSize: 15, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 700)], - height: 1.3, - ), - B_12R: TextStyle( - fontSize: 12, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 600)], - height: 1.3, - ), - B_12SB: TextStyle( - fontSize: 12, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 700)], - height: 1.3, - ), - P_14: TextStyle( - fontSize: 14, - fontFamily: 'RobotoMono', - fontVariations: [FontVariation("wght", 700)], - ), - P_12: TextStyle( - fontSize: 12, - fontFamily: 'RobotoMono', - fontVariations: [FontVariation("wght", 700)], - ), -); +enum HeadingTextCase { lower, normal, upper } + +HeadingTextCase appHeadingTextCase = HeadingTextCase.normal; + +String headingText(String text) { + switch (appHeadingTextCase) { + case HeadingTextCase.lower: + return text.toLowerCase(); + case HeadingTextCase.upper: + return text.toUpperCase(); + case HeadingTextCase.normal: + return text; + } +} + +FirkaFonts buildAppFonts({ + String headingFamily = "Montserrat", + double headingWeight = 700, + bool supportsWeight = true, +}) { + List? headingVariations(double weight) { + if (!supportsWeight) return null; + return [FontVariation("wght", weight)]; + } + + final boldWeight = supportsWeight ? headingWeight : 700.0; + final semiWeight = supportsWeight + ? (headingWeight * 600 / 700).clamp(100.0, 900.0).toDouble() + : 600.0; + + return FirkaFonts( + H_H1: TextStyle( + fontSize: 30, + fontFamily: headingFamily, + fontVariations: headingVariations(boldWeight), + ), + H_18px: TextStyle( + fontSize: 18, + fontFamily: headingFamily, + fontVariations: headingVariations(boldWeight), + ), + H_H2: TextStyle( + fontSize: 20, + fontFamily: headingFamily, + fontVariations: headingVariations(boldWeight), + ), + H_16px: TextStyle( + fontSize: 16, + fontFamily: headingFamily, + fontVariations: headingVariations(semiWeight), + ), + H_14px: TextStyle( + fontSize: 14, + fontFamily: headingFamily, + fontVariations: headingVariations(semiWeight), + ), + H_12px: TextStyle( + fontSize: 12, + fontFamily: headingFamily, + fontVariations: headingVariations(semiWeight), + ), + H_16px_trimmed: TextStyle( + fontSize: 16, + fontFamily: headingFamily, + fontVariations: headingVariations(semiWeight), + height: 1.3, + ), + B_16R: TextStyle( + fontSize: 16, + fontFamily: "Figtree", + fontVariations: [FontVariation("wght", 500)], + height: 1.3, + ), + B_16SB: TextStyle( + fontSize: 16, + fontFamily: "Figtree", + fontVariations: [FontVariation("wght", 600)], + height: 1.3, + ), + B_14R: TextStyle( + fontSize: 14, + fontFamily: "Figtree", + fontVariations: [FontVariation("wght", 500)], + height: 1.3, + ), + B_14SB: TextStyle( + fontSize: 14, + fontFamily: "Figtree", + fontVariations: [FontVariation("wght", 600)], + height: 1.3, + ), + B_15SB: TextStyle( + fontSize: 15, + fontFamily: "Figtree", + fontVariations: [FontVariation("wght", 700)], + height: 1.3, + ), + B_12R: TextStyle( + fontSize: 12, + fontFamily: "Figtree", + fontVariations: [FontVariation("wght", 600)], + height: 1.3, + ), + B_12SB: TextStyle( + fontSize: 12, + fontFamily: "Figtree", + fontVariations: [FontVariation("wght", 700)], + height: 1.3, + ), + P_14: TextStyle( + fontSize: 14, + fontFamily: "RobotoMono", + fontVariations: [FontVariation("wght", 700)], + ), + P_12: TextStyle( + fontSize: 12, + fontFamily: "RobotoMono", + fontVariations: [FontVariation("wght", 700)], + ), + ); +} + +final _defaultFonts = buildAppFonts(); final FirkaStyle lightStyle = FirkaStyle( isLight: true,