mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-16 14:14:01 +08:00
@@ -3,7 +3,12 @@ import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/utils/device_utils.dart';
|
||||
import 'package:flutter/services.dart'
|
||||
show SystemChrome, MethodChannel, SystemUiOverlay, DeviceOrientation;
|
||||
show
|
||||
SystemChrome,
|
||||
MethodChannel,
|
||||
SystemUiOverlay,
|
||||
DeviceOrientation,
|
||||
SystemUiMode;
|
||||
|
||||
bool _isDesktopFullScreen = false;
|
||||
|
||||
@@ -69,7 +74,7 @@ Future<void>? hideSystemBar() {
|
||||
return null;
|
||||
}
|
||||
_showSystemBar = false;
|
||||
return SystemChrome.setEnabledSystemUIMode(.immersiveSticky);
|
||||
return setEnabledSystemUIMode(.immersiveSticky);
|
||||
}
|
||||
|
||||
//退出全屏显示
|
||||
@@ -78,8 +83,31 @@ Future<void>? showSystemBar() {
|
||||
return null;
|
||||
}
|
||||
_showSystemBar = true;
|
||||
return SystemChrome.setEnabledSystemUIMode(
|
||||
return setEnabledSystemUIMode(
|
||||
Platform.isAndroid && DeviceUtils.sdkInt < 29 ? .manual : .edgeToEdge,
|
||||
overlays: SystemUiOverlay.values,
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: remove
|
||||
Future<void> setEnabledSystemUIMode(
|
||||
SystemUiMode mode, {
|
||||
List<SystemUiOverlay>? overlays,
|
||||
}) async {
|
||||
if (mode != SystemUiMode.manual) {
|
||||
await const MethodChannel('PiliPlus').invokeMethod(
|
||||
'SystemChrome.setEnabledSystemUIMode',
|
||||
{'arguments': mode.toString()},
|
||||
);
|
||||
} else {
|
||||
assert(mode == SystemUiMode.manual && overlays != null);
|
||||
await const MethodChannel('PiliPlus').invokeMethod(
|
||||
'SystemChrome.setEnabledSystemUIOverlays',
|
||||
{'arguments': _stringify(overlays!)},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> _stringify(List<dynamic> list) => <String>[
|
||||
for (final dynamic item in list) item.toString(),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user