mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom subtitle fontweight
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1043,6 +1043,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
int subtitlePaddingB = widget.controller.subtitlePaddingB;
|
||||
double subtitleBgOpaticy = widget.controller.subtitleBgOpaticy;
|
||||
double subtitleStrokeWidth = widget.controller.subtitleStrokeWidth;
|
||||
int subtitleFontWeight = widget.controller.subtitleFontWeight;
|
||||
|
||||
final sliderTheme = SliderThemeData(
|
||||
trackShape: MSliderTrackShape(),
|
||||
@@ -1063,7 +1064,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
widget.controller
|
||||
..subtitleStrokeWidth = subtitleStrokeWidth
|
||||
..updateSubtitleStyle()
|
||||
..putDanmakuSettings();
|
||||
..putSubtitleSettings();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -1072,7 +1073,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
widget.controller
|
||||
..subtitleBgOpaticy = subtitleBgOpaticy
|
||||
..updateSubtitleStyle()
|
||||
..putDanmakuSettings();
|
||||
..putSubtitleSettings();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -1081,7 +1082,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
widget.controller
|
||||
..subtitlePaddingB = subtitlePaddingB
|
||||
..updateSubtitleStyle()
|
||||
..putDanmakuSettings();
|
||||
..putSubtitleSettings();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -1090,7 +1091,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
widget.controller
|
||||
..subtitlePaddingH = subtitlePaddingH
|
||||
..updateSubtitleStyle()
|
||||
..putDanmakuSettings();
|
||||
..putSubtitleSettings();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -1099,7 +1100,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
widget.controller
|
||||
..subtitleFontScaleFS = subtitleFontScaleFS
|
||||
..updateSubtitleStyle()
|
||||
..putDanmakuSettings();
|
||||
..putSubtitleSettings();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -1108,7 +1109,16 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
widget.controller
|
||||
..subtitleFontScale = subtitleFontScale
|
||||
..updateSubtitleStyle()
|
||||
..putDanmakuSettings();
|
||||
..putSubtitleSettings();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void updateFontWeight(int val) {
|
||||
subtitleFontWeight = val;
|
||||
widget.controller
|
||||
..subtitleFontWeight = subtitleFontWeight
|
||||
..updateSubtitleStyle()
|
||||
..putSubtitleSettings();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -1188,6 +1198,34 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('字体粗细 ${subtitleFontWeight + 1}(可能无法精确调节)'),
|
||||
resetBtn(6, () => updateFontWeight(5)),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0,
|
||||
max: 8,
|
||||
value: subtitleFontWeight.toDouble(),
|
||||
divisions: 8,
|
||||
label: '${subtitleFontWeight + 1}',
|
||||
onChanged: (double val) {
|
||||
updateFontWeight(val.toInt());
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
||||
@@ -289,6 +289,7 @@ class PlPlayerController {
|
||||
late double subtitleBgOpaticy = GStorage.subtitleBgOpaticy;
|
||||
late bool showVipDanmaku = GStorage.showVipDanmaku;
|
||||
late double subtitleStrokeWidth = GStorage.subtitleStrokeWidth;
|
||||
late int subtitleFontWeight = GStorage.subtitleFontWeight;
|
||||
|
||||
// 播放顺序相关
|
||||
PlayRepeat playRepeat = PlayRepeat.pause;
|
||||
@@ -300,7 +301,7 @@ class PlPlayerController {
|
||||
letterSpacing: 0.1,
|
||||
wordSpacing: 0.1,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontWeight: FontWeight.values[subtitleFontWeight],
|
||||
backgroundColor: subtitleBgOpaticy == 0
|
||||
? null
|
||||
: Colors.black.withOpacity(subtitleBgOpaticy),
|
||||
@@ -1511,16 +1512,20 @@ class PlPlayerController {
|
||||
setting.put(SettingBoxKey.danmakuOpacity, opacityVal);
|
||||
setting.put(SettingBoxKey.danmakuFontScale, fontSizeVal);
|
||||
setting.put(SettingBoxKey.danmakuFontScaleFS, fontSizeFSVal);
|
||||
setting.put(SettingBoxKey.subtitleFontScale, subtitleFontScale);
|
||||
setting.put(SettingBoxKey.subtitleFontScaleFS, subtitleFontScaleFS);
|
||||
setting.put(SettingBoxKey.danmakuDuration, danmakuDurationVal);
|
||||
setting.put(SettingBoxKey.strokeWidth, strokeWidth);
|
||||
setting.put(SettingBoxKey.fontWeight, fontWeight);
|
||||
setting.put(SettingBoxKey.danmakuLineHeight, danmakuLineHeight);
|
||||
}
|
||||
|
||||
void putSubtitleSettings() {
|
||||
setting.put(SettingBoxKey.subtitleFontScale, subtitleFontScale);
|
||||
setting.put(SettingBoxKey.subtitleFontScaleFS, subtitleFontScaleFS);
|
||||
setting.put(SettingBoxKey.subtitlePaddingH, subtitlePaddingH);
|
||||
setting.put(SettingBoxKey.subtitlePaddingB, subtitlePaddingB);
|
||||
setting.put(SettingBoxKey.subtitleBgOpaticy, subtitleBgOpaticy);
|
||||
setting.put(SettingBoxKey.subtitleStrokeWidth, subtitleStrokeWidth);
|
||||
setting.put(SettingBoxKey.subtitleFontWeight, subtitleFontWeight);
|
||||
}
|
||||
|
||||
Future<void> dispose({String type = 'single'}) async {
|
||||
|
||||
@@ -318,7 +318,10 @@ class GStorage {
|
||||
setting.get(SettingBoxKey.subtitleBgOpaticy, defaultValue: 0.67);
|
||||
|
||||
static double get subtitleStrokeWidth =>
|
||||
setting.get(SettingBoxKey.subtitleStrokeWidth, defaultValue: 1.5);
|
||||
setting.get(SettingBoxKey.subtitleStrokeWidth, defaultValue: 2.0);
|
||||
|
||||
static int get subtitleFontWeight =>
|
||||
setting.get(SettingBoxKey.subtitleFontWeight, defaultValue: 5);
|
||||
|
||||
static bool get badCertificateCallback =>
|
||||
setting.get(SettingBoxKey.badCertificateCallback, defaultValue: false);
|
||||
@@ -658,6 +661,9 @@ class SettingBoxKey {
|
||||
subtitlePaddingB = 'subtitlePaddingB',
|
||||
subtitleBgOpaticy = 'subtitleBgOpaticy',
|
||||
subtitleStrokeWidth = 'subtitleStrokeWidth',
|
||||
subtitleFontScale = 'subtitleFontScale',
|
||||
subtitleFontScaleFS = 'subtitleFontScaleFS',
|
||||
subtitleFontWeight = 'subtitleFontWeight',
|
||||
badCertificateCallback = 'badCertificateCallback',
|
||||
continuePlayingPart = 'continuePlayingPart',
|
||||
cdnSpeedTest = 'cdnSpeedTest',
|
||||
@@ -723,8 +729,6 @@ class SettingBoxKey {
|
||||
strokeWidth = 'strokeWidth',
|
||||
fontWeight = 'fontWeight',
|
||||
memberTab = 'memberTab',
|
||||
subtitleFontScale = 'subtitleFontScale',
|
||||
subtitleFontScaleFS = 'subtitleFontScaleFS',
|
||||
dynamicDetailRatio = 'dynamicDetailRatio',
|
||||
|
||||
// 代理host port
|
||||
|
||||
Reference in New Issue
Block a user