Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

fix: a paused cover keeps its size while the redesigned player opens and closes

My-Name-Is-Jeffc44cb24de9ab
diff --git a/tweak/Sources/Redesigned/Player/Player.h b/tweak/Sources/Redesigned/Player/Player.h
index 3f7b8984..38198d64 100644
--- a/tweak/Sources/Redesigned/Player/Player.h
+++ b/tweak/Sources/Redesigned/Player/Player.h
@@ -59,6 +59,9 @@ UIView *SGRPlayerCoverList(void);
// The cover on screen as it is drawn, its paused shrink included, in `host`'s coordinates; CGRectNull
// when no cover has laid out.
CGRect SGRPlayerCoverFrameIn(UIView *host);
+// The scale the cover is drawn at: 1 while playing, its shrink while paused, so a stand-in can draw its
+// corners the size the cover's are.
+CGFloat SGRPlayerCoverScale(void);
// The band that cover sits in -- the room the player gives its artwork, between the header row and the
// title -- in `host`'s coordinates; CGRectNull when no cover has laid out.
CGRect SGRPlayerArtworkAreaIn(UIView *host);
diff --git a/tweak/Sources/Redesigned/Player/PlayerArtwork.x b/tweak/Sources/Redesigned/Player/PlayerArtwork.x
index 554f1163..49629ad5 100644
--- a/tweak/Sources/Redesigned/Player/PlayerArtwork.x
+++ b/tweak/Sources/Redesigned/Player/PlayerArtwork.x
@@ -8,9 +8,10 @@
// corners and the scale: the tilt view's own transform is left to the tilt Spotify gives it when the
// cover is inspected. The image clips, so the shadow is a plate of the Kit's behind it.
//
-// The scale is identity while the player opens or closes: the bar morphs into a 354pt stand-in
-// (NowPlaying_ECMKit.MaskView, 01.txt:86) and the cover under it has to match where it lands. Once
-// the transition is over a paused cover springs down.
+// A paused cover keeps its shrink while the player opens and closes: the morph flies the bar's cover to
+// the frame the cover is drawn at, transform included (SGRPlayerCoverFrameIn), so it lands at the size it
+// stays at. Holding it at full size through the transition made it land large and spring down after, or
+// grow before a close.
#import "Core/SGCore.h"
#import "Redesigned/Kit/SGRKit.h"
#import "Shared/Haptics/Haptics.h"
@@ -29,7 +30,7 @@ static NSMapTable<UIView *, UIView *> *sg_covers;
static CGFloat currentScale(void) {
SPTPlayerState *state = SGPlayerState();
- if (!state.isPaused || SGRPlayerIsTransitioning()) return 1;
+ if (!state.isPaused) return 1;
return SGRReduceMotion() ? kPausedScaleReduceMotion : kPausedScale;
}
@@ -92,6 +93,10 @@ CGRect SGRPlayerCoverFrameIn(UIView *host) {
return cover && host ? [host convertRect:cover.bounds fromView:cover] : CGRectNull;
}
+CGFloat SGRPlayerCoverScale(void) {
+ return currentScale();
+}
+
CGRect SGRPlayerArtworkAreaIn(UIView *host) {
UIView *tilt = showingTilt();
if (!tilt || !host) return CGRectNull;
@@ -358,13 +363,6 @@ static SGRPlayerArtworkWatcher *sg_artworkWatcher;
sg_covers = [NSMapTable weakToWeakObjectsMapTable];
sg_artworkWatcher = [SGRPlayerArtworkWatcher new];
SGAddPlayerStateObserver(sg_artworkWatcher);
- SGRObservePlayerTransition(sg_artworkWatcher, ^(id owner) {
- scaleEveryCover(YES);
- }, ^(id owner) {
- scaleEveryCover(YES);
- static dispatch_once_t once;
- dispatch_once(&once, ^{ SGLog(@"redesign player: transition over, cover scale %.2f", currentScale()); });
- });
SGRequireClasses(@[
@"_TtC35CreativeWorkCommons_CoverArtTiltKit16CoverArtTiltView",
@"_TtC28NowPlaying_ContentLayersImpl16CoverArtCellImpl",
diff --git a/tweak/Sources/Redesigned/Player/PlayerMorph.x b/tweak/Sources/Redesigned/Player/PlayerMorph.x
index d06959e1..f03d4999 100644
--- a/tweak/Sources/Redesigned/Player/PlayerMorph.x
+++ b/tweak/Sources/Redesigned/Player/PlayerMorph.x
@@ -191,7 +191,8 @@ static CGFloat screenRadius(void) {
}
to = CGRectOffset(to, -sheet.origin.x, -sheet.origin.y);
self->_cover.frame = CGRectOffset(lerpRect(from, to, t), sheet.origin.x, sheet.origin.y);
- self->_cover.layer.cornerRadius = lerp(from.size.width / 2, SGRRadiusArtwork * scale, t);
+ // The cover's corners are drawn under its paused shrink too.
+ self->_cover.layer.cornerRadius = lerp(from.size.width / 2, SGRRadiusArtwork * SGRPlayerCoverScale() * scale, t);
// Over an animated artwork the player's cover is hidden: the flown one fades out on the
// way there instead of landing on an empty slot.
self->_cover.alpha = SGRPlayerMotionShowing() ? 1 - ramp(0.6, 1, t) : 1;