From 02bdb466256e3992ab19e4be85b21f5a56c8fa75 Mon Sep 17 00:00:00 2001 From: orz12 Date: Mon, 15 Jan 2024 20:27:51 +0800 Subject: [PATCH] =?UTF-8?q?opt:=20=E3=80=90=E5=85=B3=E6=B3=A8=E3=80=91?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=B8=8E=E8=87=AA=E5=8A=A8=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E8=B7=B3=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 获得数据后再淡入显示,避免关注按钮跳变(如已关注状态下,会先经历默认的高亮未关注状态,再跳变为暗色已关注) 自动播放开启时取消显示封面(与官方一致),避免黑屏-亮屏(加载出封面)-黑屏(缓冲视频流)-亮屏(显示视频)的闪烁过程 --- lib/pages/video/detail/introduction/view.dart | 26 +-- lib/pages/video/detail/view.dart | 177 +++++++++--------- 2 files changed, 99 insertions(+), 104 deletions(-) diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 85a24cc5..0a3ac934 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -414,14 +414,18 @@ class _VideoInfoState extends State with TickerProviderStateMixin { ), ), const Spacer(), - AnimatedOpacity( - opacity: loadingStatus ? 0 : 1, - duration: const Duration(milliseconds: 150), - child: SizedBox( - height: 32, - child: Obx( - () => - videoIntroController.followStatus.isNotEmpty + Obx(() => AnimatedOpacity( + opacity: loadingStatus || + videoIntroController + .followStatus.isEmpty + ? 0 + : 1, + duration: const Duration(milliseconds: 50), + child: SizedBox( + height: 32, + child: Obx( + () => videoIntroController + .followStatus.isNotEmpty ? TextButton( onPressed: videoIntroController .actionRelationMod, @@ -453,9 +457,9 @@ class _VideoInfoState extends State with TickerProviderStateMixin { .actionRelationMod, child: const Text('关注'), ), - ), - ), - ), + ), + ), + )), ], ), ), diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 38b81378..b26f07e5 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -388,107 +388,98 @@ class _VideoDetailPageState extends State }, ), - Obx( - () => Visibility( - visible: videoDetailController - .isShowCover.value, - child: Positioned( - top: 0, - left: 0, - right: 0, - child: GestureDetector( - onTap: () { - handlePlay(); - }, - child: NetworkImgLayer( - type: 'emote', - src: videoDetailController - .videoItem['pic'], - width: maxWidth, - height: maxHeight, + /// 关闭自动播放时 手动播放 + if (!videoDetailController + .autoPlay.value) ...[ + Obx( + () => Visibility( + visible: videoDetailController + .isShowCover.value, + child: Positioned( + top: 0, + left: 0, + right: 0, + child: GestureDetector( + onTap: () { + handlePlay(); + }, + child: NetworkImgLayer( + type: 'emote', + src: videoDetailController + .videoItem['pic'], + width: maxWidth, + height: maxHeight, + ), ), ), ), ), - ), - /// 关闭自动播放时 手动播放 - Obx( - () => Visibility( - visible: videoDetailController - .isShowCover.value && - videoDetailController - .isEffective.value && - !videoDetailController - .autoPlay.value, - child: Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - child: AppBar( - primary: false, - foregroundColor: Colors.white, - elevation: 0, - scrolledUnderElevation: 0, - backgroundColor: - Colors.transparent, - actions: [ - IconButton( - tooltip: '稍后再看', - onPressed: () async { - var res = await UserHttp - .toViewLater( - bvid: - videoDetailController - .bvid); - SmartDialog.showToast( - res['msg']); - }, - icon: const Icon(Icons - .history_outlined), - ), - const SizedBox(width: 14) - ], - ), - ), - Positioned( - right: 12, - bottom: 10, - child: TextButton.icon( - style: ButtonStyle( - side: MaterialStateProperty - .resolveWith( - (states) { - return BorderSide( - color: Theme.of(context) - .colorScheme - .primary - .withOpacity(0.5), - width: 1); - }), + Obx( + () => Visibility( + visible: videoDetailController + .isShowCover.value && + videoDetailController + .isEffective.value, + child: Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + child: AppBar( + primary: false, + foregroundColor: + Colors.white, + elevation: 0, + scrolledUnderElevation: 0, backgroundColor: - MaterialStateProperty - .resolveWith( - (states) { - return Theme.of(context) - .colorScheme - .background - .withOpacity(0.6); - }), + Colors.transparent, + actions: [ + IconButton( + tooltip: '稍后再看', + onPressed: () async { + var res = await UserHttp + .toViewLater( + bvid: + videoDetailController + .bvid); + SmartDialog.showToast( + res['msg']); + }, + icon: const Icon(Icons + .history_outlined), + ), + const SizedBox(width: 14) + ], ), - onPressed: () => handlePlay(), - icon: const Icon( - Icons.play_circle_outline, - size: 20, - ), - label: const Text('轻触封面播放'), ), - ), - ], - )), - ), + Positioned( + right: 12, + bottom: 10, + child: TextButton.icon( + style: ButtonStyle( + backgroundColor: + MaterialStateProperty + .resolveWith( + (states) { + return Colors.white + .withOpacity(0.8); + }), + ), + onPressed: () => + handlePlay(), + icon: const Icon( + Icons.play_circle_outline, + size: 20, + ), + label: const Text('轻触封面播放'), + ), + ), + ], + )), + ), + ] ], ); },