mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-29 07:34:13 +01:00
feat(player): offer the whole cover in the full screen style
A full screen cover is cropped at the sides so it reaches down to the title: about a fifth of its width on a tall phone. A tester pointed at covers that lose their lettering or their frame that way. Playback settings, under Cover art, gain Whole cover (off by default). With it on the cover stays square at the full width and ends above the title, in both styles: in Material it fades into the blurred cover behind the page, in Mornye into its soft copy and then the page colour, as a square video already does. Cover fade applies to it as before. The switch is disabled while the cover is a card. Motion artwork keeps its own shape either way.
This commit is contained in:
1 parent
272b821db0
commit
d55798addb
10 files changed
+146
-4
No files matched your search
@@ -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"
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -108,6 +108,7 @@ AppSettings _$AppSettingsFromJson(Map<String, dynamic> 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<String, dynamic> _$AppSettingsToJson(
|
||||
'musicHapticsStrength': instance.musicHapticsStrength,
|
||||
'playerCoverStyle': instance.playerCoverStyle,
|
||||
'playerCoverFade': instance.playerCoverFade,
|
||||
'playerCoverWhole': instance.playerCoverWhole,
|
||||
'landscapeLyricsArtwork': instance.landscapeLyricsArtwork,
|
||||
'autoHideLyricsControls': instance.autoHideLyricsControls,
|
||||
'autoHideLyricsControlsWithAccessibility':
|
||||
|
||||
@@ -740,6 +740,9 @@ class SettingsNotifier extends Notifier<AppSettings> {
|
||||
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));
|
||||
|
||||
|
||||
@@ -366,6 +366,9 @@ class _NowPlayingScreenState extends ConsumerState<NowPlayingScreen> {
|
||||
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<NowPlayingScreen> {
|
||||
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<NowPlayingScreen> {
|
||||
mediaItem,
|
||||
fullScreenCover: fullScreenCover,
|
||||
coverFade: coverFade,
|
||||
wholeCover: wholeCover,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -399,6 +404,7 @@ class _NowPlayingScreenState extends ConsumerState<NowPlayingScreen> {
|
||||
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<NowPlayingScreen> {
|
||||
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<NowPlayingScreen> {
|
||||
MaterialPlayerBackdrop.mediumFadeStart,
|
||||
coverFade,
|
||||
),
|
||||
wholeCover: wholeCover,
|
||||
playsMotionArtwork: true,
|
||||
videoUrl: motionArtwork?.source,
|
||||
resolvingVideo: motionState?.isLoading == true,
|
||||
|
||||
@@ -517,6 +517,16 @@ class _PlaybackSettingsPageState extends ConsumerState<PlaybackSettingsPage>
|
||||
.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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<MornyePlayerBackground>(
|
||||
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 {
|
||||
|
||||
@@ -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<String, dynamic>,
|
||||
);
|
||||
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', () {
|
||||
|
||||
Reference in new issue
Block a user