From f85fdd542ded7b4094f5fe3bffff0e1f942506f3 Mon Sep 17 00:00:00 2001 From: PartyDonut Date: Sat, 2 Nov 2024 18:04:18 +0100 Subject: [PATCH 1/3] feature: Added option to force the player in certain orientation --- .../settings/video_player_settings.dart | 2 + .../video_player_settings.freezed.dart | 35 ++++++++++- .../settings/video_player_settings.g.dart | 13 +++++ lib/providers/library_filters_provider.g.dart | 2 +- .../video_player_settings_provider.dart | 4 ++ lib/providers/user_provider.g.dart | 2 +- .../settings/player_settings_page.dart | 6 ++ .../video_player_options_sheet.dart | 58 +++++++++++++++++++ lib/screens/video_player/video_player.dart | 13 +++++ lib/util/device_orientation_extension.dart | 11 ++++ 10 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 lib/util/device_orientation_extension.dart diff --git a/lib/models/settings/video_player_settings.dart b/lib/models/settings/video_player_settings.dart index 0f924df5..d289d5d7 100644 --- a/lib/models/settings/video_player_settings.dart +++ b/lib/models/settings/video_player_settings.dart @@ -1,5 +1,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; @@ -20,6 +21,7 @@ class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel { @Default(true) bool hardwareAccel, @Default(false) bool useLibass, @Default(100) double internalVolume, + Set? allowedOrientations, @Default(AutoNextType.static) AutoNextType nextVideoType, String? audioDevice, }) = _VideoPlayerSettingsModel; diff --git a/lib/models/settings/video_player_settings.freezed.dart b/lib/models/settings/video_player_settings.freezed.dart index d9356d77..23d854d8 100644 --- a/lib/models/settings/video_player_settings.freezed.dart +++ b/lib/models/settings/video_player_settings.freezed.dart @@ -27,6 +27,8 @@ mixin _$VideoPlayerSettingsModel { bool get hardwareAccel => throw _privateConstructorUsedError; bool get useLibass => throw _privateConstructorUsedError; double get internalVolume => throw _privateConstructorUsedError; + Set? get allowedOrientations => + throw _privateConstructorUsedError; AutoNextType get nextVideoType => throw _privateConstructorUsedError; String? get audioDevice => throw _privateConstructorUsedError; @@ -53,6 +55,7 @@ abstract class $VideoPlayerSettingsModelCopyWith<$Res> { bool hardwareAccel, bool useLibass, double internalVolume, + Set? allowedOrientations, AutoNextType nextVideoType, String? audioDevice}); } @@ -79,6 +82,7 @@ class _$VideoPlayerSettingsModelCopyWithImpl<$Res, Object? hardwareAccel = null, Object? useLibass = null, Object? internalVolume = null, + Object? allowedOrientations = freezed, Object? nextVideoType = null, Object? audioDevice = freezed, }) { @@ -107,6 +111,10 @@ class _$VideoPlayerSettingsModelCopyWithImpl<$Res, ? _value.internalVolume : internalVolume // ignore: cast_nullable_to_non_nullable as double, + allowedOrientations: freezed == allowedOrientations + ? _value.allowedOrientations + : allowedOrientations // ignore: cast_nullable_to_non_nullable + as Set?, nextVideoType: null == nextVideoType ? _value.nextVideoType : nextVideoType // ignore: cast_nullable_to_non_nullable @@ -135,6 +143,7 @@ abstract class _$$VideoPlayerSettingsModelImplCopyWith<$Res> bool hardwareAccel, bool useLibass, double internalVolume, + Set? allowedOrientations, AutoNextType nextVideoType, String? audioDevice}); } @@ -160,6 +169,7 @@ class __$$VideoPlayerSettingsModelImplCopyWithImpl<$Res> Object? hardwareAccel = null, Object? useLibass = null, Object? internalVolume = null, + Object? allowedOrientations = freezed, Object? nextVideoType = null, Object? audioDevice = freezed, }) { @@ -188,6 +198,10 @@ class __$$VideoPlayerSettingsModelImplCopyWithImpl<$Res> ? _value.internalVolume : internalVolume // ignore: cast_nullable_to_non_nullable as double, + allowedOrientations: freezed == allowedOrientations + ? _value._allowedOrientations + : allowedOrientations // ignore: cast_nullable_to_non_nullable + as Set?, nextVideoType: null == nextVideoType ? _value.nextVideoType : nextVideoType // ignore: cast_nullable_to_non_nullable @@ -211,9 +225,11 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel this.hardwareAccel = true, this.useLibass = false, this.internalVolume = 100, + final Set? allowedOrientations, this.nextVideoType = AutoNextType.static, this.audioDevice}) - : super._(); + : _allowedOrientations = allowedOrientations, + super._(); factory _$VideoPlayerSettingsModelImpl.fromJson(Map json) => _$$VideoPlayerSettingsModelImplFromJson(json); @@ -235,6 +251,17 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel @override @JsonKey() final double internalVolume; + final Set? _allowedOrientations; + @override + Set? get allowedOrientations { + final value = _allowedOrientations; + if (value == null) return null; + if (_allowedOrientations is EqualUnmodifiableSetView) + return _allowedOrientations; + // ignore: implicit_dynamic_type + return EqualUnmodifiableSetView(value); + } + @override @JsonKey() final AutoNextType nextVideoType; @@ -243,7 +270,7 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'VideoPlayerSettingsModel(screenBrightness: $screenBrightness, videoFit: $videoFit, fillScreen: $fillScreen, hardwareAccel: $hardwareAccel, useLibass: $useLibass, internalVolume: $internalVolume, nextVideoType: $nextVideoType, audioDevice: $audioDevice)'; + return 'VideoPlayerSettingsModel(screenBrightness: $screenBrightness, videoFit: $videoFit, fillScreen: $fillScreen, hardwareAccel: $hardwareAccel, useLibass: $useLibass, internalVolume: $internalVolume, allowedOrientations: $allowedOrientations, nextVideoType: $nextVideoType, audioDevice: $audioDevice)'; } @override @@ -257,6 +284,7 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel ..add(DiagnosticsProperty('hardwareAccel', hardwareAccel)) ..add(DiagnosticsProperty('useLibass', useLibass)) ..add(DiagnosticsProperty('internalVolume', internalVolume)) + ..add(DiagnosticsProperty('allowedOrientations', allowedOrientations)) ..add(DiagnosticsProperty('nextVideoType', nextVideoType)) ..add(DiagnosticsProperty('audioDevice', audioDevice)); } @@ -286,6 +314,7 @@ abstract class _VideoPlayerSettingsModel extends VideoPlayerSettingsModel { final bool hardwareAccel, final bool useLibass, final double internalVolume, + final Set? allowedOrientations, final AutoNextType nextVideoType, final String? audioDevice}) = _$VideoPlayerSettingsModelImpl; _VideoPlayerSettingsModel._() : super._(); @@ -306,6 +335,8 @@ abstract class _VideoPlayerSettingsModel extends VideoPlayerSettingsModel { @override double get internalVolume; @override + Set? get allowedOrientations; + @override AutoNextType get nextVideoType; @override String? get audioDevice; diff --git a/lib/models/settings/video_player_settings.g.dart b/lib/models/settings/video_player_settings.g.dart index 879e8af6..237d071f 100644 --- a/lib/models/settings/video_player_settings.g.dart +++ b/lib/models/settings/video_player_settings.g.dart @@ -16,6 +16,9 @@ _$VideoPlayerSettingsModelImpl _$$VideoPlayerSettingsModelImplFromJson( hardwareAccel: json['hardwareAccel'] as bool? ?? true, useLibass: json['useLibass'] as bool? ?? false, internalVolume: (json['internalVolume'] as num?)?.toDouble() ?? 100, + allowedOrientations: (json['allowedOrientations'] as List?) + ?.map((e) => $enumDecode(_$DeviceOrientationEnumMap, e)) + .toSet(), nextVideoType: $enumDecodeNullable(_$AutoNextTypeEnumMap, json['nextVideoType']) ?? AutoNextType.static, @@ -31,6 +34,9 @@ Map _$$VideoPlayerSettingsModelImplToJson( 'hardwareAccel': instance.hardwareAccel, 'useLibass': instance.useLibass, 'internalVolume': instance.internalVolume, + 'allowedOrientations': instance.allowedOrientations + ?.map((e) => _$DeviceOrientationEnumMap[e]!) + .toList(), 'nextVideoType': _$AutoNextTypeEnumMap[instance.nextVideoType]!, 'audioDevice': instance.audioDevice, }; @@ -45,6 +51,13 @@ const _$BoxFitEnumMap = { BoxFit.scaleDown: 'scaleDown', }; +const _$DeviceOrientationEnumMap = { + DeviceOrientation.portraitUp: 'portraitUp', + DeviceOrientation.landscapeLeft: 'landscapeLeft', + DeviceOrientation.portraitDown: 'portraitDown', + DeviceOrientation.landscapeRight: 'landscapeRight', +}; + const _$AutoNextTypeEnumMap = { AutoNextType.off: 'off', AutoNextType.smart: 'smart', diff --git a/lib/providers/library_filters_provider.g.dart b/lib/providers/library_filters_provider.g.dart index 0fe29511..9a87aaa7 100644 --- a/lib/providers/library_filters_provider.g.dart +++ b/lib/providers/library_filters_provider.g.dart @@ -6,7 +6,7 @@ part of 'library_filters_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$libraryFiltersHash() => r'7b4661651df7e0c019dca5bb7eb6433bcd8b3ebb'; +String _$libraryFiltersHash() => r'fd98699d8d7c1db6daefa6e53d5d90f989a8f776'; /// Copied from Dart SDK class _SystemHash { diff --git a/lib/providers/settings/video_player_settings_provider.dart b/lib/providers/settings/video_player_settings_provider.dart index c69407a2..0d7e7e50 100644 --- a/lib/providers/settings/video_player_settings_provider.dart +++ b/lib/providers/settings/video_player_settings_provider.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:screen_brightness/screen_brightness.dart'; @@ -63,4 +64,7 @@ class VideoPlayerSettingsProviderNotifier extends StateNotifier? orientation) => + state = state.copyWith(allowedOrientations: orientation); } diff --git a/lib/providers/user_provider.g.dart b/lib/providers/user_provider.g.dart index c632907e..ac9b4519 100644 --- a/lib/providers/user_provider.g.dart +++ b/lib/providers/user_provider.g.dart @@ -22,7 +22,7 @@ final showSyncButtonProviderProvider = AutoDisposeProvider.internal( ); typedef ShowSyncButtonProviderRef = AutoDisposeProviderRef; -String _$userHash() => r'418b3d4ade830479db9f48c7793ac5b646778b82'; +String _$userHash() => r'e83369c0d569d5a862aa1b92f3f0a45a9d1fe446'; /// See also [User]. @ProviderFor(User) diff --git a/lib/screens/settings/player_settings_page.dart b/lib/screens/settings/player_settings_page.dart index 65ce4a12..fec51b94 100644 --- a/lib/screens/settings/player_settings_page.dart +++ b/lib/screens/settings/player_settings_page.dart @@ -14,6 +14,7 @@ import 'package:fladder/screens/settings/widgets/settings_label_divider.dart'; import 'package:fladder/screens/settings/widgets/settings_message_box.dart'; import 'package:fladder/screens/settings/widgets/subtitle_editor.dart'; import 'package:fladder/screens/shared/animated_fade_size.dart'; +import 'package:fladder/screens/video_player/components/video_player_options_sheet.dart'; import 'package:fladder/util/adaptive_layout.dart'; import 'package:fladder/util/box_fit_extension.dart'; import 'package:fladder/util/localization_helper.dart'; @@ -151,6 +152,11 @@ class _PlayerSettingsPageState extends ConsumerState { ); }, ), + SettingsListTile( + label: Text("Force orientation"), + subLabel: Text("Allowed rotations when playing video"), + onTap: () => showOrientationOptions(context, ref), + ), ], ), ); diff --git a/lib/screens/video_player/components/video_player_options_sheet.dart b/lib/screens/video_player/components/video_player_options_sheet.dart index 396ff7a7..996f3414 100644 --- a/lib/screens/video_player/components/video_player_options_sheet.dart +++ b/lib/screens/video_player/components/video_player_options_sheet.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:collection/collection.dart'; import 'package:ficonsax/ficonsax.dart'; @@ -176,6 +177,10 @@ class _VideoOptionsMobileState extends ConsumerState { ], ), ), + SpacedListTile( + title: Text("Orientations"), + onTap: () => showOrientationOptions(context, ref), + ), ListTile( onTap: () { Navigator.of(context).pop(); @@ -492,3 +497,56 @@ Future showPlaybackSpeed(BuildContext context) { }, ); } + +Future showOrientationOptions(BuildContext context, WidgetRef ref) async { + Set? orientations = + ref.read(videoPlayerSettingsProvider.select((value) => value.allowedOrientations)); + + void toggleOrientation(DeviceOrientation orientation) { + final allowedOrientations = (orientations ?? {}).toSet(); + + if (allowedOrientations.contains(orientation)) { + allowedOrientations.remove(orientation); + } else { + allowedOrientations.add(orientation); + } + + orientations = allowedOrientations; + } + + await showDialog( + context: context, + builder: (context) { + return StatefulBuilder(builder: (context, state) { + return SimpleDialog( + contentPadding: const EdgeInsets.only(top: 8, bottom: 24), + title: Row(children: [Text(context.localized.playbackRate)]), + children: [ + const Divider(), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 12).copyWith(top: 6), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + ...DeviceOrientation.values.map( + (orientation) => CheckboxListTile.adaptive( + title: Text(orientation.name), + value: orientations == null ? true : orientations?.contains(orientation), + onChanged: (value) { + state(() => toggleOrientation(orientation)); + }, + ), + ) + ].addInBetween(const SizedBox(width: 8)), + ), + ) + ], + ); + }); + }, + ); + + ref.read(videoPlayerSettingsProvider.notifier).toggleOrientation(orientations?.isEmpty == true ? null : orientations); +} diff --git a/lib/screens/video_player/video_player.dart b/lib/screens/video_player/video_player.dart index 951d674e..4a380303 100644 --- a/lib/screens/video_player/video_player.dart +++ b/lib/screens/video_player/video_player.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:media_kit_video/media_kit_video.dart'; @@ -49,6 +50,7 @@ class _VideoPlayerState extends ConsumerState with WidgetsBindingOb @override void dispose() { WidgetsBinding.instance.removeObserver(this); + SystemChrome.setPreferredOrientations(DeviceOrientation.values); super.dispose(); } @@ -58,6 +60,8 @@ class _VideoPlayerState extends ConsumerState with WidgetsBindingOb WidgetsBinding.instance.addObserver(this); Future.microtask(() { ref.read(mediaPlaybackProvider.notifier).update((state) => state.copyWith(state: VideoPlayerState.fullScreen)); + final orientations = ref.read(videoPlayerSettingsProvider.select((value) => value.allowedOrientations)); + SystemChrome.setPreferredOrientations(orientations?.toList() ?? DeviceOrientation.values); return ref.read(videoPlayerSettingsProvider.notifier).setSavedBrightness(); }); } @@ -70,6 +74,15 @@ class _VideoPlayerState extends ConsumerState with WidgetsBindingOb final playerController = ref.watch(videoPlayerProvider.select((value) => value.controller)); + ref.listen( + videoPlayerSettingsProvider.select((value) => value.allowedOrientations), + (previous, next) { + if (previous != next) { + SystemChrome.setPreferredOrientations(next?.toList() ?? DeviceOrientation.values); + } + }, + ); + return Material( color: Colors.black, child: Theme( diff --git a/lib/util/device_orientation_extension.dart b/lib/util/device_orientation_extension.dart new file mode 100644 index 00000000..7603135f --- /dev/null +++ b/lib/util/device_orientation_extension.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +extension DeviceOrientationExtension on DeviceOrientation { + String label(BuildContext context) => switch (this) { + DeviceOrientation.portraitUp => throw UnimplementedError(), + DeviceOrientation.landscapeLeft => throw UnimplementedError(), + DeviceOrientation.portraitDown => throw UnimplementedError(), + DeviceOrientation.landscapeRight => throw UnimplementedError(), + }; +} From 944b9c0bd8d6e3ada3b8f7fd186b7775a61716b9 Mon Sep 17 00:00:00 2001 From: PartyDonut Date: Sat, 2 Nov 2024 18:35:31 +0100 Subject: [PATCH 2/3] Added translations --- lib/l10n/app_en.arb | 8 +++- .../settings/player_settings_page.dart | 4 +- .../video_player_options_sheet.dart | 43 +++++++++++++------ lib/screens/video_player/video_player.dart | 5 ++- lib/util/device_orientation_extension.dart | 10 +++-- 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 17122dee..b22796bd 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1099,5 +1099,11 @@ "deleteFilterConfirmation": "Are you sure you want to delete this filter?", "libraryFiltersLimitReached" : "Filter limit reached (10) remove some filters", "libraryFiltersRemoveAll": "Remove all filters", - "libraryFiltersRemoveAllConfirm": "This will delete all saved filters for every library" + "libraryFiltersRemoveAllConfirm": "This will delete all saved filters for every library", + "playerSettingsOrientationTitle": "Player orientation", + "playerSettingsOrientationDesc": "Force the video player into certain orientations", + "deviceOrientationPortraitUp": "Portrait Up", + "deviceOrientationPortraitDown": "Portrait Down", + "deviceOrientationLandscapeLeft": "Landscape Left", + "deviceOrientationLandscapeRight": "Landscape Right" } diff --git a/lib/screens/settings/player_settings_page.dart b/lib/screens/settings/player_settings_page.dart index fec51b94..5fc56062 100644 --- a/lib/screens/settings/player_settings_page.dart +++ b/lib/screens/settings/player_settings_page.dart @@ -153,8 +153,8 @@ class _PlayerSettingsPageState extends ConsumerState { }, ), SettingsListTile( - label: Text("Force orientation"), - subLabel: Text("Allowed rotations when playing video"), + label: Text(context.localized.playerSettingsOrientationTitle), + subLabel: Text(context.localized.playerSettingsOrientationDesc), onTap: () => showOrientationOptions(context, ref), ), ], diff --git a/lib/screens/video_player/components/video_player_options_sheet.dart b/lib/screens/video_player/components/video_player_options_sheet.dart index 996f3414..833c4c52 100644 --- a/lib/screens/video_player/components/video_player_options_sheet.dart +++ b/lib/screens/video_player/components/video_player_options_sheet.dart @@ -20,6 +20,7 @@ import 'package:fladder/screens/playlists/add_to_playlists.dart'; import 'package:fladder/screens/video_player/components/video_player_queue.dart'; import 'package:fladder/screens/video_player/components/video_subtitle_controls.dart'; import 'package:fladder/util/adaptive_layout.dart'; +import 'package:fladder/util/device_orientation_extension.dart'; import 'package:fladder/util/list_padding.dart'; import 'package:fladder/util/localization_helper.dart'; import 'package:fladder/util/refresh_state.dart'; @@ -499,19 +500,17 @@ Future showPlaybackSpeed(BuildContext context) { } Future showOrientationOptions(BuildContext context, WidgetRef ref) async { - Set? orientations = - ref.read(videoPlayerSettingsProvider.select((value) => value.allowedOrientations)); + Set orientations = ref + .read(videoPlayerSettingsProvider + .select((value) => value.allowedOrientations ?? Set.from(DeviceOrientation.values))) + .toSet(); void toggleOrientation(DeviceOrientation orientation) { - final allowedOrientations = (orientations ?? {}).toSet(); - - if (allowedOrientations.contains(orientation)) { - allowedOrientations.remove(orientation); + if (orientations.contains(orientation) && orientations.length > 1) { + orientations.remove(orientation); } else { - allowedOrientations.add(orientation); + orientations.add(orientation); } - - orientations = allowedOrientations; } await showDialog( @@ -522,7 +521,6 @@ Future showOrientationOptions(BuildContext context, WidgetRef ref) async { contentPadding: const EdgeInsets.only(top: 8, bottom: 24), title: Row(children: [Text(context.localized.playbackRate)]), children: [ - const Divider(), Padding( padding: const EdgeInsets.symmetric(horizontal: 12).copyWith(top: 6), child: Column( @@ -530,14 +528,33 @@ Future showOrientationOptions(BuildContext context, WidgetRef ref) async { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ + const Divider(), ...DeviceOrientation.values.map( (orientation) => CheckboxListTile.adaptive( - title: Text(orientation.name), - value: orientations == null ? true : orientations?.contains(orientation), + title: Text(orientation.label(context)), + value: orientations.contains(orientation), onChanged: (value) { state(() => toggleOrientation(orientation)); }, ), + ), + const Divider(), + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + ElevatedButton( + onPressed: () => Navigator.of(context).pop(), + child: Text(context.localized.cancel), + ), + FilledButton( + onPressed: () { + Navigator.of(context).pop(); + ref.read(videoPlayerSettingsProvider.notifier).toggleOrientation(orientations); + }, + child: Text(context.localized.save), + ), + ].addInBetween(const SizedBox(width: 8)), ) ].addInBetween(const SizedBox(width: 8)), ), @@ -547,6 +564,4 @@ Future showOrientationOptions(BuildContext context, WidgetRef ref) async { }); }, ); - - ref.read(videoPlayerSettingsProvider.notifier).toggleOrientation(orientations?.isEmpty == true ? null : orientations); } diff --git a/lib/screens/video_player/video_player.dart b/lib/screens/video_player/video_player.dart index 4a380303..183ac8f9 100644 --- a/lib/screens/video_player/video_player.dart +++ b/lib/screens/video_player/video_player.dart @@ -61,7 +61,8 @@ class _VideoPlayerState extends ConsumerState with WidgetsBindingOb Future.microtask(() { ref.read(mediaPlaybackProvider.notifier).update((state) => state.copyWith(state: VideoPlayerState.fullScreen)); final orientations = ref.read(videoPlayerSettingsProvider.select((value) => value.allowedOrientations)); - SystemChrome.setPreferredOrientations(orientations?.toList() ?? DeviceOrientation.values); + SystemChrome.setPreferredOrientations( + orientations?.isNotEmpty == true ? orientations!.toList() : DeviceOrientation.values); return ref.read(videoPlayerSettingsProvider.notifier).setSavedBrightness(); }); } @@ -78,7 +79,7 @@ class _VideoPlayerState extends ConsumerState with WidgetsBindingOb videoPlayerSettingsProvider.select((value) => value.allowedOrientations), (previous, next) { if (previous != next) { - SystemChrome.setPreferredOrientations(next?.toList() ?? DeviceOrientation.values); + SystemChrome.setPreferredOrientations(next?.isNotEmpty == true ? next!.toList() : DeviceOrientation.values); } }, ); diff --git a/lib/util/device_orientation_extension.dart b/lib/util/device_orientation_extension.dart index 7603135f..f79c07ac 100644 --- a/lib/util/device_orientation_extension.dart +++ b/lib/util/device_orientation_extension.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:fladder/util/localization_helper.dart'; + extension DeviceOrientationExtension on DeviceOrientation { String label(BuildContext context) => switch (this) { - DeviceOrientation.portraitUp => throw UnimplementedError(), - DeviceOrientation.landscapeLeft => throw UnimplementedError(), - DeviceOrientation.portraitDown => throw UnimplementedError(), - DeviceOrientation.landscapeRight => throw UnimplementedError(), + DeviceOrientation.portraitUp => context.localized.deviceOrientationPortraitUp, + DeviceOrientation.landscapeLeft => context.localized.deviceOrientationLandscapeLeft, + DeviceOrientation.portraitDown => context.localized.deviceOrientationPortraitDown, + DeviceOrientation.landscapeRight => context.localized.deviceOrientationLandscapeRight, }; } From e78cc98852e8aa2cef024c4b555ceeb58b1975a3 Mon Sep 17 00:00:00 2001 From: PartyDonut Date: Sat, 2 Nov 2024 18:41:21 +0100 Subject: [PATCH 3/3] removed settings from web and desktop --- lib/screens/settings/player_settings_page.dart | 11 ++++++----- .../components/video_player_options_sheet.dart | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/screens/settings/player_settings_page.dart b/lib/screens/settings/player_settings_page.dart index 5fc56062..15bb2b71 100644 --- a/lib/screens/settings/player_settings_page.dart +++ b/lib/screens/settings/player_settings_page.dart @@ -152,11 +152,12 @@ class _PlayerSettingsPageState extends ConsumerState { ); }, ), - SettingsListTile( - label: Text(context.localized.playerSettingsOrientationTitle), - subLabel: Text(context.localized.playerSettingsOrientationDesc), - onTap: () => showOrientationOptions(context, ref), - ), + if (!AdaptiveLayout.of(context).isDesktop && !kIsWeb) + SettingsListTile( + label: Text(context.localized.playerSettingsOrientationTitle), + subLabel: Text(context.localized.playerSettingsOrientationDesc), + onTap: () => showOrientationOptions(context, ref), + ), ], ), ); diff --git a/lib/screens/video_player/components/video_player_options_sheet.dart b/lib/screens/video_player/components/video_player_options_sheet.dart index 833c4c52..270fa3c3 100644 --- a/lib/screens/video_player/components/video_player_options_sheet.dart +++ b/lib/screens/video_player/components/video_player_options_sheet.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -178,10 +179,11 @@ class _VideoOptionsMobileState extends ConsumerState { ], ), ), - SpacedListTile( - title: Text("Orientations"), - onTap: () => showOrientationOptions(context, ref), - ), + if (!AdaptiveLayout.of(context).isDesktop && !kIsWeb) + SpacedListTile( + title: Text(context.localized.playerSettingsOrientationTitle), + onTap: () => showOrientationOptions(context, ref), + ), ListTile( onTap: () { Navigator.of(context).pop();