feat: show all episodes on listsheet

This commit is contained in:
bggRGjQaUbCoE
2024-10-02 12:12:50 +08:00
parent 2bd19ec5f8
commit da39a8fd1e
7 changed files with 182 additions and 79 deletions

View File

@@ -523,14 +523,16 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
if (!loadingStatus &&
widget.videoDetail?.pages != null &&
widget.videoDetail!.pages!.length > 1) ...[
Obx(() => PagesPanel(
heroTag: heroTag,
pages: widget.videoDetail!.pages!,
cid: videoIntroController.lastPlayCid.value,
bvid: videoIntroController.bvid,
changeFuc: videoIntroController.changeSeasonOrbangu,
showEpisodes: widget.showEpisodes,
))
Obx(
() => PagesPanel(
heroTag: heroTag,
pages: widget.videoDetail!.pages!,
cid: videoIntroController.lastPlayCid.value,
bvid: videoIntroController.bvid,
changeFuc: videoIntroController.changeSeasonOrbangu,
showEpisodes: widget.showEpisodes,
),
),
],
],
)),

View File

@@ -96,7 +96,13 @@ class _PagesPanelState extends State<PagesPanel> {
padding: WidgetStateProperty.all(EdgeInsets.zero),
),
onPressed: () => widget.showEpisodes(
episodes, widget.bvid, IdUtils.bv2av(widget.bvid), cid),
null,
null,
episodes,
widget.bvid,
IdUtils.bv2av(widget.bvid),
cid,
),
child: Text(
'${widget.pages.length}',
style: const TextStyle(fontSize: 13),

View File

@@ -25,32 +25,20 @@ class SeasonPanel extends StatefulWidget {
class _SeasonPanelState extends State<SeasonPanel> {
List<EpisodeItem>? episodes;
late int cid;
int? _index;
int currentIndex = 0;
// final String heroTag = Get.arguments['heroTag'];
late final String heroTag;
late VideoDetailController _videoDetailController;
final ScrollController _scrollController = ScrollController();
@override
void initState() {
super.initState();
cid = widget.cid!;
heroTag = widget.heroTag;
_videoDetailController = Get.find<VideoDetailController>(tag: heroTag);
_videoDetailController =
Get.find<VideoDetailController>(tag: widget.heroTag);
/// 根据 cid 找到对应集,找到对应 episodes
/// 有多个episodes时只显示其中一个
/// TODO 同时显示多个合集
final List<SectionItem> sections = widget.ugcSeason.sections!;
for (int i = 0; i < sections.length; i++) {
final List<EpisodeItem> episodesList = sections[i].episodes!;
for (int j = 0; j < episodesList.length; j++) {
if (episodesList[j].cid == cid) {
episodes = episodesList;
continue;
}
}
}
_findEpisode();
if (episodes == null) {
return;
}
@@ -62,6 +50,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
currentIndex = episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
_videoDetailController.cid.listen((int p0) {
cid = p0;
_findEpisode();
currentIndex = episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
if (!mounted) return;
setState(() {});
@@ -79,12 +68,6 @@ class _SeasonPanelState extends State<SeasonPanel> {
// setState(() {});
// }
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (episodes == null) {
@@ -103,7 +86,14 @@ class _SeasonPanelState extends State<SeasonPanel> {
borderRadius: BorderRadius.circular(6),
clipBehavior: Clip.hardEdge,
child: InkWell(
onTap: () => widget.showEpisodes(episodes, null, null, cid),
onTap: () => widget.showEpisodes(
_index,
widget.ugcSeason.sections,
episodes,
null,
null,
cid,
),
child: Padding(
padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
child: Row(
@@ -143,4 +133,18 @@ class _SeasonPanelState extends State<SeasonPanel> {
);
});
}
void _findEpisode() {
final List<SectionItem> sections = widget.ugcSeason.sections!;
for (int i = 0; i < sections.length; i++) {
final List<EpisodeItem> episodesList = sections[i].episodes!;
for (int j = 0; j < episodesList.length; j++) {
if (episodesList[j].cid == cid) {
_index = i;
episodes = episodesList;
break;
}
}
}
}
}

View File

@@ -1312,8 +1312,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
);
}
showEpisodes(episodes, bvid, aid, cid) {
showEpisodes(index, sections, episodes, bvid, aid, cid) {
ListSheet(
index: index,
sections: sections,
episodes: episodes,
bvid: bvid,
aid: aid,