Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: albums and singles get the playlist's header, the Kit's own view over Spotify's blanked column
Vojtěch Škopek307ba514564f
diff --git a/harness/album/README.md b/harness/album/README.mdindex 8c80f63e..fa378915 100644--- a/harness/album/README.md+++ b/harness/album/README.md@@ -25,6 +25,10 @@ At 1.5 s it measures the footer the way the page's collection does, asking everyanswers 0 for what it drops, and the log says how much footer was left (108pt of 1230pt, the album'sown line and its copyright).+Since 2026-09-18 the header is the Kit's `SGRHeaderInfo` over Spotify's blanked column, so what follows no+longer tests anything the redesign moves; it still shows Spotify's column staying blank. The metadata row's+cells arrive after the header's pass, which is what `AlbumHeader.x`'s re-read answers.+At 3.5 s it puts Spotify's own frames back on the title block, its stack and the action row and asksboth groups for a layout pass, which is what the redesign's `SGRObserveLayout` watches have to survive.The log says what the redesign answered with.diff --git a/harness/album/build.sh b/harness/album/build.shindex dd4182ce..31de3bdf 100755--- a/harness/album/build.sh+++ b/harness/album/build.sh@@ -19,7 +19,7 @@ xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-ar"$SRC"/Core/SGBackdrop.m "$SRC"/Core/SGFlagForce.m "$SRC"/Core/SGUIMode.m \"$SRC"/Redesigned/Kit/SGRTokens.m "$SRC"/Redesigned/Kit/SGRPalette.m "$SRC"/Redesigned/Kit/SGRField.m \"$SRC"/Redesigned/Kit/SGRGlass.m "$SRC"/Redesigned/Kit/SGRGlyph.m "$SRC"/Redesigned/Kit/SGRRestyle.m \- "$SRC"/Redesigned/Kit/SGRActionRow.m \+ "$SRC"/Redesigned/Kit/SGRActionRow.m "$SRC"/Redesigned/Kit/SGRHeaderInfo.m \"$SRC"/Redesigned/Kit/SGRedesign.m \-framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols \-o "$OUT/AlbumHarness.app/AlbumHarness"diff --git a/harness/playlist/build.sh b/harness/playlist/build.shindex 8dabb32c..495ad470 100755--- a/harness/playlist/build.sh+++ b/harness/playlist/build.sh@@ -19,7 +19,7 @@ xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-ar"$SRC"/Core/SGBackdrop.m "$SRC"/Core/SGFlagForce.m "$SRC"/Core/SGUIMode.m \"$SRC"/Redesigned/Kit/SGRTokens.m "$SRC"/Redesigned/Kit/SGRPalette.m "$SRC"/Redesigned/Kit/SGRField.m \"$SRC"/Redesigned/Kit/SGRGlass.m "$SRC"/Redesigned/Kit/SGRGlyph.m "$SRC"/Redesigned/Kit/SGRRestyle.m \- "$SRC"/Redesigned/Kit/SGRActionRow.m \+ "$SRC"/Redesigned/Kit/SGRActionRow.m "$SRC"/Redesigned/Kit/SGRHeaderInfo.m \"$SRC"/Redesigned/Kit/SGRedesign.m \-framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols \-o "$OUT/PlaylistHarness.app/PlaylistHarness"diff --git a/tweak/Sources/Redesigned/Album/Album.h b/tweak/Sources/Redesigned/Album/Album.hindex 9e30b776..2fb41656 100644--- a/tweak/Sources/Redesigned/Album/Album.h+++ b/tweak/Sources/Redesigned/Album/Album.h@@ -10,9 +10,8 @@//// AlbumField.x the artwork field behind the whole page, the artwork it is read from, the flags the// screen forces-// AlbumHeader.x the header: the cover full bleed at the top dissolving into the field, the title, the-// artist and the kind and date centred under it, and one row of glass controls ---// shuffle, a prominent Play capsule, add, and more where Spotify still has it+// AlbumHeader.x the header: the cover full bleed at the top dissolving into the field, and the Kit's+// SGRHeaderInfo over it -- title, artist, kind and date, shuffle, a white Play, add// AlbumRows.x the track rows on the field with no surface of their own and a hairline between them// AlbumSections.x everything under the tracks dropped but the album's own line and its copyright: no// more by the artist, no videos, no concerts, no merch, no you might also likediff --git a/tweak/Sources/Redesigned/Album/AlbumHeader.x b/tweak/Sources/Redesigned/Album/AlbumHeader.xindex cc1b1643..1d2764a6 100644--- a/tweak/Sources/Redesigned/Album/AlbumHeader.x+++ b/tweak/Sources/Redesigned/Album/AlbumHeader.x@@ -1,40 +1,29 @@-// Album redesign: the header the Music app gives an album. The cover runs full bleed across the top of the-// page and dissolves into the field under it, with no seam and no card; the title, the artist and the kind-// and date are centred under it; and one row of glass controls sits below them -- shuffle, a prominent Play-// capsule, add, and more where Spotify still keeps it in the page.+// Album redesign: the header the Music app gives an album (iOS 26.4), the same one the playlist redesign+// gives a playlist. The cover runs full bleed across the top of the page and dissolves into the page's+// colour; the title, the artist and the kind and date are centred on the bottom of that dissolve; and under+// them one row -- shuffle, a white Play capsule, and add.//// Tree (trees/clean/album/01.txt:39-152). The header is one element of the page's scrolling stack,-// id=CreativeWorkPlatform.Components.UI.CreativeWorkHeader, and everything in it is laid out by stack views-// down a chain of four:+// id=CreativeWorkPlatform.Components.UI.CreativeWorkHeader, a plain UIView whose height the element framework+// measures from what it holds, down a chain of four stack views://// UIView {0, 78} the top inset, the status bar and the navigation bar's room// UIStackView the two groups-// UIView 402x321 the top group-// UIStackView the cover row, a spacer, and the title block-// UIView 402x248 ArtWorkElement.WithCoverArt, the cover square centred in it-// UIView {0, 264} 215x57 the title block, its own stack inset 16pt from the leading edge:+// UIView 402x321 the top group: the cover square, a spacer, and the title block --// TitleRow, and ParentRow, the artist with a facepile-// UIView {0, 329} 402x71 the bottom group-// UIStackView the metadata row and the action row-// UIView 402x15 Components.UI.MetadataRow: the kind and the date-// UIStackView 206x48 explore, add, download and more+// UIView {0, 329} 402x71 the bottom group: Components.UI.MetadataRow (the kind and the date,+// cells of a collection view) and the action row//-// Whose layout pass. A view lays its children out, so a frame set from an ancestor's layoutSubviews is the-// one that is overwritten a moment later: each view moved here is taken again from a watch on its own-// parent's pass (the Kit's SGRObserveLayout), and the header's pass only finds them and starts the watch.-// Only plain UIKit classes can be watched, which every one of those stacks is; Spotify's own Swift views-// further down are never moved, only read.-//-// Centring costs width. A view moved to the middle of the page but left inside a parent that hugs its-// content is drawn there and takes no touches there, so the title block and the action row are widened to-// the page first and their contents centred inside them. Nothing else about the header's geometry changes:-// its height is the element framework's, measured from what it holds, and the page collapses, snaps and-// scrolls exactly as Spotify laid it out.+// What the header shows is the redesign's own (the Kit's SGRHeaderInfo), not Spotify's rearranged: moving+// Spotify's stacks meant answering every pass of theirs, and the element framework measured the title for+// its own font. So Spotify's whole column is concealed and the Kit's view is drawn over the header in its+// place, reading its text off Spotify's concealed labels -- so it is in the app's language and follows+// whatever Spotify shows -- and drawing and firing Spotify's own controls. The header keeps its height, its+// fade as the page scrolls and its place in the stack.//// Play and shuffle are not in the header. The album page floats them over the page, pinned to the top-// trailing corner outside the scroll (01.txt:1431, :1436), where a frame of the header's cannot reach them:-// they are concealed where they are and the row carries the Kit's stand-ins, which draw their glyph and-// fire them. Every other control of Spotify's stays its own, moved by frame and never rebuilt.+// trailing corner outside the scroll (01.txt:1431, :1436): they are concealed where they are, and the row+// draws them and fires them all the same.#import "Core/SGCore.h"#import "Redesigned/Kit/SGRKit.h"#import "Album.h"@@ -46,28 +35,31 @@ static const CGFloat kDissolve = 0.46, kTopScrim = 140, kTopScrimAlpha = 0.28;// and an artwork view narrower than this is a placeholder glyph rather than the cover.static const CGFloat kMinHero = 120, kMinCover = 80;-static char kHeaderKey, kCoverKey, kTitleKey, kParentKey, kMetaKey, kAddKey, kMoreKey, kPlayKey, kShuffleKey;-static char kGlassKey, kHeroKey, kHeroHeightKey, kCapsuleKey, kMirrorKey, kCoverWatchedKey;-static char kHeaderWatchedKey, kGroupWatchedKey, kBlockWatchedKey, kTitleWatchedKey;-static char kBottomWatchedKey, kActionsWatchedKey, kMetaWatchedKey;+static char kHeaderKey, kCoverKey, kTitleKey, kParentKey, kMetaKey, kAddKey, kDownloadKey, kPlayKey, kShuffleKey;+static char kHeroKey, kHeroHeightKey, kHeaderHeightKey, kInfoKey, kCoverWatchedKey, kHeaderWatchedKey, kRetryKey;#pragma mark - moving Spotify's views// Invisible for good. Spotify fades the header and the two floating controls by alpha as the page scrolls,// so a redesign that answers with alpha is in a fight it loses a frame of on every scroll. `hidden` on the// layer cannot be undone by a write to alpha, costs nothing per frame, and, unlike -[UIView setHidden:],-// tells neither KVO nor the stack views of it, which is what makes it safe on Spotify's Encore layouts.+// tells neither KVO nor the stack views of it, which is what makes it safe on Spotify's Encore layouts; an+// empty mask holds when Spotify shows the view again with -setHidden:NO, which the playlist page does when+// Play is pressed (Playlist/PlaylistHeader.x).static void conceal(UIView *view) {if (!view) return;if (!view.layer.hidden) view.layer.hidden = YES;+ if (!view.layer.mask) view.layer.mask = [CALayer layer];+ if (view.userInteractionEnabled) view.userInteractionEnabled = NO;view.accessibilityElementsHidden = YES;}-// Alpha 0, no touches, hidden from accessibility, set again on every pass: for the buttons of the action-// row, which Spotify arranges in a stack that traps when an arranged view hides, and which it leaves alone.-static void vanish(UIView *view) {+// Drawn by nothing but not hidden: for Spotify's own column of the header, which the redesign still reads. A+// hidden collection view makes no cells, and the kind and the date are cells ("no metadata" in the harness+// with the column hidden, 2026-09-18), so the column keeps laying itself out and only its drawing goes.+static void blank(UIView *view) {if (!view) return;- if (view.alpha != 0) view.alpha = 0;+ if (!view.layer.mask) view.layer.mask = [CALayer layer];if (view.userInteractionEnabled) view.userInteractionEnabled = NO;view.accessibilityElementsHidden = YES;}@@ -100,24 +92,6 @@ static void setFrame(UIView *view, CGRect frame) {if (view && !CGRectIsEmpty(frame) && !CGRectEqualToRect(view.frame, frame)) view.frame = frame;}-// `view` moved to the middle of its parent's width, keeping its size and its y.-static void centre(UIView *view) {- if (!view.superview || view.bounds.size.width <= 0) return;- CGRect frame = view.frame;- frame.origin.x = round((view.superview.bounds.size.width - frame.size.width) / 2);- setFrame(view, frame);-}--static void styleLabels(UIView *root, UIColor *color, UIFont *font, NSTextAlignment alignment) {- SGForEachView(root, ^(UIView *v) {- if (![v isKindOfClass:UILabel.class]) return;- UILabel *label = (UILabel *)v;- if (color && ![label.textColor isEqual:color]) label.textColor = color;- if (font && ![label.font isEqual:font]) label.font = font;- if (label.textAlignment != alignment) label.textAlignment = alignment;- });-}-// Installs `laidOut` on the view's own pass once, under `key`.static void watch(UIView *view, const void *key, void (^laidOut)(UIView *view)) {if (!view || objc_getAssociatedObject(view, key)) return;@@ -219,14 +193,14 @@ static void showCover(SGRAlbumHero *hero, UIImageView *view, UIView *header) {SGRAlbumSetArtwork(header, image);}-// The picture runs from the top of the header down to where its text begins, in the header's own space:-// below that the page's field is already drawing the very colour the picture dissolves into, so the hero-// simply stops there and there is no seam to see.+// The picture runs from the top of the header down past where its text begins, so the title and the artist+// sit on the bottom of its dissolve; below that the page's field is already drawing the very colour the+// picture dissolves into, so there is no seam to see.//-// The furthest down the text has been, rather than where it is: a header still loading puts its title-// higher than it will end up, and a header whose cover has not arrived puts it higher still. Both are-// answered by only ever letting the height grow, which settles once the cover and the artist are in.-static void applyHero(UIView *header, UIView *cover, UIView *titleBlock) {+// `bottom` is taken from the header at rest, never from where it is mid scroll, and only ever grows: a header+// still loading is shorter than it will end up, and once the cover and the artist are in it settles and the+// picture does not change size again.+static void applyHero(UIView *header, UIView *cover, CGFloat bottom) {SGRAlbumHero *hero = objc_getAssociatedObject(header, &kHeroKey);if (!hero) {hero = [[SGRAlbumHero alloc] initWithFrame:CGRectZero];@@ -236,9 +210,8 @@ static void applyHero(UIView *header, UIView *cover, UIView *titleBlock) {else if (header.subviews.firstObject != hero) [header sendSubviewToBack:hero];CGFloat height = [objc_getAssociatedObject(hero, &kHeroHeightKey) doubleValue];- CGFloat top = [header convertPoint:CGPointZero fromView:titleBlock].y;- if (top > height + 0.5) {- height = top;+ if (bottom > height + 0.5) {+ height = round(bottom);objc_setAssociatedObject(hero, &kHeroHeightKey, @(height), OBJC_ASSOCIATION_RETAIN_NONATOMIC);SGLog(@"redesign album: hero %.0fpt across the top of the header", height);}@@ -260,117 +233,93 @@ static void applyHero(UIView *header, UIView *cover, UIView *titleBlock) {conceal(cover);}-#pragma mark - the title, the artist and the date+#pragma mark - what the header shows-// The title block's stack hugs the widest thing in it and sits 16pt from the leading edge; centred in a-// block widened to the page, it is the column the Music app draws.-//-// The type is Spotify's own, colour and alignment apart. Unlike the playlist's, this header is measured-// from what it holds: the title's width is a constraint the element framework worked out for the font it-// was shown in, and a font of the Kit's a point larger is a title cut off at the end of it.-static void applyTitleStack(UIView *stack, UIView *title, UIView *parent) {- styleLabels(title, SGRPrimary(), nil, NSTextAlignmentCenter);- styleLabels(parent, SGRAccent(), nil, NSTextAlignmentCenter);- for (UIView *row in stack.subviews) {- if (row.bounds.size.height <= 0 || row.bounds.size.width <= 0) continue;- centre(row);- }+static NSString *trimmed(NSString *text) {+ NSString *clean = [text stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];+ return clean.length ? clean : nil;}-// The kind and the date ("Album • 31. 1. 2025") are cells of a collection view as wide as the page's text-// column, laid out from its leading edge. It is Spotify's own Swift class, so its pass cannot be watched-// and its cells are not moved: the row is centred by the inset the collection scrolls its content at,-// which no layout pass of Spotify's writes over.-static void applyMetadata(UIView *metadata) {- __block UICollectionView *cells = nil;- SGForEachView(metadata, ^(UIView *v) {- if (!cells && [v isKindOfClass:UICollectionView.class]) cells = (UICollectionView *)v;+// The first label under `root` with more than a letter in it: the facepile's initials are labels of their own.+static NSString *firstText(UIView *root) {+ __block NSString *found = nil;+ SGForEachView(root, ^(UIView *v) {+ if (found || ![v isKindOfClass:UILabel.class]) return;+ NSString *text = trimmed(((UILabel *)v).text);+ if (text.length > 1) found = text;});- styleLabels(metadata, SGRTertiary(), nil, NSTextAlignmentCenter);- // Asked of the layout rather than read off the scroll view: a pass runs top down, so every view whose- // pass this can be watched from has already run by the time the cells lay themselves out, and- // contentSize is a pass behind on every one of them (0 for as long as the header stands still).- CGFloat room = cells.bounds.size.width;- CGFloat content = MAX(cells.contentSize.width, cells.collectionViewLayout.collectionViewContentSize.width);- if (room <= 0 || content <= 0 || content >= room) return;- CGFloat lead = round((room - content) / 2);- if (fabs(cells.contentInset.left - lead) > 0.5) cells.contentInset = UIEdgeInsetsMake(0, lead, 0, 0);+ return found;}-#pragma mark - the action row--// Shuffle, Play and add, centred, with more beside them when Spotify has not moved it into the navigation-// bar. Glass goes inside each of Spotify's round buttons (the Kit's way: the shape is the button's own-// subview, so it goes wherever the button is put); the capsule and the stand-in carry their own.-static void applyActions(UIView *row, UIView *header, UIView *page) {- UIView *add = SGRFindByIdentifier(row, @"Components.UI.AddToButton", &kAddKey);- UIView *more = SGRFindByIdentifier(row, @"Components.UI.ContextMenuButton*", &kMoreKey);- // The Music app has neither on an album: a video entry point, and a download button the mod's own- // downloads do not need beside it.- for (NSString *identifier in @[@"Components.UI.WatchFeedEntityExplorerButton", @"DownloadButton.Granular*",- @"Components.UI.ShareButton"]) {- UIView *gone = SGRFindByIdentifier(row, identifier, NULL);- if (gone) vanish(wrapperFor(gone, row));- }+// The kind and the date ("Album • 31. 1. 2025", "Single • 2024") are cells of a collection view, a label each;+// read in the order they are drawn in.+static NSString *metadataText(UIView *metadata) {+ NSMutableArray<UILabel *> *labels = [NSMutableArray array];+ SGForEachView(metadata, ^(UIView *v) {+ if ([v isKindOfClass:UILabel.class] && trimmed(((UILabel *)v).text) && v.window) [labels addObject:(UILabel *)v];+ });+ [labels sortUsingComparator:^NSComparisonResult(UILabel *a, UILabel *b) {+ CGFloat ax = [a convertPoint:CGPointZero toView:metadata].x, bx = [b convertPoint:CGPointZero toView:metadata].x;+ return ax < bx ? NSOrderedAscending : (ax > bx ? NSOrderedDescending : NSOrderedSame);+ }];+ NSMutableArray<NSString *> *parts = [NSMutableArray array];+ for (UILabel *label in labels) [parts addObject:trimmed(label.text)];+ return parts.count ? [parts componentsJoinedByString:@" "] : nil;+}- UIView *play = floatingIn(page, @"header-play-button", &kPlayKey);- UIView *shuffle = floatingIn(page, @"Components.UI.ShuffleButton", &kShuffleKey);+static void applyHeader(UIView *header, UIView *page);- SGRPlayCapsule *capsule = objc_getAssociatedObject(row, &kCapsuleKey);- if (!capsule) {- capsule = [[SGRPlayCapsule alloc] initWithFrame:CGRectZero];- objc_setAssociatedObject(row, &kCapsuleKey, capsule, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+// The Kit's view over the whole header, its content on the header's bottom edge; Spotify's own column goes.+static SGRHeaderInfo *applyInfo(UIView *header, UIView *page) {+ SGRHeaderInfo *info = objc_getAssociatedObject(header, &kInfoKey);+ if (!info) {+ info = [[SGRHeaderInfo alloc] initWithFrame:CGRectZero];+ objc_setAssociatedObject(header, &kInfoKey, info, OBJC_ASSOCIATION_RETAIN_NONATOMIC);}- if (capsule.superview != row) [row addSubview:capsule];- if (play) {- [capsule feedFrom:play];- // Only what the button draws goes: a concealed layer still sends the actions the capsule fires.- conceal(wrapperFor(play, page));+ if (info.superview != header) [header addSubview:info];+ else if (header.subviews.lastObject != info) [header bringSubviewToFront:info];+ SGRAlbumHero *hero = objc_getAssociatedObject(header, &kHeroKey);+ for (UIView *sub in header.subviews) {+ if (sub != info && sub != hero) blank(sub);}- capsule.hidden = play == nil;+ setFrame(info, header.bounds);- SGRMirrorButton *mirror = objc_getAssociatedObject(row, &kMirrorKey);- if (!mirror) {- mirror = [[SGRMirrorButton alloc] initWithFrame:CGRectZero];- objc_setAssociatedObject(row, &kMirrorKey, mirror, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- }- if (mirror.superview != row) [row addSubview:mirror];- if (shuffle) {- [mirror feedFrom:shuffle];- conceal(wrapperFor(shuffle, page));- }- mirror.hidden = shuffle == nil;-- NSMutableArray<UIView *> *items = [NSMutableArray array];- NSMutableArray<NSNumber *> *widths = [NSMutableArray array];- if (shuffle) { [items addObject:mirror]; [widths addObject:@(SGRActionHeight)]; }- if (play) { [items addObject:capsule]; [widths addObject:@([capsule sgr_width])]; }- if (add) { [items addObject:wrapperFor(add, row)]; [widths addObject:@(SGRActionHeight)]; }- if (more) { [items addObject:wrapperFor(more, row)]; [widths addObject:@(SGRActionHeight)]; }- if (!items.count) return;-- CGFloat total = (items.count - 1) * SGRActionSpacing;- for (NSNumber *width in widths) total += width.doubleValue;- CGFloat x = round((row.bounds.size.width - total) / 2), middle = CGRectGetMidY(row.bounds);- for (NSUInteger i = 0; i < items.count; i++) {- UIView *item = items[i];- CGFloat slot = widths[i].doubleValue;- BOOL ours = item == (UIView *)capsule || item == (UIView *)mirror;- CGSize size = ours ? CGSizeMake(slot, SGRActionHeight) : item.bounds.size;- setFrame(item, CGRectMake(round(x + (slot - size.width) / 2), round(middle - size.height / 2), size.width, size.height));- x += slot + SGRActionSpacing;- }- for (UIView *button in @[add ?: NSNull.null, more ?: NSNull.null]) {- if ([button isKindOfClass:UIView.class]) SGRGlassInside(button, &kGlassKey, SGRGlassCircleSize);+ UIView *title = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.TitleRow", &kTitleKey);+ UIView *parent = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.ParentRow", &kParentKey);+ UIView *metadata = SGRFindByIdentifier(header, @"Components.UI.MetadataRow", &kMetaKey);+ NSString *length = metadataText(metadata);+ [info showTitle:firstText(title) creator:firstText(parent) ?: trimmed(parent.accessibilityLabel)+ length:length about:nil];+ // The kind and the date are cells the metadata row's collection view makes on its own pass, after the+ // header's, and nothing lays the header out again when they arrive; the collection is Spotify's own Swift+ // class, which cannot be watched. So an empty row is read again a moment later, a few times at most.+ NSInteger tries = [objc_getAssociatedObject(header, &kRetryKey) integerValue];+ if (!length && metadata && tries < 6) {+ objc_setAssociatedObject(header, &kRetryKey, @(tries + 1), OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ __weak UIView *weakHeader = header, *weakPage = page;+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ if (weakHeader && weakPage) applyHeader(weakHeader, weakPage);+ });}+ UIView *play = floatingIn(page, @"header-play-button", &kPlayKey);+ UIView *shuffle = floatingIn(page, @"Components.UI.ShuffleButton", &kShuffleKey);+ UIView *add = SGRFindByIdentifier(header, @"Components.UI.AddToButton", &kAddKey);+ UIView *download = add ? nil : SGRFindByIdentifier(header, @"DownloadButton.Granular*", &kDownloadKey);+ [info showShuffle:shuffle play:play trailing:add ?: download+ trailingFallback:[UIImage systemImageNamed:add ? @"plus" : @"arrow.down"] playColor:SGRAlbumFieldColor(header)];+ // Only what the two floating buttons draw goes: a concealed layer still sends the actions the row fires.+ if (play) conceal(wrapperFor(play, page));+ if (shuffle) conceal(wrapperFor(shuffle, page));+static BOOL logged;- if (!logged && row.window) {+ if (!logged && header.window && title) {logged = YES;- SGLog(@"redesign album: action row %@, shuffle %@, play %@, add %@, more %@", NSStringFromCGRect(row.bounds),- shuffle ? @"found" : @"missing", play ? @"found" : @"missing", add ? @"found" : @"missing",- more ? @"in the row" : @"not in the page");+ SGLog(@"redesign album: own block \"%@\" by %@, \"%@\"; shuffle %@, play %@, %@", firstText(title),+ firstText(parent) ?: @"nobody", metadataText(metadata) ?: @"no metadata", shuffle ? @"found" : @"missing",+ play ? @"found" : @"missing", add ? @"add" : (download ? @"download" : @"nothing on the right"));}+ return info;}#pragma mark - the header's pass@@ -432,70 +381,18 @@ static void applyWash(UIView *page) {}}-// The stack view `view` is arranged by, or nil: what has to lay out before `view` can be moved. Asked-// through -class, which a watch's runtime subclass answers with the class Spotify made.-static UIStackView *stackOver(UIView *view) {- UIStackView *stack = (UIStackView *)view.superview;- return [stack class] == UIStackView.class ? stack : nil;-}-static void applyHeader(UIView *header, UIView *page) {- UIView *title = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.TitleRow", &kTitleKey);- UIView *parent = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.ParentRow", &kParentKey);- UIView *titleStack = title.superview;- UIView *titleBlock = titleStack.superview;- if (!titleBlock) return;-+ if (!SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.TitleRow", &kTitleKey)) return;applyWash(page);- UIView *cover = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.ArtWorkElement.WithCoverArt", &kCoverKey);- if (cover) applyHero(header, cover, titleBlock);-- // The title block hugs its text, so it is widened to the group it is arranged in before the stack- // inside it is centred; the group lays the block out, so that is the pass it is taken from.- UIStackView *group = stackOver(titleBlock);- void (^widenBlock)(UIView *) = ^(UIView *view) {- CGRect frame = titleBlock.frame;- setFrame(titleBlock, CGRectMake(0, frame.origin.y, view.bounds.size.width, frame.size.height));- };- if (group) {- widenBlock(group);- watch(group, &kGroupWatchedKey, widenBlock);- }- centre(titleStack);- watch(titleBlock, &kBlockWatchedKey, ^(UIView *view) { centre(titleStack); });- applyTitleStack(titleStack, title, parent);- watch(titleStack, &kTitleWatchedKey, ^(UIView *view) { applyTitleStack(view, title, parent); });-- UIView *metadata = SGRFindByIdentifier(header, @"Components.UI.MetadataRow", &kMetaKey);- UIStackView *metaStack = stackOver(metadata.superview) ?: stackOver(metadata);- if (metadata) {- applyMetadata(metadata);- watch(metaStack ?: metadata, &kMetaWatchedKey, ^(UIView *view) { applyMetadata(metadata); });- }+ SGRHeaderInfo *info = applyInfo(header, page);- // The action row is whichever stack Spotify's own buttons are arranged in, found from the first of them- // that is still in the page, and widened to its group the way the title block is.- UIView *anyButton = SGRFindByIdentifier(header, @"Components.UI.AddToButton", &kAddKey)- ?: SGRFindByIdentifier(header, @"DownloadButton.Granular*", NULL)- ?: SGRFindByIdentifier(header, @"Components.UI.ContextMenuButton*", &kMoreKey);- UIStackView *actions = (UIStackView *)wrapperFor(anyButton, header).superview;- if (![actions isKindOfClass:UIStackView.class]) return;- UIStackView *bottom = stackOver(actions);- void (^widenRow)(UIView *) = ^(UIView *view) {- CGRect frame = actions.frame;- setFrame(actions, CGRectMake(0, frame.origin.y, view.bounds.size.width, frame.size.height));- };- if (bottom) {- widenRow(bottom);- watch(bottom, &kBottomWatchedKey, widenRow);- }- applyActions(actions, header, page);- // Weakly: the row is the page's own descendant, and a block of its that held the page would keep the- // whole page alive for as long as the row.- __weak UIView *weakHeader = header, *weakPage = page;- watch(actions, &kActionsWatchedKey, ^(UIView *view) {- if (weakHeader && weakPage) applyActions(view, weakHeader, weakPage);- });+ // The picture reaches to where the content's top is at rest, plus the title and the artist. The header at+ // rest is the tallest it has been, so the picture does not change size as the header loads or scrolls.+ CGFloat rest = MAX([objc_getAssociatedObject(header, &kHeaderHeightKey) doubleValue], header.bounds.size.height);+ objc_setAssociatedObject(header, &kHeaderHeightKey, @(rest), OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ CGFloat bottom = rest - SGRHeaderInfoBottom - [info contentHeightForWidth:header.bounds.size.width] + SGRHeaderInfoTitleRise;+ UIView *cover = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.ArtWorkElement.WithCoverArt", &kCoverKey);+ if (cover) applyHero(header, cover, bottom);}static void applyPage(UIView *page) {diff --git a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.hnew file mode 100644index 00000000..7f2c77f2--- /dev/null+++ b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h@@ -0,0 +1,32 @@+// The text and the controls of a redesigned page's header, under its full bleed picture, the way the Music+// app (iOS 26.4) sets a playlist or an album: the title, the creator and the length centred, one row of+// shuffle, a white Play capsule and one more round button, and the description under the row.+//+// A page conceals what Spotify draws in its header and puts this in its place, so nothing of Spotify's lays+// it out. It keeps no state of its own: the page hands it the text it read (from Spotify's model or from+// Spotify's concealed labels) and Spotify's own controls to draw from and fire, on every pass, and it lays+// itself out again only when something it shows changed.+//+// 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.+//+// Ownership: the page that adds it; it keeps only weak references to Spotify's controls.+// Threading: main thread only.+#import <UIKit/UIKit.h>++extern const CGFloat SGRHeaderInfoBottom; // 14, under the content+extern const CGFloat SGRHeaderInfoTitleRise; // 56, of the content over the picture++@interface SGRHeaderInfo : UIView+// YES when anything shown changed. nil or empty hides that line.+- (BOOL)showTitle:(NSString *)title creator:(NSString *)creator length:(NSString *)length about:(NSString *)about;+// Spotify's controls, each drawn from and fired; nil hides that button. Play stays in the middle of the+// page whether the other two are there or not. `trailingFallback` is drawn when Spotify's trailing control+// has no image to copy. `playColor` is the colour of the capsule's glyph and word.+- (void)showShuffle:(UIView *)shuffle play:(UIView *)play trailing:(UIView *)trailing+ trailingFallback:(UIImage *)trailingFallback playColor:(UIColor *)playColor;+// The height the content wants at `width`, from the top of the title to the bottom of the description.+- (CGFloat)contentHeightForWidth:(CGFloat)width;+@enddiff --git a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.mnew file mode 100644index 00000000..21b9422c--- /dev/null+++ b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m@@ -0,0 +1,149 @@+// The header's text and controls, the redesign's own. Laid out top down from where the content has to start+// for its bottom to sit SGRHeaderInfoBottom above the view's.+#import "Core/SGCore.h"+#import "SGRHeaderInfo.h"+#import "SGRActionRow.h"+#import "SGRTokens.h"++const CGFloat SGRHeaderInfoBottom = 14;+const CGFloat SGRHeaderInfoTitleRise = 56;++// The text kSide in from the edges; Play at least kPlayWidth wide, the Music app's; the gaps between.+static const CGFloat kSide = 20, kPlayWidth = 148, kRowSpacing = 16, kRowAbove = 16, kAboutAbove = 14;++static UILabel *infoLabel(UIView *parent, UIFont *font, UIColor *color, NSInteger lines, NSTextAlignment alignment) {+ UILabel *label = [UILabel new];+ label.font = font;+ label.textColor = color;+ label.numberOfLines = lines;+ label.textAlignment = alignment;+ label.lineBreakMode = NSLineBreakByTruncatingTail;+ label.hidden = YES;+ [parent addSubview:label];+ return label;+}++static BOOL setText(UILabel *label, NSString *text) {+ if ([label.text ?: @"" isEqualToString:text ?: @""]) return NO;+ label.text = text;+ label.hidden = text.length == 0;+ return YES;+}++@implementation SGRHeaderInfo {+ UILabel *_title, *_creator, *_length, *_about;+ SGRMirrorButton *_shuffle, *_trailing;+ SGRPlayCapsule *_play;+}++- (instancetype)initWithFrame:(CGRect)frame {+ if (!(self = [super initWithFrame:frame])) return nil;+ _title = infoLabel(self, SGRFont(UIFontTextStyleTitle2, UIFontWeightBold, UIContentSizeCategoryExtraLarge),+ SGRPrimary(), 2, NSTextAlignmentCenter);+ _title.accessibilityTraits = UIAccessibilityTraitHeader;+ _creator = infoLabel(self, SGRFont(UIFontTextStyleBody, UIFontWeightRegular, UIContentSizeCategoryExtraLarge),+ SGRSecondary(), 1, NSTextAlignmentCenter);+ _length = infoLabel(self, SGRFont(UIFontTextStyleFootnote, UIFontWeightRegular, UIContentSizeCategoryExtraLarge),+ SGRTertiary(), 1, NSTextAlignmentCenter);+ _about = infoLabel(self, SGRFont(UIFontTextStyleFootnote, UIFontWeightRegular, UIContentSizeCategoryExtraLarge),+ SGRSecondary(), 2, NSTextAlignmentNatural);++ _shuffle = [[SGRMirrorButton alloc] initWithFrame:CGRectZero];+ _shuffle.fallbackGlyph = [UIImage systemImageNamed:@"shuffle"];+ _play = [[SGRPlayCapsule alloc] initWithFrame:CGRectZero];+ _play.fillColor = UIColor.whiteColor;+ _trailing = [[SGRMirrorButton alloc] initWithFrame:CGRectZero];+ for (UIView *button in @[_shuffle, _play, _trailing]) {+ button.hidden = YES;+ [self addSubview:button];+ }+ return self;+}++// Touches only for the buttons: the text lets a pull or a tap through to the page under it.+- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {+ UIView *hit = [super hitTest:point withEvent:event];+ return hit == self ? nil : hit;+}++- (BOOL)showTitle:(NSString *)title creator:(NSString *)creator length:(NSString *)length about:(NSString *)about {+ BOOL changed = NO;+ changed |= setText(_title, title);+ changed |= setText(_creator, creator);+ changed |= setText(_length, length);+ changed |= setText(_about, about);+ if (changed) [self setNeedsLayout];+ return changed;+}++- (void)showShuffle:(UIView *)shuffle play:(UIView *)play trailing:(UIView *)trailing+ trailingFallback:(UIImage *)trailingFallback playColor:(UIColor *)playColor {+ _trailing.fallbackGlyph = trailingFallback;+ if (shuffle) [_shuffle feedFrom:shuffle];+ if (play) {+ if (playColor) _play.contentColor = playColor;+ [_play feedFrom:play];+ }+ if (trailing) [_trailing feedFrom:trailing];++ BOOL changed = NO;+ NSArray<UIView *> *buttons = @[_shuffle, _play, _trailing];+ NSArray<NSNumber *> *shown = @[@(shuffle != nil), @(play != nil), @(trailing != nil)];+ for (NSUInteger i = 0; i < buttons.count; i++) {+ BOOL hide = !shown[i].boolValue;+ if (buttons[i].hidden != hide) {+ buttons[i].hidden = hide;+ changed = YES;+ }+ }+ if (changed) [self setNeedsLayout];+}++- (CGFloat)contentHeightForWidth:(CGFloat)width {+ CGFloat text = MAX(0, width - 2 * kSide), height = 0;+ UILabel *previous = nil;+ for (UILabel *label in @[_title, _creator, _length]) {+ if (label.hidden) continue;+ if (previous) height += previous == _creator ? 4 : 2;+ height += ceil([label sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)].height);+ previous = label;+ }+ if (previous) height += kRowAbove;+ height += SGRActionHeight;+ if (!_about.hidden) height += kAboutAbove + ceil([_about sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)].height);+ return height;+}++- (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]);++ UILabel *previous = nil;+ for (UILabel *label in @[_title, _creator, _length]) {+ if (label.hidden) continue;+ if (previous) y += previous == _creator ? 4 : 2;+ CGFloat height = ceil([label sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)].height);+ label.frame = CGRectMake(kSide, y, text, height);+ y += height;+ previous = label;+ }+ if (previous) y += kRowAbove;++ // Play on the middle of the page, the other two hung off its sides, so it holds its place whether both+ // are there or not.+ CGFloat side = SGRActionHeight;+ CGFloat playWidth = MAX(kPlayWidth, [_play sgr_width]);+ CGRect play = CGRectMake(round((width - playWidth) / 2), y, playWidth, side);+ _play.frame = play;+ _shuffle.frame = CGRectMake(CGRectGetMinX(play) - kRowSpacing - side, y, side, side);+ _trailing.frame = CGRectMake(CGRectGetMaxX(play) + kRowSpacing, y, side, side);+ y += side;++ if (!_about.hidden) {+ y += kAboutAbove;+ _about.frame = CGRectMake(kSide, y, text, ceil([_about sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)].height));+ }+}++@enddiff --git a/tweak/Sources/Redesigned/Kit/SGRKit.h b/tweak/Sources/Redesigned/Kit/SGRKit.hindex 344a9271..dcb45402 100644--- a/tweak/Sources/Redesigned/Kit/SGRKit.h+++ b/tweak/Sources/Redesigned/Kit/SGRKit.h@@ -8,6 +8,7 @@// SGRGlass.h glass inside Spotify's round controls// SGRGlyph.h bare glyph overlays and glyph buttons// SGRActionRow.h the Play capsule and the stand-in button of a page's action row+// SGRHeaderInfo.h a page header's title, creator, length, row and description, the Music app's// SGRRestyle.h keeping Spotify's views restyled: suppress, digits, lookups, shadows, firing controls// SGRBridges.h player state, now playing artwork, the player's open and close// SGRRepaint.h the areas the redesign keeps transparent when Spotify repaints them@@ -22,6 +23,7 @@#import "SGRGlass.h"#import "SGRGlyph.h"#import "SGRActionRow.h"+#import "SGRHeaderInfo.h"#import "SGRRestyle.h"#import "SGRBridges.h"#import "SGRRepaint.h"diff --git a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.xindex 976a9a03..1dd1febf 100644--- a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x+++ b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x@@ -15,7 +15,7 @@// height: the cover's square is where the full bleed picture goes, and the block keeps its place, its size// and its fading as the header collapses.//-// What is in the block is the redesign's own (SGRPlaylistInfo), not Spotify's rearranged. Moving Spotify's+// What is in the block is the redesign's own (the Kit's SGRHeaderInfo), not Spotify's rearranged. Moving Spotify's// column and controls meant answering every layout pass of theirs -- stacks re-arranging, Auto Layout putting// frames back, buttons flashing where Spotify wanted them -- so Spotify's contents of the block are concealed// whole and one view of the redesign's own is drawn in their place, which nothing of Spotify's lays out. It@@ -252,11 +252,6 @@ static void applyHero(UIView *layout, UIView *cover, UIView *plane, UIView *bloc#pragma mark - the block, the redesign's own-// The Music app's measures: the content sits on the bottom of the block with kInfoBottom under it, the text-// kSide in from the edges, and kTitleRise of it -- the title and the creator -- over the bottom of the picture.-static const CGFloat kInfoBottom = 14, kSide = 20, kTitleRise = 56;-static const CGFloat kPlayWidth = 148, kRowSpacing = 16, kRowAbove = 16, kAboutAbove = 14;-// The page's view model: the header controller's defaultHeaderViewModel, FTPViewModelImplementation on every// playlist, Liked Songs and a shared playlist alike (device, 2026-09-18). Its getters are plain ObjC --// playlistName and playlistDescription @, isOwnedBySelf B, formatListType @ (Spotify 9.1.78) -- and each is@@ -330,174 +325,45 @@ static NSString *lengthIn(UIView *block) {return firstText(SGRFindByIdentifier(block, @"Components.Header.UI.Metadata", &kMetaKey), nil);}-static BOOL setText(UILabel *label, NSString *text) {- if ((label.text ?: @"").length == (text ?: @"").length && [label.text ?: @"" isEqualToString:text ?: @""]) return NO;- label.text = text;- label.hidden = text.length == 0;- return YES;-}--static UILabel *infoLabel(UIView *parent, UIFont *font, UIColor *color, NSInteger lines, NSTextAlignment alignment) {- UILabel *label = [UILabel new];- label.font = font;- label.textColor = color;- label.numberOfLines = lines;- label.textAlignment = alignment;- label.lineBreakMode = NSLineBreakByTruncatingTail;- label.hidden = YES;- [parent addSubview:label];- return label;-}--// Title, creator, length, the row, the description: the Music app's playlist header under its picture. Laid-// out from the bottom of the block, so whatever height Spotify gives the block the buttons stay just above the-// first track, and what does not fit rises over the picture, which is where the title belongs anyway.-@interface SGRPlaylistInfo : UIView-- (void)showFromBlock:(UIView *)block headerRoot:(UIView *)root model:(id)model;-// The height the content wants at `width`, from the top of the title to the bottom of the description.-- (CGFloat)contentHeightForWidth:(CGFloat)width;-@end--@implementation SGRPlaylistInfo {- UILabel *_title, *_creator, *_length, *_about;- SGRMirrorButton *_shuffle, *_trailing;- SGRPlayCapsule *_play;-}--- (instancetype)initWithFrame:(CGRect)frame {- if (!(self = [super initWithFrame:frame])) return nil;- _title = infoLabel(self, SGRFont(UIFontTextStyleTitle2, UIFontWeightBold, UIContentSizeCategoryExtraLarge),- SGRPrimary(), 2, NSTextAlignmentCenter);- _title.accessibilityTraits = UIAccessibilityTraitHeader;- _creator = infoLabel(self, SGRFont(UIFontTextStyleBody, UIFontWeightRegular, UIContentSizeCategoryExtraLarge),- SGRSecondary(), 1, NSTextAlignmentCenter);- _length = infoLabel(self, SGRFont(UIFontTextStyleFootnote, UIFontWeightRegular, UIContentSizeCategoryExtraLarge),- SGRTertiary(), 1, NSTextAlignmentCenter);- _about = infoLabel(self, SGRFont(UIFontTextStyleFootnote, UIFontWeightRegular, UIContentSizeCategoryExtraLarge),- SGRSecondary(), 2, NSTextAlignmentNatural);-- _shuffle = [[SGRMirrorButton alloc] initWithFrame:CGRectZero];- _shuffle.fallbackGlyph = [UIImage systemImageNamed:@"shuffle"];- _play = [[SGRPlayCapsule alloc] initWithFrame:CGRectZero];- _play.fillColor = UIColor.whiteColor;- _trailing = [[SGRMirrorButton alloc] initWithFrame:CGRectZero];- for (UIView *button in @[_shuffle, _play, _trailing]) {- button.hidden = YES;- [self addSubview:button];- }- return self;-}--// Touches only for the buttons: the text lets a pull or a tap through to the page under it.-- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {- UIView *hit = [super hitTest:point withEvent:event];- return hit == self ? nil : hit;-}--- (void)showFromBlock:(UIView *)block headerRoot:(UIView *)root model:(id)model {- BOOL changed = NO;- changed |= setText(_title, modelString(model, @"playlistName") ?: _title.text);- changed |= setText(_creator, creatorIn(block));- changed |= setText(_length, lengthIn(block));- changed |= setText(_about, plainText(modelString(model, @"playlistDescription")));+// What the playlist's header shows: the name and the description from the page's model, the creator and the+// length from Spotify's concealed labels, and on Play's right save for someone else's playlist, download for+// one's own and for Liked Songs, which Spotify reports as neither owned nor unsaved (isOwnedBySelf NO,+// formatListType liked-songs).+static void showPlaylist(SGRHeaderInfo *info, UIView *block, UIView *root, id model) {+ NSString *title = modelString(model, @"playlistName") ?: firstText(block, nil);+ [info showTitle:title creator:creatorIn(block) length:lengthIn(block)+ about:plainText(modelString(model, @"playlistDescription"))];- // The button on Play's right: save for someone else's playlist, download for one's own and for Liked- // Songs, which Spotify reports as neither owned nor unsaved (isOwnedBySelf NO, formatListType liked-songs).BOOL liked = [modelString(model, @"formatListType") isEqualToString:@"liked-songs"];BOOL own = modelFlag(model, @"isOwnedBySelf", YES) || liked;UIView *shuffle = SGRFindByIdentifier(block, @"Components.UI.ShuffleButton", &kShuffleKey);UIView *play = SGRFindByIdentifier(root, @"header-play-button", &kPlayKey);UIView *save = own ? nil : SGRFindByIdentifier(block, @"Components.UI.AddToButton", &kAddKey);UIView *download = save ? nil : SGRFindByIdentifier(block, @"DownloadButton.Granular*", &kDownloadKey);- UIView *trailing = save ?: download;- _trailing.fallbackGlyph = [UIImage systemImageNamed:save ? @"plus" : @"arrow.down"];-- if (shuffle) [_shuffle feedFrom:shuffle];- if (play) {- _play.contentColor = SGRPlaylistFieldColor(self);- [_play feedFrom:play];- // Only what the button draws goes: a concealed layer still sends the actions the capsule fires.- conceal(play);- }- if (trailing) [_trailing feedFrom:trailing];- NSArray *shown = @[@(shuffle != nil), @(play != nil), @(trailing != nil)];- NSArray *buttons = @[_shuffle, _play, _trailing];- for (NSUInteger i = 0; i < buttons.count; i++) {- UIView *button = buttons[i];- BOOL hide = ![shown[i] boolValue];- if (button.hidden != hide) { button.hidden = hide; changed = YES; }- }- if (changed) [self setNeedsLayout];+ [info showShuffle:shuffle play:play trailing:save ?: download+ trailingFallback:[UIImage systemImageNamed:save ? @"plus" : @"arrow.down"] playColor:SGRPlaylistFieldColor(info)];+ // Only what the button draws goes: a concealed layer still sends the actions the capsule fires.+ conceal(play);static BOOL logged;- if (!logged && self.window && (_title.text || play)) {+ if (!logged && info.window && (title || play)) {logged = YES;SGLog(@"redesign playlist: own block \"%@\" by %@, \"%@\"; shuffle %@, play %@, %@; model %@",- _title.text, _creator.text ?: @"nobody", _length.text ?: @"no length", shuffle ? @"found" : @"missing",+ title, creatorIn(block) ?: @"nobody", lengthIn(block) ?: @"no length", shuffle ? @"found" : @"missing",play ? @"found" : @"missing", save ? @"save" : (download ? @"download" : @"nothing on the right"),model ? NSStringFromClass([model class]) : @"missing");}}-- (CGFloat)contentHeightForWidth:(CGFloat)width {- CGFloat text = MAX(0, width - 2 * kSide), height = 0;- UILabel *previous = nil;- for (UILabel *label in @[_title, _creator, _length]) {- if (label.hidden) continue;- if (previous) height += previous == _creator ? 4 : 2;- height += ceil([label sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)].height);- previous = label;- }- if (previous) height += kRowAbove;- height += SGRActionHeight;- if (!_about.hidden) height += kAboutAbove + ceil([_about sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)].height);- return height;-}--- (void)layoutSubviews {- [super layoutSubviews];- CGFloat width = self.bounds.size.width, text = MAX(0, width - 2 * kSide);- CGFloat y = round(self.bounds.size.height - kInfoBottom - [self contentHeightForWidth:width]);-- UILabel *previous = nil;- for (UILabel *label in @[_title, _creator, _length]) {- if (label.hidden) continue;- if (previous) y += previous == _creator ? 4 : 2;- CGFloat height = ceil([label sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)].height);- label.frame = CGRectMake(kSide, y, text, height);- y += height;- previous = label;- }- if (previous) y += kRowAbove;-- // Play on the middle of the screen, the other two hung off its sides, so it holds its place whether both- // are there or not.- CGFloat side = SGRActionHeight;- CGFloat playWidth = MAX(kPlayWidth, [_play sgr_width]);- CGRect play = CGRectMake(round((width - playWidth) / 2), y, playWidth, side);- _play.frame = play;- _shuffle.frame = CGRectMake(CGRectGetMinX(play) - kRowSpacing - side, y, side, side);- _trailing.frame = CGRectMake(CGRectGetMaxX(play) + kRowSpacing, y, side, side);- y += side;-- if (!_about.hidden) {- y += kAboutAbove;- CGFloat height = ceil([_about sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)].height);- _about.frame = CGRectMake(kSide, y, text, height);- }-}--@end-// The block's own content goes, whole, and the redesign's takes its place. Spotify adds to the block as the page// loads and shows parts of it again when Play is pressed, so everything of Spotify's in it is concealed on every// pass and again from the block's own pass; concealing is idempotent and costs nothing once done.-static SGRPlaylistInfo *applyInfo(UIView *block, UIView *headerRoot, UIViewController *headerVC) {+static SGRHeaderInfo *applyInfo(UIView *block, UIView *headerRoot, UIViewController *headerVC) {// One per page, kept on the header's root: if Spotify ever hands over another block, the same view moves// into it rather than a second one being drawn beside the first.- SGRPlaylistInfo *info = objc_getAssociatedObject(headerRoot, &kInfoKey);+ SGRHeaderInfo *info = objc_getAssociatedObject(headerRoot, &kInfoKey);if (!info) {- info = [[SGRPlaylistInfo alloc] initWithFrame:CGRectZero];+ info = [[SGRHeaderInfo alloc] initWithFrame:CGRectZero];objc_setAssociatedObject(headerRoot, &kInfoKey, info, OBJC_ASSOCIATION_RETAIN_NONATOMIC);}if (info.superview != block) {@@ -512,7 +378,7 @@ static SGRPlaylistInfo *applyInfo(UIView *block, UIView *headerRoot, UIViewContrCGFloat x = -[block convertPoint:CGPointZero toView:headerRoot].x;CGRect frame = CGRectMake(round(x), 0, headerRoot.bounds.size.width, block.bounds.size.height);if (!CGRectEqualToRect(info.frame, frame)) info.frame = frame;- [info showFromBlock:block headerRoot:headerRoot model:viewModelOf(headerVC)];+ showPlaylist(info, block, headerRoot, viewModelOf(headerVC));if (!objc_getAssociatedObject(block, &kBlockWatchedKey)) {objc_setAssociatedObject(block, &kBlockWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);@@ -604,7 +470,7 @@ static void applyHeader(UIView *layout) {UIView *plane = applyBackground(layout);applyToolbar(headerRoot);applyScrims(headerRoot);- SGRPlaylistInfo *info = applyInfo(block, headerRoot, headerVC);+ SGRHeaderInfo *info = applyInfo(block, headerRoot, headerVC);// How far into the block the picture reaches: to where the content's top is at rest, plus the title and// the creator. The block's height at rest is the tallest it has been -- collapsing shrinks it (136 against@@ -612,7 +478,7 @@ static void applyHeader(UIView *layout) {// and the picture does not change size while the header moves.CGFloat rest = MAX([objc_getAssociatedObject(block, &kBlockHeightKey) doubleValue], block.bounds.size.height);objc_setAssociatedObject(block, &kBlockHeightKey, @(rest), OBJC_ASSOCIATION_RETAIN_NONATOMIC);- CGFloat reach = rest - kInfoBottom - [info contentHeightForWidth:info.bounds.size.width] + kTitleRise;+ CGFloat reach = rest - SGRHeaderInfoBottom - [info contentHeightForWidth:info.bounds.size.width] + SGRHeaderInfoTitleRise;if (cover) applyHero(layout, cover, plane, block, reach);}