hide systembar when preview

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-04-20 11:59:31 +08:00
parent 4229024adf
commit 0fb394cc36
6 changed files with 49 additions and 19 deletions

View File

@@ -25,7 +25,9 @@ import 'package:PiliPlus/common/widgets/image_viewer/image.dart';
import 'package:PiliPlus/common/widgets/image_viewer/loading_indicator.dart'; import 'package:PiliPlus/common/widgets/image_viewer/loading_indicator.dart';
import 'package:PiliPlus/common/widgets/image_viewer/viewer.dart'; import 'package:PiliPlus/common/widgets/image_viewer/viewer.dart';
import 'package:PiliPlus/common/widgets/scroll_physics.dart'; import 'package:PiliPlus/common/widgets/scroll_physics.dart';
import 'package:PiliPlus/main.dart' show tmpPadding;
import 'package:PiliPlus/models/common/image_preview_type.dart'; import 'package:PiliPlus/models/common/image_preview_type.dart';
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart';
import 'package:PiliPlus/utils/extension/string_ext.dart'; import 'package:PiliPlus/utils/extension/string_ext.dart';
import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/image_utils.dart';
@@ -76,6 +78,7 @@ class _GalleryViewerState extends State<GalleryViewer>
late final int _quality; late final int _quality;
late final RxInt _currIndex; late final RxInt _currIndex;
GlobalKey? _key; GlobalKey? _key;
EdgeInsets? _padding;
late bool _hasInit = false; late bool _hasInit = false;
Player? _player; Player? _player;
@@ -170,6 +173,25 @@ class _GalleryViewerState extends State<GalleryViewer>
); );
} }
final _hideSystemBar = PlatformUtils.isMobile && showSystemBar_;
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (_padding == null) {
final padding = MediaQuery.viewPaddingOf(context);
_padding = padding;
if (_hideSystemBar) {
tmpPadding = padding;
hideSystemBar()!.whenComplete(
() => WidgetsBinding.instance.addPostFrameCallback(
(_) => tmpPadding = null,
),
);
}
}
}
Matrix4 _onTransform(double val) { Matrix4 _onTransform(double val) {
final scale = val.lerp(1.0, 0.25); final scale = val.lerp(1.0, 0.25);
@@ -259,6 +281,9 @@ class _GalleryViewerState extends State<GalleryViewer>
} }
Future.delayed(const Duration(milliseconds: 200), _currIndex.close); Future.delayed(const Duration(milliseconds: 200), _currIndex.close);
super.dispose(); super.dispose();
if (_hideSystemBar) {
showSystemBar();
}
} }
void _onPointerDown(PointerDownEvent event) { void _onPointerDown(PointerDownEvent event) {
@@ -311,9 +336,7 @@ class _GalleryViewerState extends State<GalleryViewer>
right: 0, right: 0,
child: IgnorePointer( child: IgnorePointer(
child: Container( child: Container(
padding: padding: _padding! + const EdgeInsets.fromLTRB(12, 8, 20, 8),
MediaQuery.viewPaddingOf(context) +
const EdgeInsets.fromLTRB(12, 8, 20, 8),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topCenter, begin: Alignment.topCenter,

View File

@@ -46,6 +46,8 @@ import 'package:window_manager/window_manager.dart' hide calcWindowPosition;
WebViewEnvironment? webViewEnvironment; WebViewEnvironment? webViewEnvironment;
EdgeInsets? tmpPadding;
Future<void> _initDownPath() async { Future<void> _initDownPath() async {
if (PlatformUtils.isDesktop) { if (PlatformUtils.isDesktop) {
final customDownPath = Pref.downloadPath; final customDownPath = Pref.downloadPath;
@@ -313,16 +315,20 @@ class MyApp extends StatelessWidget {
data: mediaQuery.copyWith( data: mediaQuery.copyWith(
textScaler: textScaler, textScaler: textScaler,
size: mediaQuery.size / uiScale, size: mediaQuery.size / uiScale,
padding: mediaQuery.padding / uiScale, padding: (tmpPadding ?? mediaQuery.padding) / uiScale,
viewInsets: mediaQuery.viewInsets / uiScale, viewInsets: mediaQuery.viewInsets / uiScale,
viewPadding: mediaQuery.viewPadding / uiScale, viewPadding: (tmpPadding ?? mediaQuery.viewPadding) / uiScale,
devicePixelRatio: mediaQuery.devicePixelRatio * uiScale, devicePixelRatio: mediaQuery.devicePixelRatio * uiScale,
), ),
child: child!, child: child!,
); );
} else { } else {
child = MediaQuery( child = MediaQuery(
data: mediaQuery.copyWith(textScaler: textScaler), data: mediaQuery.copyWith(
textScaler: textScaler,
padding: tmpPadding,
viewPadding: tmpPadding,
),
child: child!, child: child!,
); );
} }

View File

@@ -84,7 +84,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
..addStatusLister(playerListener); ..addStatusLister(playerListener);
PlPlayerController.setPlayCallBack(plPlayerController.play); PlPlayerController.setPlayCallBack(plPlayerController.play);
if (plPlayerController.removeSafeArea) { if (plPlayerController.removeSafeArea) {
hideStatusBar(); hideSystemBar();
} }
} }

View File

@@ -142,7 +142,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
videoDetailController = Get.put(VideoDetailController(), tag: heroTag); videoDetailController = Get.put(VideoDetailController(), tag: heroTag);
if (videoDetailController.removeSafeArea) { if (videoDetailController.removeSafeArea) {
hideStatusBar(); hideSystemBar();
} }
if (videoDetailController.showReply) { if (videoDetailController.showReply) {
@@ -351,7 +351,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
} }
if (!videoDetailController.removeSafeArea) { if (!videoDetailController.removeSafeArea) {
showStatusBar(); showSystemBar();
} }
if (!videoDetailController.plPlayerController.isCloseAll) { if (!videoDetailController.plPlayerController.isCloseAll) {

View File

@@ -1444,7 +1444,7 @@ class PlPlayerController with BlockConfigMixin {
try { try {
if (status) { if (status) {
if (PlatformUtils.isMobile) { if (PlatformUtils.isMobile) {
hideStatusBar(); hideSystemBar();
if (orientation == null && mode == .none) { if (orientation == null && mode == .none) {
return; return;
} }
@@ -1477,7 +1477,7 @@ class PlPlayerController with BlockConfigMixin {
} else { } else {
if (PlatformUtils.isMobile) { if (PlatformUtils.isMobile) {
if (!removeSafeArea) { if (!removeSafeArea) {
showStatusBar(); showSystemBar();
} }
if (orientation == null && mode == .none) { if (orientation == null && mode == .none) {
return; return;
@@ -1633,7 +1633,7 @@ class PlPlayerController with BlockConfigMixin {
_playerCount = 0; _playerCount = 0;
if (removeSafeArea) { if (removeSafeArea) {
showStatusBar(); showSystemBar();
} }
danmakuController = null; danmakuController = null;
_stopOrientationListener(); _stopOrientationListener();

View File

@@ -62,21 +62,22 @@ Future<void>? fullMode() {
); );
} }
bool _showStatusBar = true; bool _showSystemBar = true;
Future<void>? hideStatusBar() { bool get showSystemBar_ => _showSystemBar;
if (!_showStatusBar) { Future<void>? hideSystemBar() {
if (!_showSystemBar) {
return null; return null;
} }
_showStatusBar = false; _showSystemBar = false;
return SystemChrome.setEnabledSystemUIMode(.immersiveSticky); return SystemChrome.setEnabledSystemUIMode(.immersiveSticky);
} }
//退出全屏显示 //退出全屏显示
Future<void>? showStatusBar() { Future<void>? showSystemBar() {
if (_showStatusBar) { if (_showSystemBar) {
return null; return null;
} }
_showStatusBar = true; _showSystemBar = true;
return SystemChrome.setEnabledSystemUIMode( return SystemChrome.setEnabledSystemUIMode(
Platform.isAndroid && Utils.sdkInt < 29 ? .manual : .edgeToEdge, Platform.isAndroid && Utils.sdkInt < 29 ? .manual : .edgeToEdge,
overlays: SystemUiOverlay.values, overlays: SystemUiOverlay.values,