opt: post segments

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-26 14:32:53 +08:00
parent 6fee468f49
commit 4f4f000e98
3 changed files with 107 additions and 14 deletions

View File

@@ -139,7 +139,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
body: ListView(
children: [
SetSwitchItem(
title: 'Sponsor Block',
title: '空降助手',
subTitle: '点击配置',
leading: Icon(Icons.block),
setKey: SettingBoxKey.enableSponsorBlock,

View File

@@ -134,7 +134,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
Widget get _aboudItem => ListTile(
dense: true,
title: Text('关于 SponsorBlock', style: _titleStyle),
title: Text('关于空降助手', style: _titleStyle),
subtitle: Text(_url, style: _subTitleStyle),
onTap: () => Utils.launchURL(_url),
);
@@ -248,9 +248,14 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
dense: true,
onTap: _updateBlockTrack,
title: Text(
'记录跳过片段',
'跳过次数统计跟踪',
style: _titleStyle,
),
subtitle: Text(
// from origin extension
'此功能追踪您跳过了哪些片段,让用户知道他们提交的片段帮助了多少人。同时点赞会作为依据,确保垃圾信息不会污染数据库。在您每次跳过片段时,我们都会向服务器发送一条消息。希望大家开启此项设置,以便得到更准确的统计数据。:)',
style: _subTitleStyle,
),
trailing: Transform.scale(
alignment: Alignment.centerRight,
scale: 0.8,
@@ -368,7 +373,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Sponsor Block')),
appBar: AppBar(title: Text('空降助手')),
body: CustomScrollView(
slivers: [
_dividerL,

View File

@@ -133,6 +133,10 @@ class PostSegmentModel {
enum ActionType { skip, mute, full, poi }
extension ActionTypeExt on ActionType {
String get title => ['跳过', '静音', '整个视频', '精彩时刻'][index];
}
class VideoDetailController extends GetxController
with GetSingleTickerProviderStateMixin {
/// 路由传参
@@ -1234,9 +1238,11 @@ class VideoDetailController extends GetxController
PopupMenuButton(
initialValue: list![index].category,
onSelected: (item) async {
setState(() {
list![index].category = item;
});
list![index].actionType =
_segmentType2ActionType(item)
.first;
setState(() {});
},
itemBuilder: (context) =>
SegmentType.values
@@ -1273,7 +1279,7 @@ class VideoDetailController extends GetxController
),
),
const SizedBox(width: 16),
const Text('ActionType: '),
const Text('行为类别: '),
PopupMenuButton(
initialValue:
list![index].actionType,
@@ -1284,11 +1290,18 @@ class VideoDetailController extends GetxController
},
itemBuilder: (context) => ActionType
.values
.map((item) =>
.map(
(item) =>
PopupMenuItem<ActionType>(
enabled:
_segmentType2ActionType(
list![index]
.category)
.contains(item),
value: item,
child: Text(item.name),
))
child: Text(item.title),
),
)
.toList(),
child: Row(
mainAxisSize: MainAxisSize.min,
@@ -1296,7 +1309,7 @@ class VideoDetailController extends GetxController
CrossAxisAlignment.start,
children: [
Text(
list![index].actionType.name,
list![index].actionType.title,
style: TextStyle(
fontSize: 14,
color: Theme.of(context)
@@ -1369,6 +1382,9 @@ class VideoDetailController extends GetxController
_handleSBData(res);
plPlayerController.segmentList.value =
_segmentProgressList ?? <Segment>[];
if (positionSubscription == null) {
_initSkip();
}
} else {
SmartDialog.showToast(
'提交失败: ${{
@@ -1392,4 +1408,76 @@ class VideoDetailController extends GetxController
);
},
);
List<SegmentType> _actionType2SegmentType(ActionType actionType) {
return switch (actionType) {
ActionType.skip => [
SegmentType.sponsor,
SegmentType.selfpromo,
SegmentType.interaction,
SegmentType.intro,
SegmentType.outro,
SegmentType.preview,
SegmentType.filler,
],
ActionType.mute => [
SegmentType.sponsor,
SegmentType.selfpromo,
SegmentType.interaction,
SegmentType.intro,
SegmentType.outro,
SegmentType.preview,
SegmentType.music_offtopic,
SegmentType.filler,
],
ActionType.full => [
SegmentType.sponsor,
SegmentType.selfpromo,
SegmentType.exclusive_access,
],
ActionType.poi => [
SegmentType.poi_highlight,
],
};
}
List<ActionType> _segmentType2ActionType(SegmentType segmentType) {
return switch (segmentType) {
SegmentType.sponsor => [
ActionType.skip,
ActionType.mute,
ActionType.full
],
SegmentType.selfpromo => [
ActionType.skip,
ActionType.mute,
ActionType.full
],
SegmentType.interaction => [
ActionType.skip,
ActionType.mute,
],
SegmentType.intro => [
ActionType.skip,
ActionType.mute,
],
SegmentType.outro => [
ActionType.skip,
ActionType.mute,
],
SegmentType.preview => [
ActionType.skip,
ActionType.mute,
],
SegmentType.music_offtopic => [
ActionType.mute,
],
SegmentType.poi_highlight => [ActionType.poi],
SegmentType.filler => [
ActionType.skip,
ActionType.mute,
],
SegmentType.exclusive_access => [ActionType.full],
};
}
}