From 1454190f431e1217c27d0dcc9acabf5cb5fc2385 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 4 Aug 2023 19:15:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=95=AA=E5=89=A7=E9=80=89=E9=9B=86?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=8A=A0=E8=BD=BD=E3=80=81=E5=88=86=E9=9B=86?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bangumi/introduction/controller.dart | 72 +++---------------- lib/pages/bangumi/introduction/view.dart | 18 +++-- lib/pages/bangumi/widgets/bangumi_panel.dart | 40 +++++------ lib/pages/history/widgets/item.dart | 25 ++++--- lib/pages/video/detail/reply/controller.dart | 3 + lib/pages/video/detail/reply/view.dart | 3 +- 6 files changed, 58 insertions(+), 103 deletions(-) diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index 91e3d527..c4bb1bb8 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -10,6 +10,7 @@ import 'package:pilipala/models/bangumi/info.dart'; import 'package:pilipala/models/user/fav_folder.dart'; import 'package:pilipala/models/video_detail_res.dart'; import 'package:pilipala/pages/video/detail/index.dart'; +import 'package:pilipala/pages/video/detail/reply/index.dart'; import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/storage.dart'; @@ -330,75 +331,18 @@ class BangumiIntroController extends GetxController { return result; } - // 关注/取关up - Future actionRelationMod() async { - feedBack(); - if (user.get(UserBoxKey.userMid) == null) { - SmartDialog.showToast('账号未登录'); - return; - } - int currentStatus = followStatus['attribute']; - int actionStatus = 0; - switch (currentStatus) { - case 0: - actionStatus = 1; - break; - case 2: - actionStatus = 2; - break; - default: - actionStatus = 0; - break; - } - SmartDialog.show( - useSystem: true, - animationType: SmartAnimationType.centerFade_otherSlide, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('提示'), - content: Text(currentStatus == 0 ? '关注UP主?' : '取消关注UP主?'), - actions: [ - TextButton( - onPressed: () => SmartDialog.dismiss(), - child: const Text('点错了')), - TextButton( - onPressed: () async { - var result = await VideoHttp.relationMod( - mid: videoDetail.value.owner!.mid!, - act: actionStatus, - reSrc: 14, - ); - if (result['status']) { - switch (currentStatus) { - case 0: - actionStatus = 2; - break; - case 2: - actionStatus = 0; - break; - default: - actionStatus = 0; - break; - } - followStatus['attribute'] = actionStatus; - followStatus.refresh(); - } - SmartDialog.dismiss(); - }, - child: const Text('确认'), - ) - ], - ); - }, - ); - } - // 修改分P或番剧分集 - Future changeSeasonOrbangu(bvid, cid) async { + Future changeSeasonOrbangu(bvid, cid, aid) async { + // 重新获取视频资源 VideoDetailController videoDetailCtr = Get.find(tag: Get.arguments['heroTag']); videoDetailCtr.bvid = bvid; videoDetailCtr.cid = cid; videoDetailCtr.queryVideoUrl(); + // 重新请求评论 + VideoReplyController videoReplyCtr = + Get.find(tag: Get.arguments['heroTag']); + videoReplyCtr.aid = aid; + videoReplyCtr.queryReplyList(type: 'init'); } } diff --git a/lib/pages/bangumi/introduction/view.dart b/lib/pages/bangumi/introduction/view.dart index 081ecc4e..41d7dc51 100644 --- a/lib/pages/bangumi/introduction/view.dart +++ b/lib/pages/bangumi/introduction/view.dart @@ -304,14 +304,20 @@ class _BangumiInfoState extends State { // 点赞收藏转发 布局样式2 actionGrid(context, bangumiIntroController), // 番剧分p - if (!widget.loadingStatus && - widget.bangumiDetail!.episodes!.isNotEmpty) ...[ + if ((!widget.loadingStatus && + widget.bangumiDetail!.episodes!.isNotEmpty) || + bangumiItem != null && + bangumiItem!.episodes!.isNotEmpty) ...[ BangumiPanel( - pages: widget.bangumiDetail!.episodes!, - cid: widget.bangumiDetail!.episodes!.first.cid, + pages: bangumiItem != null + ? bangumiItem!.episodes! + : widget.bangumiDetail!.episodes!, + cid: bangumiItem != null + ? bangumiItem!.episodes!.first.cid + : widget.bangumiDetail!.episodes!.first.cid, sheetHeight: sheetHeight, - changeFuc: (bvid, cid) => - bangumiIntroController.changeSeasonOrbangu(bvid, cid), + changeFuc: (bvid, cid, aid) => bangumiIntroController + .changeSeasonOrbangu(bvid, cid, aid), ) ], ], diff --git a/lib/pages/bangumi/widgets/bangumi_panel.dart b/lib/pages/bangumi/widgets/bangumi_panel.dart index 5d39b7cd..692112fd 100644 --- a/lib/pages/bangumi/widgets/bangumi_panel.dart +++ b/lib/pages/bangumi/widgets/bangumi_panel.dart @@ -64,18 +64,7 @@ class _BangumiPanelState extends State { itemCount: widget.pages.length, itemBuilder: (context, index) { return ListTile( - onTap: () async { - if (widget.pages[index].badge != null) { - SmartDialog.showToast('需要大会员'); - return; - } - await widget.changeFuc!( - widget.pages[index].bvid, - widget.pages[index].cid, - ); - currentIndex = index; - setState(() {}); - }, + onTap: () => changeFucCall(widget.pages[index], index), dense: false, title: Text( widget.pages[index].longTitle!, @@ -103,6 +92,20 @@ class _BangumiPanelState extends State { ); } + void changeFucCall(item, i) async { + if (item.badge != null) { + SmartDialog.showToast('需要大会员'); + return; + } + await widget.changeFuc!( + item.bvid, + item.cid, + item.aid, + ); + currentIndex = i; + setState(() {}); + } + @override Widget build(BuildContext context) { return Column( @@ -158,18 +161,7 @@ class _BangumiPanelState extends State { borderRadius: BorderRadius.circular(6), clipBehavior: Clip.hardEdge, child: InkWell( - onTap: () async { - if (widget.pages[i].badge != null) { - SmartDialog.showToast('需要大会员'); - return; - } - await widget.changeFuc!( - widget.pages[i].bvid, - widget.pages[i].cid, - ); - currentIndex = i; - setState(() {}); - }, + onTap: () => changeFucCall(widget.pages[i], i), child: Padding( padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 10), diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index c4a7b791..11183d0e 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -62,14 +62,23 @@ class HistoryItem extends StatelessWidget { int cid = result['data'].cid!; String pic = result['data'].pic!; String heroTag = Utils.makeHeroTag(cid); - Get.toNamed( - '/video?bvid=$bvid&cid=$cid&epId=${result['data'].epId}', - arguments: { - 'pic': pic, - 'heroTag': heroTag, - 'videoType': SearchType.media_bangumi, - }, - ); + var epid = result['data'].epId; + if (epid != null) { + Get.toNamed( + '/video?bvid=$bvid&cid=$cid&epId=${result['data'].epId}', + arguments: { + 'pic': pic, + 'heroTag': heroTag, + 'videoType': SearchType.media_bangumi, + }, + ); + } else { + int cid = videoItem.history.cid ?? + // videoItem.history.oid ?? + await SearchHttp.ab2c(aid: aid, bvid: bvid); + Get.toNamed('/video?bvid=$bvid&cid=$cid', + arguments: {'heroTag': heroTag, 'pic': videoItem.cover}); + } } } else { if (videoItem.history.epid != '') { diff --git a/lib/pages/video/detail/reply/controller.dart b/lib/pages/video/detail/reply/controller.dart index c920c38f..5bde42ba 100644 --- a/lib/pages/video/detail/reply/controller.dart +++ b/lib/pages/video/detail/reply/controller.dart @@ -34,6 +34,9 @@ class VideoReplyController extends GetxController { Future queryReplyList({type = 'init'}) async { isLoadingMore = true; + if (type == 'init') { + currentPage = 0; + } var res = await ReplyHttp.replyList( oid: aid!, pageNum: currentPage + 1, diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index dc12f07f..83744c47 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -281,7 +281,8 @@ class _VideoReplyPanelState extends State isScrollControlled: true, builder: (BuildContext context) { return VideoReplyNewDialog( - oid: IdUtils.bv2av(Get.parameters['bvid']!), + oid: _videoReplyController.aid ?? + IdUtils.bv2av(Get.parameters['bvid']!), root: 0, parent: 0, replyType: ReplyType.video,