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: the album header no longer jumps when Play turns to Pause (#25)

My-Name-Is-Jeff53e9922ffccd
diff --git a/tweak/Sources/Redesigned/Album/AlbumHeader.x b/tweak/Sources/Redesigned/Album/AlbumHeader.x
index 8c54429a..76b8cc1b 100644
--- a/tweak/Sources/Redesigned/Album/AlbumHeader.x
+++ b/tweak/Sources/Redesigned/Album/AlbumHeader.x
@@ -416,6 +416,14 @@ static SGRHeaderInfo *applyInfo(UIView *header, UIView *page) {
setFrame(info, header.bounds);
UIView *title = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.TitleRow", &kTitleKey);
+ // Spotify's header grows and shrinks as its Play turns to Pause (issue #25), its title row does not.
+ if (title.window) {
+ CGFloat top = [title convertRect:title.bounds toView:header].origin.y;
+ if (fabs(top - info.pinnedTop) > 0.5) {
+ info.pinnedTop = top;
+ [info setNeedsLayout];
+ }
+ }
UIView *parent = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.ParentRow", &kParentKey);
UIView *metadata = SGRFindByIdentifier(header, @"Components.UI.MetadataRow", &kMetaKey);
NSString *length = metadataText(metadata);
diff --git a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h
index 6cb7dfd5..0aa02f53 100644
--- a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h
+++ b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h
@@ -10,7 +10,8 @@
// Its content sits on its bottom edge with SGRHeaderInfoBottom under it, whatever height the page gives it,
// so the buttons stay just above the first track; what does not fit rises over the picture. The page's
// picture reaches SGRHeaderInfoTitleRise below the content's top, so the title and the creator sit on the
-// bottom of its dissolve.
+// bottom of its dissolve. A page whose header changes height under it (the album's, a point or more as Play
+// turns to Pause, more with a taller font) pins the content's top instead (pinnedTop).
//
// Ownership: the page that adds it; it keeps only weak references to Spotify's controls.
// Threading: main thread only.
@@ -48,6 +49,9 @@ extern const CGFloat SGRHeaderInfoTitleRise; // 56, of the content over the pic
- (void)showTitleImage:(UIImage *)image;
// The height the content wants at `width`, from the top of the title to the bottom of the description.
- (CGFloat)contentHeightForWidth:(CGFloat)width;
+// Where the content starts, from the top; 0 keeps it on the bottom edge. Content that would then run past the
+// bottom goes back on the bottom edge.
+@property (nonatomic) CGFloat pinnedTop;
@end
// The image view of the leading face on Spotify's creator line `root` -- the playlist header's collaborators
diff --git a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m
index 758f9db2..b62b752d 100644
--- a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m
+++ b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m
@@ -278,7 +278,9 @@ UIImageView *SGRCreatorPicture(UIView *root) {
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat width = self.bounds.size.width, text = MAX(0, width - 2 * kSide);
- CGFloat y = round(self.bounds.size.height - SGRHeaderInfoBottom - [self contentHeightForWidth:width]);
+ CGFloat content = [self contentHeightForWidth:width];
+ CGFloat y = round(self.bounds.size.height - SGRHeaderInfoBottom - content);
+ if (self.pinnedTop > 0 && self.pinnedTop + content <= self.bounds.size.height) y = round(self.pinnedTop);
// No name, no picture: it belongs to the line.
_picture.hidden = !_picture.image || _creator.hidden;