diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 676a5fd1..846d602c 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -3,13 +3,10 @@ import 'dart:convert'; import 'package:PiliPlus/http/constants.dart'; import 'package:PiliPlus/http/init.dart'; -import 'package:PiliPlus/http/loading_state.dart'; -import 'package:PiliPlus/http/search.dart'; import 'package:PiliPlus/http/user.dart'; import 'package:PiliPlus/http/video.dart'; import 'package:PiliPlus/models/bangumi/info.dart'; import 'package:PiliPlus/models/user/fav_folder.dart'; -import 'package:PiliPlus/pages/common/common_data_controller.dart'; import 'package:PiliPlus/pages/dynamics_repost/view.dart'; import 'package:PiliPlus/pages/video/controller.dart'; import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart'; @@ -28,8 +25,7 @@ import 'package:get/get.dart'; import 'package:html/dom.dart' as dom; import 'package:html/parser.dart' as html_parser; -class BangumiIntroController - extends CommonDataController { +class BangumiIntroController extends GetxController { // 视频bvid String bvid = Get.parameters['bvid'] ?? ''; var seasonId = Get.parameters['seasonId'] != null @@ -44,15 +40,7 @@ class BangumiIntroController ? '追番' : '追剧'; - // 是否预渲染 骨架屏 - bool preRender = false; - - // 视频详情 上个页面传入 - Map? videoItem = {}; - BangumiInfoModel? bangumiItem; - - // up主粉丝数 - Map userStat = {'follower': '-'}; + BangumiInfoModel bangumiItem = Get.arguments['bangumiItem']; // 是否点赞 RxBool hasLike = false.obs; @@ -62,11 +50,14 @@ class BangumiIntroController bool get hasCoin => _coinNum.value != 0; // 是否收藏 RxBool hasFav = false.obs; + dynamic videoTags; - bool isLogin = false; - Rx favFolderData = FavFolderData().obs; + List? favIds; - dynamic userInfo; + Rx favFolderData = FavFolderData().obs; + + bool isLogin = Accounts.main.isLogin; + int mid = Accounts.main.mid; late final enableQuickFav = GStorage.setting.get(SettingBoxKey.enableQuickFav, defaultValue: false); @@ -74,30 +65,15 @@ class BangumiIntroController @override void onInit() { super.onInit(); - if (Get.arguments.isNotEmpty as bool) { - if (Get.arguments.containsKey('bangumiItem') as bool) { - preRender = true; - bangumiItem = Get.arguments['bangumiItem']; + if (isLogin) { + if (seasonId != null) { + queryIsFollowed(); + } + if (epId != null) { + queryBangumiLikeCoinFav(); } } - userInfo = GStorage.userInfo.get('userInfoCache'); - isLogin = userInfo != null; - - if (isLogin && epId != null) { - queryBangumiLikeCoinFav(); - } - - queryData(); - - if (isLogin && seasonId != null) { - queryIsFollowed(); - } - } - - @override - Future queryData([bool isRefresh = true]) async { - await queryVideoTags(); - return super.queryData(isRefresh); + queryVideoTags(); } Future queryVideoTags() async { @@ -107,18 +83,6 @@ class BangumiIntroController } } - @override - bool customHandleResponse( - bool isRefresh, Success response) { - epId ??= response.response.episodes?.firstOrNull?.id; - loadingState.value = response; - return true; - } - - @override - Future> customGetData() => - SearchHttp.bangumiInfoNew(seasonId: seasonId, epId: epId); - // 获取点赞/投币/收藏状态 Future queryBangumiLikeCoinFav() async { var result = await VideoHttp.bangumiLikeCoinFav(epId: epId); @@ -136,9 +100,8 @@ class BangumiIntroController var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value); if (result['status']) { SmartDialog.showToast(!hasLike.value ? result['data']['toast'] : '取消赞'); - BangumiInfoModel bangumiDetail = (loadingState.value as Success).response; - bangumiDetail.stat!['likes'] = - bangumiDetail.stat!['likes'] + (!hasLike.value ? 1 : -1); + bangumiItem.stat!['likes'] = + bangumiItem.stat!['likes'] + (!hasLike.value ? 1 : -1); hasLike.value = !hasLike.value; } else { SmartDialog.showToast(result['msg']); @@ -153,11 +116,10 @@ class BangumiIntroController ); if (res['status']) { SmartDialog.showToast('投币成功'); - BangumiInfoModel bangumiDetail = (loadingState.value as Success).response; - bangumiDetail.stat!['coins'] = bangumiDetail.stat!['coins'] + coin; + bangumiItem.stat!['coins'] = bangumiItem.stat!['coins'] + coin; if (selectLike && hasLike.value.not) { hasLike.value = true; - bangumiDetail.stat!['likes'] = bangumiDetail.stat!['likes'] + 1; + bangumiItem.stat!['likes'] = bangumiItem.stat!['likes'] + 1; } _coinNum.value += coin; GlobalData().afterCoin(coin); @@ -168,7 +130,7 @@ class BangumiIntroController // 投币 Future actionCoinVideo() async { - if (userInfo == null) { + if (!isLogin) { SmartDialog.showToast('账号未登录'); return; } @@ -306,7 +268,7 @@ class BangumiIntroController ), onTap: () { Get.back(); - EpisodeItem? item = bangumiItem?.episodes + EpisodeItem? item = bangumiItem.episodes ?.firstWhereOrNull((item) => item.epId == epId); showModalBottomSheet( context: context, @@ -331,9 +293,9 @@ class BangumiIntroController '5' || '7' => 4099, _ => -1, }, - pic: bangumiItem?.cover, + pic: bangumiItem.cover, title: - '${bangumiItem?.title}${item != null ? '\n${item.showTitle}' : ''}', + '${bangumiItem.title}${item != null ? '\n${item.showTitle}' : ''}', uname: '', ), ); @@ -348,9 +310,9 @@ class BangumiIntroController onTap: () { Get.back(); try { - EpisodeItem item = bangumiItem!.episodes! + EpisodeItem item = bangumiItem.episodes! .firstWhere((item) => item.epId == epId); - final title = '${bangumiItem!.title!} ${item.showTitle}'; + final title = '${bangumiItem.title!} ${item.showTitle}'; PageUtils.pmShare( context, content: { @@ -360,7 +322,7 @@ class BangumiIntroController "headline": title, "source": 16, "thumb": item.cover, - "source_desc": switch (bangumiItem!.type) { + "source_desc": switch (bangumiItem.type) { 1 => '番剧', 2 => '电影', 3 => '纪录片', @@ -439,8 +401,7 @@ class BangumiIntroController // 追番 Future bangumiAdd() async { - var result = await VideoHttp.bangumiAdd( - seasonId: (loadingState.value as Success).response.seasonId); + var result = await VideoHttp.bangumiAdd(seasonId: bangumiItem.seasonId); if (result['status']) { isFollowed.value = true; followStatus.value = 2; @@ -450,8 +411,7 @@ class BangumiIntroController // 取消追番 Future bangumiDel() async { - var result = await VideoHttp.bangumiDel( - seasonId: (loadingState.value as Success).response.seasonId); + var result = await VideoHttp.bangumiDel(seasonId: bangumiItem.seasonId); if (result['status']) { isFollowed.value = false; } @@ -460,7 +420,7 @@ class BangumiIntroController Future bangumiUpdate(status) async { var result = await VideoHttp.bangumiUpdate( - seasonId: [(loadingState.value as Success).response.seasonId], + seasonId: [bangumiItem.seasonId], status: status, ); if (result['status']) { @@ -472,7 +432,7 @@ class BangumiIntroController Future queryVideoInFolder() async { favIds = null; var result = await VideoHttp.videoInFolder( - mid: userInfo.mid, + mid: mid, rid: epId, // bangumi type: 24, // bangumi ); @@ -487,10 +447,7 @@ class BangumiIntroController } bool prevPlay() { - late List episodes; - if ((loadingState.value as Success).response.episodes != null) { - episodes = (loadingState.value as Success).response.episodes!; - } + List episodes = bangumiItem.episodes!; VideoDetailController videoDetailCtr = Get.find(tag: Get.arguments['heroTag']); int currentIndex = @@ -516,21 +473,11 @@ class BangumiIntroController /// 列表循环或者顺序播放时,自动播放下一个;自动连播时,播放相关视频 bool nextPlay() { try { - late List episodes; + List episodes = bangumiItem.episodes!; VideoDetailController videoDetailCtr = Get.find(tag: Get.arguments['heroTag']); PlayRepeat playRepeat = videoDetailCtr.plPlayerController.playRepeat; - if ((loadingState.value as Success).response.episodes != - null) { - episodes = (loadingState.value as Success) - .response - .episodes!; - } else { - if (playRepeat == PlayRepeat.autoPlayRelated) { - return playRelated(); - } - } int currentIndex = episodes.indexWhere((e) => e.cid == videoDetailCtr.cid.value); int nextIndex = currentIndex + 1; @@ -539,7 +486,7 @@ class BangumiIntroController if (playRepeat == PlayRepeat.listCycle) { nextIndex = 0; } else if (playRepeat == PlayRepeat.autoPlayRelated) { - return playRelated(); + return false; } else { return false; } @@ -556,15 +503,10 @@ class BangumiIntroController } } - bool playRelated() { - SmartDialog.showToast('番剧暂无相关视频'); - return false; - } - // 一键三连 Future actionOneThree() async { feedBack(); - if (userInfo == null) { + if (!isLogin) { SmartDialog.showToast('账号未登录'); return; } @@ -610,7 +552,7 @@ class BangumiIntroController // 收藏 void showFavBottomSheet(BuildContext context, {type = 'tap'}) { - if (userInfo == null) { + if (!isLogin) { SmartDialog.showToast('账号未登录'); return; } diff --git a/lib/pages/video/introduction/pgc/view.dart b/lib/pages/video/introduction/pgc/view.dart index a824098b..880c0d32 100644 --- a/lib/pages/video/introduction/pgc/view.dart +++ b/lib/pages/video/introduction/pgc/view.dart @@ -4,9 +4,7 @@ import 'package:PiliPlus/common/constants.dart'; import 'package:PiliPlus/common/widgets/badge.dart'; import 'package:PiliPlus/common/widgets/dialog/dialog.dart'; import 'package:PiliPlus/common/widgets/image/network_img_layer.dart'; -import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart'; import 'package:PiliPlus/common/widgets/stat/stat.dart'; -import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models/bangumi/info.dart'; import 'package:PiliPlus/models/common/image_preview_type.dart'; import 'package:PiliPlus/pages/video/controller.dart'; @@ -15,7 +13,6 @@ import 'package:PiliPlus/pages/video/introduction/pgc/widgets/bangumi_panel.dart import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart'; import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_row_item.dart'; import 'package:PiliPlus/utils/extension.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -44,95 +41,10 @@ class _BangumiIntroPanelState extends State with AutomaticKeepAliveClientMixin { late BangumiIntroController bangumiIntroController; late VideoDetailController videoDetailCtr; - late int cid; - StreamSubscription? _listener; -// 添加页面缓存 - @override - bool get wantKeepAlive => true; + late final _coinKey = GlobalKey(); + late final _favKey = GlobalKey(); - @override - void initState() { - super.initState(); - cid = widget.cid!; - bangumiIntroController = - Get.put(BangumiIntroController(), tag: widget.heroTag); - videoDetailCtr = Get.find(tag: widget.heroTag); - _listener = videoDetailCtr.cid.listen((int p0) { - cid = p0; - if (!mounted) return; - setState(() {}); - }); - } - - @override - void dispose() { - _listener?.cancel(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - super.build(context); - return Obx(() => _buildBody(bangumiIntroController.loadingState.value)); - } - - Widget _buildBody(LoadingState loadingState) { - return switch (loadingState) { - Loading() => BangumiInfo( - heroTag: widget.heroTag, - isLoading: true, - bangumiDetail: null, - cid: cid, - showEpisodes: widget.showEpisodes, - showIntroDetail: () {}, - ), - Success(:var response) => BangumiInfo( - heroTag: widget.heroTag, - isLoading: false, - bangumiDetail: response, - cid: cid, - showEpisodes: widget.showEpisodes, - showIntroDetail: () => widget.showIntroDetail( - response, - bangumiIntroController.videoTags, - ), - ), - Error(:var errMsg) => HttpError( - errMsg: errMsg, - onReload: bangumiIntroController.onReload, - ), - }; - } -} - -class BangumiInfo extends StatefulWidget { - const BangumiInfo({ - super.key, - this.isLoading = false, - this.bangumiDetail, - this.cid, - required this.showEpisodes, - required this.showIntroDetail, - required this.heroTag, - }); - - final bool isLoading; - final BangumiInfoModel? bangumiDetail; - final int? cid; - final Function showEpisodes; - final Function showIntroDetail; - final String heroTag; - - @override - State createState() => _BangumiInfoState(); -} - -class _BangumiInfoState extends State { - late final BangumiIntroController bangumiIntroController; - late final VideoDetailController videoDetailCtr; - late final BangumiInfoModel? bangumiItem; - int? cid; bool isProcessing = false; Future handleState(Future Function() action) async { if (isProcessing.not) { @@ -142,10 +54,8 @@ class _BangumiInfoState extends State { } } - late final _coinKey = GlobalKey(); - late final _favKey = GlobalKey(); - - StreamSubscription? _listener; + @override + bool get wantKeepAlive => true; @override void initState() { @@ -153,32 +63,14 @@ class _BangumiInfoState extends State { bangumiIntroController = Get.put(BangumiIntroController(), tag: widget.heroTag); videoDetailCtr = Get.find(tag: widget.heroTag); - bangumiItem = bangumiIntroController.bangumiItem; - cid = widget.cid!; - debugPrint('cid: $cid'); - _listener = videoDetailCtr.cid.listen((p0) { - cid = p0; - if (!mounted) return; - setState(() {}); - }); - } - - @override - void dispose() { - _listener?.cancel(); - super.dispose(); - } - - // 视频介绍 - void showIntroDetail() { - feedBack(); - widget.showIntroDetail(); } @override Widget build(BuildContext context) { + super.build(context); final ThemeData theme = Theme.of(context); - bool isLandscape = + final bangumiItem = bangumiIntroController.bangumiItem; + final isLandscape = MediaQuery.of(context).orientation == Orientation.landscape; return SliverPadding( padding: EdgeInsets.only( @@ -188,246 +80,196 @@ class _BangumiInfoState extends State { bottom: StyleString.safeSpace + MediaQuery.paddingOf(context).bottom, ), sliver: SliverToBoxAdapter( - child: !widget.isLoading || bangumiItem != null - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( - clipBehavior: Clip.none, - children: [ - GestureDetector( - onTap: () { - videoDetailCtr.onViewImage(); - context.imageView( - imgList: [ - SourceModel( - url: !widget.isLoading - ? widget.bangumiDetail!.cover! - : bangumiItem!.cover!, - ) - ], - onDismissed: videoDetailCtr.onDismissed, - ); - }, - child: Hero( - tag: !widget.isLoading - ? widget.bangumiDetail!.cover! - : bangumiItem!.cover!, - child: NetworkImgLayer( - width: isLandscape ? 115 / 0.75 : 115, - height: isLandscape ? 115 : 115 / 0.75, - src: !widget.isLoading - ? widget.bangumiDetail!.cover! - : bangumiItem!.cover!, - semanticsLabel: '封面', - ), - ), - ), - if (bangumiItem != null && - bangumiItem!.rating != null) - PBadge( - text: - '评分 ${!widget.isLoading ? widget.bangumiDetail!.rating!['score']! : bangumiItem!.rating!['score']!}', - top: null, - right: 6, - bottom: 6, - left: null, - ), - ], - ), - const SizedBox(width: 10), - Expanded( - child: GestureDetector( - onTap: showIntroDetail, - behavior: HitTestBehavior.opaque, - child: SizedBox( - height: isLandscape ? 115 : 115 / 0.75, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text( - !widget.isLoading - ? widget.bangumiDetail!.title! - : bangumiItem!.title!, - style: const TextStyle( - fontSize: 16, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), - const SizedBox(width: 20), - Obx( - () => FilledButton.tonal( - style: FilledButton.styleFrom( - tapTargetSize: - MaterialTapTargetSize.shrinkWrap, - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 10, - ), - visualDensity: VisualDensity.compact, - foregroundColor: - bangumiIntroController - .isFollowed.value - ? theme.colorScheme.outline - : null, - backgroundColor: - bangumiIntroController - .isFollowed.value - ? theme.colorScheme - .onInverseSurface - : null, - ), - onPressed: bangumiIntroController - .followStatus.value == - -1 - ? null - : () { - if (bangumiIntroController - .isFollowed.value) { - showPgcFollowDialog( - context: context, - type: bangumiIntroController - .type, - followStatus: - bangumiIntroController - .followStatus.value, - onUpdateStatus: - (followStatus) { - if (followStatus == -1) { - bangumiIntroController - .bangumiDel(); - } else { - bangumiIntroController - .bangumiUpdate( - followStatus); - } - }, - ); - } else { - bangumiIntroController - .bangumiAdd(); - } - }, - child: Text( - bangumiIntroController - .isFollowed.value - ? '已${bangumiIntroController.type}' - : '${bangumiIntroController.type}', - ), - ), - ), - ], - ), - Row( - children: [ - StatView( - context: context, - theme: 'gray', - value: Utils.numFormat(!widget.isLoading - ? widget.bangumiDetail!.stat!['views'] - : bangumiItem!.stat!['views']), - ), - const SizedBox(width: 6), - StatDanMu( - context: context, - theme: 'gray', - value: Utils.numFormat(!widget.isLoading - ? widget - .bangumiDetail!.stat!['danmakus'] - : bangumiItem!.stat!['danmakus']), - ), - if (isLandscape) ...[ - const SizedBox(width: 6), - AreasAndPubTime( - widget: widget, - bangumiItem: bangumiItem, - theme: theme, - ), - const SizedBox(width: 6), - NewEpDesc( - widget: widget, - bangumiItem: bangumiItem, - theme: theme, - ), - ] - ], - ), - SizedBox(height: isLandscape ? 2 : 6), - if (!isLandscape) - AreasAndPubTime( - widget: widget, - bangumiItem: bangumiItem, - theme: theme, - ), - if (!isLandscape) - NewEpDesc( - widget: widget, - bangumiItem: bangumiItem, - theme: theme, - ), - const Spacer(), - Text( - '简介:${!widget.isLoading ? widget.bangumiDetail!.evaluate! : bangumiItem!.evaluate!}', - maxLines: isLandscape ? 2 : 3, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 13, - color: theme.colorScheme.outline, - ), - ), - ], - ), - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + clipBehavior: Clip.none, + children: [ + GestureDetector( + onTap: () { + videoDetailCtr.onViewImage(); + context.imageView( + imgList: [ + SourceModel( + url: bangumiItem.cover!, + ) + ], + onDismissed: videoDetailCtr.onDismissed, + ); + }, + child: Hero( + tag: bangumiItem.cover!, + child: NetworkImgLayer( + width: isLandscape ? 115 / 0.75 : 115, + height: isLandscape ? 115 : 115 / 0.75, + src: bangumiItem.cover!, + semanticsLabel: '封面', ), ), - ], - ), - const SizedBox(height: 6), - // 点赞收藏转发 布局样式2 - actionGrid(theme, bangumiIntroController), - // 番剧分p - if ((!widget.isLoading && - widget.bangumiDetail!.episodes!.isNotEmpty) || - bangumiItem != null && - bangumiItem!.episodes!.isNotEmpty) ...[ - BangumiPanel( - heroTag: widget.heroTag, - pages: bangumiItem != null - ? bangumiItem!.episodes! - : widget.bangumiDetail!.episodes!, - cid: cid ?? - (bangumiItem != null - ? bangumiItem!.episodes!.first.cid - : widget.bangumiDetail!.episodes!.first.cid), - changeFuc: bangumiIntroController.changeSeasonOrbangu, - showEpisodes: widget.showEpisodes, - newEp: bangumiItem?.newEp, - ) + ), + if (bangumiItem.rating != null) + PBadge( + text: '评分 ${bangumiItem.rating!['score']!}', + top: null, + right: 6, + bottom: 6, + left: null, + ), ], - ], - ) - : const SizedBox( - height: 100, - child: Center( - child: CircularProgressIndicator(), ), - ), + const SizedBox(width: 10), + Expanded( + child: GestureDetector( + onTap: () => widget.showIntroDetail( + bangumiItem, bangumiIntroController.videoTags), + behavior: HitTestBehavior.opaque, + child: SizedBox( + height: isLandscape ? 115 : 115 / 0.75, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + bangumiItem.title!, + style: const TextStyle( + fontSize: 16, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ), + const SizedBox(width: 20), + Obx( + () => FilledButton.tonal( + style: FilledButton.styleFrom( + tapTargetSize: + MaterialTapTargetSize.shrinkWrap, + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 10, + ), + visualDensity: VisualDensity.compact, + foregroundColor: + bangumiIntroController.isFollowed.value + ? theme.colorScheme.outline + : null, + backgroundColor: + bangumiIntroController.isFollowed.value + ? theme.colorScheme.onInverseSurface + : null, + ), + onPressed: bangumiIntroController + .followStatus.value == + -1 + ? null + : () { + if (bangumiIntroController + .isFollowed.value) { + showPgcFollowDialog( + context: context, + type: bangumiIntroController.type, + followStatus: + bangumiIntroController + .followStatus.value, + onUpdateStatus: (followStatus) { + if (followStatus == -1) { + bangumiIntroController + .bangumiDel(); + } else { + bangumiIntroController + .bangumiUpdate( + followStatus); + } + }, + ); + } else { + bangumiIntroController.bangumiAdd(); + } + }, + child: Text( + bangumiIntroController.isFollowed.value + ? '已${bangumiIntroController.type}' + : '${bangumiIntroController.type}', + ), + ), + ), + ], + ), + Row( + children: [ + StatView( + context: context, + theme: 'gray', + value: + Utils.numFormat(bangumiItem.stat!['views']), + ), + const SizedBox(width: 6), + StatDanMu( + context: context, + theme: 'gray', + value: Utils.numFormat( + bangumiItem.stat!['danmakus']), + ), + if (isLandscape) ...[ + const SizedBox(width: 6), + areasAndPubTime(theme, bangumiItem), + const SizedBox(width: 6), + newEpDesc(theme, bangumiItem), + ] + ], + ), + SizedBox(height: isLandscape ? 2 : 6), + if (!isLandscape) ...[ + areasAndPubTime(theme, bangumiItem), + newEpDesc(theme, bangumiItem), + ], + const Spacer(), + Text( + '简介:${bangumiItem.evaluate!}', + maxLines: isLandscape ? 2 : 3, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 13, + color: theme.colorScheme.outline, + ), + ), + ], + ), + ), + ), + ), + ], + ), + const SizedBox(height: 6), + // 点赞收藏转发 布局样式2 + actionGrid(theme, bangumiItem, bangumiIntroController), + // 番剧分p + if (bangumiItem.episodes!.isNotEmpty) ...[ + BangumiPanel( + heroTag: widget.heroTag, + pages: bangumiItem.episodes!, + cid: videoDetailCtr.cid.value, + changeFuc: bangumiIntroController.changeSeasonOrbangu, + showEpisodes: widget.showEpisodes, + newEp: bangumiItem.newEp, + ) + ], + ], + ), ), ); } - Widget actionGrid( - ThemeData theme, BangumiIntroController bangumiIntroController) { + Widget actionGrid(ThemeData theme, BangumiInfoModel bangumiItem, + BangumiIntroController bangumiIntroController) { return Material( color: theme.colorScheme.surface, child: Padding( @@ -445,13 +287,9 @@ class _BangumiInfoState extends State { handleState(bangumiIntroController.actionLikeVideo), onLongPress: bangumiIntroController.actionOneThree, selectStatus: bangumiIntroController.hasLike.value, - loadingStatus: false, + isLoading: false, semanticsLabel: '点赞', - text: !widget.isLoading - ? Utils.numFormat(widget.bangumiDetail!.stat!['likes']!) - : Utils.numFormat( - bangumiItem!.stat!['likes']!, - ), + text: Utils.numFormat(bangumiItem.stat!['likes']!), needAnim: true, hasTriple: bangumiIntroController.hasLike.value && bangumiIntroController.hasCoin && @@ -476,13 +314,9 @@ class _BangumiInfoState extends State { onTap: () => handleState(bangumiIntroController.actionCoinVideo), selectStatus: bangumiIntroController.hasCoin, - loadingStatus: false, + isLoading: false, semanticsLabel: '投币', - text: !widget.isLoading - ? Utils.numFormat(widget.bangumiDetail!.stat!['coins']!) - : Utils.numFormat( - bangumiItem!.stat!['coins']!, - ), + text: Utils.numFormat(bangumiItem.stat!['coins']!), needAnim: true, ), ), @@ -496,14 +330,9 @@ class _BangumiInfoState extends State { onLongPress: () => bangumiIntroController .showFavBottomSheet(context, type: 'longPress'), selectStatus: bangumiIntroController.hasFav.value, - loadingStatus: false, + isLoading: false, semanticsLabel: '收藏', - text: !widget.isLoading - ? Utils.numFormat( - widget.bangumiDetail!.stat!['favorite']!) - : Utils.numFormat( - bangumiItem!.stat!['favorite']!, - ), + text: Utils.numFormat(bangumiItem.stat!['favorite']!), needAnim: true, ), ), @@ -512,21 +341,18 @@ class _BangumiInfoState extends State { selectIcon: const Icon(FontAwesomeIcons.reply), onTap: () => videoDetailCtr.tabCtr.animateTo(1), selectStatus: false, - loadingStatus: false, + isLoading: false, semanticsLabel: '评论', - text: !widget.isLoading - ? Utils.numFormat(widget.bangumiDetail!.stat!['reply']!) - : Utils.numFormat(bangumiItem!.stat!['reply']!), + text: Utils.numFormat(bangumiItem.stat!['reply']!), ), ActionItem( - icon: const Icon(FontAwesomeIcons.shareFromSquare), - onTap: () => bangumiIntroController.actionShareVideo(context), - selectStatus: false, - loadingStatus: false, - semanticsLabel: '转发', - text: !widget.isLoading - ? Utils.numFormat(widget.bangumiDetail!.stat!['share']!) - : Utils.numFormat(bangumiItem!.stat!['share']!)), + icon: const Icon(FontAwesomeIcons.shareFromSquare), + onTap: () => bangumiIntroController.actionShareVideo(context), + selectStatus: false, + isLoading: false, + semanticsLabel: '转发', + text: Utils.numFormat(bangumiItem.stat!['share']!), + ), ], ), ), @@ -535,95 +361,72 @@ class _BangumiInfoState extends State { } Widget actionRow( - BuildContext context, + BangumiInfoModel bangumiItem, BangumiIntroController bangumiIntroController, VideoDetailController videoDetailCtr, ) { - return Row(children: [ - Obx( - () => ActionRowItem( - icon: const Icon(FontAwesomeIcons.thumbsUp), - onTap: () => handleState(bangumiIntroController.actionLikeVideo), - selectStatus: bangumiIntroController.hasLike.value, - loadingStatus: widget.isLoading, - text: !widget.isLoading - ? widget.bangumiDetail!.stat!['likes']!.toString() - : '-', + return Row( + children: [ + Obx( + () => ActionRowItem( + icon: const Icon(FontAwesomeIcons.thumbsUp), + onTap: () => handleState(bangumiIntroController.actionLikeVideo), + selectStatus: bangumiIntroController.hasLike.value, + isLoading: false, + text: bangumiItem.stat!['likes']!.toString(), + ), ), - ), - const SizedBox(width: 8), - Obx( - () => ActionRowItem( - icon: const Icon(FontAwesomeIcons.b), - onTap: () => handleState(bangumiIntroController.actionCoinVideo), - selectStatus: bangumiIntroController.hasCoin, - loadingStatus: widget.isLoading, - text: !widget.isLoading - ? widget.bangumiDetail!.stat!['coins']!.toString() - : '-', + const SizedBox(width: 8), + Obx( + () => ActionRowItem( + icon: const Icon(FontAwesomeIcons.b), + onTap: () => handleState(bangumiIntroController.actionCoinVideo), + selectStatus: bangumiIntroController.hasCoin, + isLoading: false, + text: bangumiItem.stat!['coins']!.toString(), + ), ), - ), - const SizedBox(width: 8), - Obx( - () => ActionRowItem( - icon: const Icon(FontAwesomeIcons.heart), - onTap: () => bangumiIntroController.showFavBottomSheet(context), - onLongPress: () => bangumiIntroController.showFavBottomSheet(context, - type: 'longPress'), - selectStatus: bangumiIntroController.hasFav.value, - loadingStatus: widget.isLoading, - text: !widget.isLoading - ? widget.bangumiDetail!.stat!['favorite']!.toString() - : '-', + const SizedBox(width: 8), + Obx( + () => ActionRowItem( + icon: const Icon(FontAwesomeIcons.heart), + onTap: () => bangumiIntroController.showFavBottomSheet(context), + onLongPress: () => bangumiIntroController + .showFavBottomSheet(context, type: 'longPress'), + selectStatus: bangumiIntroController.hasFav.value, + isLoading: false, + text: bangumiItem.stat!['favorite']!.toString(), + ), ), - ), - const SizedBox(width: 8), - ActionRowItem( - icon: const Icon(FontAwesomeIcons.comment), - onTap: () { - videoDetailCtr.tabCtr.animateTo(1); - }, - selectStatus: false, - loadingStatus: widget.isLoading, - text: !widget.isLoading - ? widget.bangumiDetail!.stat!['reply']!.toString() - : '-', - ), - const SizedBox(width: 8), - ActionRowItem( + const SizedBox(width: 8), + ActionRowItem( + icon: const Icon(FontAwesomeIcons.comment), + onTap: () { + videoDetailCtr.tabCtr.animateTo(1); + }, + selectStatus: false, + isLoading: false, + text: bangumiItem.stat!['reply']!.toString(), + ), + const SizedBox(width: 8), + ActionRowItem( icon: const Icon(FontAwesomeIcons.share), onTap: () => bangumiIntroController.actionShareVideo(context), selectStatus: false, - loadingStatus: widget.isLoading, - text: '转发'), - ]); + isLoading: false, + text: '转发', + ), + ], + ); } -} -class AreasAndPubTime extends StatelessWidget { - const AreasAndPubTime({ - super.key, - required this.widget, - required this.bangumiItem, - required this.theme, - }); - - final BangumiInfo widget; - final BangumiInfoModel? bangumiItem; - final ThemeData theme; - - @override - Widget build(BuildContext context) { + Widget areasAndPubTime(ThemeData theme, BangumiInfoModel bangumiItem) { return Row( children: [ Text( - !widget.isLoading - ? (widget.bangumiDetail!.areas!.isNotEmpty - ? widget.bangumiDetail!.areas!.first['name'] - : '') - : (bangumiItem!.areas!.isNotEmpty - ? bangumiItem!.areas!.first['name'] - : ''), + (bangumiItem.areas!.isNotEmpty + ? bangumiItem.areas!.first['name'] + : ''), style: TextStyle( fontSize: 12, color: theme.colorScheme.outline, @@ -631,9 +434,7 @@ class AreasAndPubTime extends StatelessWidget { ), const SizedBox(width: 6), Text( - !widget.isLoading - ? widget.bangumiDetail!.publish!['pub_time_show'] - : bangumiItem!.publish!['pub_time_show'], + bangumiItem.publish!['pub_time_show'], style: TextStyle( fontSize: 12, color: theme.colorScheme.outline, @@ -642,26 +443,10 @@ class AreasAndPubTime extends StatelessWidget { ], ); } -} -class NewEpDesc extends StatelessWidget { - const NewEpDesc({ - super.key, - required this.widget, - required this.bangumiItem, - required this.theme, - }); - - final BangumiInfo widget; - final BangumiInfoModel? bangumiItem; - final ThemeData theme; - - @override - Widget build(BuildContext context) { + Widget newEpDesc(ThemeData theme, BangumiInfoModel bangumiItem) { return Text( - !widget.isLoading - ? widget.bangumiDetail!.newEp!['desc'] - : bangumiItem!.newEp!['desc'], + bangumiItem.newEp!['desc'], style: TextStyle( fontSize: 12, color: theme.colorScheme.outline, diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index 8e7844a0..67ca173e 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -71,7 +71,7 @@ class _VideoIntroPanelState extends State return Obx( () => videoIntroController.videoDetail.value.title == null ? VideoInfo( - loadingStatus: true, + isLoading: true, videoIntroController: videoIntroController, heroTag: widget.heroTag, showAiBottomSheet: widget.showAiBottomSheet, @@ -80,7 +80,7 @@ class _VideoIntroPanelState extends State ) : VideoInfo( key: ValueKey(widget.heroTag), - loadingStatus: false, + isLoading: false, videoIntroController: videoIntroController, heroTag: widget.heroTag, showAiBottomSheet: widget.showAiBottomSheet, @@ -92,7 +92,7 @@ class _VideoIntroPanelState extends State } class VideoInfo extends StatefulWidget { - final bool loadingStatus; + final bool isLoading; final String heroTag; final Function showAiBottomSheet; final Function showEpisodes; @@ -101,7 +101,7 @@ class VideoInfo extends StatefulWidget { const VideoInfo({ super.key, - this.loadingStatus = false, + this.isLoading = false, required this.heroTag, required this.showAiBottomSheet, required this.showEpisodes, @@ -236,7 +236,7 @@ class _VideoInfoState extends State { // 视频介绍 void showIntroDetail() { - if (widget.loadingStatus) { + if (widget.isLoading) { return; } feedBack(); @@ -246,9 +246,8 @@ class _VideoInfoState extends State { // 用户主页 void onPushMember() { feedBack(); - int? mid = !widget.loadingStatus - ? videoDetail.owner?.mid - : videoItem['owner']?.mid; + int? mid = + !widget.isLoading ? videoDetail.owner?.mid : videoItem['owner']?.mid; if (mid != null) { if (context.orientation == Orientation.landscape && _horizontalMemberPage) { @@ -369,7 +368,7 @@ class _VideoInfoState extends State { childBuilder: (index) => GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - int? ownerMid = !widget.loadingStatus + int? ownerMid = !widget.isLoading ? videoDetail.owner?.mid : videoItem['owner']?.mid; if (videoItem['staff'][index].mid == @@ -557,7 +556,7 @@ class _VideoInfoState extends State { StatView( context: context, theme: 'gray', - value: Utils.numFormat(!widget.loadingStatus + value: Utils.numFormat(!widget.isLoading ? videoDetail.stat?.view ?? '-' : videoItem['stat']?.view ?? '-'), textColor: theme.colorScheme.outline, @@ -566,7 +565,7 @@ class _VideoInfoState extends State { StatDanMu( context: context, theme: 'gray', - value: Utils.numFormat(!widget.loadingStatus + value: Utils.numFormat(!widget.isLoading ? videoDetail.stat?.danmaku ?? '-' : videoItem['stat']?.danmu ?? '-'), textColor: theme.colorScheme.outline, @@ -574,7 +573,7 @@ class _VideoInfoState extends State { const SizedBox(width: 10), Text( Utils.dateFormat( - !widget.loadingStatus + !widget.isLoading ? videoDetail.pubdate : videoItem['pubdate'], formatType: 'detail'), @@ -769,7 +768,7 @@ class _VideoInfoState extends State { actionGrid(context, videoIntroController), ], // 合集 - if (!widget.loadingStatus && + if (!widget.isLoading && videoDetail.ugcSeason != null && (context.orientation != Orientation.landscape || (context.orientation == Orientation.landscape && @@ -784,7 +783,7 @@ class _VideoInfoState extends State { videoIntroController: videoIntroController, ), ), - if (!widget.loadingStatus && + if (!widget.isLoading && videoDetail.pages != null && videoDetail.pages!.length > 1 && (context.orientation != Orientation.landscape || @@ -857,9 +856,9 @@ class _VideoInfoState extends State { onLongPress: () => handleState(videoIntroController.actionOneThree), selectStatus: videoIntroController.hasLike.value, - loadingStatus: widget.loadingStatus, + isLoading: widget.isLoading, semanticsLabel: '点赞', - text: !widget.loadingStatus + text: !widget.isLoading ? Utils.numFormat(videoDetail.stat!.like!) : '-', needAnim: true, @@ -884,7 +883,7 @@ class _VideoInfoState extends State { selectIcon: const Icon(FontAwesomeIcons.solidThumbsDown), onTap: () => handleState(videoIntroController.actionDislikeVideo), selectStatus: videoIntroController.hasDislike.value, - loadingStatus: widget.loadingStatus, + isLoading: widget.isLoading, semanticsLabel: '点踩', text: "点踩", ), @@ -896,9 +895,9 @@ class _VideoInfoState extends State { selectIcon: const Icon(FontAwesomeIcons.b), onTap: () => handleState(videoIntroController.actionCoinVideo), selectStatus: videoIntroController.hasCoin, - loadingStatus: widget.loadingStatus, + isLoading: widget.isLoading, semanticsLabel: '投币', - text: !widget.loadingStatus + text: !widget.isLoading ? Utils.numFormat(videoDetail.stat!.coin!) : '-', needAnim: true, @@ -913,9 +912,9 @@ class _VideoInfoState extends State { onLongPress: () => videoIntroController .showFavBottomSheet(context, type: 'longPress'), selectStatus: videoIntroController.hasFav.value, - loadingStatus: widget.loadingStatus, + isLoading: widget.isLoading, semanticsLabel: '收藏', - text: !widget.loadingStatus + text: !widget.isLoading ? Utils.numFormat(videoDetail.stat!.favorite!) : '-', needAnim: true, @@ -927,7 +926,7 @@ class _VideoInfoState extends State { selectIcon: const Icon(FontAwesomeIcons.solidClock), onTap: () => handleState(videoIntroController.viewLater), selectStatus: videoIntroController.hasLater.value, - loadingStatus: widget.loadingStatus, + isLoading: widget.isLoading, semanticsLabel: '再看', text: '再看', ), @@ -936,9 +935,9 @@ class _VideoInfoState extends State { icon: const Icon(FontAwesomeIcons.shareFromSquare), onTap: () => videoIntroController.actionShareVideo(context), selectStatus: false, - loadingStatus: widget.loadingStatus, + isLoading: widget.isLoading, semanticsLabel: '分享', - text: !widget.loadingStatus + text: !widget.isLoading ? Utils.numFormat(videoDetail.stat!.share!) : '分享', ), @@ -958,9 +957,8 @@ class _VideoInfoState extends State { icon: const Icon(FontAwesomeIcons.thumbsUp), onTap: () => handleState(videoIntroController.actionLikeVideo), selectStatus: videoIntroController.hasLike.value, - loadingStatus: widget.loadingStatus, - text: - !widget.loadingStatus ? videoDetail.stat!.like!.toString() : '-', + isLoading: widget.isLoading, + text: !widget.isLoading ? videoDetail.stat!.like!.toString() : '-', ), ), const SizedBox(width: 8), @@ -969,9 +967,8 @@ class _VideoInfoState extends State { icon: const Icon(FontAwesomeIcons.b), onTap: () => handleState(videoIntroController.actionCoinVideo), selectStatus: videoIntroController.hasCoin, - loadingStatus: widget.loadingStatus, - text: - !widget.loadingStatus ? videoDetail.stat!.coin!.toString() : '-', + isLoading: widget.isLoading, + text: !widget.isLoading ? videoDetail.stat!.coin!.toString() : '-', ), ), const SizedBox(width: 8), @@ -982,10 +979,9 @@ class _VideoInfoState extends State { onLongPress: () => videoIntroController.showFavBottomSheet(context, type: 'longPress'), selectStatus: videoIntroController.hasFav.value, - loadingStatus: widget.loadingStatus, - text: !widget.loadingStatus - ? videoDetail.stat!.favorite!.toString() - : '-', + isLoading: widget.isLoading, + text: + !widget.isLoading ? videoDetail.stat!.favorite!.toString() : '-', ), ), const SizedBox(width: 8), @@ -995,15 +991,15 @@ class _VideoInfoState extends State { videoDetailCtr.tabCtr.animateTo(1); }, selectStatus: false, - loadingStatus: widget.loadingStatus, - text: !widget.loadingStatus ? videoDetail.stat!.reply!.toString() : '-', + isLoading: widget.isLoading, + text: !widget.isLoading ? videoDetail.stat!.reply!.toString() : '-', ), const SizedBox(width: 8), ActionRowItem( icon: const Icon(FontAwesomeIcons.share), onTap: () => videoIntroController.actionShareVideo(context), selectStatus: false, - loadingStatus: widget.loadingStatus, + isLoading: widget.isLoading, text: '转发', ), ]); diff --git a/lib/pages/video/introduction/ugc/widgets/action_item.dart b/lib/pages/video/introduction/ugc/widgets/action_item.dart index c2ed42d5..801ba3e4 100644 --- a/lib/pages/video/introduction/ugc/widgets/action_item.dart +++ b/lib/pages/video/introduction/ugc/widgets/action_item.dart @@ -12,7 +12,7 @@ class ActionItem extends StatefulWidget { final Icon? selectIcon; final Function? onTap; final Function? onLongPress; - final bool? loadingStatus; + final bool? isLoading; final String? text; final bool selectStatus; final String semanticsLabel; @@ -27,7 +27,7 @@ class ActionItem extends StatefulWidget { this.selectIcon, this.onTap, this.onLongPress, - this.loadingStatus, + this.isLoading, this.text, this.selectStatus = false, this.needAnim = false, @@ -183,7 +183,7 @@ class ActionItemState extends State ), if (widget.text != null) AnimatedOpacity( - opacity: widget.loadingStatus! ? 0 : 1, + opacity: widget.isLoading! ? 0 : 1, duration: const Duration(milliseconds: 200), child: AnimatedSwitcher( duration: const Duration(milliseconds: 300), diff --git a/lib/pages/video/introduction/ugc/widgets/action_row_item.dart b/lib/pages/video/introduction/ugc/widgets/action_row_item.dart index 1a511da4..589cf4c2 100644 --- a/lib/pages/video/introduction/ugc/widgets/action_row_item.dart +++ b/lib/pages/video/introduction/ugc/widgets/action_row_item.dart @@ -5,7 +5,7 @@ class ActionRowItem extends StatelessWidget { final Icon? icon; final Icon? selectIcon; final Function? onTap; - final bool? loadingStatus; + final bool? isLoading; final String? text; final bool selectStatus; final Function? onLongPress; @@ -15,7 +15,7 @@ class ActionRowItem extends StatelessWidget { this.icon, this.selectIcon, this.onTap, - this.loadingStatus, + this.isLoading, this.text, this.selectStatus = false, this.onLongPress, @@ -53,7 +53,7 @@ class ActionRowItem extends StatelessWidget { const SizedBox(width: 6), ], AnimatedOpacity( - opacity: loadingStatus! ? 0 : 1, + opacity: isLoading! ? 0 : 1, duration: const Duration(milliseconds: 200), child: AnimatedSwitcher( duration: const Duration(milliseconds: 300), diff --git a/lib/pages/video/introduction/ugc/widgets/menu_row.dart b/lib/pages/video/introduction/ugc/widgets/menu_row.dart index 1e9bf989..bd730ed7 100644 --- a/lib/pages/video/introduction/ugc/widgets/menu_row.dart +++ b/lib/pages/video/introduction/ugc/widgets/menu_row.dart @@ -4,9 +4,9 @@ import 'package:flutter/material.dart'; class MenuRow extends StatelessWidget { const MenuRow({ super.key, - this.loadingStatus, + this.isLoading, }); - final bool? loadingStatus; + final bool? isLoading; @override Widget build(BuildContext context) { @@ -20,28 +20,28 @@ class MenuRow extends StatelessWidget { child: Row(children: [ ActionRowLineItem( onTap: () => {}, - loadingStatus: loadingStatus, + isLoading: isLoading, text: '推荐', selectStatus: false, ), const SizedBox(width: 8), ActionRowLineItem( onTap: () => {}, - loadingStatus: loadingStatus, + isLoading: isLoading, text: '弹幕', selectStatus: false, ), const SizedBox(width: 8), ActionRowLineItem( onTap: () => {}, - loadingStatus: loadingStatus, + isLoading: isLoading, text: '评论列表', selectStatus: false, ), const SizedBox(width: 8), ActionRowLineItem( onTap: () => {}, - loadingStatus: loadingStatus, + isLoading: isLoading, text: '播放列表', selectStatus: false, ), @@ -51,7 +51,7 @@ class MenuRow extends StatelessWidget { } Widget actionRowLineItem( - ThemeData theme, Function? onTap, bool? loadingStatus, String? text, + ThemeData theme, Function? onTap, bool? isLoading, String? text, {bool selectStatus = false}) { return Material( color: selectStatus @@ -78,7 +78,7 @@ class MenuRow extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ AnimatedOpacity( - opacity: loadingStatus! ? 0 : 1, + opacity: isLoading! ? 0 : 1, duration: const Duration(milliseconds: 200), child: Text( text!, @@ -103,13 +103,13 @@ class ActionRowLineItem extends StatelessWidget { required this.selectStatus, this.onTap, this.text, - this.loadingStatus = false, + this.isLoading = false, this.iconData, this.icon, }); final bool selectStatus; final Function? onTap; - final bool? loadingStatus; + final bool? isLoading; final String? text; final IconData? iconData; final Widget? icon; @@ -152,7 +152,7 @@ class ActionRowLineItem extends StatelessWidget { else if (icon != null) icon!, AnimatedOpacity( - opacity: loadingStatus! ? 0 : 1, + opacity: isLoading! ? 0 : 1, duration: const Duration(milliseconds: 200), child: Text( text!, diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index cf4f6ad2..acafd66c 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -10,7 +10,6 @@ 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/bangumi/info.dart' as bangumi; -import 'package:PiliPlus/models/bangumi/info.dart'; import 'package:PiliPlus/models/common/episode_panel_type.dart'; import 'package:PiliPlus/models/common/reply/reply_type.dart'; import 'package:PiliPlus/models/common/search_type.dart'; @@ -103,8 +102,6 @@ class _VideoDetailPageVState extends State videoDetailController.plPlayerController.horizontalPreview; StreamSubscription? _listenerDetail; - StreamSubscription? _listenerLoadingState; - StreamSubscription? _listenerCid; StreamSubscription? _listenerFS; Box get setting => GStorage.setting; @@ -137,23 +134,6 @@ class _VideoDetailPageVState extends State }); if (videoDetailController.videoType == SearchType.media_bangumi) { bangumiIntroController = Get.put(BangumiIntroController(), tag: heroTag); - _listenerLoadingState = - bangumiIntroController.loadingState.listen((value) { - if (!context.mounted) return; - if (value is Success) { - videoPlayerServiceHandler.onVideoDetailChange( - value.response, videoDetailController.cid.value, heroTag); - } - }); - _listenerCid = videoDetailController.cid.listen((p0) { - if (!context.mounted) return; - if (bangumiIntroController.loadingState.value is Success) { - videoPlayerServiceHandler.onVideoDetailChange( - (bangumiIntroController.loadingState.value as Success).response, - p0, - heroTag); - } - }); } autoExitFullscreen = setting.get(SettingBoxKey.enableAutoExit, defaultValue: true); @@ -337,8 +317,6 @@ class _VideoDetailPageVState extends State @override void dispose() { _listenerDetail?.cancel(); - _listenerLoadingState?.cancel(); - _listenerCid?.cancel(); _listenerFS?.cancel(); videoDetailController.skipTimer?.cancel(); diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 8fd5209c..2e0ff7d3 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -5,7 +5,6 @@ import 'dart:math'; import 'package:PiliPlus/common/constants.dart'; import 'package:PiliPlus/common/widgets/progress_bar/audio_video_progress_bar.dart'; import 'package:PiliPlus/common/widgets/progress_bar/segment_progress_bar.dart'; -import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models/common/super_resolution_type.dart'; import 'package:PiliPlus/models/video_detail_res.dart'; import 'package:PiliPlus/pages/video/controller.dart'; @@ -266,7 +265,7 @@ class _PLVideoPlayerState extends State bool isSeason = videoIntroController?.videoDetail.value.ugcSeason != null; bool isPage = videoIntroController?.videoDetail.value.pages != null && videoIntroController!.videoDetail.value.pages!.length > 1; - bool isBangumi = bangumiIntroController?.loadingState.value is Success; + bool isBangumi = bangumiIntroController != null; bool anySeason = isSeason || isPage || isBangumi; double widgetWidth = isFullScreen && context.orientation == Orientation.landscape ? 42 : 35; @@ -508,9 +507,7 @@ class _PLVideoPlayerState extends State videoIntroController!.videoDetail.value.pages!; episodes = pages; } else if (isBangumi) { - episodes = (bangumiIntroController!.loadingState.value as Success) - .response - .episodes!; + episodes = bangumiIntroController!.bangumiItem.episodes!; } widget.showEpisodes?.call( index,