From e9095932edc07d4256b713e6af9d8e7517c44ad8 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 16 Sep 2023 22:51:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E7=AE=80=E4=BB=8B?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=BC=82=E5=B8=B8=E3=80=81=E4=BA=8C=E6=A5=BC?= =?UTF-8?q?=E6=96=B0=E5=9B=9E=E5=A4=8D=E7=9A=84=E8=AF=84=E8=AE=BA=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/introduction/view.dart | 38 +++++++++++-------- .../video/detail/replyReply/controller.dart | 11 +++--- lib/pages/video/detail/replyReply/view.dart | 7 ++-- lib/pages/video/detail/view.dart | 11 ++++-- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 410c14c6..e961f135 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -199,6 +199,9 @@ class _VideoInfoState extends State with TickerProviderStateMixin { // 视频介绍 showIntroDetail() { + if (loadingStatus) { + return; + } feedBack(); showBottomSheet( context: context, @@ -254,22 +257,25 @@ class _VideoInfoState extends State with TickerProviderStateMixin { ), ), const SizedBox(width: 20), - SizedBox( - width: 34, - height: 34, - child: IconButton( - style: ButtonStyle( - padding: - MaterialStateProperty.all(EdgeInsets.zero), - backgroundColor: - MaterialStateProperty.resolveWith((states) { - return t.highlightColor.withOpacity(0.2); - }), - ), - onPressed: showIntroDetail, - icon: Icon( - Icons.more_horiz, - color: Theme.of(context).colorScheme.primary, + Opacity( + opacity: loadingStatus ? 0 : 1, + child: SizedBox( + width: 34, + height: 34, + child: IconButton( + style: ButtonStyle( + padding: + MaterialStateProperty.all(EdgeInsets.zero), + backgroundColor: + MaterialStateProperty.resolveWith((states) { + return t.highlightColor.withOpacity(0.2); + }), + ), + onPressed: showIntroDetail, + icon: Icon( + Icons.more_horiz, + color: Theme.of(context).colorScheme.primary, + ), ), ), ), diff --git a/lib/pages/video/detail/replyReply/controller.dart b/lib/pages/video/detail/replyReply/controller.dart index bd5cfd1f..6ce3722f 100644 --- a/lib/pages/video/detail/replyReply/controller.dart +++ b/lib/pages/video/detail/replyReply/controller.dart @@ -26,11 +26,6 @@ class VideoReplyReplyController extends GetxController { currentPage = 0; } - // 上拉加载 - Future onLoad() async { - queryReplyList(type: 'onLoad'); - } - Future queryReplyList({type = 'init'}) async { if (type == 'init') { currentPage = 0; @@ -49,11 +44,11 @@ class VideoReplyReplyController extends GetxController { if (replyList.length == res['data'].page.count) { noMore.value = '没有更多了'; } + currentPage++; } else { // 未登录状态replies可能返回null noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了'; } - currentPage++; if (type == 'init') { // List replies = res['data'].replies; // 添加置顶回复 @@ -72,6 +67,10 @@ class VideoReplyReplyController extends GetxController { // res['data'].replies = replies; replyList.value = replies; } else { + // 每次回复之后,翻页请求有且只有相同的一条回复数据 + if (replies.length == 1 && replies.last.rpid == replyList.last.rpid) { + return; + } replyList.addAll(replies); // res['data'].replies.addAll(replyList); } diff --git a/lib/pages/video/detail/replyReply/view.dart b/lib/pages/video/detail/replyReply/view.dart index 0d86cb5b..f2a72faf 100644 --- a/lib/pages/video/detail/replyReply/view.dart +++ b/lib/pages/video/detail/replyReply/view.dart @@ -1,3 +1,4 @@ +import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; @@ -54,9 +55,9 @@ class _VideoReplyReplyPanelState extends State { () { if (scrollController.position.pixels >= scrollController.position.maxScrollExtent - 300) { - if (!_videoReplyReplyController.isLoadingMore) { - _videoReplyReplyController.onLoad(); - } + EasyThrottle.throttle('replylist', const Duration(seconds: 2), () { + _videoReplyReplyController.queryReplyList(type: 'onLoad'); + }); } }, ); diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 79ac16d2..37c023ca 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -99,10 +99,13 @@ class _VideoDetailPageState extends State plPlayerController!.triggerFullScreen(status: false); } // 播放完展示控制栏 - PiPStatus currentStatus = await videoDetailController.floating!.pipStatus; - if (currentStatus == PiPStatus.disabled) { - plPlayerController!.onLockControl(false); - } + try { + PiPStatus currentStatus = + await videoDetailController.floating!.pipStatus; + if (currentStatus == PiPStatus.disabled) { + plPlayerController!.onLockControl(false); + } + } catch (_) {} } }