forked from firka/firka
feat: initial customization screen
- Most buttons are stubs
This commit is contained in:
BIN
firka/assets/fonts/FiraCode-VariableFont_wght.ttf
Normal file
BIN
firka/assets/fonts/FiraCode-VariableFont_wght.ttf
Normal file
Binary file not shown.
BIN
firka/assets/fonts/JustMeAgainDownHere.ttf
Normal file
BIN
firka/assets/fonts/JustMeAgainDownHere.ttf
Normal file
Binary file not shown.
BIN
firka/assets/fonts/Monoton-Regular.ttf
Normal file
BIN
firka/assets/fonts/Monoton-Regular.ttf
Normal file
Binary file not shown.
BIN
firka/assets/fonts/PirataOne-Regular.ttf
Normal file
BIN
firka/assets/fonts/PirataOne-Regular.ttf
Normal file
Binary file not shown.
BIN
firka/assets/fonts/Vollkorn-VariableFont_wght.ttf
Normal file
BIN
firka/assets/fonts/Vollkorn-VariableFont_wght.ttf
Normal file
Binary file not shown.
@@ -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"
|
||||
|
||||
@@ -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<void> _initData(AppInitialization init) async {
|
||||
|
||||
@@ -131,6 +131,68 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
never,
|
||||
);
|
||||
|
||||
final appIconPickerTree = <SettingsUiNode>[
|
||||
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,
|
||||
),
|
||||
|
||||
@@ -23,9 +23,20 @@ void registerSettingsEffects(
|
||||
|
||||
repo.onChange(SettingsRegistry.themeBrightness, (_) async {
|
||||
initTheme(initData);
|
||||
initData.themeCubit.refresh();
|
||||
initData.homeRefreshCubit.requestRefresh();
|
||||
});
|
||||
|
||||
Future<void> 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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 = <Setting>[
|
||||
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<double> get bellDelay =>
|
||||
SilentlySettable(this, SettingsRegistry.bellDelay);
|
||||
SilentlySettable<double> get rounding1 =>
|
||||
SilentlySettable(this, SettingsRegistry.rounding1);
|
||||
SilentlySettable<double> get rounding2 =>
|
||||
SilentlySettable(this, SettingsRegistry.rounding2);
|
||||
SilentlySettable<double> get rounding3 =>
|
||||
SilentlySettable(this, SettingsRegistry.rounding3);
|
||||
SilentlySettable<double> get rounding4 =>
|
||||
SilentlySettable(this, SettingsRegistry.rounding4);
|
||||
SilentlySettable<bool> get classAvgOnGraph =>
|
||||
SilentlySettable(this, SettingsRegistry.classAvgOnGraph);
|
||||
SilentlySettable<bool> get leftHandedMode =>
|
||||
SilentlySettable(this, SettingsRegistry.leftHandedMode);
|
||||
SilentlySettable<AppLanguage> get language =>
|
||||
SilentlySettable(this, SettingsRegistry.language);
|
||||
SilentlySettable<String> get appIcon =>
|
||||
SilentlySettable(this, SettingsRegistry.appIcon);
|
||||
SilentlySettable<bool> get childProtection =>
|
||||
SilentlySettable(this, SettingsRegistry.childProtection);
|
||||
SilentlySettable<bool> get betaWarning =>
|
||||
SilentlySettable(this, SettingsRegistry.betaWarning);
|
||||
SilentlySettable<bool> get ttToastLessonNo =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastLessonNo);
|
||||
SilentlySettable<bool> get ttToastTestsAndHw =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastTestsAndHw);
|
||||
SilentlySettable<bool> get ttToastBreaks =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastBreaks);
|
||||
SilentlySettable<bool> get statsForNerds =>
|
||||
SilentlySettable(this, SettingsRegistry.statsForNerds);
|
||||
SilentlySettable<bool> get developerOptsEnabled =>
|
||||
SilentlySettable(this, SettingsRegistry.developerOptsEnabled);
|
||||
SilentlySettable<ThemeBrightness> get themeBrightness =>
|
||||
SilentlySettable(this, SettingsRegistry.themeBrightness);
|
||||
SilentlySettable<bool> get ttToastSubstitution =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastSubstitution);
|
||||
SilentlySettable<bool> get liveActivityEnabled =>
|
||||
SilentlySettable(this, SettingsRegistry.liveActivityEnabled);
|
||||
SilentlySettable<bool> get liveActivityPrivacyEverDeclined =>
|
||||
SilentlySettable(this, SettingsRegistry.liveActivityPrivacyEverDeclined);
|
||||
SilentlySettable<bool> get morningNotificationEnabled =>
|
||||
SilentlySettable(this, SettingsRegistry.morningNotificationEnabled);
|
||||
SilentlySettable<double> get morningNotificationTime =>
|
||||
SilentlySettable(this, SettingsRegistry.morningNotificationTime);
|
||||
SilentlySettable<bool> get ttToastABTimetable =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastABTimetable);
|
||||
SilentlySettable<bool> get wearOsSupport =>
|
||||
SilentlySettable(this, SettingsRegistry.wearOsSupport);
|
||||
SilentlySettable<double> get bellDelay => SilentlySettable(this, SettingsRegistry.bellDelay);
|
||||
SilentlySettable<double> get rounding1 => SilentlySettable(this, SettingsRegistry.rounding1);
|
||||
SilentlySettable<double> get rounding2 => SilentlySettable(this, SettingsRegistry.rounding2);
|
||||
SilentlySettable<double> get rounding3 => SilentlySettable(this, SettingsRegistry.rounding3);
|
||||
SilentlySettable<double> get rounding4 => SilentlySettable(this, SettingsRegistry.rounding4);
|
||||
SilentlySettable<bool> get classAvgOnGraph => SilentlySettable(this, SettingsRegistry.classAvgOnGraph);
|
||||
SilentlySettable<bool> get leftHandedMode => SilentlySettable(this, SettingsRegistry.leftHandedMode);
|
||||
SilentlySettable<AppLanguage> get language => SilentlySettable(this, SettingsRegistry.language);
|
||||
SilentlySettable<String> get appIcon => SilentlySettable(this, SettingsRegistry.appIcon);
|
||||
SilentlySettable<bool> get childProtection => SilentlySettable(this, SettingsRegistry.childProtection);
|
||||
SilentlySettable<bool> get betaWarning => SilentlySettable(this, SettingsRegistry.betaWarning);
|
||||
SilentlySettable<bool> get ttToastLessonNo => SilentlySettable(this, SettingsRegistry.ttToastLessonNo);
|
||||
SilentlySettable<bool> get ttToastTestsAndHw => SilentlySettable(this, SettingsRegistry.ttToastTestsAndHw);
|
||||
SilentlySettable<bool> get ttToastBreaks => SilentlySettable(this, SettingsRegistry.ttToastBreaks);
|
||||
SilentlySettable<bool> get statsForNerds => SilentlySettable(this, SettingsRegistry.statsForNerds);
|
||||
SilentlySettable<bool> get developerOptsEnabled => SilentlySettable(this, SettingsRegistry.developerOptsEnabled);
|
||||
SilentlySettable<ThemeBrightness> get themeBrightness => SilentlySettable(this, SettingsRegistry.themeBrightness);
|
||||
SilentlySettable<bool> get ttToastSubstitution => SilentlySettable(this, SettingsRegistry.ttToastSubstitution);
|
||||
SilentlySettable<bool> get liveActivityEnabled => SilentlySettable(this, SettingsRegistry.liveActivityEnabled);
|
||||
SilentlySettable<bool> get liveActivityPrivacyEverDeclined => SilentlySettable(this, SettingsRegistry.liveActivityPrivacyEverDeclined);
|
||||
SilentlySettable<bool> get morningNotificationEnabled => SilentlySettable(this, SettingsRegistry.morningNotificationEnabled);
|
||||
SilentlySettable<double> get morningNotificationTime => SilentlySettable(this, SettingsRegistry.morningNotificationTime);
|
||||
SilentlySettable<bool> get ttToastABTimetable => SilentlySettable(this, SettingsRegistry.ttToastABTimetable);
|
||||
SilentlySettable<bool> get wearOsSupport => SilentlySettable(this, SettingsRegistry.wearOsSupport);
|
||||
SilentlySettable<TitleFont> get titleFont => SilentlySettable(this, SettingsRegistry.titleFont);
|
||||
SilentlySettable<double> get titleWeight => SilentlySettable(this, SettingsRegistry.titleWeight);
|
||||
SilentlySettable<TitleCapitalization> get titleCapitalization => SilentlySettable(this, SettingsRegistry.titleCapitalization);
|
||||
}
|
||||
|
||||
@@ -127,6 +127,15 @@ class SettingsUiAppIconPreview extends SettingsUiNode {
|
||||
const SettingsUiAppIconPreview(super.visible);
|
||||
}
|
||||
|
||||
class SettingsUiPersonalization extends SettingsUiNode {
|
||||
final List<SettingsUiNode> appIconPickerChildren;
|
||||
|
||||
const SettingsUiPersonalization(
|
||||
this.appIconPickerChildren,
|
||||
bool Function() visible,
|
||||
) : super(visible);
|
||||
}
|
||||
|
||||
class SettingsUiAppIconPicker extends SettingsUiNode {
|
||||
final Map<String, List<String>> iconGroups;
|
||||
final SettingsUiBoolean childProtection;
|
||||
|
||||
25
firka/lib/core/settings/title_font.dart
Normal file
25
firka/lib/core/settings/title_font.dart
Normal file
@@ -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,
|
||||
};
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.subjects,
|
||||
headingText(widget.data.l10n.subjects),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
|
||||
@@ -63,7 +63,7 @@ class _HomeOmissionsScreen extends FirkaState<HomeOmissionsScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.omissions,
|
||||
headingText(widget.data.l10n.omissions),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
|
||||
@@ -411,7 +411,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.timetable,
|
||||
headingText(widget.data.l10n.timetable),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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<SettingsPersonalizationView> createState() =>
|
||||
_SettingsPersonalizationViewState();
|
||||
}
|
||||
|
||||
class _SettingsPersonalizationViewState
|
||||
extends State<SettingsPersonalizationView> {
|
||||
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 = <Widget>[];
|
||||
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<Color> 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<Color>((_) {
|
||||
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<void> 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<ThemeCubit>.value(
|
||||
value: widget.data.themeCubit,
|
||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||
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),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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<SettingsScreen> {
|
||||
|
||||
late List<TokenModel> tokens;
|
||||
late final AppIconPickerCubit appIconPickerCubit;
|
||||
StreamSubscription<ThemeState>? _themeSub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -46,10 +51,14 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
|
||||
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<SettingsScreen> {
|
||||
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<SettingsScreen> {
|
||||
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<SettingsScreen> {
|
||||
|
||||
continue;
|
||||
}
|
||||
if (item is SettingsUiPersonalization) {
|
||||
widgets.add(
|
||||
SettingsPersonalizationView(
|
||||
data: widget.data,
|
||||
item: item,
|
||||
),
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (item is SettingsUiAppIconPicker) {
|
||||
widgets.add(
|
||||
SettingsAppIconPickerView(
|
||||
|
||||
@@ -160,7 +160,7 @@ class _WelcomeWidgetState extends State<WelcomeWidget> {
|
||||
getIconForCycle(dayCycle),
|
||||
const SizedBox(height: 16.0),
|
||||
Text(
|
||||
getTitle(dayCycle),
|
||||
headingText(getTitle(dayCycle)),
|
||||
style: appStyle.fonts.H_H2.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<FontVariation>? 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,
|
||||
|
||||
Reference in New Issue
Block a user