diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index ca2e74d52..10a4d3f97 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -9426,6 +9426,14 @@ "@playerCoverFadeLong": { "description": "Cover fade choice: the blur reaches far up the cover" }, + "playerCoverWhole": "Whole cover", + "@playerCoverWhole": { + "description": "Setting that shows a full screen cover without cropping its sides" + }, + "playerCoverWholeDescription": "Keep the sides of a full screen cover. It then ends above the title", + "@playerCoverWholeDescription": { + "description": "Subtitle of the Whole cover setting" + }, "musicHaptics": "Music haptics", "@musicHaptics": { "description": "Setting that vibrates the phone along with the music" diff --git a/lib/models/settings.dart b/lib/models/settings.dart index 033064f1a..6b42fc2da 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -297,6 +297,8 @@ class AppSettings { final String playerCoverStyle; // 'default' (card), 'fullscreen' or '' @JsonKey(fromJson: playerCoverFadeFromJson) final String playerCoverFade; // 'short', 'medium' or 'long' + /// A full screen cover keeps its sides, and so ends above the title. + final bool playerCoverWhole; final bool landscapeLyricsArtwork; final bool autoHideLyricsControls; @@ -596,6 +598,7 @@ class AppSettings { this.musicHapticsStrength = 0.5, this.playerCoverStyle = '', this.playerCoverFade = 'medium', + this.playerCoverWhole = false, this.landscapeLyricsArtwork = false, this.autoHideLyricsControls = true, this.autoHideLyricsControlsWithAccessibility = false, @@ -797,6 +800,7 @@ class AppSettings { double? musicHapticsStrength, String? playerCoverStyle, String? playerCoverFade, + bool? playerCoverWhole, bool? landscapeLyricsArtwork, bool? autoHideLyricsControls, bool? autoHideLyricsControlsWithAccessibility, @@ -977,6 +981,7 @@ class AppSettings { musicHapticsStrength: musicHapticsStrength ?? this.musicHapticsStrength, playerCoverStyle: playerCoverStyle ?? this.playerCoverStyle, playerCoverFade: playerCoverFade ?? this.playerCoverFade, + playerCoverWhole: playerCoverWhole ?? this.playerCoverWhole, landscapeLyricsArtwork: landscapeLyricsArtwork ?? this.landscapeLyricsArtwork, autoHideLyricsControls: diff --git a/lib/models/settings.g.dart b/lib/models/settings.g.dart index 012d6884e..3cb341483 100644 --- a/lib/models/settings.g.dart +++ b/lib/models/settings.g.dart @@ -108,6 +108,7 @@ AppSettings _$AppSettingsFromJson(Map json) => AppSettings( playerCoverFade: json['playerCoverFade'] == null ? 'medium' : playerCoverFadeFromJson(json['playerCoverFade']), + playerCoverWhole: json['playerCoverWhole'] as bool? ?? false, landscapeLyricsArtwork: json['landscapeLyricsArtwork'] as bool? ?? false, autoHideLyricsControls: json['autoHideLyricsControls'] as bool? ?? true, autoHideLyricsControlsWithAccessibility: @@ -320,6 +321,7 @@ Map _$AppSettingsToJson( 'musicHapticsStrength': instance.musicHapticsStrength, 'playerCoverStyle': instance.playerCoverStyle, 'playerCoverFade': instance.playerCoverFade, + 'playerCoverWhole': instance.playerCoverWhole, 'landscapeLyricsArtwork': instance.landscapeLyricsArtwork, 'autoHideLyricsControls': instance.autoHideLyricsControls, 'autoHideLyricsControlsWithAccessibility': diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index 934af2c53..7e0b1793a 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -740,6 +740,9 @@ class SettingsNotifier extends Notifier { void setPlayerCoverFade(String fade) => _commit(state.copyWith(playerCoverFade: playerCoverFadeFromJson(fade))); + void setPlayerCoverWhole(bool whole) => + _commit(state.copyWith(playerCoverWhole: whole)); + void setLandscapeLyricsArtwork(bool enabled) => _commit(state.copyWith(landscapeLyricsArtwork: enabled)); diff --git a/lib/screens/now_playing_screen.dart b/lib/screens/now_playing_screen.dart index a846d1b7e..026034e33 100644 --- a/lib/screens/now_playing_screen.dart +++ b/lib/screens/now_playing_screen.dart @@ -366,6 +366,9 @@ class _NowPlayingScreenState extends ConsumerState { final coverFade = ref.watch( settingsProvider.select((s) => s.playerCoverFade), ); + final wholeCover = ref.watch( + settingsProvider.select((s) => s.playerCoverWhole), + ); return LyricsScreenAwake( visible: _currentPage == 1 && mediaItem != null, child: mornye @@ -374,6 +377,7 @@ class _NowPlayingScreenState extends ConsumerState { mediaItem, fullScreenCover: fullScreenCover, coverFade: coverFade, + wholeCover: wholeCover, ) // Material takes the track's artwork scheme. The providers it needs // are read above, so the scoped builder reads none. A skip moves @@ -388,6 +392,7 @@ class _NowPlayingScreenState extends ConsumerState { mediaItem, fullScreenCover: fullScreenCover, coverFade: coverFade, + wholeCover: wholeCover, ), ), ), @@ -399,6 +404,7 @@ class _NowPlayingScreenState extends ConsumerState { MediaItem? mediaItem, { required bool fullScreenCover, required String coverFade, + required bool wholeCover, }) { final mornye = context.isMornye; final colorScheme = mornye @@ -468,10 +474,11 @@ class _NowPlayingScreenState extends ConsumerState { final fullBleed = mornye && (motionArtwork != null || fullScreenCover); final screen = MediaQuery.sizeOf(context); // A still cover is cropped at the sides to reach down to the title, as - // in the Material full-screen style; landscape keeps the square card. + // in the Material full-screen style; landscape keeps the square card, + // and so does the whole cover setting. final stillFullBleed = fullBleed && motionArtwork == null; final artworkRatio = stillFullBleed - ? _landscape || screen.height <= 0 + ? _landscape || wholeCover || screen.height <= 0 ? 1.0 : (screen.width / (screen.height * 0.56)).clamp(0.5, 1.0) : motionRatio; @@ -920,6 +927,7 @@ class _NowPlayingScreenState extends ConsumerState { MaterialPlayerBackdrop.mediumFadeStart, coverFade, ), + wholeCover: wholeCover, playsMotionArtwork: true, videoUrl: motionArtwork?.source, resolvingVideo: motionState?.isLoading == true, diff --git a/lib/screens/settings/playback_settings_page.dart b/lib/screens/settings/playback_settings_page.dart index b2d2fd3e0..54ebda2db 100644 --- a/lib/screens/settings/playback_settings_page.dart +++ b/lib/screens/settings/playback_settings_page.dart @@ -517,6 +517,16 @@ class _PlaybackSettingsPageState extends ConsumerState .read(settingsProvider.notifier) .setPlayerCoverFade(fade), ), + SettingsSwitchItem( + icon: Icons.fit_screen_outlined, + title: context.l10n.playerCoverWhole, + subtitle: context.l10n.playerCoverWholeDescription, + value: settings.playerCoverWhole, + enabled: coverStyle == 'fullscreen', + onChanged: (value) => ref + .read(settingsProvider.notifier) + .setPlayerCoverWhole(value), + ), SettingsSwitchItem( icon: Icons.splitscreen_outlined, title: context.l10n.landscapeLyricsArtwork, diff --git a/lib/utils/settings_search_catalog.dart b/lib/utils/settings_search_catalog.dart index fc9fbb43e..f41696314 100644 --- a/lib/utils/settings_search_catalog.dart +++ b/lib/utils/settings_search_catalog.dart @@ -455,6 +455,12 @@ class SettingsSearchCatalog { subtitle: l10n.playerCoverFadeDescription, keywords: const ['artwork', 'cover', 'blur', 'fade', 'gradient'], ), + SettingsSearchEntry( + icon: Icons.fit_screen_outlined, + title: l10n.playerCoverWhole, + subtitle: l10n.playerCoverWholeDescription, + keywords: const ['artwork', 'cover', 'crop', 'cut', 'fit', 'square'], + ), SettingsSearchEntry( icon: Icons.splitscreen_outlined, title: l10n.landscapeLyricsArtwork, diff --git a/lib/widgets/material_player_backdrop.dart b/lib/widgets/material_player_backdrop.dart index 5298956f9..ba2e0b30b 100644 --- a/lib/widgets/material_player_backdrop.dart +++ b/lib/widgets/material_player_backdrop.dart @@ -25,6 +25,7 @@ class MaterialPlayerBackdrop extends StatelessWidget { required this.colorScheme, required this.showArtwork, this.fadeStart = mediumFadeStart, + this.wholeCover = false, this.playsMotionArtwork = false, this.videoUrl, this.resolvingVideo = false, @@ -43,6 +44,9 @@ class MaterialPlayerBackdrop extends StatelessWidget { /// The share of the cover's height where it starts to fade into the blur. final double fadeStart; + /// Keeps the cover square, with its sides, so it ends above the title. + final bool wholeCover; + /// Plays [videoUrl] in place of the sharp cover, which shows until the /// video is ready. The phone player sets it; desktop keeps a still cover. final bool playsMotionArtwork; @@ -85,8 +89,8 @@ class MaterialPlayerBackdrop extends StatelessWidget { left: 0, right: 0, // Taller than wide on phones: the sides are cropped so the cover - // reaches down to the title instead of leaving an empty band. - height: size.width < size.height * 0.56 + // reaches down to the title, unless the whole cover is asked for. + height: !wholeCover && size.width < size.height * 0.56 ? size.height * 0.56 : size.width.clamp(0.0, size.height * 0.62), child: AnimatedOpacity( diff --git a/test/now_playing_lyrics_transition_test.dart b/test/now_playing_lyrics_transition_test.dart index 21d6fbc2b..b7e04aaf9 100644 --- a/test/now_playing_lyrics_transition_test.dart +++ b/test/now_playing_lyrics_transition_test.dart @@ -758,6 +758,46 @@ void main() { }); for (final mornye in [false, true]) { + testWidgets('the whole cover setting keeps a full screen cover square ' + '($mornye)', (tester) async { + await pumpNowPlaying( + tester, + theme: mornye ? MornyeTheme.build(Brightness.dark) : AppTheme.light(), + size: const Size(390, 844), + ); + mediaItems.add(item('first')); + await settlePlayer(tester); + final settings = ProviderScope.containerOf( + tester.element(find.byType(NowPlayingScreen)), + ).read(settingsProvider.notifier); + settings.setPlayerCoverStyle('fullscreen'); + await settlePlayer(tester); + // The cover's box: 390 wide, and cropped to reach 56% of the height. + Size cover() => mornye + ? Size( + 390, + 390 / + tester + .widget( + find.byType(MornyePlayerBackground), + ) + .artworkAspectRatio!, + ) + : tester.getSize( + find.descendant( + of: find.byType(MaterialPlayerBackdrop), + matching: find.byType(Hero), + ), + ); + expect(cover().width, 390); + expect(cover().height, closeTo(844 * 0.56, 0.01)); + settings.setPlayerCoverWhole(true); + await settlePlayer(tester); + expect(cover().width, 390); + expect(cover().height, closeTo(390, 0.01)); + expect(tester.takeException(), isNull); + }); + testWidgets('cover style switches live and survives rotation ($mornye)', ( tester, ) async { diff --git a/test/player_presentation_settings_test.dart b/test/player_presentation_settings_test.dart index 184f3a3c6..b5ba06071 100644 --- a/test/player_presentation_settings_test.dart +++ b/test/player_presentation_settings_test.dart @@ -152,6 +152,62 @@ void main() { ); expect(tester.takeException(), isNull); }); + + testWidgets('whole cover is off, then switched on, saved and searchable, ' + 'mornye $mornye', (tester) async { + SharedPreferences.setMockInitialValues({}); + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + expect(AppSettings.fromJson(const {}).playerCoverWhole, isFalse); + final container = ProviderContainer( + overrides: [ + initialSettingsProvider.overrideWithValue( + const AppSettings(playerCoverStyle: 'fullscreen'), + ), + ], + ); + addTearDown(container.dispose); + await tester.pumpWidget( + UncontrolledProviderScope( + container: container, + child: MaterialApp( + theme: mornye + ? MornyeTheme.build(Brightness.dark) + : AppTheme.light(), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: const PlaybackSettingsPage(), + ), + ), + ); + final title = find.text('Whole cover'); + await tester.scrollUntilVisible( + title, + 200, + scrollable: find.byType(Scrollable).first, + ); + await tester.ensureVisible(title); + await tester.pumpAndSettle(); + await tester.tap(title); + await tester.pumpAndSettle(); + expect(container.read(settingsProvider).playerCoverWhole, isTrue); + final prefs = await SharedPreferences.getInstance(); + final restored = AppSettings.fromJson( + jsonDecode(prefs.getString('app_settings')!) as Map, + ); + expect(restored.playerCoverWhole, isTrue); + final l10n = AppLocalizations.of(tester.element(title)); + expect( + SettingsSearchCatalog(l10n).playback.where( + (entry) => + entry.title == l10n.playerCoverWhole && + entry.matches(SettingsSearchQuery('crop')), + ), + hasLength(1), + ); + expect(tester.takeException(), isNull); + }); } test('fullscreen lyrics accessibility opt-in survives a round trip', () {