From b04c3d878df4b10dc160bf502e546868ba0cadef Mon Sep 17 00:00:00 2001 From: dom Date: Mon, 18 May 2026 14:50:53 +0800 Subject: [PATCH] custom angle degree Closes #2140 Signed-off-by: dom --- lib/pages/setting/models/play_settings.dart | 32 ++++++++++++++++++++- lib/plugin/pl_player/controller.dart | 1 + lib/utils/storage_key.dart | 3 +- lib/utils/storage_pref.dart | 3 ++ pubspec.lock | 2 +- 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/pages/setting/models/play_settings.dart b/lib/pages/setting/models/play_settings.dart index c240ef005..bffc4e1fd 100644 --- a/lib/pages/setting/models/play_settings.dart +++ b/lib/pages/setting/models/play_settings.dart @@ -1,4 +1,4 @@ -import 'dart:io'; +import 'dart:io' show Platform; import 'package:PiliPlus/common/widgets/custom_icon.dart'; import 'package:PiliPlus/models/common/super_chat_type.dart'; @@ -7,6 +7,7 @@ import 'package:PiliPlus/pages/main/controller.dart'; import 'package:PiliPlus/pages/setting/models/model.dart'; import 'package:PiliPlus/pages/setting/pages/fullscreen_sc_size.dart'; import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart'; +import 'package:PiliPlus/pages/setting/widgets/slider_dialog.dart'; import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart'; import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart'; import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart'; @@ -42,6 +43,13 @@ List get playSettings => [ title: '倍速设置', subtitle: '设置视频播放速度', ), + if (Platform.isAndroid) + NormalModel( + onTap: _showAngleDegreesDialog, + leading: const Icon(MdiIcons.angleAcute), + title: '倾斜角度阈值', + getSubtitle: () => '当前:「${Pref.angleDegrees}°」', + ), const SwitchModel( title: '自动播放', subtitle: '进入详情页自动播放', @@ -346,3 +354,25 @@ Future _showProgressBehaviorDialog( setState(); } } + +Future _showAngleDegreesDialog( + BuildContext context, + VoidCallback setState, +) async { + final res = await showDialog( + context: context, + builder: (context) => SliderDialog( + title: '倾斜角度阈值', + min: 10.0, + max: 90.0, + divisions: 90, + precise: 0, + value: Pref.angleDegrees.toDouble(), + suffix: '°', + ), + ); + if (res != null) { + await GStorage.setting.put(SettingBoxKey.angleDegrees, res.toInt()); + setState(); + } +} diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index d999691c8..570871bc9 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -570,6 +570,7 @@ class PlPlayerController with BlockConfigMixin { .onOrientationChanged( useSensor: Platform.isAndroid, checkIsAutoRotate: checkIsAutoRotate, + angleDegrees: Platform.isAndroid ? Pref.angleDegrees : null, ) .listen(_onOrientationChanged); } diff --git a/lib/utils/storage_key.dart b/lib/utils/storage_key.dart index a67fb8522..df3858fe0 100644 --- a/lib/utils/storage_key.dart +++ b/lib/utils/storage_key.dart @@ -151,7 +151,8 @@ abstract final class SettingBoxKey { showDynDispute = 'showDynDispute', touchSlopH = 'touchSlopH', floatingNavBar = 'floatingNavBar', - removeSafeArea = 'removeSafeArea'; + removeSafeArea = 'removeSafeArea', + angleDegrees = 'angleDegrees'; static const String minimizeOnExit = 'minimizeOnExit', windowSize = 'windowSize', diff --git a/lib/utils/storage_pref.dart b/lib/utils/storage_pref.dart index 64f3eba6d..b212baf76 100644 --- a/lib/utils/storage_pref.dart +++ b/lib/utils/storage_pref.dart @@ -982,4 +982,7 @@ abstract final class Pref { static bool get removeSafeArea => _setting.get(SettingBoxKey.removeSafeArea, defaultValue: false); + + static int get angleDegrees => + _setting.get(SettingBoxKey.angleDegrees, defaultValue: 30); } diff --git a/pubspec.lock b/pubspec.lock index 076be8a14..3aa7a30c8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1252,7 +1252,7 @@ packages: description: path: "." ref: master - resolved-ref: a987a459f17af0002397e49800ba4f68912b375c + resolved-ref: "9cbe7c07a697a199b36ab050248091a3aab8dd3f" url: "https://github.com/bggRGjQaUbCoE/flutter_native_device_orientation.git" source: git version: "2.0.5"