From 8c7001c801cd19f998777f822d6bc80f49559772 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Thu, 24 Apr 2025 11:35:19 +0800 Subject: [PATCH] opt: safearea Signed-off-by: bggRGjQaUbCoE --- lib/pages/dynamics/detail/view.dart | 20 +- lib/pages/hot/view.dart | 6 +- lib/pages/html/view.dart | 20 +- lib/pages/live/view.dart | 14 +- .../season_series/season_series_page.dart | 22 +- lib/pages/msg_feed_top/sys_msg/view.dart | 12 +- lib/plugin/pl_player/view.dart | 200 +++++++++--------- lib/utils/app_scheme.dart | 86 +++++--- 8 files changed, 211 insertions(+), 169 deletions(-) diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index 25f4a855..54035b5a 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -170,14 +170,18 @@ class _DynamicDetailPageState extends State titleSpacing: automaticallyImplyLeading ? null : 12, automaticallyImplyLeading: automaticallyImplyLeading, ), - body: VideoReplyReplyPanel( - id: id, - oid: oid, - rpid: rpid, - source: 'dynamic', - replyType: ReplyType.values[replyType], - firstFloor: replyItem, - onDispose: onDispose, + body: SafeArea( + top: false, + bottom: false, + child: VideoReplyReplyPanel( + id: id, + oid: oid, + rpid: rpid, + source: 'dynamic', + replyType: ReplyType.values[replyType], + firstFloor: replyItem, + onDispose: onDispose, + ), ), ); if (this.context.orientation == Orientation.portrait) { diff --git a/lib/pages/hot/view.dart b/lib/pages/hot/view.dart index 07028f94..4abc4fc2 100644 --- a/lib/pages/hot/view.dart +++ b/lib/pages/hot/view.dart @@ -92,7 +92,11 @@ class _HotPageState extends CommonPageState Get.to( Scaffold( appBar: AppBar(title: const Text('排行榜')), - body: RankPage(), + body: SafeArea( + top: false, + bottom: false, + child: RankPage(), + ), ), ); } diff --git a/lib/pages/html/view.dart b/lib/pages/html/view.dart index 876cbaba..7f5f3a75 100644 --- a/lib/pages/html/view.dart +++ b/lib/pages/html/view.dart @@ -168,14 +168,18 @@ class _HtmlRenderPageState extends State titleSpacing: automaticallyImplyLeading ? null : 12, automaticallyImplyLeading: automaticallyImplyLeading, ), - body: VideoReplyReplyPanel( - id: id, - oid: oid, - rpid: rpid, - source: 'dynamic', - replyType: ReplyType.values[type], - firstFloor: replyItem, - onDispose: onDispose, + body: SafeArea( + top: false, + bottom: false, + child: VideoReplyReplyPanel( + id: id, + oid: oid, + rpid: rpid, + source: 'dynamic', + replyType: ReplyType.values[type], + firstFloor: replyItem, + onDispose: onDispose, + ), ), ); if (this.context.orientation == Orientation.portrait) { diff --git a/lib/pages/live/view.dart b/lib/pages/live/view.dart index ceb0ecd6..052507ae 100644 --- a/lib/pages/live/view.dart +++ b/lib/pages/live/view.dart @@ -277,12 +277,14 @@ class _LivePageState extends CommonPageState () => Text('${controller.liveCount.value}人正在直播'), ), ), - body: CustomScrollView( - slivers: [ - Obx( - () => _buildFollowListBody(controller.followListState.value), - ), - ], + body: SafeArea( + top: false, + bottom: false, + child: CustomScrollView( + slivers: [ + Obx(() => _buildFollowListBody(controller.followListState.value)), + ], + ), ), ); diff --git a/lib/pages/member/content/member_contribute/content/season_series/season_series_page.dart b/lib/pages/member/content/member_contribute/content/season_series/season_series_page.dart index 14171bed..91500e5a 100644 --- a/lib/pages/member/content/member_contribute/content/season_series/season_series_page.dart +++ b/lib/pages/member/content/member_contribute/content/season_series/season_series_page.dart @@ -70,15 +70,19 @@ class _SeasonSeriesPageState extends State appBar: AppBar( title: Text(item['meta']['name']), ), - body: MemberVideo( - type: isSeason - ? ContributeType.season - : ContributeType.series, - heroTag: widget.heroTag, - mid: widget.mid, - seasonId: isSeason ? id : null, - seriesId: isSeason ? null : id, - title: item['meta']['name'], + body: SafeArea( + top: false, + bottom: false, + child: MemberVideo( + type: isSeason + ? ContributeType.season + : ContributeType.series, + heroTag: widget.heroTag, + mid: widget.mid, + seasonId: isSeason ? id : null, + seriesId: isSeason ? null : id, + title: item['meta']['name'], + ), ), ), ); diff --git a/lib/pages/msg_feed_top/sys_msg/view.dart b/lib/pages/msg_feed_top/sys_msg/view.dart index a8279b8c..9576d434 100644 --- a/lib/pages/msg_feed_top/sys_msg/view.dart +++ b/lib/pages/msg_feed_top/sys_msg/view.dart @@ -54,11 +54,13 @@ class _SysMsgPageState extends State { Widget _buildBody(LoadingState?> loadingState) { return switch (loadingState) { - Loading() => SliverList.builder( - itemCount: 12, - itemBuilder: (context, index) { - return const MsgFeedSysMsgSkeleton(); - }, + Loading() => SliverSafeArea( + sliver: SliverList.builder( + itemCount: 12, + itemBuilder: (context, index) { + return const MsgFeedSysMsgSkeleton(); + }, + ), ), Success() => loadingState.response?.isNotEmpty == true ? SliverList.separated( diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 92260068..07459e05 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -1528,34 +1528,37 @@ class _PLVideoPlayerState extends State ), // 锁 - Obx( - () => Visibility( - visible: - plPlayerController.videoType.value != 'live' && isFullScreen, - child: Align( - alignment: Alignment.centerLeft, - child: FractionalTranslation( - translation: const Offset(1, -0.4), - child: Visibility( - visible: plPlayerController.showControls.value && - (isFullScreen || plPlayerController.controlsLock.value), - child: DecoratedBox( - decoration: BoxDecoration( - color: const Color(0x45000000), - borderRadius: BorderRadius.circular(8), - ), - child: ComBtn( - icon: Icon( - plPlayerController.controlsLock.value - ? FontAwesomeIcons.lock - : FontAwesomeIcons.lockOpen, - semanticLabel: - plPlayerController.controlsLock.value ? '解锁' : '锁定', - size: 15, - color: Colors.white, + SafeArea( + child: Obx( + () => Visibility( + visible: + plPlayerController.videoType.value != 'live' && isFullScreen, + child: Align( + alignment: Alignment.centerLeft, + child: FractionalTranslation( + translation: const Offset(1, -0.4), + child: Visibility( + visible: plPlayerController.showControls.value && + (isFullScreen || plPlayerController.controlsLock.value), + child: DecoratedBox( + decoration: BoxDecoration( + color: const Color(0x45000000), + borderRadius: BorderRadius.circular(8), + ), + child: ComBtn( + icon: Icon( + plPlayerController.controlsLock.value + ? FontAwesomeIcons.lock + : FontAwesomeIcons.lockOpen, + semanticLabel: plPlayerController.controlsLock.value + ? '解锁' + : '锁定', + size: 15, + color: Colors.white, + ), + onTap: () => plPlayerController.onLockControl( + !plPlayerController.controlsLock.value), ), - onTap: () => plPlayerController.onLockControl( - !plPlayerController.controlsLock.value), ), ), ), @@ -1565,80 +1568,83 @@ class _PLVideoPlayerState extends State ), // 截图 - Obx( - () => Align( - alignment: Alignment.centerRight, - child: FractionalTranslation( - translation: const Offset(-1, -0.4), - child: Visibility( - visible: plPlayerController.showControls.value && isFullScreen, - child: DecoratedBox( - decoration: BoxDecoration( - color: const Color(0x45000000), - borderRadius: BorderRadius.circular(8), - ), - child: ComBtn( - icon: const Icon( - Icons.photo_camera, - semanticLabel: '截图', - size: 20, - color: Colors.white, + SafeArea( + child: Obx( + () => Align( + alignment: Alignment.centerRight, + child: FractionalTranslation( + translation: const Offset(-1, -0.4), + child: Visibility( + visible: + plPlayerController.showControls.value && isFullScreen, + child: DecoratedBox( + decoration: BoxDecoration( + color: const Color(0x45000000), + borderRadius: BorderRadius.circular(8), ), - onTap: () { - SmartDialog.showToast('截图中'); - plPlayerController.videoPlayerController - ?.screenshot(format: 'image/png') - .then((value) { - if (value != null && context.mounted) { - SmartDialog.showToast('点击弹窗保存截图'); - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - // title: const Text('点击保存'), - titlePadding: EdgeInsets.zero, - contentPadding: const EdgeInsets.all(8), - insetPadding: - EdgeInsets.only(left: context.width / 2), - //移除圆角 - shape: const RoundedRectangleBorder(), - content: GestureDetector( - onTap: () async { - String name = DateTime.now().toString(); - final SaveResult result = - await SaverGallery.saveImage( - value, - fileName: name, - androidRelativePath: - "Pictures/Screenshots", - skipIfExists: false, - ); + child: ComBtn( + icon: const Icon( + Icons.photo_camera, + semanticLabel: '截图', + size: 20, + color: Colors.white, + ), + onTap: () { + SmartDialog.showToast('截图中'); + plPlayerController.videoPlayerController + ?.screenshot(format: 'image/png') + .then((value) { + if (value != null && context.mounted) { + SmartDialog.showToast('点击弹窗保存截图'); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + // title: const Text('点击保存'), + titlePadding: EdgeInsets.zero, + contentPadding: const EdgeInsets.all(8), + insetPadding: + EdgeInsets.only(left: context.width / 2), + //移除圆角 + shape: const RoundedRectangleBorder(), + content: GestureDetector( + onTap: () async { + String name = DateTime.now().toString(); + final SaveResult result = + await SaverGallery.saveImage( + value, + fileName: name, + androidRelativePath: + "Pictures/Screenshots", + skipIfExists: false, + ); - if (result.isSuccess) { - Get.back(); - SmartDialog.showToast( - '$name.png已保存到相册/截图'); - } else { - await SmartDialog.showToast( - '保存失败,${result.errorMessage}'); - } - }, - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: context.width / 3, - maxHeight: context.height / 3, + if (result.isSuccess) { + Get.back(); + SmartDialog.showToast( + '$name.png已保存到相册/截图'); + } else { + await SmartDialog.showToast( + '保存失败,${result.errorMessage}'); + } + }, + child: ConstrainedBox( + constraints: BoxConstraints( + maxWidth: context.width / 3, + maxHeight: context.height / 3, + ), + child: Image.memory(value), ), - child: Image.memory(value), ), - ), - ); - }, - ); - } else { - SmartDialog.showToast('截图失败'); - } - }); - }, + ); + }, + ); + } else { + SmartDialog.showToast('截图失败'); + } + }); + }, + ), ), ), ), diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 14f437ca..f0887f2b 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -133,16 +133,20 @@ class PiliScheme { ), ], ), - body: VideoReplyReplyPanel( - oid: int.parse(oid), - rpid: rpid, - source: 'routePush', - replyType: ReplyType.video, - firstFloor: null, - id: queryParameters['comment_secondary_id'] != null - ? int.tryParse( - queryParameters['comment_secondary_id']!) - : null, + body: SafeArea( + top: false, + bottom: false, + child: VideoReplyReplyPanel( + oid: int.parse(oid), + rpid: rpid, + source: 'routePush', + replyType: ReplyType.video, + firstFloor: null, + id: queryParameters['comment_secondary_id'] != null + ? int.tryParse( + queryParameters['comment_secondary_id']!) + : null, + ), ), ), ); @@ -285,13 +289,17 @@ class PiliScheme { ), ], ), - body: VideoReplyReplyPanel( - oid: oid, - rpid: rootId, - id: rpId, - source: 'routePush', - replyType: ReplyType.values[type], - firstFloor: null, + body: SafeArea( + top: false, + bottom: false, + child: VideoReplyReplyPanel( + oid: oid, + rpid: rootId, + id: rpId, + source: 'routePush', + replyType: ReplyType.values[type], + firstFloor: null, + ), ), ), ); @@ -331,12 +339,16 @@ class PiliScheme { ), ], ), - body: VideoReplyReplyPanel( - oid: oid, - rpid: rpId, - source: 'routePush', - replyType: ReplyType.values[type], - firstFloor: null, + body: SafeArea( + top: false, + bottom: false, + child: VideoReplyReplyPanel( + oid: oid, + rpid: rpId, + source: 'routePush', + replyType: ReplyType.values[type], + firstFloor: null, + ), ), ), ); @@ -393,18 +405,22 @@ class PiliScheme { ), ], ), - body: VideoReplyReplyPanel( - oid: oid ?? int.parse(dynId), - rpid: rpid, - source: 'routePush', - replyType: businessId != null - ? ReplyType.values[businessId] - : ReplyType.dynamics, - firstFloor: null, - id: queryParameters['comment_secondary_id'] != null - ? int.tryParse( - queryParameters['comment_secondary_id']!) - : null, + body: SafeArea( + top: false, + bottom: false, + child: VideoReplyReplyPanel( + oid: oid ?? int.parse(dynId), + rpid: rpid, + source: 'routePush', + replyType: businessId != null + ? ReplyType.values[businessId] + : ReplyType.dynamics, + firstFloor: null, + id: queryParameters['comment_secondary_id'] != null + ? int.tryParse( + queryParameters['comment_secondary_id']!) + : null, + ), ), ), );