mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom app font weight
Closes #533 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -154,9 +154,9 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
indicatorColor: Theme.of(context).colorScheme.primary,
|
indicatorColor: Theme.of(context).colorScheme.primary,
|
||||||
labelColor: Theme.of(context).colorScheme.primary,
|
labelColor: Theme.of(context).colorScheme.primary,
|
||||||
unselectedLabelColor: Theme.of(context).colorScheme.onSurface,
|
unselectedLabelColor: Theme.of(context).colorScheme.onSurface,
|
||||||
labelStyle: TextStyle(
|
labelStyle:
|
||||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
|
||||||
),
|
const TextStyle(fontSize: 13),
|
||||||
tabs:
|
tabs:
|
||||||
DynamicsType.values.map((e) => Tab(text: e.labels)).toList(),
|
DynamicsType.values.map((e) => Tab(text: e.labels)).toList(),
|
||||||
onTap: (index) {
|
onTap: (index) {
|
||||||
|
|||||||
@@ -66,7 +66,10 @@ class _MemberContributeState extends State<MemberContribute>
|
|||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
indicatorSize: TabBarIndicatorSize.tab,
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
labelStyle: const TextStyle(fontSize: 14),
|
labelStyle: TabBarTheme.of(context)
|
||||||
|
.labelStyle
|
||||||
|
?.copyWith(fontSize: 14) ??
|
||||||
|
const TextStyle(fontSize: 14),
|
||||||
labelColor:
|
labelColor:
|
||||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||||
unselectedLabelColor: Theme.of(context).colorScheme.outline,
|
unselectedLabelColor: Theme.of(context).colorScheme.outline,
|
||||||
|
|||||||
@@ -120,7 +120,10 @@ class _SearchResultPageState extends State<SearchResultPage>
|
|||||||
),
|
),
|
||||||
indicatorSize: TabBarIndicatorSize.tab,
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||||
labelStyle: const TextStyle(fontSize: 13),
|
labelStyle: TabBarTheme.of(context)
|
||||||
|
.labelStyle
|
||||||
|
?.copyWith(fontSize: 13) ??
|
||||||
|
const TextStyle(fontSize: 13),
|
||||||
dividerColor: Colors.transparent,
|
dividerColor: Colors.transparent,
|
||||||
dividerHeight: 0,
|
dividerHeight: 0,
|
||||||
unselectedLabelColor: Theme.of(context).colorScheme.outline,
|
unselectedLabelColor: Theme.of(context).colorScheme.outline,
|
||||||
|
|||||||
@@ -146,6 +146,37 @@ List<SettingsModel> get styleSettings => [
|
|||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
needReboot: true,
|
needReboot: true,
|
||||||
),
|
),
|
||||||
|
SettingsModel(
|
||||||
|
settingsType: SettingsType.sw1tch,
|
||||||
|
title: 'App字体字重',
|
||||||
|
subtitle: '点击设置',
|
||||||
|
setKey: SettingBoxKey.appFontWeight,
|
||||||
|
defaultVal: false,
|
||||||
|
onTap: () {
|
||||||
|
showDialog<double>(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (context) {
|
||||||
|
return SlideDialog(
|
||||||
|
title: 'App字体字重',
|
||||||
|
value: GStorage.appFontWeight.toDouble() + 1,
|
||||||
|
min: 1,
|
||||||
|
max: FontWeight.values.length.toDouble(),
|
||||||
|
divisions: FontWeight.values.length - 1,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).then((res) async {
|
||||||
|
if (res != null) {
|
||||||
|
await GStorage.setting
|
||||||
|
.put(SettingBoxKey.appFontWeight, res.toInt() - 1);
|
||||||
|
Get.forceAppUpdate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
leading: const Icon(Icons.text_fields),
|
||||||
|
onChanged: (value) {
|
||||||
|
Get.forceAppUpdate();
|
||||||
|
},
|
||||||
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.sw1tch,
|
settingsType: SettingsType.sw1tch,
|
||||||
title: 'MD3样式底栏',
|
title: 'MD3样式底栏',
|
||||||
|
|||||||
@@ -36,20 +36,27 @@ class SetSwitchItem extends StatefulWidget {
|
|||||||
class _SetSwitchItemState extends State<SetSwitchItem> {
|
class _SetSwitchItemState extends State<SetSwitchItem> {
|
||||||
late bool val;
|
late bool val;
|
||||||
|
|
||||||
@override
|
void setVal() {
|
||||||
void didUpdateWidget(SetSwitchItem oldWidget) {
|
if (widget.setKey == SettingBoxKey.appFontWeight) {
|
||||||
super.didUpdateWidget(oldWidget);
|
val = GStorage.appFontWeight != -1;
|
||||||
if (oldWidget.setKey != widget.setKey) {
|
} else {
|
||||||
val = GStorage.setting
|
val = GStorage.setting
|
||||||
.get(widget.setKey, defaultValue: widget.defaultVal ?? false);
|
.get(widget.setKey, defaultValue: widget.defaultVal ?? false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(SetSwitchItem oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (oldWidget.setKey != widget.setKey) {
|
||||||
|
setVal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
val = GStorage.setting
|
setVal();
|
||||||
.get(widget.setKey, defaultValue: widget.defaultVal ?? false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchChange(value) async {
|
void switchChange(value) async {
|
||||||
@@ -89,7 +96,12 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
|
|||||||
|
|
||||||
val = value ?? !val;
|
val = value ?? !val;
|
||||||
|
|
||||||
await GStorage.setting.put(widget.setKey, val);
|
if (widget.setKey == SettingBoxKey.appFontWeight) {
|
||||||
|
await GStorage.setting.put(SettingBoxKey.appFontWeight, val ? 4 : -1);
|
||||||
|
} else {
|
||||||
|
await GStorage.setting.put(widget.setKey, val);
|
||||||
|
}
|
||||||
|
|
||||||
widget.onChanged?.call(val);
|
widget.onChanged?.call(val);
|
||||||
if (widget.needReboot == true) {
|
if (widget.needReboot == true) {
|
||||||
SmartDialog.showToast('重启生效');
|
SmartDialog.showToast('重启生效');
|
||||||
|
|||||||
@@ -1231,7 +1231,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
: null,
|
: null,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
labelStyle: const TextStyle(fontSize: 13),
|
labelStyle:
|
||||||
|
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
|
||||||
|
const TextStyle(fontSize: 13),
|
||||||
labelPadding:
|
labelPadding:
|
||||||
const EdgeInsets.symmetric(horizontal: 10.0), // 设置每个标签的宽度
|
const EdgeInsets.symmetric(horizontal: 10.0), // 设置每个标签的宽度
|
||||||
dividerColor: Colors.transparent,
|
dividerColor: Colors.transparent,
|
||||||
|
|||||||
@@ -1610,7 +1610,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
: null,
|
: null,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
labelStyle: const TextStyle(fontSize: 13),
|
labelStyle:
|
||||||
|
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
|
||||||
|
const TextStyle(fontSize: 13),
|
||||||
labelPadding:
|
labelPadding:
|
||||||
const EdgeInsets.symmetric(horizontal: 10.0), // 设置每个标签的宽度
|
const EdgeInsets.symmetric(horizontal: 10.0), // 设置每个标签的宽度
|
||||||
dividerColor: Colors.transparent,
|
dividerColor: Colors.transparent,
|
||||||
|
|||||||
@@ -436,6 +436,9 @@ class GStorage {
|
|||||||
GStorage.setting.get(SettingBoxKey.liveQualityCellular,
|
GStorage.setting.get(SettingBoxKey.liveQualityCellular,
|
||||||
defaultValue: LiveQuality.superHD.code);
|
defaultValue: LiveQuality.superHD.code);
|
||||||
|
|
||||||
|
static int get appFontWeight =>
|
||||||
|
GStorage.setting.get(SettingBoxKey.appFontWeight, defaultValue: -1);
|
||||||
|
|
||||||
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
||||||
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
||||||
|
|
||||||
@@ -717,6 +720,7 @@ class SettingBoxKey {
|
|||||||
retryDelay = 'retryDelay',
|
retryDelay = 'retryDelay',
|
||||||
liveQuality = 'liveQuality',
|
liveQuality = 'liveQuality',
|
||||||
liveQualityCellular = 'liveQualityCellular',
|
liveQualityCellular = 'liveQualityCellular',
|
||||||
|
appFontWeight = 'appFontWeight',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
@@ -64,16 +64,46 @@ class Utils {
|
|||||||
bool isDark = false,
|
bool isDark = false,
|
||||||
required FlexSchemeVariant variant,
|
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(
|
ThemeData themeData = ThemeData(
|
||||||
colorScheme: colorScheme,
|
colorScheme: colorScheme,
|
||||||
useMaterial3: true,
|
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(
|
appBarTheme: AppBarTheme(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
backgroundColor: isDynamic ? null : colorScheme.surface,
|
backgroundColor: isDynamic ? null : colorScheme.surface,
|
||||||
titleTextStyle: TextStyle(fontSize: 16, color: colorScheme.onSurface),
|
titleTextStyle: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
fontWeight: fontWeight,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
navigationBarTheme: NavigationBarThemeData(
|
navigationBarTheme: NavigationBarThemeData(
|
||||||
surfaceTintColor: isDynamic ? colorScheme.onSurfaceVariant : null,
|
surfaceTintColor: isDynamic ? colorScheme.onSurfaceVariant : null,
|
||||||
@@ -114,6 +144,7 @@ class Utils {
|
|||||||
titleTextStyle: TextStyle(
|
titleTextStyle: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
color: colorScheme.onSurface,
|
color: colorScheme.onSurface,
|
||||||
|
fontWeight: fontWeight,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user