SystemUIOverlays

This commit is contained in:
niuhuan 2021-12-07 23:53:19 +08:00
parent 2c9d4626d9
commit 05189114d2
5 changed files with 38 additions and 21 deletions

View File

@ -76,7 +76,7 @@ VPN->代理->分流, 这三个功能如果同时设置, 您会在您手机的VPN
### 开发环境准备
- [golang](https://golang.org/) (1.16以上版本)
- [flutter](https://flutter.dev/) (2.5.3)(flutter不同版本api差异较大,建议使用同样版本)
- [flutter](https://flutter.dev/) (2.5.3)(flutter不同版本api差异较大,建议使用临近的版本)
### 环境配置

View File

@ -36,7 +36,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "niuhuan.pikapika"
minSdkVersion 16
targetSdkVersion 31
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

View File

@ -1,5 +1,7 @@
///
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -15,7 +17,6 @@ enum FullScreenUI {
const _propertyName = "fullScreenUI";
late FullScreenUI fullScreenUI;
Future<void> initFullScreenUI() async {
fullScreenUI = _fullScreenUIFromString(await method.loadProperty(
_propertyName,
@ -67,21 +68,25 @@ void switchFullScreenUI() {
list.clear();
break;
}
print(fullScreenUI);
SystemChrome.setEnabledSystemUIOverlays(list);
if (Platform.isAndroid || Platform.isIOS) {
SystemChrome.setEnabledSystemUIOverlays(list);
}
}
Widget fullScreenUISetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: Text("全屏UI"),
subtitle: Text(currentFullScreenUIName()),
onTap: () async {
await chooseFullScreenUI(context);
setState(() {});
},
);
},
);
if (Platform.isAndroid || Platform.isIOS) {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: Text("全屏UI"),
subtitle: Text(currentFullScreenUIName()),
onTap: () async {
await chooseFullScreenUI(context);
setState(() {});
},
);
},
);
}
return Container();
}

View File

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -216,8 +217,13 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
Future _onFullScreenChange(bool fullScreen) async {
setState(() {
SystemChrome.setEnabledSystemUIOverlays(
fullScreen ? [] : SystemUiOverlay.values);
if (fullScreen) {
if (Platform.isAndroid || Platform.isIOS) {
SystemChrome.setEnabledSystemUIOverlays([]);
}
} else {
switchFullScreenUI();
}
_fullScreen = fullScreen;
});
}

View File

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -198,8 +199,13 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
Future _onFullScreenChange(bool fullScreen) async {
setState(() {
SystemChrome.setEnabledSystemUIOverlays(
fullScreen ? [] : SystemUiOverlay.values);
if (fullScreen) {
if (Platform.isAndroid || Platform.isIOS) {
SystemChrome.setEnabledSystemUIOverlays([]);
}
} else {
switchFullScreenUI();
}
_fullScreen = fullScreen;
});
}