mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom show reply
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -387,14 +387,18 @@ class BangumiIntroController extends CommonController {
|
|||||||
if (cover is String && cover.isNotEmpty) {
|
if (cover is String && cover.isNotEmpty) {
|
||||||
videoDetailCtr.videoItem['pic'] = cover;
|
videoDetailCtr.videoItem['pic'] = cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新请求评论
|
// 重新请求评论
|
||||||
try {
|
if (videoDetailCtr.showReply) {
|
||||||
/// 未渲染回复组件时可能异常
|
try {
|
||||||
VideoReplyController videoReplyCtr =
|
/// 未渲染回复组件时可能异常
|
||||||
Get.find<VideoReplyController>(tag: Get.arguments['heroTag']);
|
VideoReplyController videoReplyCtr =
|
||||||
videoReplyCtr.aid = aid;
|
Get.find<VideoReplyController>(tag: Get.arguments['heroTag']);
|
||||||
videoReplyCtr.onRefresh();
|
videoReplyCtr.aid = aid;
|
||||||
} catch (_) {}
|
videoReplyCtr.onRefresh();
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
if (userLogin) {
|
if (userLogin) {
|
||||||
queryBangumiLikeCoinFav();
|
queryBangumiLikeCoinFav();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,6 +229,18 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
setKey: SettingBoxKey.showRelatedVideo,
|
setKey: SettingBoxKey.showRelatedVideo,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
),
|
),
|
||||||
|
SetSwitchItem(
|
||||||
|
title: '显示视频评论',
|
||||||
|
leading: Icon(Icons.reply_all),
|
||||||
|
setKey: SettingBoxKey.showVideoReply,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
|
SetSwitchItem(
|
||||||
|
title: '显示番剧评论',
|
||||||
|
leading: Icon(Icons.reply_all),
|
||||||
|
setKey: SettingBoxKey.showBangumiReply,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
SetSwitchItem(
|
SetSwitchItem(
|
||||||
title: '默认展开视频简介',
|
title: '默认展开视频简介',
|
||||||
leading: Icon(Icons.expand_more),
|
leading: Icon(Icons.expand_more),
|
||||||
|
|||||||
@@ -218,6 +218,11 @@ class VideoDetailController extends GetxController
|
|||||||
|
|
||||||
late final showRelatedVideo = GStorage.showRelatedVideo;
|
late final showRelatedVideo = GStorage.showRelatedVideo;
|
||||||
|
|
||||||
|
late final _showVideoReply = GStorage.showVideoReply;
|
||||||
|
late final _showBangumiReply = GStorage.showBangumiReply;
|
||||||
|
bool get showReply =>
|
||||||
|
videoType == SearchType.video ? _showVideoReply : _showBangumiReply;
|
||||||
|
|
||||||
late final bool enableSponsorBlock;
|
late final bool enableSponsorBlock;
|
||||||
PlayerStatus? playerStatus;
|
PlayerStatus? playerStatus;
|
||||||
StreamSubscription<Duration>? positionSubscription;
|
StreamSubscription<Duration>? positionSubscription;
|
||||||
@@ -361,9 +366,11 @@ class VideoDetailController extends GetxController
|
|||||||
videoItem['pic'] = cover;
|
videoItem['pic'] = cover;
|
||||||
queryVideoUrl();
|
queryVideoUrl();
|
||||||
|
|
||||||
Get.find<VideoReplyController>(tag: heroTag)
|
if (showReply) {
|
||||||
..aid = aid
|
Get.find<VideoReplyController>(tag: heroTag)
|
||||||
..onRefresh();
|
..aid = aid
|
||||||
|
..onRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
Get.find<VideoIntroController>(tag: heroTag)
|
Get.find<VideoIntroController>(tag: heroTag)
|
||||||
..lastPlayCid.value = cid
|
..lastPlayCid.value = cid
|
||||||
|
|||||||
@@ -549,6 +549,7 @@ class VideoIntroController extends GetxController
|
|||||||
}
|
}
|
||||||
videoDetailCtr.danmakuCid.value = cid;
|
videoDetailCtr.danmakuCid.value = cid;
|
||||||
videoDetailCtr.queryVideoUrl();
|
videoDetailCtr.queryVideoUrl();
|
||||||
|
|
||||||
// 重新请求相关视频
|
// 重新请求相关视频
|
||||||
if (videoDetailCtr.showRelatedVideo) {
|
if (videoDetailCtr.showRelatedVideo) {
|
||||||
try {
|
try {
|
||||||
@@ -557,13 +558,16 @@ class VideoIntroController extends GetxController
|
|||||||
..queryData();
|
..queryData();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新请求评论
|
// 重新请求评论
|
||||||
try {
|
if (videoDetailCtr.showReply) {
|
||||||
final VideoReplyController videoReplyCtr =
|
try {
|
||||||
Get.find<VideoReplyController>(tag: heroTag);
|
Get.find<VideoReplyController>(tag: heroTag)
|
||||||
videoReplyCtr.aid = aid;
|
..aid = aid
|
||||||
videoReplyCtr.onRefresh();
|
..onRefresh();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
this.bvid = bvid;
|
this.bvid = bvid;
|
||||||
lastPlayCid.value = cid;
|
lastPlayCid.value = cid;
|
||||||
queryVideoIntro();
|
queryVideoIntro();
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
'${videoIntroController.videoDetail.value.bvid}');
|
'${videoIntroController.videoDetail.value.bvid}');
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'${videoIntroController.videoDetail.value.bvid}',
|
videoIntroController.videoDetail.value.bvid ?? '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
|||||||
@@ -100,9 +100,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
}
|
}
|
||||||
videoDetailController = Get.put(VideoDetailController(), tag: heroTag);
|
videoDetailController = Get.put(VideoDetailController(), tag: heroTag);
|
||||||
|
|
||||||
_videoReplyController = Get.put(
|
if (videoDetailController.showReply) {
|
||||||
VideoReplyController(videoDetailController.oid.value, '0', '1'),
|
_videoReplyController = Get.put(
|
||||||
tag: heroTag);
|
VideoReplyController(videoDetailController.oid.value, '0', '1'),
|
||||||
|
tag: heroTag);
|
||||||
|
}
|
||||||
videoIntroController = Get.put(VideoIntroController(), tag: heroTag);
|
videoIntroController = Get.put(VideoIntroController(), tag: heroTag);
|
||||||
videoIntroController.videoDetail.listen((value) {
|
videoIntroController.videoDetail.listen((value) {
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
@@ -179,7 +181,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// 获取视频资源,初始化播放器
|
// 获取视频资源,初始化播放器
|
||||||
Future<void> videoSourceInit() async {
|
Future<void> videoSourceInit() async {
|
||||||
_futureBuilderFuture = videoDetailController.queryVideoUrl();
|
_futureBuilderFuture = videoDetailController.queryVideoUrl();
|
||||||
_videoReplyController.queryData();
|
if (videoDetailController.showReply) {
|
||||||
|
_videoReplyController.queryData();
|
||||||
|
}
|
||||||
if (videoDetailController.autoPlay.value) {
|
if (videoDetailController.autoPlay.value) {
|
||||||
plPlayerController = videoDetailController.plPlayerController;
|
plPlayerController = videoDetailController.plPlayerController;
|
||||||
plPlayerController!.addStatusLister(playerListener);
|
plPlayerController!.addStatusLister(playerListener);
|
||||||
@@ -561,14 +565,17 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
tabbarBuild(),
|
buildTabbar(
|
||||||
|
showReply: videoDetailController.showReply,
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
physics: const ClampingScrollPhysics(),
|
physics: const ClampingScrollPhysics(),
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
videoIntro(),
|
videoIntro(),
|
||||||
videoReplyPanel,
|
if (videoDetailController.showReply)
|
||||||
|
videoReplyPanel,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -610,14 +617,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
tabbarBuild(),
|
buildTabbar(showReply: videoDetailController.showReply),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
physics: const ClampingScrollPhysics(),
|
physics: const ClampingScrollPhysics(),
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
videoIntro(),
|
videoIntro(),
|
||||||
videoReplyPanel,
|
if (videoDetailController.showReply)
|
||||||
|
videoReplyPanel,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -653,14 +661,16 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
tabbarBuild(false),
|
buildTabbar(
|
||||||
|
needIndicator: false,
|
||||||
|
showReply: videoDetailController.showReply,
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: videoIntro()),
|
Expanded(child: videoIntro()),
|
||||||
Expanded(
|
if (videoDetailController.showReply)
|
||||||
child: videoReplyPanel,
|
Expanded(child: videoReplyPanel)
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -699,8 +709,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
tabbarBuild(false, '', true),
|
buildTabbar(
|
||||||
Expanded(child: videoReplyPanel),
|
showIntro: false,
|
||||||
|
showReply: videoDetailController.showReply,
|
||||||
|
),
|
||||||
|
if (videoDetailController.showReply)
|
||||||
|
Expanded(child: videoReplyPanel),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -790,13 +804,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
tabbarBuild(
|
buildTabbar(
|
||||||
videoDetailController.videoType !=
|
introText: '相关视频',
|
||||||
SearchType.media_bangumi,
|
showIntro: videoDetailController.videoType ==
|
||||||
'相关视频',
|
SearchType.video &&
|
||||||
videoDetailController.videoType ==
|
videoDetailController.showRelatedVideo,
|
||||||
SearchType.media_bangumi ||
|
showReply: videoDetailController.showReply,
|
||||||
videoDetailController.showRelatedVideo.not,
|
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
@@ -812,7 +825,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
RelatedVideoPanel(heroTag: heroTag),
|
RelatedVideoPanel(heroTag: heroTag),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
videoReplyPanel,
|
if (videoDetailController.showReply)
|
||||||
|
videoReplyPanel,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -1133,15 +1147,58 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget tabbarBuild([
|
Widget buildTabbar({
|
||||||
bool needIndicator = true,
|
bool needIndicator = true,
|
||||||
String introText = '简介',
|
String introText = '简介',
|
||||||
bool isSingle = false,
|
bool showIntro = true,
|
||||||
]) {
|
bool showReply = true,
|
||||||
if (videoDetailController.tabCtr.length != (isSingle ? 1 : 2)) {
|
}) {
|
||||||
videoDetailController.tabCtr =
|
int length = (showIntro ? 1 : 0) + (showReply ? 1 : 0);
|
||||||
TabController(length: isSingle ? 1 : 2, vsync: this);
|
if (length != 0 && videoDetailController.tabCtr.length != length) {
|
||||||
|
videoDetailController.tabCtr = TabController(length: length, vsync: this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget tabbar() => TabBar(
|
||||||
|
labelColor: needIndicator.not || length == 1
|
||||||
|
? Theme.of(context).colorScheme.onSurface
|
||||||
|
: null,
|
||||||
|
indicatorColor:
|
||||||
|
needIndicator.not || length == 1 ? Colors.transparent : null,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
controller: videoDetailController.tabCtr,
|
||||||
|
labelStyle: const TextStyle(fontSize: 13),
|
||||||
|
labelPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 10.0), // 设置每个标签的宽度
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
onTap: (value) {
|
||||||
|
void animToTop() {
|
||||||
|
if (value == 0) {
|
||||||
|
if (showIntro) {
|
||||||
|
_introController.animToTop();
|
||||||
|
} else if (showReply) {
|
||||||
|
_videoReplyController.animateToTop();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_videoReplyController.animateToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needIndicator.not || length == 1) {
|
||||||
|
animToTop();
|
||||||
|
} else if (videoDetailController.tabCtr.indexIsChanging.not) {
|
||||||
|
animToTop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tabs: [
|
||||||
|
if (showIntro) Tab(text: introText),
|
||||||
|
if (showReply)
|
||||||
|
Tab(
|
||||||
|
text:
|
||||||
|
'评论${_videoReplyController.count.value == -1 ? '' : ' ${_videoReplyController.count.value}'}',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 45,
|
height: 45,
|
||||||
@@ -1156,42 +1213,13 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
child: Material(
|
child: Material(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
if (length == 0)
|
||||||
flex: 1,
|
const Spacer()
|
||||||
child: Obx(
|
else
|
||||||
() => TabBar(
|
Flexible(
|
||||||
labelColor: needIndicator
|
flex: 1,
|
||||||
? null
|
child: showReply ? Obx(() => tabbar()) : tabbar(),
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
indicatorColor: needIndicator ? null : Colors.transparent,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
controller: videoDetailController.tabCtr,
|
|
||||||
labelStyle: const TextStyle(fontSize: 13),
|
|
||||||
labelPadding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 10.0), // 设置每个标签的宽度
|
|
||||||
dividerColor: Colors.transparent,
|
|
||||||
onTap: (value) {
|
|
||||||
if (isSingle) {
|
|
||||||
_videoReplyController.animateToTop();
|
|
||||||
} else if (!needIndicator ||
|
|
||||||
!videoDetailController.tabCtr.indexIsChanging) {
|
|
||||||
if (value == 0) {
|
|
||||||
_introController.animToTop();
|
|
||||||
} else {
|
|
||||||
_videoReplyController.animateToTop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tabs: [
|
|
||||||
if (!isSingle) Tab(text: introText),
|
|
||||||
Tab(
|
|
||||||
text:
|
|
||||||
'评论${_videoReplyController.count.value == -1 ? '' : ' ${_videoReplyController.count.value}'}',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: Center(
|
child: Center(
|
||||||
@@ -1289,7 +1317,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
|
|
||||||
Widget videoIntro([bool needRelated = true]) {
|
Widget videoIntro([bool needRelated = true]) {
|
||||||
Widget introPanel() => CustomScrollView(
|
Widget introPanel() => CustomScrollView(
|
||||||
controller: _introController,
|
controller: needRelated ? _introController : null,
|
||||||
slivers: [
|
slivers: [
|
||||||
if (videoDetailController.videoType == SearchType.video) ...[
|
if (videoDetailController.videoType == SearchType.video) ...[
|
||||||
VideoIntroPanel(
|
VideoIntroPanel(
|
||||||
|
|||||||
Reference in New Issue
Block a user