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以上版本) - [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). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "niuhuan.pikapika" applicationId "niuhuan.pikapika"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 31 targetSdkVersion 30
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
} }

View File

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

View File

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

View File

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