From 83d121fd9cd0d2978df8ce7ed9b5327c63f61c0b Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 13 Apr 2024 15:04:33 +0800 Subject: [PATCH 1/2] opt: sheetHeight --- lib/pages/video/detail/controller.dart | 2 + lib/pages/video/detail/introduction/view.dart | 6 +-- lib/pages/video/detail/reply_reply/view.dart | 44 +++++++++---------- lib/pages/video/detail/view.dart | 4 +- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 2f750a24..4d40e535 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -106,6 +106,7 @@ class VideoDetailController extends GetxController BottomControlType.fit, BottomControlType.fullscreen, ].obs; + RxDouble sheetHeight = 0.0.obs; @override void onInit() { @@ -172,6 +173,7 @@ class VideoDetailController extends GetxController firstFloor: firstFloor, replyType: ReplyType.video, source: 'videoDetail', + sheetHeight: sheetHeight.value, ); }); replyReplyBottomSheetCtr?.closed.then((value) { diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 70fa578d..a7eae6d2 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -372,7 +372,7 @@ class _VideoInfoState extends State with TickerProviderStateMixin { ), /// 点赞收藏转发 - actionGrid(context, videoIntroController), + Material(child: actionGrid(context, videoIntroController)), // 合集 videoPart 简洁 if (widget.videoDetail!.ugcSeason != null) ...[ Obx( @@ -381,7 +381,7 @@ class _VideoInfoState extends State with TickerProviderStateMixin { cid: videoIntroController.lastPlayCid.value != 0 ? videoIntroController.lastPlayCid.value : widget.videoDetail!.pages!.first.cid, - sheetHeight: sheetHeight, + sheetHeight: videoDetailCtr.sheetHeight.value, changeFuc: (bvid, cid, aid) => videoIntroController.changeSeasonOrbangu( bvid, @@ -399,7 +399,7 @@ class _VideoInfoState extends State with TickerProviderStateMixin { () => PagesPanel( pages: widget.videoDetail!.pages!, cid: videoIntroController.lastPlayCid.value, - sheetHeight: sheetHeight, + sheetHeight: videoDetailCtr.sheetHeight.value, changeFuc: (cid) => videoIntroController.changeSeasonOrbangu( videoIntroController.bvid, cid, diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 344ca1b1..3fe84c71 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -19,6 +19,7 @@ class VideoReplyReplyPanel extends StatefulWidget { this.firstFloor, this.source, this.replyType, + this.sheetHeight, super.key, }); final int? oid; @@ -27,6 +28,7 @@ class VideoReplyReplyPanel extends StatefulWidget { final ReplyItemModel? firstFloor; final String? source; final ReplyType? replyType; + final double? sheetHeight; @override State createState() => _VideoReplyReplyPanelState(); @@ -36,7 +38,6 @@ class _VideoReplyReplyPanelState extends State { late VideoReplyReplyController _videoReplyReplyController; late AnimationController replyAnimationCtl; final Box localCache = GStrorage.localCache; - late double sheetHeight; Future? _futureBuilderFuture; late ScrollController scrollController; @@ -62,7 +63,6 @@ class _VideoReplyReplyPanelState extends State { }, ); - sheetHeight = localCache.get('sheetHeight'); _futureBuilderFuture = _videoReplyReplyController.queryReplyList(); } @@ -77,33 +77,31 @@ class _VideoReplyReplyPanelState extends State { @override Widget build(BuildContext context) { return Container( - height: widget.source == 'videoDetail' ? sheetHeight : null, + height: widget.source == 'videoDetail' ? widget.sheetHeight : null, color: Theme.of(context).colorScheme.background, child: Column( children: [ if (widget.source == 'videoDetail') - Container( - height: 45, - padding: const EdgeInsets.only(left: 12, right: 2), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const Text('评论详情'), - IconButton( - icon: const Icon(Icons.close, size: 20), - onPressed: () { - _videoReplyReplyController.currentPage = 0; - widget.closePanel?.call; - Navigator.pop(context); - }, - ), - ], + AppBar( + toolbarHeight: 45, + automaticallyImplyLeading: false, + centerTitle: false, + title: Text( + '评论详情', + style: Theme.of(context).textTheme.titleSmall, ), + actions: [ + IconButton( + icon: const Icon(Icons.close, size: 20), + onPressed: () { + _videoReplyReplyController.currentPage = 0; + widget.closePanel?.call; + Navigator.pop(context); + }, + ), + const SizedBox(width: 14), + ], ), - Divider( - height: 1, - color: Theme.of(context).dividerColor.withOpacity(0.1), - ), Expanded( child: RefreshIndicator( onRefresh: () async { diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 10b60c10..05ce2f5e 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -67,6 +67,7 @@ class _VideoDetailPageState extends State super.initState(); heroTag = Get.arguments['heroTag']; vdCtr = Get.put(VideoDetailController(), tag: heroTag); + vdCtr.sheetHeight.value = localCache.get('sheetHeight'); videoIntroController = Get.put( VideoIntroController(bvid: Get.parameters['bvid']!), tag: heroTag); @@ -112,6 +113,8 @@ class _VideoDetailPageState extends State _extendNestCtr.addListener( () { final double offset = _extendNestCtr.position.pixels; + vdCtr.sheetHeight.value = + Get.size.height - videoHeight - statusBarHeight + offset; appbarStream.add(offset); }, ); @@ -271,7 +274,6 @@ class _VideoDetailPageState extends State @override Widget build(BuildContext context) { - // final double videoHeight = MediaQuery.sizeOf(context).width * 9 / 16; final sizeContext = MediaQuery.sizeOf(context); final _context = MediaQuery.of(context); late double defaultVideoHeight = sizeContext.width * 9 / 16; From ff5101d3d0cf71e9f2dd856f8886d8bd8ab86f11 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 13 Apr 2024 15:46:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?opt:=20=E5=8F=AF=E6=8B=96=E5=8A=A8=E6=A0=87?= =?UTF-8?q?=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/view.dart | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 05ce2f5e..7a1de4e4 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -47,7 +47,7 @@ class _VideoDetailPageState extends State late BangumiIntroController bangumiIntroController; late String heroTag; - PlayerStatus playerStatus = PlayerStatus.playing; + Rx playerStatus = PlayerStatus.playing.obs; double doubleOffset = 0; final Box localCache = GStrorage.localCache; @@ -122,7 +122,7 @@ class _VideoDetailPageState extends State // 播放器状态监听 void playerListener(PlayerStatus? status) async { - playerStatus = status!; + playerStatus.value = status!; if (status == PlayerStatus.completed) { // 结束播放退出全屏 if (autoExitFullcreen) { @@ -368,6 +368,18 @@ class _VideoDetailPageState extends State child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ + Obx(() => AnimatedOpacity( + opacity: playerStatus.value != PlayerStatus.playing + ? 1 + : 0, + duration: const Duration(milliseconds: 100), + child: const Icon( + Icons.drag_handle_rounded, + size: 20, + color: Colors.grey, + ), + )), + const SizedBox(width: 8), SizedBox( height: 32, child: TextButton( @@ -406,7 +418,7 @@ class _VideoDetailPageState extends State ), ), ), - const SizedBox(width: 14), + const SizedBox(width: 18), ], ), )), @@ -559,7 +571,7 @@ class _VideoDetailPageState extends State Orientation.landscape || plPlayerController?.isFullScreen.value == true ? MediaQuery.sizeOf(context).height - : playerStatus != PlayerStatus.playing + : playerStatus.value != PlayerStatus.playing ? kToolbarHeight : pinnedHeaderHeight; }, @@ -626,7 +638,7 @@ class _VideoDetailPageState extends State return ScrollAppBar( snapshot.data!.toDouble(), () => continuePlay(), - playerStatus, + playerStatus.value, null, ); }),