mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-30 06:10:10 +08:00
refa: danmaku & feat: scroll fixed velocity (#1791)
This commit is contained in:
committed by
GitHub
parent
0a40d11133
commit
49b7ea14c3
@@ -5,6 +5,7 @@ import 'package:PiliPlus/pages/danmaku/controller.dart';
|
||||
import 'package:PiliPlus/pages/danmaku/danmaku_model.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_status.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/danmaku_options.dart';
|
||||
import 'package:PiliPlus/utils/danmaku_utils.dart';
|
||||
import 'package:canvas_danmaku/canvas_danmaku.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -29,6 +30,8 @@ class PlDanmaku extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<PlDanmaku> createState() => _PlDanmakuState();
|
||||
|
||||
bool get notFullscreen => !isFullScreen || isPipMode;
|
||||
}
|
||||
|
||||
class _PlDanmakuState extends State<PlDanmaku> {
|
||||
@@ -65,22 +68,13 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
||||
@override
|
||||
void didUpdateWidget(PlDanmaku oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.isPipMode != widget.isPipMode ||
|
||||
oldWidget.isFullScreen != widget.isFullScreen) {
|
||||
_updateFontSize();
|
||||
if (oldWidget.notFullscreen != widget.notFullscreen) {
|
||||
_controller?.updateOption(
|
||||
DanmakuOptions.get(notFullscreen: widget.notFullscreen),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _updateFontSize() {
|
||||
_controller?.updateOption(
|
||||
_controller!.option.copyWith(fontSize: _fontSize),
|
||||
);
|
||||
}
|
||||
|
||||
double get _fontSize => !widget.isFullScreen || widget.isPipMode
|
||||
? 15 * playerController.danmakuFontScale
|
||||
: 15 * playerController.danmakuFontScaleFS;
|
||||
|
||||
// 播放器状态监听
|
||||
void playerListener(PlayerStatus? status) {
|
||||
if (status == PlayerStatus.playing) {
|
||||
@@ -114,7 +108,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
||||
List<DanmakuElem>? currentDanmakuList = _plDanmakuController
|
||||
.getCurrentDanmaku(currentPosition);
|
||||
if (currentDanmakuList != null) {
|
||||
final blockColorful = playerController.blockColorful;
|
||||
final blockColorful = DanmakuOptions.blockColorful;
|
||||
for (DanmakuElem e in currentDanmakuList) {
|
||||
if (e.mode == 7) {
|
||||
try {
|
||||
@@ -177,22 +171,9 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
||||
createdController: (e) {
|
||||
playerController.danmakuController = _controller = e;
|
||||
},
|
||||
option: DanmakuOption(
|
||||
fontSize: _fontSize,
|
||||
fontWeight: playerController.danmakuFontWeight,
|
||||
area: playerController.showArea,
|
||||
hideTop: playerController.blockTypes.contains(5),
|
||||
hideScroll: playerController.blockTypes.contains(2),
|
||||
hideBottom: playerController.blockTypes.contains(4),
|
||||
hideSpecial: playerController.blockTypes.contains(7),
|
||||
duration:
|
||||
playerController.danmakuDuration /
|
||||
playerController.playbackSpeed,
|
||||
staticDuration:
|
||||
playerController.danmakuStaticDuration /
|
||||
playerController.playbackSpeed,
|
||||
strokeWidth: playerController.danmakuStrokeWidth,
|
||||
lineHeight: playerController.danmakuLineHeight,
|
||||
option: DanmakuOptions.get(
|
||||
notFullscreen: widget.notFullscreen,
|
||||
speed: playerController.playbackSpeed,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -19,6 +19,7 @@ import 'package:PiliPlus/pages/live_room/send_danmaku/view.dart';
|
||||
import 'package:PiliPlus/pages/video/widgets/header_control.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/data_source.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/danmaku_options.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
import 'package:PiliPlus/tcp/live.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
@@ -433,7 +434,7 @@ class LiveRoomController extends GetxController {
|
||||
danmakuController?.addDanmaku(
|
||||
DanmakuContentItem(
|
||||
msg,
|
||||
color: plPlayerController.blockColorful
|
||||
color: DanmakuOptions.blockColorful
|
||||
? Colors.white
|
||||
: DmUtils.decimalToColor(extra['color']),
|
||||
type: DmUtils.getPosition(extra['mode']),
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:PiliPlus/pages/live_room/widgets/header_control.dart';
|
||||
import 'package:PiliPlus/pages/video/widgets/player_focus.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_status.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/danmaku_options.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/view.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
@@ -974,6 +975,8 @@ class LiveDanmaku extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<LiveDanmaku> createState() => _LiveDanmakuState();
|
||||
|
||||
bool get notFullscreen => !isFullScreen || isPipMode;
|
||||
}
|
||||
|
||||
class _LiveDanmakuState extends State<LiveDanmaku> {
|
||||
@@ -982,27 +985,13 @@ class _LiveDanmakuState extends State<LiveDanmaku> {
|
||||
@override
|
||||
void didUpdateWidget(LiveDanmaku oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.isPipMode != widget.isPipMode ||
|
||||
oldWidget.isFullScreen != widget.isFullScreen) {
|
||||
_updateFontSize();
|
||||
if (oldWidget.notFullscreen != widget.notFullscreen) {
|
||||
plPlayerController.danmakuController?.updateOption(
|
||||
DanmakuOptions.get(notFullscreen: widget.notFullscreen),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _updateFontSize() {
|
||||
plPlayerController.danmakuController?.updateOption(
|
||||
plPlayerController.danmakuController!.option.copyWith(
|
||||
fontSize: _fontSize,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
double get _fontSize =>
|
||||
plPlayerController.isDesktopPip ||
|
||||
!widget.isFullScreen ||
|
||||
widget.isPipMode
|
||||
? 15 * plPlayerController.danmakuFontScale
|
||||
: 15 * plPlayerController.danmakuFontScaleFS;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(
|
||||
@@ -1017,22 +1006,7 @@ class _LiveDanmakuState extends State<LiveDanmaku> {
|
||||
widget.liveRoomController.danmakuController =
|
||||
plPlayerController.danmakuController = e;
|
||||
},
|
||||
option: DanmakuOption(
|
||||
fontSize: _fontSize,
|
||||
fontWeight: plPlayerController.danmakuFontWeight,
|
||||
area: plPlayerController.showArea,
|
||||
hideTop: plPlayerController.blockTypes.contains(5),
|
||||
hideScroll: plPlayerController.blockTypes.contains(2),
|
||||
hideBottom: plPlayerController.blockTypes.contains(4),
|
||||
duration:
|
||||
plPlayerController.danmakuDuration /
|
||||
plPlayerController.playbackSpeed,
|
||||
staticDuration:
|
||||
plPlayerController.danmakuStaticDuration /
|
||||
plPlayerController.playbackSpeed,
|
||||
strokeWidth: plPlayerController.danmakuStrokeWidth,
|
||||
lineHeight: plPlayerController.danmakuLineHeight,
|
||||
),
|
||||
option: DanmakuOptions.get(notFullscreen: widget.notFullscreen),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||
import 'package:PiliPlus/pages/live_room/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/widgets/header_control.dart'
|
||||
show HeaderMixin;
|
||||
import 'package:PiliPlus/pages/video/widgets/header_mixin.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/video_fit_type.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/widgets/common_btn.dart';
|
||||
|
||||
@@ -25,13 +25,13 @@ import 'package:PiliPlus/models_new/video/video_play_info/subtitle.dart';
|
||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||
import 'package:PiliPlus/pages/danmaku/danmaku_model.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/switch_item.dart';
|
||||
import 'package:PiliPlus/pages/video/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/local/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/menu_row.dart';
|
||||
import 'package:PiliPlus/pages/video/widgets/header_mixin.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
||||
@@ -169,636 +169,6 @@ mixin TimeBatteryMixin<T extends StatefulWidget> on State<T> {
|
||||
}
|
||||
}
|
||||
|
||||
mixin HeaderMixin<T extends StatefulWidget> on State<T> {
|
||||
PlPlayerController get plPlayerController;
|
||||
|
||||
bool get isFullScreen => plPlayerController.isFullScreen.value;
|
||||
|
||||
void showBottomSheet(StatefulWidgetBuilder builder, {double? padding}) {
|
||||
PageUtils.showVideoBottomSheet(
|
||||
context,
|
||||
isFullScreen: () => isFullScreen,
|
||||
padding: padding,
|
||||
child: StatefulBuilder(
|
||||
builder: (context, setState) => plPlayerController.darkVideoPage
|
||||
? Theme(
|
||||
data: Theme.of(this.context),
|
||||
child: builder(this.context, setState),
|
||||
)
|
||||
: builder(context, setState),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget resetBtn(
|
||||
ThemeData theme,
|
||||
Object def,
|
||||
VoidCallback onPressed, {
|
||||
bool isDanmaku = true,
|
||||
}) {
|
||||
return iconButton(
|
||||
tooltip: '默认值: $def',
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
onPressed();
|
||||
if (isDanmaku) {
|
||||
plPlayerController.putDanmakuSettings();
|
||||
} else {
|
||||
plPlayerController.putSubtitleSettings();
|
||||
}
|
||||
},
|
||||
iconColor: theme.colorScheme.outline,
|
||||
size: 24,
|
||||
iconSize: 24,
|
||||
);
|
||||
}
|
||||
|
||||
/// 弹幕功能
|
||||
void showSetDanmaku({bool isLive = false}) {
|
||||
// 屏蔽类型
|
||||
const blockTypesList = [
|
||||
(value: 2, label: '滚动'),
|
||||
(value: 5, label: '顶部'),
|
||||
(value: 4, label: '底部'),
|
||||
(value: 6, label: '彩色'),
|
||||
(value: 7, label: '高级'),
|
||||
];
|
||||
final blockTypes = plPlayerController.blockTypes;
|
||||
// 智能云屏蔽
|
||||
int danmakuWeight = plPlayerController.danmakuWeight;
|
||||
// 显示区域
|
||||
double showArea = plPlayerController.showArea;
|
||||
// 不透明度
|
||||
double danmakuOpacity = plPlayerController.danmakuOpacity.value;
|
||||
// 字体大小
|
||||
double danmakuFontScale = plPlayerController.danmakuFontScale;
|
||||
// 全屏字体大小
|
||||
double danmakuFontScaleFS = plPlayerController.danmakuFontScaleFS;
|
||||
double danmakuLineHeight = plPlayerController.danmakuLineHeight;
|
||||
// 弹幕速度
|
||||
double danmakuDuration = plPlayerController.danmakuDuration;
|
||||
double danmakuStaticDuration = plPlayerController.danmakuStaticDuration;
|
||||
// 弹幕描边
|
||||
double danmakuStrokeWidth = plPlayerController.danmakuStrokeWidth;
|
||||
// 字体粗细
|
||||
int danmakuFontWeight = plPlayerController.danmakuFontWeight;
|
||||
bool massiveMode = plPlayerController.massiveMode;
|
||||
|
||||
final DanmakuController<DanmakuExtra>? danmakuController =
|
||||
plPlayerController.danmakuController;
|
||||
|
||||
final isFullScreen = this.isFullScreen;
|
||||
|
||||
showBottomSheet(
|
||||
(context, setState) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
final sliderTheme = SliderThemeData(
|
||||
trackHeight: 10,
|
||||
trackShape: const MSliderTrackShape(),
|
||||
thumbColor: theme.colorScheme.primary,
|
||||
activeTrackColor: theme.colorScheme.primary,
|
||||
inactiveTrackColor: theme.colorScheme.onInverseSurface,
|
||||
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 6.0),
|
||||
);
|
||||
|
||||
void updateLineHeight(double val) {
|
||||
plPlayerController.danmakuLineHeight = danmakuLineHeight = val
|
||||
.toPrecision(1);
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(
|
||||
lineHeight: danmakuLineHeight,
|
||||
),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
void updateDuration(double val) {
|
||||
plPlayerController.danmakuDuration = danmakuDuration = val
|
||||
.toPrecision(1);
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(
|
||||
duration: danmakuDuration / plPlayerController.playbackSpeed,
|
||||
),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
void updateStaticDuration(double val) {
|
||||
plPlayerController.danmakuStaticDuration = danmakuStaticDuration = val
|
||||
.toPrecision(1);
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(
|
||||
staticDuration:
|
||||
danmakuStaticDuration / plPlayerController.playbackSpeed,
|
||||
),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
void updateFontSizeFS(double val) {
|
||||
plPlayerController.danmakuFontScaleFS = danmakuFontScaleFS = val;
|
||||
setState(() {});
|
||||
if (isFullScreen) {
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(
|
||||
fontSize: (15 * danmakuFontScaleFS).toDouble(),
|
||||
),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
void updateFontSize(double val) {
|
||||
plPlayerController.danmakuFontScale = danmakuFontScale = val;
|
||||
setState(() {});
|
||||
if (!isFullScreen) {
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(
|
||||
fontSize: (15 * danmakuFontScale).toDouble(),
|
||||
),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
void updateStrokeWidth(double val) {
|
||||
plPlayerController.danmakuStrokeWidth = danmakuStrokeWidth = val;
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(
|
||||
strokeWidth: danmakuStrokeWidth,
|
||||
),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
void updateFontWeight(double val) {
|
||||
plPlayerController.danmakuFontWeight = danmakuFontWeight = val
|
||||
.toInt();
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(fontWeight: danmakuFontWeight),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
void updateOpacity(double val) {
|
||||
plPlayerController.danmakuOpacity.value = danmakuOpacity = val;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void updateShowArea(double val) {
|
||||
plPlayerController.showArea = showArea = val.toPrecision(1);
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(area: showArea),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
void updateDanmakuWeight(double val) {
|
||||
plPlayerController.danmakuWeight = danmakuWeight = val.toInt();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void onUpdateBlockType(int blockType, bool blocked) {
|
||||
if (blocked) {
|
||||
blockTypes.remove(blockType);
|
||||
} else {
|
||||
blockTypes.add(blockType);
|
||||
}
|
||||
plPlayerController
|
||||
..blockTypes = blockTypes
|
||||
..blockColorful = blockTypes.contains(6)
|
||||
..putDanmakuSettings();
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(
|
||||
hideTop: blockTypes.contains(5),
|
||||
hideBottom: blockTypes.contains(4),
|
||||
hideScroll: blockTypes.contains(2),
|
||||
hideSpecial: blockTypes.contains(7),
|
||||
// 添加或修改其他需要修改的选项属性
|
||||
),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Material(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 45,
|
||||
child: Center(
|
||||
child: Text('弹幕设置', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (!isLive) ...[
|
||||
Row(
|
||||
children: [
|
||||
Text('智能云屏蔽 $danmakuWeight 级'),
|
||||
const Spacer(),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
onPressed: () => Get
|
||||
..back()
|
||||
..toNamed(
|
||||
'/danmakuBlock',
|
||||
arguments: plPlayerController,
|
||||
),
|
||||
child: Text(
|
||||
"屏蔽管理(${plPlayerController.filters.count})",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0,
|
||||
max: 10,
|
||||
value: danmakuWeight.toDouble(),
|
||||
divisions: 10,
|
||||
label: '$danmakuWeight',
|
||||
onChanged: updateDanmakuWeight,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const Text('按类型屏蔽'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: blockTypesList.map(
|
||||
(e) {
|
||||
final blocked = blockTypes.contains(e.value);
|
||||
return ActionRowLineItem(
|
||||
onTap: () => onUpdateBlockType(e.value, blocked),
|
||||
text: e.label,
|
||||
selectStatus: blocked,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
SetSwitchItem(
|
||||
title: '海量弹幕',
|
||||
contentPadding: EdgeInsets.zero,
|
||||
titleStyle: const TextStyle(fontSize: 14),
|
||||
defaultVal: massiveMode,
|
||||
setKey: SettingBoxKey.danmakuMassiveMode,
|
||||
onChanged: (value) {
|
||||
massiveMode = value;
|
||||
plPlayerController.massiveMode = value;
|
||||
setState(() {});
|
||||
try {
|
||||
danmakuController?.updateOption(
|
||||
danmakuController.option.copyWith(massiveMode: value),
|
||||
);
|
||||
} catch (_) {}
|
||||
},
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('显示区域 ${showArea * 100}%'),
|
||||
resetBtn(
|
||||
theme,
|
||||
'50.0%',
|
||||
() => updateShowArea(0.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0.1,
|
||||
max: 1,
|
||||
value: showArea,
|
||||
divisions: 9,
|
||||
label: '${showArea * 100}%',
|
||||
onChanged: updateShowArea,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('不透明度 ${danmakuOpacity * 100}%'),
|
||||
resetBtn(
|
||||
theme,
|
||||
'100.0%',
|
||||
() => updateOpacity(1.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0,
|
||||
max: 1,
|
||||
value: danmakuOpacity,
|
||||
divisions: 10,
|
||||
label: '${danmakuOpacity * 100}%',
|
||||
onChanged: updateOpacity,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('字体粗细 ${danmakuFontWeight + 1}(可能无法精确调节)'),
|
||||
resetBtn(
|
||||
theme,
|
||||
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: danmakuFontWeight.toDouble(),
|
||||
divisions: 8,
|
||||
label: '${danmakuFontWeight + 1}',
|
||||
onChanged: updateFontWeight,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('描边粗细 $danmakuStrokeWidth'),
|
||||
resetBtn(
|
||||
theme,
|
||||
1.5,
|
||||
() => updateStrokeWidth(1.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0,
|
||||
max: 5,
|
||||
value: danmakuStrokeWidth,
|
||||
divisions: 10,
|
||||
label: '$danmakuStrokeWidth',
|
||||
onChanged: updateStrokeWidth,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'字体大小 ${(danmakuFontScale * 100).toStringAsFixed(1)}%',
|
||||
),
|
||||
resetBtn(
|
||||
theme,
|
||||
'100.0%',
|
||||
() => updateFontSize(1.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0.5,
|
||||
max: 2.5,
|
||||
value: danmakuFontScale,
|
||||
divisions: 20,
|
||||
label:
|
||||
'${(danmakuFontScale * 100).toStringAsFixed(1)}%',
|
||||
onChanged: updateFontSize,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'全屏字体大小 ${(danmakuFontScaleFS * 100).toStringAsFixed(1)}%',
|
||||
),
|
||||
resetBtn(
|
||||
theme,
|
||||
'120.0%',
|
||||
() => updateFontSizeFS(1.2),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0.5,
|
||||
max: 2.5,
|
||||
value: danmakuFontScaleFS,
|
||||
divisions: 20,
|
||||
label:
|
||||
'${(danmakuFontScaleFS * 100).toStringAsFixed(1)}%',
|
||||
onChanged: updateFontSizeFS,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('滚动弹幕时长 $danmakuDuration 秒'),
|
||||
resetBtn(
|
||||
theme,
|
||||
7.0,
|
||||
() => updateDuration(7.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 1,
|
||||
max: 50,
|
||||
value: danmakuDuration,
|
||||
divisions: 49,
|
||||
label: danmakuDuration.toString(),
|
||||
onChanged: updateDuration,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('静态弹幕时长 $danmakuStaticDuration 秒'),
|
||||
resetBtn(
|
||||
theme,
|
||||
4.0,
|
||||
() => updateStaticDuration(4.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 1,
|
||||
max: 50,
|
||||
value: danmakuStaticDuration,
|
||||
divisions: 49,
|
||||
label: danmakuStaticDuration.toString(),
|
||||
onChanged: updateStaticDuration,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('弹幕行高 $danmakuLineHeight'),
|
||||
resetBtn(
|
||||
theme,
|
||||
1.6,
|
||||
() => updateLineHeight(1.6),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 1.0,
|
||||
max: 3.0,
|
||||
value: danmakuLineHeight,
|
||||
onChanged: updateLineHeight,
|
||||
onChangeEnd: (_) =>
|
||||
plPlayerController.putDanmakuSettings(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HeaderControl extends StatefulWidget {
|
||||
const HeaderControl({
|
||||
required this.isPortrait,
|
||||
@@ -2298,9 +1668,9 @@ class HeaderControlState extends State<HeaderControl>
|
||||
bgColor: theme.colorScheme.surface,
|
||||
),
|
||||
),
|
||||
?_buildDanmakuList(ctr.staticDanmaku),
|
||||
?_buildDanmakuList(ctr.scrollDanmaku),
|
||||
?_buildDanmakuList(ctr.specialDanmaku),
|
||||
?_buildDanmakuList(ctr.staticDanmaku.nonNulls.toList()),
|
||||
?_buildDanmakuList(ctr.scrollDanmaku.expand((e) => e).toList()),
|
||||
?_buildDanmakuList(ctr.specialDanmaku.toList()),
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 12)),
|
||||
],
|
||||
),
|
||||
@@ -2311,7 +1681,6 @@ class HeaderControlState extends State<HeaderControl>
|
||||
|
||||
Widget? _buildDanmakuList(List<DanmakuItem<DanmakuExtra>> list) {
|
||||
if (list.isEmpty) return null;
|
||||
list = List.of(list);
|
||||
|
||||
return SliverList.builder(
|
||||
itemCount: list.length,
|
||||
@@ -2972,23 +2341,3 @@ class HeaderControlState extends State<HeaderControl>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MSliderTrackShape extends RoundedRectSliderTrackShape {
|
||||
const MSliderTrackShape();
|
||||
|
||||
@override
|
||||
Rect getPreferredRect({
|
||||
required RenderBox parentBox,
|
||||
Offset offset = Offset.zero,
|
||||
SliderThemeData? sliderTheme,
|
||||
bool isEnabled = false,
|
||||
bool isDiscrete = false,
|
||||
}) {
|
||||
const double trackHeight = 3;
|
||||
final double trackLeft = offset.dx;
|
||||
final double trackTop =
|
||||
offset.dy + (parentBox.size.height - trackHeight) / 2 + 4;
|
||||
final double trackWidth = parentBox.size.width;
|
||||
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
|
||||
}
|
||||
}
|
||||
|
||||
581
lib/pages/video/widgets/header_mixin.dart
Normal file
581
lib/pages/video/widgets/header_mixin.dart
Normal file
@@ -0,0 +1,581 @@
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/switch_item.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/menu_row.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/danmaku_options.dart';
|
||||
import 'package:PiliPlus/utils/extension/num_ext.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
mixin HeaderMixin<T extends StatefulWidget> on State<T> {
|
||||
PlPlayerController get plPlayerController;
|
||||
|
||||
bool get isFullScreen => plPlayerController.isFullScreen.value;
|
||||
|
||||
Future<void>? showBottomSheet(
|
||||
StatefulWidgetBuilder builder, {
|
||||
double? padding,
|
||||
}) {
|
||||
return PageUtils.showVideoBottomSheet(
|
||||
context,
|
||||
isFullScreen: () => isFullScreen,
|
||||
padding: padding,
|
||||
child: StatefulBuilder(
|
||||
builder: (context, setState) => plPlayerController.darkVideoPage
|
||||
? Theme(
|
||||
data: Theme.of(this.context),
|
||||
child: builder(this.context, setState),
|
||||
)
|
||||
: builder(context, setState),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget resetBtn(
|
||||
ThemeData theme,
|
||||
Object def,
|
||||
VoidCallback onPressed, {
|
||||
bool isDanmaku = true,
|
||||
}) {
|
||||
return iconButton(
|
||||
tooltip: '默认值: $def',
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
onPressed();
|
||||
if (isDanmaku) {
|
||||
// plPlayerController.putDanmakuSettings();
|
||||
} else {
|
||||
plPlayerController.putSubtitleSettings();
|
||||
}
|
||||
},
|
||||
iconColor: theme.colorScheme.outline,
|
||||
size: 24,
|
||||
iconSize: 24,
|
||||
);
|
||||
}
|
||||
|
||||
/// 弹幕功能
|
||||
Future<void> showSetDanmaku({bool isLive = false}) async {
|
||||
// 屏蔽类型
|
||||
const blockTypesList = [
|
||||
(value: 2, label: '滚动'),
|
||||
(value: 5, label: '顶部'),
|
||||
(value: 4, label: '底部'),
|
||||
(value: 6, label: '彩色'),
|
||||
(value: 7, label: '高级'),
|
||||
];
|
||||
|
||||
final danmakuController = plPlayerController.danmakuController;
|
||||
|
||||
final isFullScreen = this.isFullScreen;
|
||||
|
||||
await showBottomSheet(
|
||||
(context, setState) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
void setOptions() => danmakuController?.updateOption(
|
||||
DanmakuOptions.get(
|
||||
notFullscreen: !isFullScreen,
|
||||
speed: plPlayerController.playbackSpeed,
|
||||
),
|
||||
);
|
||||
|
||||
final sliderTheme = SliderThemeData(
|
||||
trackHeight: 10,
|
||||
trackShape: const MSliderTrackShape(),
|
||||
thumbColor: theme.colorScheme.primary,
|
||||
activeTrackColor: theme.colorScheme.primary,
|
||||
inactiveTrackColor: theme.colorScheme.onInverseSurface,
|
||||
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 6.0),
|
||||
);
|
||||
|
||||
void updateLineHeight(double val) {
|
||||
DanmakuOptions.danmakuLineHeight = val.toPrecision(1);
|
||||
setState(() {});
|
||||
setOptions();
|
||||
}
|
||||
|
||||
void updateDuration(double val) {
|
||||
DanmakuOptions.danmakuDuration = val.toPrecision(1);
|
||||
setState(() {});
|
||||
setOptions();
|
||||
}
|
||||
|
||||
void updateStaticDuration(double val) {
|
||||
DanmakuOptions.danmakuStaticDuration = val.toPrecision(1);
|
||||
setState(() {});
|
||||
setOptions();
|
||||
}
|
||||
|
||||
void updateFontSizeFS(double val) {
|
||||
DanmakuOptions.danmakuFontScaleFS = val;
|
||||
setState(() {});
|
||||
if (isFullScreen) {
|
||||
setOptions();
|
||||
}
|
||||
}
|
||||
|
||||
void updateFontSize(double val) {
|
||||
DanmakuOptions.danmakuFontScale = val;
|
||||
setState(() {});
|
||||
if (!isFullScreen) {
|
||||
setOptions();
|
||||
}
|
||||
}
|
||||
|
||||
void updateStrokeWidth(double val) {
|
||||
DanmakuOptions.danmakuStrokeWidth = val;
|
||||
setState(() {});
|
||||
setOptions();
|
||||
}
|
||||
|
||||
void updateFontWeight(double val) {
|
||||
DanmakuOptions.danmakuFontWeight = val.toInt();
|
||||
setOptions();
|
||||
}
|
||||
|
||||
void updateOpacity(double val) {
|
||||
plPlayerController.danmakuOpacity.value = val;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void updateShowArea(double val) {
|
||||
DanmakuOptions.danmakuShowArea = val.toPrecision(1);
|
||||
setState(() {});
|
||||
setOptions();
|
||||
}
|
||||
|
||||
void onUpdateBlockType(int blockType, bool blocked) {
|
||||
if (blocked) {
|
||||
DanmakuOptions.blockTypes.remove(blockType);
|
||||
} else {
|
||||
DanmakuOptions.blockTypes.add(blockType);
|
||||
}
|
||||
DanmakuOptions.blockColorful = DanmakuOptions.blockTypes.contains(6);
|
||||
setState(() {});
|
||||
setOptions();
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Material(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 45,
|
||||
child: Center(
|
||||
child: Text('弹幕设置', style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (!isLive) ...[
|
||||
Row(
|
||||
children: [
|
||||
Text('智能云屏蔽 ${plPlayerController.danmakuWeight} 级'),
|
||||
const Spacer(),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
onPressed: () => Get
|
||||
..back()
|
||||
..toNamed(
|
||||
'/danmakuBlock',
|
||||
arguments: plPlayerController,
|
||||
),
|
||||
child: Text(
|
||||
"屏蔽管理(${plPlayerController.filters.count})",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0,
|
||||
max: 10,
|
||||
value: plPlayerController.danmakuWeight.toDouble(),
|
||||
divisions: 10,
|
||||
label: '${plPlayerController.danmakuWeight}',
|
||||
onChanged: (val) =>
|
||||
plPlayerController.danmakuWeight = val.toInt(),
|
||||
onChangeEnd: (val) => GStorage.setting.put(
|
||||
SettingBoxKey.danmakuWeight,
|
||||
val.toInt(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const Text('按类型屏蔽'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: blockTypesList.map(
|
||||
(e) {
|
||||
final blocked = DanmakuOptions.blockTypes.contains(
|
||||
e.value,
|
||||
);
|
||||
return ActionRowLineItem(
|
||||
onTap: () => onUpdateBlockType(e.value, blocked),
|
||||
text: e.label,
|
||||
selectStatus: blocked,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
SetSwitchItem(
|
||||
title: '海量弹幕',
|
||||
contentPadding: EdgeInsets.zero,
|
||||
titleStyle: const TextStyle(fontSize: 14),
|
||||
defaultVal: DanmakuOptions.massiveMode,
|
||||
setKey: SettingBoxKey.danmakuMassiveMode,
|
||||
onChanged: (value) {
|
||||
DanmakuOptions.massiveMode = value;
|
||||
setState(() {});
|
||||
setOptions();
|
||||
},
|
||||
),
|
||||
SetSwitchItem(
|
||||
title: '滚动弹幕固定速度',
|
||||
contentPadding: EdgeInsets.zero,
|
||||
titleStyle: const TextStyle(fontSize: 14),
|
||||
defaultVal: DanmakuOptions.scrollFixedVelocity,
|
||||
setKey: SettingBoxKey.danmakuFixedV,
|
||||
onChanged: (value) {
|
||||
DanmakuOptions.scrollFixedVelocity = value;
|
||||
setState(() {});
|
||||
setOptions();
|
||||
},
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('显示区域 ${DanmakuOptions.danmakuShowArea * 100}%'),
|
||||
resetBtn(
|
||||
theme,
|
||||
'50.0%',
|
||||
() => updateShowArea(0.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0.1,
|
||||
max: 1,
|
||||
value: DanmakuOptions.danmakuShowArea,
|
||||
divisions: 9,
|
||||
label: '${DanmakuOptions.danmakuShowArea * 100}%',
|
||||
onChanged: updateShowArea,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('不透明度 ${plPlayerController.danmakuOpacity * 100}%'),
|
||||
resetBtn(
|
||||
theme,
|
||||
'100.0%',
|
||||
() => updateOpacity(1.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0,
|
||||
max: 1,
|
||||
value: plPlayerController.danmakuOpacity.value,
|
||||
divisions: 10,
|
||||
label: '${plPlayerController.danmakuOpacity * 100}%',
|
||||
onChanged: updateOpacity,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'字体粗细 ${DanmakuOptions.danmakuFontWeight + 1}(可能无法精确调节)',
|
||||
),
|
||||
resetBtn(
|
||||
theme,
|
||||
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: DanmakuOptions.danmakuFontWeight.toDouble(),
|
||||
divisions: 8,
|
||||
label: '${DanmakuOptions.danmakuFontWeight + 1}',
|
||||
onChanged: updateFontWeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('描边粗细 ${DanmakuOptions.danmakuStrokeWidth}'),
|
||||
resetBtn(
|
||||
theme,
|
||||
1.5,
|
||||
() => updateStrokeWidth(1.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0,
|
||||
max: 5,
|
||||
value: DanmakuOptions.danmakuStrokeWidth,
|
||||
divisions: 10,
|
||||
label: DanmakuOptions.danmakuStrokeWidth
|
||||
.toStringAsFixed(0),
|
||||
onChanged: updateStrokeWidth,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'字体大小 ${(DanmakuOptions.danmakuFontScale * 100).toStringAsFixed(1)}%',
|
||||
),
|
||||
resetBtn(
|
||||
theme,
|
||||
'100.0%',
|
||||
() => updateFontSize(1.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0.5,
|
||||
max: 2.5,
|
||||
value: DanmakuOptions.danmakuFontScale,
|
||||
divisions: 20,
|
||||
label:
|
||||
'${(DanmakuOptions.danmakuFontScale * 100).toStringAsFixed(1)}%',
|
||||
onChanged: updateFontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'全屏字体大小 ${(DanmakuOptions.danmakuFontScaleFS * 100).toStringAsFixed(1)}%',
|
||||
),
|
||||
resetBtn(
|
||||
theme,
|
||||
'120.0%',
|
||||
() => updateFontSizeFS(1.2),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0.5,
|
||||
max: 2.5,
|
||||
value: DanmakuOptions.danmakuFontScaleFS,
|
||||
divisions: 20,
|
||||
label:
|
||||
'${(DanmakuOptions.danmakuFontScaleFS * 100).toStringAsFixed(1)}%',
|
||||
onChanged: updateFontSizeFS,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('滚动弹幕时长 ${DanmakuOptions.danmakuDuration} 秒'),
|
||||
resetBtn(
|
||||
theme,
|
||||
7.0,
|
||||
() => updateDuration(7.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 1,
|
||||
max: 50,
|
||||
value: DanmakuOptions.danmakuDuration,
|
||||
divisions: 49,
|
||||
label: DanmakuOptions.danmakuDuration.toString(),
|
||||
onChanged: updateDuration,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('静态弹幕时长 ${DanmakuOptions.danmakuStaticDuration} 秒'),
|
||||
resetBtn(
|
||||
theme,
|
||||
4.0,
|
||||
() => updateStaticDuration(4.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 1,
|
||||
max: 50,
|
||||
value: DanmakuOptions.danmakuStaticDuration,
|
||||
divisions: 49,
|
||||
label: DanmakuOptions.danmakuStaticDuration.toString(),
|
||||
onChanged: updateStaticDuration,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('弹幕行高 ${DanmakuOptions.danmakuLineHeight}'),
|
||||
resetBtn(
|
||||
theme,
|
||||
1.6,
|
||||
() => updateLineHeight(1.6),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 1.0,
|
||||
max: 3.0,
|
||||
value: DanmakuOptions.danmakuLineHeight,
|
||||
onChanged: updateLineHeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
await DanmakuOptions.save();
|
||||
}
|
||||
}
|
||||
|
||||
class MSliderTrackShape extends RoundedRectSliderTrackShape {
|
||||
const MSliderTrackShape();
|
||||
|
||||
@override
|
||||
Rect getPreferredRect({
|
||||
required RenderBox parentBox,
|
||||
Offset offset = Offset.zero,
|
||||
SliderThemeData? sliderTheme,
|
||||
bool isEnabled = false,
|
||||
bool isDiscrete = false,
|
||||
}) {
|
||||
const double trackHeight = 3;
|
||||
final double trackLeft = offset.dx;
|
||||
final double trackTop =
|
||||
offset.dy + (parentBox.size.height - trackHeight) / 2 + 4;
|
||||
final double trackWidth = parentBox.size.width;
|
||||
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user