A cross platform Audiobookshelf client for Android and iOS
Dart
Add a setting to lock the screen in portrait
Barnabase8695d7b05b3
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex 5f88dbfd..8e2017b2 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -25,7 +25,7 @@ import '../widgets/update_dialog.dart';import '../screens/admin_screen.dart';import '../screens/downloads_screen.dart';import '../screens/bookmarks_screen.dart';-import '../main.dart' show applyThemeMode, applyTrustAllCerts, applyFlatBackground, applyColorSource, applyManualSeed, applyGradientIntensity, applyUseColorEverywhere, localeNotifier, flatNotifier, gradientIntensityNotifier, snappyTransitionsNotifier;+import '../main.dart' show applyThemeMode, applyTrustAllCerts, applyFlatBackground, applyColorSource, applyManualSeed, applyGradientIntensity, applyUseColorEverywhere, applyOrientationLock, localeNotifier, flatNotifier, gradientIntensityNotifier, snappyTransitionsNotifier;import '../services/wording.dart';import '../widgets/absorb_page_header.dart';import '../widgets/theme_presets.dart';@@ -108,6 +108,7 @@ class _SettingsScreenState extends State<SettingsScreen> {bool _showExplicitBadge = true;bool _loggingEnabled = false;bool _fullScreenPlayer = false;+ bool _lockPortrait = false;// card button layout is now managed in the edit sheet (more menu)bool _snappyTransitions = false;bool _classicWording = false;@@ -701,8 +702,10 @@ class _SettingsScreenState extends State<SettingsScreen> {final rmabBaseUrl = await ScopedPrefs.getString(kRmabBaseUrlKey);final rmabApiToken = await ScopedPrefs.getString(kRmabApiTokenKey);final sleepRewind = await PlayerSettings.getSleepRewindSeconds();+ final lockPortrait = await PlayerSettings.getLockPortrait();if (mounted) setState(() {_sleepRewindSeconds = sleepRewind;+ _lockPortrait = lockPortrait;_rmabBaseUrl = rmabBaseUrl;_rmabApiToken = rmabApiToken;_rewindSettings = s;@@ -1339,6 +1342,21 @@ class _SettingsScreenState extends State<SettingsScreen> {classicWordingNotifier.value = v;} : null,),+ const Divider(height: 1, indent: 16, endIndent: 16),+ SwitchListTile(+ title: const Text('Lock rotation'),+ subtitle: Text(+ _lockPortrait+ ? 'Screen stays in portrait'+ : 'Screen can rotate with the device',+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),+ value: _lockPortrait,+ onChanged: _loaded ? (v) {+ setState(() => _lockPortrait = v);+ PlayerSettings.setLockPortrait(v);+ applyOrientationLock();+ } : null,+ ),],),const SizedBox(height: 16),diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex 0b391fde..b70820f3 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -471,6 +471,11 @@ class PlayerSettings {static Future<bool> getFullScreenPlayer() => _get('fullScreenPlayer', false);static Future<void> setFullScreenPlayer(bool value) => _set('fullScreenPlayer', value);+ /// When on, the screen is locked to portrait (rotation disabled). Default off+ /// keeps the current behaviour where all orientations are allowed.+ static Future<bool> getLockPortrait() => _get('lockPortrait', false);+ static Future<void> setLockPortrait(bool value) => _set('lockPortrait', value);+static Future<bool> getSnappyTransitions() => _get('snappyTransitions', false);static Future<void> setSnappyTransitions(bool value) => _set('snappyTransitions', value);