diff --git a/lib/common/widgets/self_sized_horizontal_list.dart b/lib/common/widgets/self_sized_horizontal_list.dart index a4b4f115..ec15b6a9 100644 --- a/lib/common/widgets/self_sized_horizontal_list.dart +++ b/lib/common/widgets/self_sized_horizontal_list.dart @@ -67,7 +67,7 @@ class _SelfSizedHorizontalListState extends State { padding: widget.padding, scrollDirection: Axis.horizontal, itemCount: widget.itemCount, - itemBuilder: (c, i) => widget.childBuilder.call(i), + itemBuilder: (c, i) => widget.childBuilder(i), separatorBuilder: (c, i) => SizedBox(width: widget.gapSize), ), ); diff --git a/lib/models_new/media_list/data.dart b/lib/models_new/media_list/data.dart index df1210db..e4331fa4 100644 --- a/lib/models_new/media_list/data.dart +++ b/lib/models_new/media_list/data.dart @@ -1,22 +1,24 @@ import 'package:PiliPlus/models_new/media_list/media_list.dart'; class MediaListData { - List? mediaList; + List mediaList; bool? hasMore; int? totalCount; String? nextStartKey; MediaListData({ - this.mediaList, + required this.mediaList, this.hasMore, this.totalCount, this.nextStartKey, }); factory MediaListData.fromJson(Map json) => MediaListData( - mediaList: (json['media_list'] as List?) - ?.map((e) => MediaListItemModel.fromJson(e as Map)) - .toList(), + mediaList: + (json['media_list'] as List?) + ?.map((e) => MediaListItemModel.fromJson(e as Map)) + .toList() ?? + [], hasMore: json['has_more'] as bool?, totalCount: json['total_count'] as int?, nextStartKey: json['next_start_key'] as String?, diff --git a/lib/models_new/media_list/media_list.dart b/lib/models_new/media_list/media_list.dart index 4a690d68..d8d70761 100644 --- a/lib/models_new/media_list/media_list.dart +++ b/lib/models_new/media_list/media_list.dart @@ -1,15 +1,15 @@ import 'package:PiliPlus/models/model_owner.dart'; import 'package:PiliPlus/models_new/fav/fav_detail/cnt_info.dart'; -import 'package:PiliPlus/models_new/media_list/badge.dart'; import 'package:PiliPlus/models_new/media_list/coin.dart'; import 'package:PiliPlus/models_new/media_list/ogv_info.dart'; import 'package:PiliPlus/models_new/media_list/page.dart'; import 'package:PiliPlus/models_new/media_list/rights.dart'; +import 'package:PiliPlus/models_new/video/video_detail/episode.dart'; import 'package:PiliPlus/utils/extension.dart'; -class MediaListItemModel { +class MediaListItemModel extends BaseEpisodeItem { + @override int? get id => aid; - int? aid; int? offset; int? index; String? intro; @@ -17,32 +17,27 @@ class MediaListItemModel { int? tid; int? copyRight; CntInfo? cntInfo; - String? cover; int? duration; int? pubtime; int? likeState; int? favState; int? page; List? pages; - String? title; int? type; Owner? upper; String? link; - String? bvid; String? shortLink; Rights? rights; dynamic elecInfo; Coin? coin; OgvInfo? ogvInfo; double? progressPercent; - Badge? badge; bool? forbidFav; int? moreType; int? businessOid; - int? cid; MediaListItemModel({ - this.aid, + super.aid, this.offset, this.index, this.intro, @@ -50,29 +45,29 @@ class MediaListItemModel { this.tid, this.copyRight, this.cntInfo, - this.cover, + super.cover, this.duration, this.pubtime, this.likeState, this.favState, this.page, this.pages, - this.title, + super.title, this.type, this.upper, this.link, - this.bvid, + super.bvid, this.shortLink, this.rights, this.elecInfo, this.coin, this.ogvInfo, this.progressPercent, - this.badge, + super.badge, this.forbidFav, this.moreType, this.businessOid, - this.cid, + super.cid, }); MediaListItemModel.fromJson(Map json) { @@ -106,7 +101,7 @@ class MediaListItemModel { ? null : OgvInfo.fromJson(json['ogv_info']); progressPercent = (json['progress_percent'] as num?)?.toDouble(); - badge = json['badge'] == null ? null : Badge.fromJson(json['badge']); + badge = json['badge']?['text']; forbidFav = json['forbid_fav'] as bool?; moreType = json['more_type'] as int?; businessOid = json['business_oid'] as int?; diff --git a/lib/models_new/pgc/pgc_info_model/episode.dart b/lib/models_new/pgc/pgc_info_model/episode.dart index 58c39046..e70f9be7 100644 --- a/lib/models_new/pgc/pgc_info_model/episode.dart +++ b/lib/models_new/pgc/pgc_info_model/episode.dart @@ -8,11 +8,9 @@ import 'package:PiliPlus/models_new/video/video_detail/episode.dart' class EpisodeItem extends BaseEpisodeItem { BadgeInfo? badgeInfo; int? badgeType; - String? cover; Dimension? dimension; int? duration; bool? enableVt; - int? epId; String? from; bool? isViewHide; String? link; @@ -39,11 +37,11 @@ class EpisodeItem extends BaseEpisodeItem { this.badgeType, super.bvid, super.cid, - this.cover, + super.cover, this.dimension, this.duration, this.enableVt, - this.epId, + super.epId, this.from, super.id, this.isViewHide, diff --git a/lib/models_new/video/video_detail/episode.dart b/lib/models_new/video/video_detail/episode.dart index 15c26bc1..e1802c6a 100644 --- a/lib/models_new/video/video_detail/episode.dart +++ b/lib/models_new/video/video_detail/episode.dart @@ -1,21 +1,25 @@ import 'package:PiliPlus/models_new/video/video_detail/arc.dart'; import 'package:PiliPlus/models_new/video/video_detail/page.dart'; -abstract class BaseEpisodeItem { +class BaseEpisodeItem { int? id; int? aid; int? cid; + int? epId; String? bvid; String? badge; String? title; + String? cover; BaseEpisodeItem({ this.id, this.aid, this.cid, + this.epId, this.bvid, this.badge, this.title, + this.cover, }); } @@ -26,6 +30,8 @@ class EpisodeItem extends BaseEpisodeItem { Arc? arc; Part? page; List? pages; + @override + String? get cover => arc?.pic; EpisodeItem({ this.seasonId, diff --git a/lib/models_new/video/video_detail/page.dart b/lib/models_new/video/video_detail/page.dart index 546a3dd6..54568fc6 100644 --- a/lib/models_new/video/video_detail/page.dart +++ b/lib/models_new/video/video_detail/page.dart @@ -1,7 +1,7 @@ import 'package:PiliPlus/models_new/video/video_detail/dimension.dart'; +import 'package:PiliPlus/models_new/video/video_detail/episode.dart'; -class Part { - int? cid; +class Part extends BaseEpisodeItem { int? page; String? from; String? pagePart; @@ -11,10 +11,9 @@ class Part { Dimension? dimension; int? ctime; String? firstFrame; - String? badge; Part({ - this.cid, + super.cid, this.page, this.from, this.pagePart, @@ -24,7 +23,7 @@ class Part { this.dimension, this.ctime, this.firstFrame, - this.badge, + super.badge, }); factory Part.fromJson(Map json) => Part( diff --git a/lib/models_new/video/video_stein_edgeinfo/choice.dart b/lib/models_new/video/video_stein_edgeinfo/choice.dart index 334c94d9..2101ee8a 100644 --- a/lib/models_new/video/video_stein_edgeinfo/choice.dart +++ b/lib/models_new/video/video_stein_edgeinfo/choice.dart @@ -1,18 +1,18 @@ -class Choice { - int? id; +import 'package:PiliPlus/models_new/video/video_detail/episode.dart'; + +class Choice extends BaseEpisodeItem { String? platformAction; String? nativeAction; String? condition; - int? cid; String? option; int? isDefault; Choice({ - this.id, + super.id, this.platformAction, this.nativeAction, this.condition, - this.cid, + super.cid, this.option, this.isDefault, }); diff --git a/lib/pages/episode_panel/view.dart b/lib/pages/episode_panel/view.dart index 5697c706..c0d581ea 100644 --- a/lib/pages/episode_panel/view.dart +++ b/lib/pages/episode_panel/view.dart @@ -75,7 +75,7 @@ class EpisodePanel extends CommonSlidePage { final int initialTabIndex; final bool? isSupportReverse; final bool? isReversed; - final Function onChangeEpisode; + final ValueChanged onChangeEpisode; final VoidCallback? onReverse; final VoidCallback? onClose; @@ -330,7 +330,7 @@ class _EpisodePanelState extends CommonSlidePageState { Widget _buildEpisodeItem({ required ThemeData theme, - required dynamic episode, + required ugc.BaseEpisodeItem episode, required int index, required int length, required bool isCurrentIndex, @@ -379,7 +379,7 @@ class _EpisodePanelState extends CommonSlidePageState { type: MaterialType.transparency, child: InkWell( onTap: () { - if (episode.badge != null && episode.badge == "会员") { + if (episode.badge == "会员") { UserInfoData? userInfo = GStorage.userInfo.get('userInfoCache'); int vipStatus = userInfo?.vipStatus ?? 0; if (vipStatus != 1) { @@ -392,14 +392,7 @@ class _EpisodePanelState extends CommonSlidePageState { if (!widget.showTitle) { _currentItemIndex = index; } - final isEpisode = episode is ugc.BaseEpisodeItem; - widget.onChangeEpisode( - episode is pgc.EpisodeItem ? episode.epId : null, - isEpisode ? episode.bvid : widget.bvid, - episode.cid, - isEpisode ? episode.aid : widget.aid, - cover, - ); + widget.onChangeEpisode(episode); if (widget.type == EpisodeType.season) { try { Get.find( diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index b20ebe1d..cf20fe4c 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -329,29 +329,23 @@ class VideoDetailController extends GetxController ); if (res['status']) { MediaListData data = res['data']; - if (data.mediaList?.isNotEmpty == true) { + if (data.mediaList.isNotEmpty) { if (isReverse) { - mediaList.value = data.mediaList!; - try { - for (var item in mediaList) { - if (item.cid != null) { + mediaList.value = data.mediaList; + for (var item in mediaList) { + if (item.cid != null) { + try { Get.find( tag: heroTag, - ).onChangeEpisode( - null, - item.bvid, - item.cid, - item.aid, - item.cover, - ); - break; - } + ).onChangeEpisode(item); + } catch (_) {} + break; } - } catch (_) {} + } } else if (isLoadPrevious) { - mediaList.insertAll(0, data.mediaList!); + mediaList.insertAll(0, data.mediaList); } else { - mediaList.addAll(data.mediaList!); + mediaList.addAll(data.mediaList); } } } else { @@ -364,11 +358,9 @@ class VideoDetailController extends GetxController if (mediaList.isNotEmpty) { Widget panel() => MediaListPanel( mediaList: mediaList, - changeMediaList: (bvid, cid, aid, cover) { + onChangeEpisode: (episode) { try { - Get.find( - tag: heroTag, - ).onChangeEpisode(null, bvid, cid, aid, cover); + Get.find(tag: heroTag).onChangeEpisode(episode); } catch (_) {} }, panelTitle: watchLaterTitle, @@ -904,13 +896,7 @@ class VideoDetailController extends GetxController Get.find(tag: heroTag); Part part = ugcIntroController.videoDetail.value.pages![item]; - ugcIntroController.onChangeEpisode( - null, - bvid, - part.cid, - IdUtils.bv2av(bvid), - null, - ); + ugcIntroController.onChangeEpisode(part); SmartDialog.showToast('已跳至第${item + 1}P'); } catch (e) { if (kDebugMode) debugPrint('$e'); diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 61d7c011..51d0e28e 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -5,11 +5,14 @@ import 'package:PiliPlus/grpc/bilibili/app/viewunite/pgcanymodel.pb.dart' show ViewPgcAny; import 'package:PiliPlus/grpc/view.dart'; import 'package:PiliPlus/http/constants.dart'; +import 'package:PiliPlus/http/search.dart'; import 'package:PiliPlus/http/video.dart'; import 'package:PiliPlus/models/pgc_lcf.dart'; import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart'; import 'package:PiliPlus/models_new/pgc/pgc_info_model/result.dart'; import 'package:PiliPlus/models_new/triple/pgc_triple.dart'; +import 'package:PiliPlus/models_new/video/video_detail/episode.dart' + hide EpisodeItem; import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart'; import 'package:PiliPlus/pages/common/common_intro_controller.dart'; import 'package:PiliPlus/pages/dynamics_repost/view.dart'; @@ -20,6 +23,7 @@ import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart'; import 'package:PiliPlus/services/service_locator.dart'; import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/global_data.dart'; +import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; @@ -257,41 +261,55 @@ class PgcIntroController extends CommonIntroController { } // 修改分P或番剧分集 - void onChangeEpisode(dynamic epId, bvid, cid, aid, cover) { - // 重新获取视频资源 - this.epId = epId; - this.bvid = bvid; + Future onChangeEpisode(BaseEpisodeItem episode) async { + try { + final int epId = episode.epId!; + final String bvid = episode.bvid ?? this.bvid; + final int aid = episode.aid ?? IdUtils.bv2av(bvid); + final int? cid = + episode.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid); + if (cid == null) { + return; + } + final String? cover = episode.cover; - final videoDetailCtr = - Get.find(tag: Get.arguments['heroTag']) - ..plPlayerController.pause() - ..makeHeartBeat() - ..onReset() - ..epId = epId - ..bvid = bvid - ..cid.value = cid - ..queryVideoUrl(); - if (cover is String && cover.isNotEmpty) { - videoDetailCtr.cover.value = cover; + // 重新获取视频资源 + this.epId = epId; + this.bvid = bvid; + + final videoDetailCtr = + Get.find(tag: Get.arguments['heroTag']) + ..plPlayerController.pause() + ..makeHeartBeat() + ..onReset() + ..epId = epId + ..bvid = bvid + ..cid.value = cid + ..queryVideoUrl(); + if (cover != null && cover.isNotEmpty) { + videoDetailCtr.cover.value = cover; + } + + // 重新请求评论 + if (videoDetailCtr.showReply) { + try { + Get.find(tag: Get.arguments['heroTag']) + ..aid = aid + ..onReload(); + } catch (_) {} + } + + if (accountService.isLogin.value) { + queryPgcLikeCoinFav(); + } + + hasLater.value = false; + this.cid.value = cid; + queryVideoIntro(); + queryOnlineTotal(); + } catch (e) { + debugPrint('pgc onChangeEpisode: $e'); } - - // 重新请求评论 - if (videoDetailCtr.showReply) { - try { - Get.find(tag: Get.arguments['heroTag']) - ..aid = aid - ..onReload(); - } catch (_) {} - } - - if (accountService.isLogin.value) { - queryPgcLikeCoinFav(); - } - - hasLater.value = false; - this.cid.value = cid; - queryVideoIntro(); - queryOnlineTotal(); } // 追番 @@ -342,14 +360,7 @@ class PgcIntroController extends CommonIntroController { return false; } } - final episode = episodes[prevIndex]; - onChangeEpisode( - episode.epId, - episode.bvid, - episode.cid, - episode.aid, - episode.cover, - ); + onChangeEpisode(episodes[prevIndex]); return true; } @@ -377,14 +388,7 @@ class PgcIntroController extends CommonIntroController { return false; } } - final episode = episodes[nextIndex]; - onChangeEpisode( - episode.epId, - episode.bvid, - episode.cid, - episode.aid, - episode.cover, - ); + onChangeEpisode(episodes[nextIndex]); return true; } catch (_) { return false; diff --git a/lib/pages/video/introduction/pgc/widgets/pgc_panel.dart b/lib/pages/video/introduction/pgc/widgets/pgc_panel.dart index bd6f0013..e8bb529f 100644 --- a/lib/pages/video/introduction/pgc/widgets/pgc_panel.dart +++ b/lib/pages/video/introduction/pgc/widgets/pgc_panel.dart @@ -3,6 +3,8 @@ import 'dart:async'; import 'package:PiliPlus/models/user/info.dart'; import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart'; import 'package:PiliPlus/models_new/pgc/pgc_info_model/new_ep.dart'; +import 'package:PiliPlus/models_new/video/video_detail/episode.dart' + hide EpisodeItem; import 'package:PiliPlus/pages/video/controller.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/utils.dart'; @@ -23,7 +25,7 @@ class PgcPanel extends StatefulWidget { final List pages; final int? cid; - final Function onChangeEpisode; + final ValueChanged onChangeEpisode; final Function showEpisodes; final String heroTag; final NewEp? newEp; @@ -149,18 +151,10 @@ class _PgcPanelState extends State { child: InkWell( borderRadius: const BorderRadius.all(Radius.circular(6)), onTap: () { - if (item.badge != null && - item.badge == '会员' && - vipStatus != 1) { + if (item.badge == '会员' && vipStatus != 1) { SmartDialog.showToast('需要大会员'); } - widget.onChangeEpisode( - item.epId, - item.bvid, - item.cid, - item.aid, - item.cover, - ); + widget.onChangeEpisode(item); }, child: Padding( padding: const EdgeInsets.symmetric( diff --git a/lib/pages/video/introduction/ugc/controller.dart b/lib/pages/video/introduction/ugc/controller.dart index 435ea5ac..5ab1c719 100644 --- a/lib/pages/video/introduction/ugc/controller.dart +++ b/lib/pages/video/introduction/ugc/controller.dart @@ -465,68 +465,80 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { } // 修改分P或番剧分集 - bool onChangeEpisode(dynamic epid, bvid, cid, aid, cover, [isStein]) { - // 重新获取视频资源 - final videoDetailCtr = Get.find(tag: heroTag); - - if (videoDetailCtr.isPlayAll) { - if (videoDetailCtr.mediaList.indexWhere((item) => item.bvid == bvid) == - -1) { - PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'pic': cover, - 'heroTag': Utils.makeHeroTag(bvid), - }, - ); - return false; + Future onChangeEpisode(BaseEpisodeItem episode, {bool? isStein}) async { + try { + final String bvid = episode.bvid ?? this.bvid; + final int aid = episode.aid ?? IdUtils.bv2av(bvid); + final int? cid = + episode.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid); + if (cid == null) { + return; } + final String? cover = episode.cover; + + // 重新获取视频资源 + final videoDetailCtr = Get.find(tag: heroTag); + + if (videoDetailCtr.isPlayAll) { + if (videoDetailCtr.mediaList.indexWhere((item) => item.bvid == bvid) == + -1) { + PageUtils.toVideoPage( + 'bvid=$bvid&cid=$cid', + arguments: { + 'pic': ?cover, + 'heroTag': Utils.makeHeroTag(bvid), + }, + ); + return; + } + } + + videoDetailCtr + ..plPlayerController.pause() + ..makeHeartBeat() + ..updateMediaListHistory(aid) + ..onReset(isStein) + ..bvid = bvid + ..oid.value = aid + ..cid.value = cid + ..queryVideoUrl(); + + if (this.bvid != bvid) { + reload = true; + aiConclusionResult = null; + + if (cover != null && cover.isNotEmpty) { + videoDetailCtr.cover.value = cover; + } + + // 重新请求相关视频 + if (videoDetailCtr.plPlayerController.showRelatedVideo) { + try { + Get.find(tag: heroTag) + ..bvid = bvid + ..queryData(); + } catch (_) {} + } + + // 重新请求评论 + if (videoDetailCtr.showReply) { + try { + Get.find(tag: heroTag) + ..aid = aid + ..onReload(); + } catch (_) {} + } + + hasLater.value = false; + this.bvid = bvid; + queryVideoIntro(); + } + + this.cid.value = cid; + queryOnlineTotal(); + } catch (e) { + debugPrint('ugc onChangeEpisode: $e'); } - - videoDetailCtr - ..plPlayerController.pause() - ..makeHeartBeat() - ..updateMediaListHistory(aid) - ..onReset(isStein) - ..bvid = bvid - ..oid.value = aid ?? IdUtils.bv2av(bvid) - ..cid.value = cid - ..queryVideoUrl(); - - if (this.bvid != bvid) { - reload = true; - aiConclusionResult = null; - - if (cover is String && cover.isNotEmpty) { - videoDetailCtr.cover.value = cover; - } - - // 重新请求相关视频 - if (videoDetailCtr.plPlayerController.showRelatedVideo) { - try { - Get.find(tag: heroTag) - ..bvid = bvid - ..queryData(); - } catch (_) {} - } - - // 重新请求评论 - if (videoDetailCtr.showReply) { - try { - Get.find(tag: heroTag) - ..aid = aid - ..onReload(); - } catch (_) {} - } - - hasLater.value = false; - this.bvid = bvid; - queryVideoIntro(); - } - - this.cid.value = cid; - queryOnlineTotal(); - return true; } @override @@ -538,7 +550,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { /// 播放上一个 @override bool prevPlay([bool skipPages = false]) { - final List episodes = []; + final List episodes = []; bool isPages = false; final videoDetailCtr = Get.find(tag: heroTag); @@ -566,7 +578,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { ? videoDetail.isPageReversed == true ? videoDetail.pages!.last.cid : videoDetail.pages!.first.cid - : this.cid.value), + : cid.value), ); int prevIndex = currentIndex - 1; final PlayRepeat playRepeat = videoDetailCtr.plPlayerController.playRepeat; @@ -583,10 +595,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { return false; } } - final int cid = episodes[prevIndex].cid!; - final String rBvid = isPages ? bvid : episodes[prevIndex].bvid; - final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[prevIndex].aid!; - onChangeEpisode(null, rBvid, cid, rAid, null); + onChangeEpisode(episodes[prevIndex]); return true; } @@ -594,7 +603,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { @override bool nextPlay([bool skipPages = false]) { try { - final List episodes = []; + final List episodes = []; bool isPages = false; final videoDetailCtr = Get.find(tag: heroTag); final videoDetail = this.videoDetail.value; @@ -671,10 +680,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { } cid = episodes[nextIndex].cid!; } - - final String rBvid = isPages ? bvid : episodes[nextIndex].bvid; - final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!; - onChangeEpisode(null, rBvid, cid, rAid, null); + onChangeEpisode(episodes[nextIndex]); return true; } catch (_) { return false; @@ -703,29 +709,14 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { } final firstItem = relatedCtr.loadingState.value.data!.first; - try { - if (firstItem.cid != null) { - onChangeEpisode( - null, - firstItem.bvid, - firstItem.cid, - firstItem.aid, - firstItem.cover, - ); - } else { - SearchHttp.ab2c(aid: firstItem.aid, bvid: firstItem.bvid).then( - (cid) => onChangeEpisode( - null, - firstItem.bvid, - cid, - firstItem.aid, - firstItem.cover, - ), - ); - } - } catch (err) { - SmartDialog.showToast(err.toString()); - } + onChangeEpisode( + BaseEpisodeItem( + aid: firstItem.aid, + bvid: firstItem.bvid, + cid: firstItem.cid, + cover: firstItem.cover, + ), + ); return true; } diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index 2db91d51..b20852bc 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -320,7 +320,6 @@ class _UgcIntroPanelState extends State .horizontalSeasonPanel)) SeasonPanel( heroTag: widget.heroTag, - onChangeEpisode: ugcIntroController.onChangeEpisode, showEpisodes: widget.showEpisodes, ugcIntroController: ugcIntroController, ), diff --git a/lib/pages/video/introduction/ugc/widgets/page.dart b/lib/pages/video/introduction/ugc/widgets/page.dart index 9faa35ae..33d7114b 100644 --- a/lib/pages/video/introduction/ugc/widgets/page.dart +++ b/lib/pages/video/introduction/ugc/widgets/page.dart @@ -156,13 +156,7 @@ class _PagesPanelState extends State { if (widget.showEpisodes == null) { Get.back(); } - widget.ugcIntroController.onChangeEpisode( - null, - widget.bvid, - item.cid, - IdUtils.bv2av(widget.bvid), - widget.cover, - ); + widget.ugcIntroController.onChangeEpisode(item); if (widget.list != null && widget .ugcIntroController diff --git a/lib/pages/video/introduction/ugc/widgets/season.dart b/lib/pages/video/introduction/ugc/widgets/season.dart index 277e0654..12bfe59a 100644 --- a/lib/pages/video/introduction/ugc/widgets/season.dart +++ b/lib/pages/video/introduction/ugc/widgets/season.dart @@ -11,13 +11,11 @@ import 'package:get/get.dart'; class SeasonPanel extends StatefulWidget { const SeasonPanel({ super.key, - required this.onChangeEpisode, required this.heroTag, required this.showEpisodes, this.onTap, required this.ugcIntroController, }); - final Function onChangeEpisode; final String heroTag; final Function showEpisodes; final bool? onTap; diff --git a/lib/pages/video/medialist/view.dart b/lib/pages/video/medialist/view.dart index 7edba5c7..23695f6b 100644 --- a/lib/pages/video/medialist/view.dart +++ b/lib/pages/video/medialist/view.dart @@ -6,10 +6,10 @@ import 'package:PiliPlus/common/widgets/image/image_save.dart'; import 'package:PiliPlus/common/widgets/image/network_img_layer.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/common/widgets/stat/stat.dart'; -import 'package:PiliPlus/http/search.dart'; import 'package:PiliPlus/models/common/badge_type.dart'; import 'package:PiliPlus/models/common/stat_type.dart'; import 'package:PiliPlus/models_new/media_list/media_list.dart'; +import 'package:PiliPlus/models_new/video/video_detail/episode.dart'; import 'package:PiliPlus/pages/common/common_collapse_slide_page.dart'; import 'package:PiliPlus/utils/duration_util.dart'; import 'package:flutter/material.dart' hide RefreshCallback; @@ -22,7 +22,7 @@ class MediaListPanel extends CommonCollapseSlidePage { const MediaListPanel({ super.key, required this.mediaList, - this.changeMediaList, + required this.onChangeEpisode, this.panelTitle, required this.getBvId, required this.loadMoreMedia, @@ -34,7 +34,7 @@ class MediaListPanel extends CommonCollapseSlidePage { }); final List mediaList; - final Function? changeMediaList; + final ValueChanged onChangeEpisode; final String? panelTitle; final Function getBvId; final VoidCallback loadMoreMedia; @@ -162,20 +162,13 @@ class _MediaListPanelState child: Material( type: MaterialType.transparency, child: InkWell( - onTap: () async { + onTap: () { if (item.type != 2) { SmartDialog.showToast('不支持播放该类型视频'); return; } Get.back(); - String bvid = item.bvid!; - int? aid = item.aid; - String cover = item.cover ?? ''; - final int? cid = - item.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid); - if (cid != null) { - widget.changeMediaList?.call(bvid, cid, aid, cover); - } + widget.onChangeEpisode(item); }, onLongPress: () => imageSaveDialog( title: item.title, @@ -206,12 +199,12 @@ class _MediaListPanelState width: boxConstraints.maxWidth, height: boxConstraints.maxHeight, ), - if (item.badge?.text?.isNotEmpty == true) + if (item.badge?.isNotEmpty == true) PBadge( - text: item.badge?.text, + text: item.badge, right: 6.0, top: 6.0, - type: switch (item.badge?.text) { + type: switch (item.badge) { '充电专属' => PBadgeType.error, _ => PBadgeType.primary, }, diff --git a/lib/pages/video/member/view.dart b/lib/pages/video/member/view.dart index 4924e89d..49090ef7 100644 --- a/lib/pages/video/member/view.dart +++ b/lib/pages/video/member/view.dart @@ -10,6 +10,7 @@ import 'package:PiliPlus/models/common/image_preview_type.dart'; import 'package:PiliPlus/models/common/image_type.dart'; import 'package:PiliPlus/models/member/info.dart'; import 'package:PiliPlus/models_new/space/space_archive/item.dart'; +import 'package:PiliPlus/models_new/video/video_detail/episode.dart'; import 'package:PiliPlus/pages/member_video/widgets/video_card_h_member_video.dart'; import 'package:PiliPlus/pages/video/controller.dart'; import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart'; @@ -17,7 +18,6 @@ import 'package:PiliPlus/pages/video/member/controller.dart'; import 'package:PiliPlus/services/account_service.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/grid.dart'; -import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/num_util.dart'; import 'package:PiliPlus/utils/request_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; @@ -200,18 +200,14 @@ class _HorizontalMemberPageState extends State { videoItem: videoItem, bvid: _bvid, onTap: () { - final status = widget.ugcIntroController - .onChangeEpisode( - null, - videoItem.bvid, - videoItem.cid, - IdUtils.bv2av(videoItem.bvid!), - videoItem.cover, - ); - if (status) { - _bvid = videoItem.bvid; - setState(() {}); - } + Get.back(); + widget.ugcIntroController.onChangeEpisode( + BaseEpisodeItem( + bvid: videoItem.bvid, + cid: videoItem.cid, + cover: videoItem.cover, + ), + ); }, ); }, diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index 94e316aa..37467560 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -11,9 +11,7 @@ import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart' import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/main.dart'; import 'package:PiliPlus/models/common/episode_panel_type.dart'; -import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart' as pgc; import 'package:PiliPlus/models_new/pgc/pgc_info_model/result.dart'; -import 'package:PiliPlus/models_new/video/video_detail/episode.dart'; import 'package:PiliPlus/models_new/video/video_detail/page.dart'; import 'package:PiliPlus/models_new/video/video_tag/data.dart'; import 'package:PiliPlus/pages/common/common_intro_controller.dart'; @@ -1771,12 +1769,8 @@ class _VideoDetailPageVState extends State ), onPressed: () { ugcIntroController.onChangeEpisode( - null, - videoDetailController.bvid, - item.cid, - IdUtils.bv2av(videoDetailController.bvid), - null, - true, + item, + isStein: true, ); videoDetailController.getSteinEdgeInfo( item.id, @@ -1968,7 +1962,6 @@ class _VideoDetailPageVState extends State child: SeasonPanel( heroTag: heroTag, onTap: false, - onChangeEpisode: ugcIntroController.onChangeEpisode, showEpisodes: showEpisodes, ugcIntroController: ugcIntroController, ), @@ -2153,22 +2146,6 @@ class _VideoDetailPageVState extends State return; } - void onChangeEpisode(episode) { - final isEpisode = episode is BaseEpisodeItem; - final isPgc = episode is pgc.EpisodeItem; - ugcIntroController.onChangeEpisode( - isPgc ? episode.epId : null, - isEpisode ? episode.bvid : bvid, - episode.cid, - isEpisode ? episode.aid : aid, - episode is EpisodeItem - ? episode.arc?.pic - : isPgc - ? episode.cover - : null, - ); - } - final videoDetail = ugcIntroController.videoDetail.value; if (isSeason) { // reverse season @@ -2194,7 +2171,7 @@ class _VideoDetailPageVState extends State .episodes! .first; if (episode.cid != videoDetailController.cid.value) { - onChangeEpisode(episode); + ugcIntroController.onChangeEpisode(episode); videoDetailController.seasonCid = episode.cid; } else { videoDetailController @@ -2214,7 +2191,7 @@ class _VideoDetailPageVState extends State // switch to first episode var episode = videoDetail.pages!.first; if (episode.cid != videoDetailController.cid.value) { - onChangeEpisode(episode); + ugcIntroController.onChangeEpisode(episode); } else { videoDetailController.cid.refresh(); } diff --git a/lib/plugin/pl_player/widgets/backward_seek.dart b/lib/plugin/pl_player/widgets/backward_seek.dart index dcbb02fb..8e2bdaf5 100644 --- a/lib/plugin/pl_player/widgets/backward_seek.dart +++ b/lib/plugin/pl_player/widgets/backward_seek.dart @@ -26,7 +26,7 @@ class BackwardSeekIndicatorState extends State { super.initState(); duration = Duration(seconds: widget.duration); timer = Timer(const Duration(milliseconds: 400), () { - widget.onSubmitted.call(duration); + widget.onSubmitted(duration); }); } @@ -39,7 +39,7 @@ class BackwardSeekIndicatorState extends State { void increment() { timer?.cancel(); timer = Timer(const Duration(milliseconds: 400), () { - widget.onSubmitted.call(duration); + widget.onSubmitted(duration); }); setState(() { duration += Duration(seconds: widget.duration); diff --git a/lib/plugin/pl_player/widgets/forward_seek.dart b/lib/plugin/pl_player/widgets/forward_seek.dart index 44c2f6d9..9d60c932 100644 --- a/lib/plugin/pl_player/widgets/forward_seek.dart +++ b/lib/plugin/pl_player/widgets/forward_seek.dart @@ -26,7 +26,7 @@ class ForwardSeekIndicatorState extends State { super.initState(); duration = Duration(seconds: widget.duration); timer = Timer(const Duration(milliseconds: 400), () { - widget.onSubmitted.call(duration); + widget.onSubmitted(duration); }); } @@ -39,7 +39,7 @@ class ForwardSeekIndicatorState extends State { void increment() { timer?.cancel(); timer = Timer(const Duration(milliseconds: 400), () { - widget.onSubmitted.call(duration); + widget.onSubmitted(duration); }); setState(() { duration += Duration(seconds: widget.duration);