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',