mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-08 12:04:50 +08:00
custom angle degree on android
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||
import 'package:PiliPlus/pages/setting/models/model.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/slider_dialog.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
@@ -7,6 +10,7 @@ import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
||||
List<SettingsModel> get playSettings => [
|
||||
const SwitchModel(
|
||||
@@ -22,6 +26,13 @@ List<SettingsModel> get playSettings => [
|
||||
title: '倍速设置',
|
||||
subtitle: '设置视频播放速度',
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
NormalModel(
|
||||
onTap: _showAngleDegreesDialog,
|
||||
leading: const Icon(MdiIcons.angleAcute),
|
||||
title: '倾斜角度阈值',
|
||||
getSubtitle: () => '当前:「${Pref.angleDegrees}°」',
|
||||
),
|
||||
SwitchModel(
|
||||
title: '全屏显示电池电量',
|
||||
leading: const Icon(Icons.battery_3_bar),
|
||||
@@ -76,3 +87,25 @@ List<SettingsModel> get playSettings => [
|
||||
.whenComplete(setState),
|
||||
),
|
||||
];
|
||||
|
||||
Future<void> _showAngleDegreesDialog(
|
||||
BuildContext context,
|
||||
VoidCallback setState,
|
||||
) async {
|
||||
final res = await showDialog<double>(
|
||||
context: context,
|
||||
builder: (context) => SliderDialog(
|
||||
title: '倾斜角度阈值',
|
||||
min: 10.0,
|
||||
max: 90.0,
|
||||
divisions: 80,
|
||||
precise: 0,
|
||||
value: Pref.angleDegrees.toDouble(),
|
||||
suffix: '°',
|
||||
),
|
||||
);
|
||||
if (res != null) {
|
||||
await GStorage.setting.put(SettingBoxKey.angleDegrees, res.toInt());
|
||||
setState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,7 +487,9 @@ class PlPlayerController with BlockConfigMixin {
|
||||
PlPlayerController._() {
|
||||
if (PlatformUtils.isMobile) {
|
||||
_orientationListener = NativeDeviceOrientationPlatform.instance
|
||||
.onOrientationChanged(useSensor: Platform.isAndroid)
|
||||
.onOrientationChanged(
|
||||
angleDegrees: Platform.isAndroid ? Pref.angleDegrees : null,
|
||||
)
|
||||
.listen(_onOrientationChanged);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ abstract final class SettingBoxKey {
|
||||
followOrderType = 'followOrderType',
|
||||
enableImgMenu = 'enableImgMenu',
|
||||
touchSlopH = 'touchSlopH',
|
||||
floatingNavBar = 'floatingNavBar';
|
||||
floatingNavBar = 'floatingNavBar',
|
||||
angleDegrees = 'angleDegrees';
|
||||
|
||||
static const String windowSize = 'windowSize',
|
||||
windowPosition = 'windowPosition',
|
||||
|
||||
@@ -518,4 +518,7 @@ abstract final class Pref {
|
||||
|
||||
static bool get floatingNavBar =>
|
||||
_setting.get(SettingBoxKey.floatingNavBar, defaultValue: false);
|
||||
|
||||
static int get angleDegrees =>
|
||||
_setting.get(SettingBoxKey.angleDegrees, defaultValue: 30);
|
||||
}
|
||||
|
||||
@@ -1203,7 +1203,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: a987a459f17af0002397e49800ba4f68912b375c
|
||||
resolved-ref: "2c74f4d534dfd9b8f66382f82b3540f32be9abd9"
|
||||
url: "https://github.com/bggRGjQaUbCoE/flutter_native_device_orientation.git"
|
||||
source: git
|
||||
version: "2.0.5"
|
||||
|
||||
Reference in New Issue
Block a user