mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 未开启横屏时不转屏
This commit is contained in:
@@ -28,7 +28,9 @@ import './services/loggeer.dart';
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
MediaKit.ensureInitialized();
|
||||
SystemChrome.setPreferredOrientations(
|
||||
await GStrorage.init();
|
||||
if (GStrorage.setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
|
||||
await SystemChrome.setPreferredOrientations(
|
||||
//支持竖屏与横屏
|
||||
[
|
||||
DeviceOrientation.portraitUp,
|
||||
@@ -36,8 +38,15 @@ void main() async {
|
||||
DeviceOrientation.landscapeLeft,
|
||||
DeviceOrientation.landscapeRight,
|
||||
],
|
||||
).then((_) async {
|
||||
await GStrorage.init();
|
||||
);
|
||||
} else {
|
||||
await SystemChrome.setPreferredOrientations(
|
||||
//支持竖屏
|
||||
[
|
||||
DeviceOrientation.portraitUp,
|
||||
],
|
||||
);
|
||||
}
|
||||
await setupServiceLocator();
|
||||
Request();
|
||||
await Request.setCookie();
|
||||
@@ -78,7 +87,6 @@ void main() async {
|
||||
Data.init();
|
||||
GStrorage.lazyInit();
|
||||
PiliSchame.init();
|
||||
});
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:auto_orientation/auto_orientation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/video/play/quality.dart';
|
||||
@@ -116,11 +118,20 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
setKey: SettingBoxKey.enableAutoExit,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
SetSwitchItem(
|
||||
title: '横屏适配(测试)',
|
||||
subTitle: '开启该项在播放页启用横屏布局与逻辑',
|
||||
setKey: SettingBoxKey.horizontalScreen,
|
||||
defaultVal: false,
|
||||
callFn: (value) {
|
||||
if (value) {
|
||||
autoScreen();
|
||||
SmartDialog.showToast('已开启横屏适配');
|
||||
} else {
|
||||
AutoOrientation.portraitUpMode();
|
||||
SmartDialog.showToast('已关闭横屏适配');
|
||||
}
|
||||
}
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '开启硬解',
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:auto_orientation/auto_orientation.dart';
|
||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||
import 'package:floating/floating.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -198,6 +199,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (!horizontalScreen) {
|
||||
AutoOrientation.portraitUpMode();
|
||||
}
|
||||
shutdownTimerService.handleWaitingFinished();
|
||||
if (plPlayerController != null) {
|
||||
plPlayerController!.removeStatusLister(playerListener);
|
||||
|
||||
@@ -42,6 +42,16 @@ Future<void> verticalScreen() async {
|
||||
]);
|
||||
}
|
||||
|
||||
//全向
|
||||
Future<void> autoScreen() async {
|
||||
await SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
DeviceOrientation.landscapeLeft,
|
||||
DeviceOrientation.landscapeRight,
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> enterFullScreen() async {
|
||||
await SystemChrome.setEnabledSystemUIMode(
|
||||
SystemUiMode.immersiveSticky,
|
||||
|
||||
Reference in New Issue
Block a user