fix: show episodes from player

This commit is contained in:
bggRGjQaUbCoE
2024-10-02 14:07:18 +08:00
parent da39a8fd1e
commit 611f78163b
2 changed files with 45 additions and 34 deletions

View File

@@ -72,7 +72,7 @@ class ListSheetContent extends StatefulWidget {
required this.onClose, required this.onClose,
}); });
final int index; final dynamic index;
final dynamic sections; final dynamic sections;
final dynamic episodes; final dynamic episodes;
final String? bvid; final String? bvid;
@@ -93,6 +93,7 @@ class _ListSheetContentState extends State<ListSheetContent>
0; 0;
late List<bool> reverse; late List<bool> reverse;
int get _index => widget.index ?? 0;
bool get _isList => widget.sections is List && widget.sections.length > 1; bool get _isList => widget.sections is List && widget.sections.length > 1;
TabController? _ctr; TabController? _ctr;
StreamController? _indexStream; StreamController? _indexStream;
@@ -105,7 +106,7 @@ class _ListSheetContentState extends State<ListSheetContent>
_ctr = TabController( _ctr = TabController(
vsync: this, vsync: this,
length: widget.sections.length, length: widget.sections.length,
initialIndex: widget.index, initialIndex: _index,
)..addListener(() { )..addListener(() {
_indexStream?.add(_ctr?.index); _indexStream?.add(_ctr?.index);
}); });
@@ -116,7 +117,7 @@ class _ListSheetContentState extends State<ListSheetContent>
reverse = reverse =
_isList ? List.generate(widget.sections.length, (_) => false) : [false]; _isList ? List.generate(widget.sections.length, (_) => false) : [false];
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
itemScrollController[widget.index].jumpTo(index: currentIndex); itemScrollController[_index].jumpTo(index: currentIndex);
}); });
} }
@@ -295,8 +296,8 @@ class _ListSheetContentState extends State<ListSheetContent>
tooltip: '跳至当前', tooltip: '跳至当前',
icon: const Icon(Icons.my_location), icon: const Icon(Icons.my_location),
onPressed: () async { onPressed: () async {
if (_ctr != null && _ctr?.index != widget.index) { if (_ctr != null && _ctr?.index != (_index)) {
_ctr?.animateTo(widget.index); _ctr?.animateTo(_index);
await Future.delayed(const Duration(milliseconds: 225)); await Future.delayed(const Duration(milliseconds: 225));
} }
itemScrollController[_ctr?.index ?? 0].scrollTo( itemScrollController[_ctr?.index ?? 0].scrollTo(
@@ -362,7 +363,8 @@ class _ListSheetContentState extends State<ListSheetContent>
); );
} }
Widget _buildBody(i, episodes) => ScrollablePositionedList.separated( Widget _buildBody(i, episodes) => Material(
child: ScrollablePositionedList.separated(
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom + 20, bottom: MediaQuery.of(context).padding.bottom + 20,
), ),
@@ -374,7 +376,7 @@ class _ListSheetContentState extends State<ListSheetContent>
index, index,
episodes.length, episodes.length,
i != null i != null
? i == widget.index ? i == (_index)
? currentIndex == index ? currentIndex == index
: false : false
: currentIndex == index, : currentIndex == index,
@@ -385,5 +387,6 @@ class _ListSheetContentState extends State<ListSheetContent>
height: 1, height: 1,
color: Theme.of(context).dividerColor.withOpacity(0.1), color: Theme.of(context).dividerColor.withOpacity(0.1),
), ),
),
); );
} }

View File

@@ -341,32 +341,40 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
color: Colors.white, color: Colors.white,
), ),
fuc: () { fuc: () {
int? index;
int currentCid = widget.controller.cid; int currentCid = widget.controller.cid;
String bvid = widget.controller.bvid; String bvid = widget.controller.bvid;
final List episodes = []; List episodes = [];
late Function changeFucCall; late Function changeFucCall;
if (isSeason) { if (isSeason) {
final List<SectionItem> sections = final List<SectionItem> sections =
videoIntroController!.videoDetail.value.ugcSeason!.sections!; videoIntroController!.videoDetail.value.ugcSeason!.sections!;
for (int i = 0; i < sections.length; i++) { for (int i = 0; i < sections.length; i++) {
final List<EpisodeItem> episodesList = sections[i].episodes!; final List<EpisodeItem> episodesList = sections[i].episodes!;
episodes.addAll(episodesList); for (int j = 0; j < episodesList.length; j++) {
if (episodesList[j].cid == widget.controller.cid) {
index = i;
episodes = episodesList;
break;
}
}
} }
changeFucCall = videoIntroController!.changeSeasonOrbangu; changeFucCall = videoIntroController!.changeSeasonOrbangu;
} else if (isPage) { } else if (isPage) {
final List<Part> pages = final List<Part> pages =
videoIntroController!.videoDetail.value.pages!; videoIntroController!.videoDetail.value.pages!;
episodes.addAll(pages); episodes = pages;
changeFucCall = videoIntroController!.changeSeasonOrbangu; changeFucCall = videoIntroController!.changeSeasonOrbangu;
} else if (isBangumi) { } else if (isBangumi) {
episodes.addAll( episodes = (bangumiIntroController!.loadingState.value as Success)
(bangumiIntroController!.loadingState.value as Success)
.response .response
.episodes!); .episodes!;
changeFucCall = bangumiIntroController!.changeSeasonOrbangu; changeFucCall = bangumiIntroController!.changeSeasonOrbangu;
} }
if (widget.showEpisodes != null) { if (widget.showEpisodes != null) {
widget.showEpisodes!( widget.showEpisodes!(
index,
videoIntroController?.videoDetail.value.ugcSeason?.sections,
episodes, episodes,
bvid, bvid,
IdUtils.bv2av(bvid), IdUtils.bv2av(bvid),