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/viewer.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/plugin/pl_player/utils/fullscreen.dart';
import 'package:PiliPlus/utils/extension/num_ext.dart';
import 'package:PiliPlus/utils/extension/string_ext.dart';
import 'package:PiliPlus/utils/image_utils.dart';
@@ -76,6 +78,7 @@ class _GalleryViewerState extends State<GalleryViewer>
late final int _quality;
late final RxInt _currIndex;
GlobalKey? _key;
EdgeInsets? _padding;
late bool _hasInit = false;
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) {
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);
super.dispose();
if (_hideSystemBar) {
showSystemBar();
}
}
void _onPointerDown(PointerDownEvent event) {
@@ -311,9 +336,7 @@ class _GalleryViewerState extends State<GalleryViewer>
right: 0,
child: IgnorePointer(
child: Container(
padding:
MediaQuery.viewPaddingOf(context) +
const EdgeInsets.fromLTRB(12, 8, 20, 8),
padding: _padding! + const EdgeInsets.fromLTRB(12, 8, 20, 8),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,

View File

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

View File

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

View File

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

View File

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

View File

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