From 99cdec62a1a89267f1073e3f75e2cb13c7b60726 Mon Sep 17 00:00:00 2001 From: My-Responsitories <107370289+My-Responsitories@users.noreply.github.com> Date: Mon, 10 Mar 2025 18:46:07 +0800 Subject: [PATCH] view later (#419) --- .../video/detail/introduction/controller.dart | 10 +++++++ lib/pages/video/detail/introduction/view.dart | 26 +++++++------------ lib/pages/video/detail/view.dart | 4 +-- lib/pages/video/detail/view_v.dart | 13 +++------- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index e26d0c14..4dafda05 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -59,6 +59,8 @@ class VideoIntroController extends GetxController RxBool hasCoin = false.obs; // 是否收藏 RxBool hasFav = false.obs; + // 是否稍后再看 + RxBool hasLater = false.obs; bool isLogin = false; Rx favFolderData = FavFolderData().obs; List? favIds; @@ -308,6 +310,14 @@ class VideoIntroController extends GetxController } } + Future viewLater() async { + var res = await (hasLater.value + ? UserHttp.toViewDel(aids: [IdUtils.bv2av(bvid)]) + : await UserHttp.toViewLater(bvid: bvid)); + if (res['status']) hasLater.value = !hasLater.value; + SmartDialog.showToast(res['msg']); + } + void coinVideo(int coin, [bool selectLike = false]) async { if (videoDetail.value.stat?.coin == null) { // not init diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index ce30c306..0ecff184 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -889,12 +889,6 @@ class _VideoInfoState extends State with TickerProviderStateMixin { text: "点踩", ), ), - // ActionItem( - // icon: const Icon(FontAwesomeIcons.clock), - // onTap: () => videoIntroController.actionShareVideo(), - // selectStatus: false, - // loadingStatus: loadingStatus, - // text: '稍后再看'), Obx( () => ActionItem( key: _coinKey, @@ -927,16 +921,16 @@ class _VideoInfoState extends State with TickerProviderStateMixin { needAnim: true, ), ), - ActionItem( - icon: const Icon(FontAwesomeIcons.comment), - onTap: () => videoDetailCtr.tabCtr - .animateTo(videoDetailCtr.tabCtr.index == 1 ? 0 : 1), - selectStatus: false, - loadingStatus: widget.loadingStatus, - semanticsLabel: '评论', - text: !widget.loadingStatus - ? Utils.numFormat(videoDetail.stat!.reply!) - : '评论', + Obx( + () => ActionItem( + icon: const Icon(FontAwesomeIcons.clock), + selectIcon: const Icon(FontAwesomeIcons.solidClock), + onTap: () => handleState(videoIntroController.viewLater), + selectStatus: videoIntroController.hasLater.value, + loadingStatus: widget.loadingStatus, + semanticsLabel: '再看', + text: '再看', + ), ), ActionItem( icon: const Icon(FontAwesomeIcons.shareFromSquare), diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 79df6baf..924eeb71 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -1058,9 +1058,7 @@ class _VideoDetailPageState extends State onSelected: (String type) async { switch (type) { case 'later': - var res = await UserHttp.toViewLater( - bvid: videoDetailController.bvid); - SmartDialog.showToast(res['msg']); + await videoIntroController.viewLater(); break; case 'report': if (videoDetailController.userInfo == null) { diff --git a/lib/pages/video/detail/view_v.dart b/lib/pages/video/detail/view_v.dart index 33b5a681..9731905b 100644 --- a/lib/pages/video/detail/view_v.dart +++ b/lib/pages/video/detail/view_v.dart @@ -881,13 +881,8 @@ class _VideoDetailPageVState extends State onSelected: (String type) async { switch (type) { case 'later': - var res = await UserHttp - .toViewLater( - bvid: - videoDetailController - .bvid); - SmartDialog.showToast( - res['msg']); + await videoIntroController + .viewLater(); break; case 'report': if (videoDetailController @@ -1449,9 +1444,7 @@ class _VideoDetailPageVState extends State onSelected: (String type) async { switch (type) { case 'later': - var res = await UserHttp.toViewLater( - bvid: videoDetailController.bvid); - SmartDialog.showToast(res['msg']); + await videoIntroController.viewLater(); break; case 'report': if (videoDetailController.userInfo == null) {