diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index e3b9c4122..f7c3bd515 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -30,6 +30,7 @@ import 'package:PiliPlus/pages/video/widgets/player_focus.dart'; import 'package:PiliPlus/plugin/pl_player/controller.dart'; import 'package:PiliPlus/plugin/pl_player/models/play_status.dart'; import 'package:PiliPlus/plugin/pl_player/utils/danmaku_options.dart'; +import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart'; import 'package:PiliPlus/plugin/pl_player/view/view.dart'; import 'package:PiliPlus/services/service_locator.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; @@ -81,12 +82,19 @@ class _LiveRoomPageState extends State plPlayerController = _liveRoomController.plPlayerController ..addStatusLister(playerListener); PlPlayerController.setPlayCallBack(plPlayerController.play); + if (plPlayerController.removeSafeArea) { + hideStatusBar(); + } } @override void didChangeDependencies() { super.didChangeDependencies(); - padding = MediaQuery.viewPaddingOf(context); + if (plPlayerController.removeSafeArea) { + padding = .zero; + } else { + padding = MediaQuery.viewPaddingOf(context); + } final size = MediaQuery.sizeOf(context); maxWidth = size.width; maxHeight = size.height; @@ -391,6 +399,7 @@ class _LiveRoomPageState extends State }, ), Scaffold( + primary: !plPlayerController.removeSafeArea, resizeToAvoidBottomInset: false, backgroundColor: Colors.transparent, appBar: isFullScreen && !isPortrait @@ -486,6 +495,7 @@ class _LiveRoomPageState extends State PreferredSizeWidget _buildAppBar(bool isFullScreen) { final color = Theme.of(context).colorScheme.onSurfaceVariant; return AppBar( + primary: !plPlayerController.removeSafeArea, toolbarHeight: isFullScreen ? 0 : null, backgroundColor: Colors.transparent, foregroundColor: Colors.white, diff --git a/lib/pages/setting/models/style_settings.dart b/lib/pages/setting/models/style_settings.dart index a95d6399d..2c683c44a 100644 --- a/lib/pages/setting/models/style_settings.dart +++ b/lib/pages/setting/models/style_settings.dart @@ -136,6 +136,12 @@ List get styleSettings => [ '当前: 主页${Pref.recommendCardWidth.toInt()}dp 其他${Pref.smallCardWidth.toInt()}dp,屏幕宽度:${MediaQuery.widthOf(Get.context!).toPrecision(2)}dp。宽度越小列数越多。', onTap: _showCardWidthDialog, ), + const SwitchModel( + title: '播放页移除安全边距', + leading: Icon(Icons.fit_screen_outlined), + setKey: SettingBoxKey.removeSafeArea, + defaultVal: false, + ), SwitchModel( title: '视频播放页使用深色主题', leading: const Icon(Icons.dark_mode_outlined), diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index 9659d871b..56f1c78c0 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -124,6 +124,7 @@ class VideoDetailController extends GetxController final plPlayerController = PlPlayerController.getInstance() ..brightness.value = -1; bool get setSystemBrightness => plPlayerController.setSystemBrightness; + bool get removeSafeArea => plPlayerController.removeSafeArea; late VideoItem firstVideo; String? videoUrl; diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index c6f2af720..b9ffbc115 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -59,7 +59,6 @@ import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/mobile_observer.dart'; import 'package:PiliPlus/utils/num_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; @@ -142,6 +141,10 @@ class _VideoDetailPageVState extends State PlPlayerController.setPlayCallBack(playCallBack); videoDetailController = Get.put(VideoDetailController(), tag: heroTag); + if (videoDetailController.removeSafeArea) { + hideStatusBar(); + } + if (videoDetailController.showReply) { _videoReplyController = Get.put( VideoReplyController( @@ -347,6 +350,10 @@ class _VideoDetailPageVState extends State } } + if (!videoDetailController.removeSafeArea) { + showStatusBar(); + } + if (!videoDetailController.plPlayerController.isCloseAll) { videoPlayerServiceHandler?.onVideoDetailDispose(heroTag); if (plPlayerController != null) { @@ -357,9 +364,7 @@ class _VideoDetailPageVState extends State } } removeObserverMobile(this); - if (PlatformUtils.isMobile) { - showStatusBar(); - } + super.dispose(); } @@ -449,7 +454,11 @@ class _VideoDetailPageVState extends State @override void didChangeDependencies() { super.didChangeDependencies(); - padding = MediaQuery.viewPaddingOf(context); + if (videoDetailController.removeSafeArea) { + padding = .zero; + } else { + padding = MediaQuery.viewPaddingOf(context); + } final size = MediaQuery.sizeOf(context); maxWidth = size.width; @@ -507,6 +516,9 @@ class _VideoDetailPageVState extends State } } + bool get removeAppBar => + videoDetailController.removeSafeArea || (isFullScreen && !isPortrait); + Widget get childWhenDisabled { videoDetailController.animationController ..removeListener(animListener) @@ -516,7 +528,7 @@ class _VideoDetailPageVState extends State final isFullScreen = this.isFullScreen; return Scaffold( resizeToAvoidBottomInset: false, - appBar: isFullScreen && !isPortrait + appBar: removeAppBar ? null : PreferredSize( preferredSize: const Size.fromHeight(0), @@ -818,7 +830,7 @@ class _VideoDetailPageVState extends State final isFullScreen = this.isFullScreen; return Scaffold( resizeToAvoidBottomInset: false, - appBar: isFullScreen && !isPortrait + appBar: removeAppBar ? null : AppBar(backgroundColor: Colors.black, toolbarHeight: 0), body: Padding( @@ -1048,7 +1060,7 @@ class _VideoDetailPageVState extends State final isFullScreen = this.isFullScreen; return Scaffold( resizeToAvoidBottomInset: false, - appBar: isFullScreen && !isPortrait + appBar: removeAppBar ? null : AppBar(backgroundColor: Colors.black, toolbarHeight: 0), body: Padding( diff --git a/lib/pages/video/widgets/header_control.dart b/lib/pages/video/widgets/header_control.dart index 6a1424c19..bd615448e 100644 --- a/lib/pages/video/widgets/header_control.dart +++ b/lib/pages/video/widgets/header_control.dart @@ -1881,7 +1881,7 @@ class HeaderControlState extends State : const SizedBox.shrink(), ), ], - if (isFullScreen || PlatformUtils.isDesktop) ...[ + if (!isPortrait || isFullScreen || PlatformUtils.isDesktop) ...[ SizedBox( width: btnWidth, height: btnHeight, diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index c98d9c154..15c23de32 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1424,6 +1424,7 @@ class PlPlayerController with BlockConfigMixin { bool isManualFS = true; late final FullScreenMode mode = Pref.fullScreenMode; late final horizontalScreen = Pref.horizontalScreen; + late final removeSafeArea = Pref.removeSafeArea; // 全屏 bool _fsProcessing = false; @@ -1475,12 +1476,26 @@ class PlPlayerController with BlockConfigMixin { } } else { if (PlatformUtils.isMobile) { - showStatusBar(); + if (!removeSafeArea) { + showStatusBar(); + } if (orientation == null && mode == .none) { return; } if (!horizontalScreen) { await portraitUpMode(); + } else { + switch (_orientation) { + case .portraitUp: + await portraitUpMode(); + case .landscapeLeft: + await landscapeLeftMode(); + case .portraitDown: + await portraitDownMode(); + case .landscapeRight: + await landscapeRightMode(); + case _: + } } } else { await exitDesktopFullScreen(); @@ -1617,6 +1632,9 @@ class PlPlayerController with BlockConfigMixin { } _playerCount = 0; + if (removeSafeArea) { + showStatusBar(); + } danmakuController = null; _stopOrientationListener(); _disableAutoEnterPip(); diff --git a/lib/plugin/pl_player/view/view.dart b/lib/plugin/pl_player/view/view.dart index 21bb16adc..3de04686c 100644 --- a/lib/plugin/pl_player/view/view.dart +++ b/lib/plugin/pl_player/view/view.dart @@ -1616,6 +1616,7 @@ class _PLVideoPlayerState extends State isTop: true, controller: animationController, isFullScreen: isFullScreen, + removeSafeArea: plPlayerController.removeSafeArea, child: plPlayerController.isDesktopPip ? GestureDetector( behavior: HitTestBehavior.translucent, @@ -1628,6 +1629,7 @@ class _PLVideoPlayerState extends State isTop: false, controller: animationController, isFullScreen: isFullScreen, + removeSafeArea: plPlayerController.removeSafeArea, child: widget.bottomControl ?? BottomControl( @@ -1816,6 +1818,7 @@ class _PLVideoPlayerState extends State if (plPlayerController.showFsLockBtn) ViewSafeArea( right: false, + left: !plPlayerController.removeSafeArea, child: Align( alignment: Alignment.centerLeft, child: FractionalTranslation( @@ -1859,6 +1862,7 @@ class _PLVideoPlayerState extends State if (plPlayerController.showFsScreenshotBtn) ViewSafeArea( left: false, + right: !plPlayerController.removeSafeArea, child: Obx( () => Align( alignment: Alignment.centerRight, diff --git a/lib/plugin/pl_player/widgets/app_bar_ani.dart b/lib/plugin/pl_player/widgets/app_bar_ani.dart index 1699a2ab4..fd8058e31 100644 --- a/lib/plugin/pl_player/widgets/app_bar_ani.dart +++ b/lib/plugin/pl_player/widgets/app_bar_ani.dart @@ -8,12 +8,14 @@ class AppBarAni extends StatelessWidget { required this.controller, required this.isTop, required this.isFullScreen, + required this.removeSafeArea, }); final Widget child; final AnimationController controller; final bool isTop; final bool isFullScreen; + final bool removeSafeArea; static final _topPos = Tween( begin: const Offset(0.0, -1.0), @@ -53,11 +55,13 @@ class AppBarAni extends StatelessWidget { decoration: BoxDecoration( gradient: isTop ? _topDecoration : _bottomDecoration, ), - child: ViewSafeArea( - left: isFullScreen, - right: isFullScreen, - child: child, - ), + child: removeSafeArea + ? child + : ViewSafeArea( + left: isFullScreen, + right: isFullScreen, + child: child, + ), ), ); } diff --git a/lib/utils/storage_key.dart b/lib/utils/storage_key.dart index 06b93bd40..227cba460 100644 --- a/lib/utils/storage_key.dart +++ b/lib/utils/storage_key.dart @@ -149,7 +149,8 @@ abstract final class SettingBoxKey { enableImgMenu = 'enableImgMenu', showDynDispute = 'showDynDispute', touchSlopH = 'touchSlopH', - floatingNavBar = 'floatingNavBar'; + floatingNavBar = 'floatingNavBar', + removeSafeArea = 'removeSafeArea'; static const String minimizeOnExit = 'minimizeOnExit', windowSize = 'windowSize', diff --git a/lib/utils/storage_pref.dart b/lib/utils/storage_pref.dart index a08ec6aba..4c9994ec1 100644 --- a/lib/utils/storage_pref.dart +++ b/lib/utils/storage_pref.dart @@ -970,4 +970,7 @@ abstract final class Pref { static bool get floatingNavBar => _setting.get(SettingBoxKey.floatingNavBar, defaultValue: false); + + static bool get removeSafeArea => + _setting.get(SettingBoxKey.removeSafeArea, defaultValue: false); }