From bcd85f98cfda4e5bfec4148957eb0457c965984a Mon Sep 17 00:00:00 2001 From: orz12 Date: Sun, 2 Jun 2024 14:41:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=92=AD=E6=94=BE=E9=A1=B5=E8=99=9A?= =?UTF-8?q?=E6=8B=9F=E9=94=AE=E3=80=81=E5=B0=8F=E7=99=BD=E6=9D=A1=E3=80=81?= =?UTF-8?q?=E6=8C=96=E5=AD=94=E5=B1=8F=E5=BA=95=E8=89=B2=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E8=89=B2=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=A1=B5=E7=8A=B6=E6=80=81=E6=A0=8F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=BA=E8=83=8C=E6=99=AF=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/setting/style_setting.dart | 8 ++ lib/pages/video/detail/view.dart | 123 ++++++++++++++------------- lib/utils/storage.dart | 2 + 3 files changed, 73 insertions(+), 60 deletions(-) diff --git a/lib/pages/setting/style_setting.dart b/lib/pages/setting/style_setting.dart index e4225148..318a89e8 100644 --- a/lib/pages/setting/style_setting.dart +++ b/lib/pages/setting/style_setting.dart @@ -133,6 +133,14 @@ class _StyleSettingState extends State { style: subTitleStyle, ), ), + const SetSwitchItem( + title: '播放页状态栏显示为背景色', + subTitle: '关闭则显示为黑色', + leading: Icon(Icons.border_outer_outlined), + setKey: SettingBoxKey.videoPlayerShowStatusBarBackgroundColor, + defaultVal: false, + needReboot: true, + ), const SetSwitchItem( title: '播放页移除安全边距', subTitle: '隐藏状态栏、撑满屏幕,但播放控件仍处于安全域内', diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index b47cb613..24806830 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -60,6 +60,7 @@ class _VideoDetailPageState extends State late bool autoPiP; late bool pipNoDanmaku; late bool removeSafeArea; + late bool showStatusBarBackgroundColor; final Floating floating = Floating(); // 生命周期监听 // late final AppLifecycleListener _lifecycleListener; @@ -102,6 +103,9 @@ class _VideoDetailPageState extends State setting.get(SettingBoxKey.enableVerticalExpand, defaultValue: false); removeSafeArea = setting.get(SettingBoxKey.videoPlayerRemoveSafeArea, defaultValue: false); + showStatusBarBackgroundColor = setting.get( + SettingBoxKey.videoPlayerShowStatusBarBackgroundColor, + defaultValue: false); if (removeSafeArea) hideStatusBar(); videoSourceInit(); appbarStreamListen(); @@ -465,11 +469,14 @@ class _VideoDetailPageState extends State appBar: removeSafeArea ? null : AppBar( - backgroundColor: Colors.black, + backgroundColor: + showStatusBarBackgroundColor ? null : Colors.black, elevation: 0, toolbarHeight: 0, - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarIconBrightness: Brightness.light), + systemOverlayStyle: showStatusBarBackgroundColor + ? null + : const SystemUiOverlayStyle( + statusBarIconBrightness: Brightness.light), ), // appBar: PreferredSize( // preferredSize: const Size.fromHeight(0), @@ -508,7 +515,8 @@ class _VideoDetailPageState extends State if (!removeSafeArea) showStatusBar(); } return Container( - color: Colors.black, + color: + showStatusBarBackgroundColor ? null : Colors.black, height: MediaQuery.of(context).orientation == Orientation.landscape || isFullScreen.value == true @@ -831,10 +839,7 @@ class _VideoDetailPageState extends State if (enableVerticalExpand && plPlayerController?.direction.value == 'vertical') { final double videoheight = context.height - - (removeSafeArea - ? 0 - : (MediaQuery.of(context).padding.top + - MediaQuery.of(context).padding.bottom)); + (removeSafeArea ? 0 : MediaQuery.of(context).padding.top); final double videowidth = videoheight * 9 / 16; return Row( children: [ @@ -1018,8 +1023,7 @@ class _VideoDetailPageState extends State videoheight - (removeSafeArea ? 0 - : (MediaQuery.of(context).padding.top + - MediaQuery.of(context).padding.bottom)), + : MediaQuery.of(context).padding.top), child: CustomScrollView( key: PageStorageKey( '简介${videoDetailController.bvid}'), @@ -1048,10 +1052,7 @@ class _VideoDetailPageState extends State : (MediaQuery.of(context).padding.left + MediaQuery.of(context).padding.right))), height: context.height - - (removeSafeArea - ? 0 - : (MediaQuery.of(context).padding.top + - MediaQuery.of(context).padding.bottom)), + (removeSafeArea ? 0 : MediaQuery.of(context).padding.top), child: // TabBarView( // physics: const BouncingScrollPhysics(), @@ -1076,52 +1077,54 @@ class _VideoDetailPageState extends State ], ); }); - Widget childWhenDisabledLandscape = SafeArea( - left: !removeSafeArea && isFullScreen.value != true, - right: !removeSafeArea && isFullScreen.value != true, - top: !removeSafeArea, - bottom: !removeSafeArea, - child: Stack(children: [ - Scaffold( - resizeToAvoidBottomInset: false, - key: videoDetailController.scaffoldKey, - backgroundColor: Colors.black, - appBar: removeSafeArea - ? null - : AppBar( - backgroundColor: Colors.black, - elevation: 0, - toolbarHeight: 0, - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarIconBrightness: Brightness.light), - ), - body: Container( - color: Theme.of(context).colorScheme.background, - child: childWhenDisabledLandscapeInner)) - ])); - Widget childWhenDisabledAlmostSquare = SafeArea( - left: !removeSafeArea && isFullScreen.value != true, - right: !removeSafeArea && isFullScreen.value != true, - top: !removeSafeArea, - bottom: !removeSafeArea, - child: Stack(children: [ - Scaffold( - resizeToAvoidBottomInset: false, - key: videoDetailController.scaffoldKey, - backgroundColor: Colors.black, - appBar: removeSafeArea - ? null - : AppBar( - backgroundColor: Colors.black, - elevation: 0, - toolbarHeight: 0, - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarIconBrightness: Brightness.light), - ), - body: Container( - color: Theme.of(context).colorScheme.background, - child: childWhenDisabledAlmostSquareInner)) - ])); + Widget childWhenDisabledLandscape = Stack(children: [ + Scaffold( + resizeToAvoidBottomInset: false, + key: videoDetailController.scaffoldKey, + // backgroundColor: Colors.black, + appBar: removeSafeArea + ? null + : AppBar( + backgroundColor: + showStatusBarBackgroundColor ? null : Colors.black, + elevation: 0, + toolbarHeight: 0, + // systemOverlayStyle: const SystemUiOverlayStyle( + // statusBarIconBrightness: Brightness.light), + ), + body: Container( + color: Theme.of(context).colorScheme.background, + child: SafeArea( + left: !removeSafeArea && isFullScreen.value != true, + right: !removeSafeArea && isFullScreen.value != true, + top: !removeSafeArea, + bottom: false, //!removeSafeArea, + child: childWhenDisabledLandscapeInner))) + ]); + Widget childWhenDisabledAlmostSquare = Stack(children: [ + Scaffold( + resizeToAvoidBottomInset: false, + key: videoDetailController.scaffoldKey, + // backgroundColor: Colors.black, + appBar: removeSafeArea + ? null + : AppBar( + backgroundColor: + showStatusBarBackgroundColor ? null : Colors.black, + elevation: 0, + toolbarHeight: 0, + // systemOverlayStyle: const SystemUiOverlayStyle( + // statusBarIconBrightness: Brightness.light), + ), + body: Container( + color: Theme.of(context).colorScheme.background, + child: SafeArea( + left: !removeSafeArea && isFullScreen.value != true, + right: !removeSafeArea && isFullScreen.value != true, + top: !removeSafeArea, + bottom: false, //!removeSafeArea, + child: childWhenDisabledAlmostSquareInner))) + ]); Widget childWhenEnabled = Obx( () => !videoDetailController.autoPlay.value ? const SizedBox() diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 2d963280..2c6e9d79 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -181,6 +181,8 @@ class SettingBoxKey { displayMode = 'displayMode', maxRowWidth = 'maxRowWidth', // 首页列最大宽度(dp) videoPlayerRemoveSafeArea = 'videoPlayerRemoveSafeArea', // 视频播放器移除安全边距 + videoPlayerShowStatusBarBackgroundColor = + 'videoPlayerShowStatusBarBackgroundColor', // 播放页状态栏显示为背景色 dynamicsWaterfallFlow = 'dynamicsWaterfallFlow', // 动态瀑布流 upPanelPosition = 'upPanelPosition', // up主面板位置 useSideBar = 'useSideBar',