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,
),
),
const SetSwitchItem(
title: '播放页状态栏显示为背景色',
subTitle: '关闭则显示为黑色',
leading: Icon(Icons.border_outer_outlined),
setKey: SettingBoxKey.videoPlayerShowStatusBarBackgroundColor,
defaultVal: false,
needReboot: true,
),
const SetSwitchItem(
title: '播放页移除安全边距',
subTitle: '隐藏状态栏、撑满屏幕,但播放控件仍处于安全域内',

View File

@@ -60,6 +60,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
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<VideoDetailPage>
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,10 +469,13 @@ class _VideoDetailPageState extends State<VideoDetailPage>
appBar: removeSafeArea
? null
: AppBar(
backgroundColor: Colors.black,
backgroundColor:
showStatusBarBackgroundColor ? null : Colors.black,
elevation: 0,
toolbarHeight: 0,
systemOverlayStyle: const SystemUiOverlayStyle(
systemOverlayStyle: showStatusBarBackgroundColor
? null
: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light),
),
// appBar: PreferredSize(
@@ -508,7 +515,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
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<VideoDetailPage>
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<VideoDetailPage>
videoheight -
(removeSafeArea
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom)),
: MediaQuery.of(context).padding.top),
child: CustomScrollView(
key: PageStorageKey<String>(
'简介${videoDetailController.bvid}'),
@@ -1048,10 +1052,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
: (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<VideoDetailPage>
],
);
});
Widget childWhenDisabledLandscape = SafeArea(
left: !removeSafeArea && isFullScreen.value != true,
right: !removeSafeArea && isFullScreen.value != true,
top: !removeSafeArea,
bottom: !removeSafeArea,
child: Stack(children: [
Widget childWhenDisabledLandscape = Stack(children: [
Scaffold(
resizeToAvoidBottomInset: false,
key: videoDetailController.scaffoldKey,
backgroundColor: Colors.black,
// backgroundColor: Colors.black,
appBar: removeSafeArea
? null
: AppBar(
backgroundColor: Colors.black,
backgroundColor:
showStatusBarBackgroundColor ? null : Colors.black,
elevation: 0,
toolbarHeight: 0,
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light),
// systemOverlayStyle: const SystemUiOverlayStyle(
// statusBarIconBrightness: Brightness.light),
),
body: Container(
color: Theme.of(context).colorScheme.background,
child: childWhenDisabledLandscapeInner))
]));
Widget childWhenDisabledAlmostSquare = SafeArea(
child: SafeArea(
left: !removeSafeArea && isFullScreen.value != true,
right: !removeSafeArea && isFullScreen.value != true,
top: !removeSafeArea,
bottom: !removeSafeArea,
child: Stack(children: [
bottom: false, //!removeSafeArea,
child: childWhenDisabledLandscapeInner)))
]);
Widget childWhenDisabledAlmostSquare = Stack(children: [
Scaffold(
resizeToAvoidBottomInset: false,
key: videoDetailController.scaffoldKey,
backgroundColor: Colors.black,
// backgroundColor: Colors.black,
appBar: removeSafeArea
? null
: AppBar(
backgroundColor: Colors.black,
backgroundColor:
showStatusBarBackgroundColor ? null : Colors.black,
elevation: 0,
toolbarHeight: 0,
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light),
// systemOverlayStyle: const SystemUiOverlayStyle(
// statusBarIconBrightness: Brightness.light),
),
body: Container(
color: Theme.of(context).colorScheme.background,
child: childWhenDisabledAlmostSquareInner))
]));
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()

View File

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