diff --git a/lib/common/widgets/list_sheet.dart b/lib/common/widgets/list_sheet.dart index 174a5b826..5360d17da 100644 --- a/lib/common/widgets/list_sheet.dart +++ b/lib/common/widgets/list_sheet.dart @@ -72,7 +72,7 @@ class ListSheetContent extends StatefulWidget { required this.onClose, }); - final int index; + final dynamic index; final dynamic sections; final dynamic episodes; final String? bvid; @@ -93,6 +93,7 @@ class _ListSheetContentState extends State 0; late List reverse; + int get _index => widget.index ?? 0; bool get _isList => widget.sections is List && widget.sections.length > 1; TabController? _ctr; StreamController? _indexStream; @@ -105,7 +106,7 @@ class _ListSheetContentState extends State _ctr = TabController( vsync: this, length: widget.sections.length, - initialIndex: widget.index, + initialIndex: _index, )..addListener(() { _indexStream?.add(_ctr?.index); }); @@ -116,7 +117,7 @@ class _ListSheetContentState extends State reverse = _isList ? List.generate(widget.sections.length, (_) => false) : [false]; WidgetsBinding.instance.addPostFrameCallback((_) { - itemScrollController[widget.index].jumpTo(index: currentIndex); + itemScrollController[_index].jumpTo(index: currentIndex); }); } @@ -295,8 +296,8 @@ class _ListSheetContentState extends State tooltip: '跳至当前', icon: const Icon(Icons.my_location), onPressed: () async { - if (_ctr != null && _ctr?.index != widget.index) { - _ctr?.animateTo(widget.index); + if (_ctr != null && _ctr?.index != (_index)) { + _ctr?.animateTo(_index); await Future.delayed(const Duration(milliseconds: 225)); } itemScrollController[_ctr?.index ?? 0].scrollTo( @@ -362,28 +363,30 @@ class _ListSheetContentState extends State ); } - Widget _buildBody(i, episodes) => ScrollablePositionedList.separated( - padding: EdgeInsets.only( - bottom: MediaQuery.of(context).padding.bottom + 20, - ), - reverse: reverse[i ?? 0], - itemCount: episodes.length, - itemBuilder: (BuildContext context, int index) { - return buildEpisodeListItem( - episodes[index], - index, - episodes.length, - i != null - ? i == widget.index - ? currentIndex == index - : false - : currentIndex == index, - ); - }, - itemScrollController: itemScrollController[i ?? 0], - separatorBuilder: (_, index) => Divider( - height: 1, - color: Theme.of(context).dividerColor.withOpacity(0.1), + Widget _buildBody(i, episodes) => Material( + child: ScrollablePositionedList.separated( + padding: EdgeInsets.only( + bottom: MediaQuery.of(context).padding.bottom + 20, + ), + reverse: reverse[i ?? 0], + itemCount: episodes.length, + itemBuilder: (BuildContext context, int index) { + return buildEpisodeListItem( + episodes[index], + index, + episodes.length, + i != null + ? i == (_index) + ? currentIndex == index + : false + : currentIndex == index, + ); + }, + itemScrollController: itemScrollController[i ?? 0], + separatorBuilder: (_, index) => Divider( + height: 1, + color: Theme.of(context).dividerColor.withOpacity(0.1), + ), ), ); } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 6f0601229..9c9b7919b 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -341,32 +341,40 @@ class _PLVideoPlayerState extends State color: Colors.white, ), fuc: () { + int? index; int currentCid = widget.controller.cid; String bvid = widget.controller.bvid; - final List episodes = []; + List episodes = []; late Function changeFucCall; if (isSeason) { final List sections = videoIntroController!.videoDetail.value.ugcSeason!.sections!; for (int i = 0; i < sections.length; i++) { final List 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; } else if (isPage) { final List pages = videoIntroController!.videoDetail.value.pages!; - episodes.addAll(pages); + episodes = pages; changeFucCall = videoIntroController!.changeSeasonOrbangu; } else if (isBangumi) { - episodes.addAll( - (bangumiIntroController!.loadingState.value as Success) - .response - .episodes!); + episodes = (bangumiIntroController!.loadingState.value as Success) + .response + .episodes!; changeFucCall = bangumiIntroController!.changeSeasonOrbangu; } if (widget.showEpisodes != null) { widget.showEpisodes!( + index, + videoIntroController?.videoDetail.value.ugcSeason?.sections, episodes, bvid, IdUtils.bv2av(bvid),