feat: custom app font weight

Closes #533

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-26 21:39:58 +08:00
parent f5e9375917
commit 5d0b2dc8e3
9 changed files with 103 additions and 15 deletions

View File

@@ -436,6 +436,9 @@ class GStorage {
GStorage.setting.get(SettingBoxKey.liveQualityCellular,
defaultValue: LiveQuality.superHD.code);
static int get appFontWeight =>
GStorage.setting.get(SettingBoxKey.appFontWeight, defaultValue: -1);
static List<double> get dynamicDetailRatio => List<double>.from(setting
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
@@ -717,6 +720,7 @@ class SettingBoxKey {
retryDelay = 'retryDelay',
liveQuality = 'liveQuality',
liveQualityCellular = 'liveQualityCellular',
appFontWeight = 'appFontWeight',
// Sponsor Block
enableSponsorBlock = 'enableSponsorBlock',

View File

@@ -64,16 +64,46 @@ class Utils {
bool isDark = false,
required FlexSchemeVariant variant,
}) {
final appFontWeight =
GStorage.appFontWeight.clamp(-1, FontWeight.values.length - 1);
final fontWeight =
appFontWeight == -1 ? null : FontWeight.values[appFontWeight];
late final textStyle = TextStyle(fontWeight: fontWeight);
ThemeData themeData = ThemeData(
colorScheme: colorScheme,
useMaterial3: true,
textTheme: fontWeight == null
? null
: TextTheme(
displayLarge: textStyle,
displayMedium: textStyle,
displaySmall: textStyle,
headlineLarge: textStyle,
headlineMedium: textStyle,
headlineSmall: textStyle,
titleLarge: textStyle,
titleMedium: textStyle,
titleSmall: textStyle,
bodyLarge: textStyle,
bodyMedium: textStyle,
bodySmall: textStyle,
labelLarge: textStyle,
labelMedium: textStyle,
labelSmall: textStyle,
),
tabBarTheme:
fontWeight == null ? null : TabBarTheme(labelStyle: textStyle),
appBarTheme: AppBarTheme(
elevation: 0,
titleSpacing: 0,
centerTitle: false,
scrolledUnderElevation: 0,
backgroundColor: isDynamic ? null : colorScheme.surface,
titleTextStyle: TextStyle(fontSize: 16, color: colorScheme.onSurface),
titleTextStyle: TextStyle(
fontSize: 16,
color: colorScheme.onSurface,
fontWeight: fontWeight,
),
),
navigationBarTheme: NavigationBarThemeData(
surfaceTintColor: isDynamic ? colorScheme.onSurfaceVariant : null,
@@ -114,6 +144,7 @@ class Utils {
titleTextStyle: TextStyle(
fontSize: 18,
color: colorScheme.onSurface,
fontWeight: fontWeight,
),
),
);