feat: 播放页虚拟键、小白条、挖孔屏底色改为背景色,新增播放页状态栏显示为背景色

This commit is contained in:
orz12
2024-06-02 14:41:44 +08:00
parent 82befc4df0
commit bcd85f98cf
3 changed files with 73 additions and 60 deletions

View File

@@ -133,6 +133,14 @@ class _StyleSettingState extends State<StyleSetting> {
style: subTitleStyle, style: subTitleStyle,
), ),
), ),
const SetSwitchItem(
title: '播放页状态栏显示为背景色',
subTitle: '关闭则显示为黑色',
leading: Icon(Icons.border_outer_outlined),
setKey: SettingBoxKey.videoPlayerShowStatusBarBackgroundColor,
defaultVal: false,
needReboot: true,
),
const SetSwitchItem( const SetSwitchItem(
title: '播放页移除安全边距', title: '播放页移除安全边距',
subTitle: '隐藏状态栏、撑满屏幕,但播放控件仍处于安全域内', subTitle: '隐藏状态栏、撑满屏幕,但播放控件仍处于安全域内',

View File

@@ -60,6 +60,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
late bool autoPiP; late bool autoPiP;
late bool pipNoDanmaku; late bool pipNoDanmaku;
late bool removeSafeArea; late bool removeSafeArea;
late bool showStatusBarBackgroundColor;
final Floating floating = Floating(); final Floating floating = Floating();
// 生命周期监听 // 生命周期监听
// late final AppLifecycleListener _lifecycleListener; // late final AppLifecycleListener _lifecycleListener;
@@ -102,6 +103,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
setting.get(SettingBoxKey.enableVerticalExpand, defaultValue: false); setting.get(SettingBoxKey.enableVerticalExpand, defaultValue: false);
removeSafeArea = setting.get(SettingBoxKey.videoPlayerRemoveSafeArea, removeSafeArea = setting.get(SettingBoxKey.videoPlayerRemoveSafeArea,
defaultValue: false); defaultValue: false);
showStatusBarBackgroundColor = setting.get(
SettingBoxKey.videoPlayerShowStatusBarBackgroundColor,
defaultValue: false);
if (removeSafeArea) hideStatusBar(); if (removeSafeArea) hideStatusBar();
videoSourceInit(); videoSourceInit();
appbarStreamListen(); appbarStreamListen();
@@ -465,11 +469,14 @@ class _VideoDetailPageState extends State<VideoDetailPage>
appBar: removeSafeArea appBar: removeSafeArea
? null ? null
: AppBar( : AppBar(
backgroundColor: Colors.black, backgroundColor:
showStatusBarBackgroundColor ? null : Colors.black,
elevation: 0, elevation: 0,
toolbarHeight: 0, toolbarHeight: 0,
systemOverlayStyle: const SystemUiOverlayStyle( systemOverlayStyle: showStatusBarBackgroundColor
statusBarIconBrightness: Brightness.light), ? null
: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light),
), ),
// appBar: PreferredSize( // appBar: PreferredSize(
// preferredSize: const Size.fromHeight(0), // preferredSize: const Size.fromHeight(0),
@@ -508,7 +515,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (!removeSafeArea) showStatusBar(); if (!removeSafeArea) showStatusBar();
} }
return Container( return Container(
color: Colors.black, color:
showStatusBarBackgroundColor ? null : Colors.black,
height: MediaQuery.of(context).orientation == height: MediaQuery.of(context).orientation ==
Orientation.landscape || Orientation.landscape ||
isFullScreen.value == true isFullScreen.value == true
@@ -831,10 +839,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (enableVerticalExpand && if (enableVerticalExpand &&
plPlayerController?.direction.value == 'vertical') { plPlayerController?.direction.value == 'vertical') {
final double videoheight = context.height - final double videoheight = context.height -
(removeSafeArea (removeSafeArea ? 0 : MediaQuery.of(context).padding.top);
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom));
final double videowidth = videoheight * 9 / 16; final double videowidth = videoheight * 9 / 16;
return Row( return Row(
children: [ children: [
@@ -1018,8 +1023,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
videoheight - videoheight -
(removeSafeArea (removeSafeArea
? 0 ? 0
: (MediaQuery.of(context).padding.top + : MediaQuery.of(context).padding.top),
MediaQuery.of(context).padding.bottom)),
child: CustomScrollView( child: CustomScrollView(
key: PageStorageKey<String>( key: PageStorageKey<String>(
'简介${videoDetailController.bvid}'), '简介${videoDetailController.bvid}'),
@@ -1048,10 +1052,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
: (MediaQuery.of(context).padding.left + : (MediaQuery.of(context).padding.left +
MediaQuery.of(context).padding.right))), MediaQuery.of(context).padding.right))),
height: context.height - height: context.height -
(removeSafeArea (removeSafeArea ? 0 : MediaQuery.of(context).padding.top),
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom)),
child: child:
// TabBarView( // TabBarView(
// physics: const BouncingScrollPhysics(), // physics: const BouncingScrollPhysics(),
@@ -1076,52 +1077,54 @@ class _VideoDetailPageState extends State<VideoDetailPage>
], ],
); );
}); });
Widget childWhenDisabledLandscape = SafeArea( Widget childWhenDisabledLandscape = Stack(children: [
left: !removeSafeArea && isFullScreen.value != true, Scaffold(
right: !removeSafeArea && isFullScreen.value != true, resizeToAvoidBottomInset: false,
top: !removeSafeArea, key: videoDetailController.scaffoldKey,
bottom: !removeSafeArea, // backgroundColor: Colors.black,
child: Stack(children: [ appBar: removeSafeArea
Scaffold( ? null
resizeToAvoidBottomInset: false, : AppBar(
key: videoDetailController.scaffoldKey, backgroundColor:
backgroundColor: Colors.black, showStatusBarBackgroundColor ? null : Colors.black,
appBar: removeSafeArea elevation: 0,
? null toolbarHeight: 0,
: AppBar( // systemOverlayStyle: const SystemUiOverlayStyle(
backgroundColor: Colors.black, // statusBarIconBrightness: Brightness.light),
elevation: 0, ),
toolbarHeight: 0, body: Container(
systemOverlayStyle: const SystemUiOverlayStyle( color: Theme.of(context).colorScheme.background,
statusBarIconBrightness: Brightness.light), child: SafeArea(
), left: !removeSafeArea && isFullScreen.value != true,
body: Container( right: !removeSafeArea && isFullScreen.value != true,
color: Theme.of(context).colorScheme.background, top: !removeSafeArea,
child: childWhenDisabledLandscapeInner)) bottom: false, //!removeSafeArea,
])); child: childWhenDisabledLandscapeInner)))
Widget childWhenDisabledAlmostSquare = SafeArea( ]);
left: !removeSafeArea && isFullScreen.value != true, Widget childWhenDisabledAlmostSquare = Stack(children: [
right: !removeSafeArea && isFullScreen.value != true, Scaffold(
top: !removeSafeArea, resizeToAvoidBottomInset: false,
bottom: !removeSafeArea, key: videoDetailController.scaffoldKey,
child: Stack(children: [ // backgroundColor: Colors.black,
Scaffold( appBar: removeSafeArea
resizeToAvoidBottomInset: false, ? null
key: videoDetailController.scaffoldKey, : AppBar(
backgroundColor: Colors.black, backgroundColor:
appBar: removeSafeArea showStatusBarBackgroundColor ? null : Colors.black,
? null elevation: 0,
: AppBar( toolbarHeight: 0,
backgroundColor: Colors.black, // systemOverlayStyle: const SystemUiOverlayStyle(
elevation: 0, // statusBarIconBrightness: Brightness.light),
toolbarHeight: 0, ),
systemOverlayStyle: const SystemUiOverlayStyle( body: Container(
statusBarIconBrightness: Brightness.light), color: Theme.of(context).colorScheme.background,
), child: SafeArea(
body: Container( left: !removeSafeArea && isFullScreen.value != true,
color: Theme.of(context).colorScheme.background, right: !removeSafeArea && isFullScreen.value != true,
child: childWhenDisabledAlmostSquareInner)) top: !removeSafeArea,
])); bottom: false, //!removeSafeArea,
child: childWhenDisabledAlmostSquareInner)))
]);
Widget childWhenEnabled = Obx( Widget childWhenEnabled = Obx(
() => !videoDetailController.autoPlay.value () => !videoDetailController.autoPlay.value
? const SizedBox() ? const SizedBox()

View File

@@ -181,6 +181,8 @@ class SettingBoxKey {
displayMode = 'displayMode', displayMode = 'displayMode',
maxRowWidth = 'maxRowWidth', // 首页列最大宽度dp maxRowWidth = 'maxRowWidth', // 首页列最大宽度dp
videoPlayerRemoveSafeArea = 'videoPlayerRemoveSafeArea', // 视频播放器移除安全边距 videoPlayerRemoveSafeArea = 'videoPlayerRemoveSafeArea', // 视频播放器移除安全边距
videoPlayerShowStatusBarBackgroundColor =
'videoPlayerShowStatusBarBackgroundColor', // 播放页状态栏显示为背景色
dynamicsWaterfallFlow = 'dynamicsWaterfallFlow', // 动态瀑布流 dynamicsWaterfallFlow = 'dynamicsWaterfallFlow', // 动态瀑布流
upPanelPosition = 'upPanelPosition', // up主面板位置 upPanelPosition = 'upPanelPosition', // up主面板位置
useSideBar = 'useSideBar', useSideBar = 'useSideBar',