Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
fix: Liked Songs laid out like a playlist, its title centred, Shuffle Play in the middle with its glyph, and no blue band as it scrolls
Vojtěch Škopekb203f20e9cd5
diff --git a/harness/playlist/README.md b/harness/playlist/README.mdindex 45aec91a..886fdee7 100644--- a/harness/playlist/README.md+++ b/harness/playlist/README.md@@ -24,3 +24,7 @@ screen, not pinned to it. At 16 s it fades Spotify's cover square and colour wasscroll does, with nothing laid out, and reports what the redesign's scroll pass made of them.What it does not cover: the real element framework's autolayout, and the flags `PlaylistField.x` forces.++`liked` on the launch line (`xcrun simctl launch booted com.vojta.playlistharness liked`) builds Liked Songs+instead, from `trees/continuous/1.txt` (2026-09-18): no cover, a 238pt header, the count in a stack of its own,+the play button 80x48, and `LiquidGlass.gradientContainer`, which it fades in at 3 s as a scroll does.diff --git a/harness/playlist/main.m b/harness/playlist/main.mindex ac20fe29..02cc3cb2 100644--- a/harness/playlist/main.m+++ b/harness/playlist/main.m@@ -42,6 +42,16 @@@interface _TtGC13Element_UIKit11ElementViewT_P_P__ : UIView @end@implementation _TtGC13Element_UIKit11ElementViewT_P_P__ @end+// The plain UIView Liked Songs' shuffle stack sits in: its own pass puts the stack back where Spotify's+// constraints want it, on the right of the row, which is what made the shuffle flash there on the phone.+@interface MockRightHost : UIView @end+@implementation MockRightHost+- (void)layoutSubviews {+ [super layoutSubviews];+ self.subviews.firstObject.frame = CGRectMake(52, 0, 48, 48);+}+@end+@interface MockCondensedButton : UIControl @end@implementation MockCondensedButton @end@@ -109,6 +119,103 @@ static UIView *actionButton(UIView *row, CGRect frame, NSString *identifier, NSSreturn action;}++// Liked Songs (trees/continuous/1.txt, 2026-09-18): the same page with no cover, a 238pt header, a column of+// only the title and the count (the count in a stack of its own, 314pt of label and a 56pt spacer), no add or+// more in the row, the play button 80x48 with its 48pt disc at x=16, and LiquidGlass.gradientContainer, the+// scrim Spotify fades in as the page scrolls. `liked` on the launch line builds it; at 3 s it is scrolled.+static void buildLikedSongs(UIViewController *page, CGFloat W) {+ UIViewController *headerVC = [SPTFreeTierPlaylistEncoreHeaderViewController new];+ [page addChildViewController:headerVC];+ UIView *header = headerVC.view;+ header.frame = CGRectMake(0, -72, W, 310);+ header.accessibilityIdentifier = @"PL.Header";+ header.backgroundColor = UIColor.clearColor;+ [page.view addSubview:header];+ [headerVC didMoveToParentViewController:page];++ UIView *headerLayout = box(header, UIView.class, CGRectMake(0, 72, W, 238), nil);+ UIView *clipping = box(headerLayout, UIView.class, headerLayout.bounds, @"_clippingView");+ UIView *background = box(clipping, UIView.class, clipping.bounds, @"_backgroundViewContainer");+ UIView *wash = box(background, UIView.class, background.bounds, nil);+ UIView *gradient = box(wash, _TtC19LegacyUI_ECMCoreKit13GradientView.class, wash.bounds, nil);+ gradient.backgroundColor = [UIColor colorWithRed:0.25 green:0.2 blue:0.7 alpha:1];+ UIView *safeArea = box(clipping, UIView.class, clipping.bounds, @"_safeAreaView");+ UIView *contentContainer = box(safeArea, UIView.class, CGRectMake(0, -72, W, 310), @"_headerContentContainer");+ UIView *contentView = box(contentContainer, UIView.class, CGRectMake(0, 72, W, 238), @"_contentViewContainer");+ UIView *layout = box(contentView, _TtC28EncoreConsumerMobile_BaseKit19HeaderContentLayout.class, contentView.bounds, nil);++ UIView *slot = box(layout, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class, CGRectMake(178.33, 68, 45.33, 45.33), nil);+ box(slot, UIView.class, slot.bounds, nil);++ UIView *block = box(layout, UIView.class, CGRectMake(0, 129.33, 386, 108.67), nil);+ UIView *blockInner = box(box(block, UIView.class, block.bounds, nil), UIView.class, CGRectMake(0, 0, 386, 100.67), nil);+ UIView *columnStack = box(blockInner, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class, CGRectMake(16, 0, 370, 100.67), nil);+ UIView *columnAndRow = box(columnStack, UIView.class, columnStack.bounds, nil);+ UIView *columnHost = box(columnAndRow, UIView.class, CGRectMake(0, 0, 370, 44.67), nil);+ UIView *titleStack = box(columnHost, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class, columnHost.bounds, nil);+ UIView *column = box(titleStack, UIView.class, titleStack.bounds, nil);+ label(column, CGRectMake(0, 0, 370, 25.33), @"Liked Songs", 21, UIColor.whiteColor, @"Encore.Label");+ UIView *countStack = box(column, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class, CGRectMake(0, 29.33, 370, 15.33), nil);+ UIView *countRow = box(countStack, UIView.class, countStack.bounds, nil);+ label(countRow, CGRectMake(0, 0, 314, 15.33), @"1 016 songs", 11, [UIColor colorWithWhite:1 alpha:0.4],+ @"Components.Header.UI.Metadata").textAlignment = NSTextAlignmentLeft;+ box(countRow, UIView.class, CGRectMake(314, 7.67, 56, 0), nil);++ UIView *rowHost = box(columnAndRow, UIView.class, CGRectMake(0, 52.67, 370, 48), nil);+ UIView *rowStack = box(rowHost, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class, rowHost.bounds, nil);+ UIView *container = box(rowStack, UIView.class, rowStack.bounds, nil);+ UIView *left = box(container, UIView.class, CGRectMake(0, 0, 96, 48), nil);+ UIView *leftStack = box(left, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class, CGRectMake(-10, 0, 106, 48), nil);+ UIView *element = box(box(leftStack, UIView.class, leftStack.bounds, nil), _TtGC13Element_UIKit11ElementViewT_P_P__.class, CGRectMake(0, 0, 106, 48), nil);+ UIStackView *actions = (UIStackView *)box(element, UIStackView.class, element.bounds, @"HeaderActionsRow");+ actionButton(actions, CGRectMake(0, 4, 58, 40), @"Components.UI.WatchFeedEntityExplorerButton", @"Explore Liked Songs");+ actionButton(actions, CGRectMake(58, 0, 48, 48), @"DownloadButton.Granular.None", @"Download");+ box(container, UIView.class, CGRectMake(96, 23.67, 174, 1), nil);+ UIView *right = box(container, MockRightHost.class, CGRectMake(270, 0, 100, 48), nil);+ UIView *rightStack = box(right, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class, CGRectMake(-184, 0, 48, 48), nil);+ UIView *shuffleHost = box(box(rightStack, UIView.class, rightStack.bounds, nil), UIView.class, CGRectMake(0, 0, 48, 48), nil);+ UIView *shuffle = box(shuffleHost, UIButton.class, shuffleHost.bounds, @"Components.UI.ShuffleButton");+ shuffle.accessibilityLabel = @"Shuffle tracks";+ UIImageView *shuffleGlyph = [[UIImageView alloc] initWithFrame:CGRectInset(shuffle.bounds, 12, 12)];+ shuffleGlyph.image = [UIImage systemImageNamed:@"shuffle"];+ shuffleGlyph.tintColor = [UIColor colorWithRed:0.02 green:0.97 blue:0 alpha:1];+ [shuffle addSubview:shuffleGlyph];++ UIView *scrim = box(headerLayout, UIView.class, CGRectMake(0, 0, W, 124), @"LiquidGlass.gradientContainer");+ scrim.alpha = 0;+ box(scrim, UIView.class, scrim.bounds, @"LiquidGlass.GradientView").backgroundColor = [UIColor colorWithRed:0.25 green:0.3 blue:0.9 alpha:1];++ UIView *foreground = box(headerLayout, UIView.class, headerLayout.bounds, @"_foregroundViewContainer");+ UIView *playButton = box(foreground, _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView.class, CGRectMake(322, 182, 80, 48), @"header-play-button");+ UIControl *condensed = (UIControl *)box(playButton, MockCondensedButton.class, CGRectMake(16, 0, 48, 48), nil);+ condensed.accessibilityLabel = @"Shuffle Play";+ UIImageView *disc = [[UIImageView alloc] initWithFrame:condensed.bounds];+ disc.image = [[UIImage systemImageNamed:@"shuffle"] imageByApplyingSymbolConfiguration:+ [UIImageSymbolConfiguration configurationWithPointSize:18]];+ disc.contentMode = UIViewContentModeCenter;+ disc.backgroundColor = [UIColor colorWithRed:0.02 green:0.97 blue:0 alpha:1];+ [condensed addSubview:disc];++ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ scrim.alpha = 1;+ [layout setNeedsLayout];+ [layout layoutIfNeeded];+ // Spotify's parent laying the shuffle out again, after every pass of the header's.+ [right setNeedsLayout];+ [right layoutIfNeeded];+ CGRect shuffleInRow = [container convertRect:shuffle.bounds fromView:shuffle];+ UIView *capsule = container.subviews.lastObject;+ NSLog(@"[harness] liked: after the shuffle's parent laid out: shuffle %@, capsule %@ (%@), screen middle %.1f",+ NSStringFromCGRect([container convertRect:shuffleInRow toView:nil]),+ NSStringFromCGRect([container convertRect:capsule.frame toView:nil]), capsule.class,+ CGRectGetMidX(page.view.bounds));+ NSLog(@"[harness] liked: scrolled, scrim a=%.2f hidden=%d masked=%d; column rows %@ / %@",+ scrim.alpha, scrim.layer.hidden, scrim.layer.mask != nil,+ NSStringFromCGRect(column.subviews[0].frame), NSStringFromCGRect(column.subviews[1].frame));+ });+}+@interface SGRHarnessDelegate : UIResponder <UIApplicationDelegate>@property (nonatomic, strong) UIWindow *window;@end@@ -144,6 +251,12 @@ static UIView *actionButton(UIView *row, CGRect frame, NSString *identifier, NSSlabel(row, CGRectMake(76, 32, W - 130, 18), tracks[i][1], 14, [UIColor colorWithWhite:1 alpha:0.7], @"Track.Row.Content.Subtitle");}+ if ([NSProcessInfo.processInfo.arguments containsObject:@"liked"]) {+ buildLikedSongs(page, W);+ [self.window makeKeyAndVisible];+ return YES;+ }+// the headerUIViewController *headerVC = [SPTFreeTierPlaylistEncoreHeaderViewController new];[page addChildViewController:headerVC];diff --git a/tweak/Sources/Redesigned/Kit/SGRActionRow.m b/tweak/Sources/Redesigned/Kit/SGRActionRow.mindex 5b4a68d0..b596a2da 100644--- a/tweak/Sources/Redesigned/Kit/SGRActionRow.m+++ b/tweak/Sources/Redesigned/Kit/SGRActionRow.m@@ -105,7 +105,10 @@ static NSString *wordIn(UIView *button) {_source = source;NSString *word = wordIn(source);- UIImageView *glyph = glyphIn(source, source.bounds.size.width);+ // The disc is as tall as the button, not always as wide: Liked Songs' is 80x48 with the 48pt disc at+ // x=16 (trees/continuous/1.txt, 2026-09-18), and matched by width the capsule drew no glyph at all.+ CGSize size = source.bounds.size;+ UIImageView *glyph = glyphIn(source, MIN(size.width, size.height));UIFont *font = SGRFont(UIFontTextStyleSubheadline, UIFontWeightSemibold, UIContentSizeCategoryLarge);if (![_title.font isEqual:font]) _title.font = font;diff --git a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.xindex 2f0c78d9..bf8bad15 100644--- a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x+++ b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x@@ -37,8 +37,9 @@ static const CGFloat kDissolve = 0.46, kTopScrim = 140, kTopScrimAlpha = 0.28;static const CGFloat kMinHero = 120, kMinCover = 80;static char kCoverKey, kRowKey, kMetaKey, kPlayKey, kGlassKey, kLayoutKey;-static char kShuffleKey, kAddKey, kMoreKey, kToolbarKey;+static char kShuffleKey, kAddKey, kMoreKey, kToolbarKey, kScrimKey, kBarScrimKey;static char kHeroKey, kHeroHeightKey, kCapsuleKey, kColumnWatchedKey, kRowWatchedKey, kCoverWatchedKey;+static char kParentWatchedKey;#pragma mark - finding things@@ -328,8 +329,10 @@ static void applyColumn(UIView *column) {CGFloat spacing = 0;for (NSUInteger i = 0; i + 1 < rows.count; i++) spacing += gaps[i].doubleValue;// Spotify measured the column for the same four, so this is room enough; a description that has grown- // since gives the gaps up first and then goes, rather than reaching down into the action row.- BOOL spaced = bare + spacing <= room;+ // since gives the gaps up first and then goes, rather than reaching down into the action row. Gaps that+ // do not fit shrink to what does rather than going all at once: Liked Songs' column is title and length+ // with 4pt between (trees/continuous/1.txt, 2026-09-18), and with none the title sat on the song count.+ CGFloat scale = spacing > 0 ? MAX(0, MIN(1, (room - bare) / spacing)) : 0;if (bare > room && description && [rows containsObject:description]) {[rows removeObject:description];vanish(description);@@ -346,14 +349,58 @@ static void applyColumn(UIView *column) {if (part.bounds.size.width > 0 && part.bounds.size.width < content) content = part.bounds.size.width;}CGFloat x = content < size.width - 1 ? round((width - content) / 2) : 0;+ // Liked Songs' length fills the width but its label does not: 314pt of it with a 56pt spacer after,+ // so centred text in it sat 28pt left of the title (trees/continuous/1.txt, 2026-09-18). The row+ // moves by what puts the label's middle on the column's.+ if (row == length && x == 0) {+ UIView *label = SGRFindByIdentifier(row, @"Components.Header.UI.Metadata", &kMetaKey);+ if (label && label.bounds.size.width < size.width - 1) {+ x = round(width / 2 - CGRectGetMidX([row convertRect:label.bounds fromView:label]));+ }+ }CGRect frame = CGRectMake(x, round(y), size.width, size.height);if (!CGRectEqualToRect(row.frame, frame)) row.frame = frame;- y += size.height + (spaced && i + 1 < rows.count ? gaps[i].doubleValue : 0);+ y += size.height + (i + 1 < rows.count ? gaps[i].doubleValue * scale : 0);}}+// The column is the view that holds the title as well as the length. Spotify sets both in stacks, and on a+// playlist the first view up from the length that sits in a stack is the column; on Liked Songs the length+// has a stack of its own inside it, and taking that one styled and centred nothing but the song count,+// leaving the title at the left (trees/continuous/1.txt, 2026-09-18). So a stacked view counts only when+// something showing sits beside the length in it.+static UIView *columnOf(UIView *metadata, UIView *block) {+ UIView *first = nil;+ for (UIView *v = metadata; v && v != block; v = v.superview) {+ if (![NSStringFromClass(v.superview.class) containsString:@"AutoLayoutStackView"]) continue;+ if (!first) first = v;+ for (UIView *sub in v.subviews) {+ if (sub.hidden || sub.bounds.size.height <= 0 || [metadata isDescendantOfView:sub]) continue;+ return v;+ }+ }+ return first;+}+#pragma mark - the action row+// A control moved by frame goes back where Spotify put it the next time its own parent lays out, and that+// can come after every pass the redesign sees: Liked Songs' shuffle sits in a stack of its own on the right+// of the row, and a page opening showed it there for a moment before the next header pass took it to the+// left of Play (device, 2026-09-18). So the parent is watched too. One watch per view, which is why the row+// itself -- already watched from the header's pass -- is left alone; Swift parents cannot be watched and are+// only marked, so the pass does not try again.+static void applyActions(UIView *block, UIView *headerRoot);+static void watchParent(UIView *item, UIView *block, UIView *headerRoot) {+ UIView *parent = item.superview;+ if (!parent || objc_getAssociatedObject(parent, &kRowWatchedKey) || objc_getAssociatedObject(parent, &kParentWatchedKey)) return;+ objc_setAssociatedObject(parent, &kParentWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ __weak UIView *weakBlock = block, *weakRoot = headerRoot;+ SGRObserveLayout(parent, ^(UIView *view) {+ if (weakBlock && weakRoot) applyActions(weakBlock, weakRoot);+ });+}+// 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 carries its own.@@ -402,9 +449,22 @@ static void applyActions(UIView *block, UIView *headerRoot) {if (more) { [items addObject:wrapperFor(more, container)]; [widths addObject:@(SGRActionHeight)]; }if (!items.count) return;- CGFloat total = (items.count - 1) * SGRActionSpacing;- for (NSNumber *width in widths) total += width.doubleValue;- CGFloat x = round((container.bounds.size.width - total) / 2), middle = CGRectGetMidY(container.bounds);+ // Play in the middle of the screen, what comes before it hanging off its left and the rest off its right,+ // so it stays put whether the row has shuffle and add either side (a playlist) or shuffle alone (Liked+ // Songs, where centring the pair put the capsule 30pt right of the title, device 2026-09-18). The screen's+ // middle rather than the container's: the container is inset differently on each page.+ CGFloat middleX = [container convertPoint:CGPointMake(CGRectGetMidX(headerRoot.bounds), 0) fromView:headerRoot].x;+ NSUInteger lead = [items indexOfObject:capsule];+ CGFloat x;+ if (lead == NSNotFound) {+ CGFloat total = (items.count - 1) * SGRActionSpacing;+ for (NSNumber *width in widths) total += width.doubleValue;+ x = round(middleX - total / 2);+ } else {+ x = round(middleX - widths[lead].doubleValue / 2);+ for (NSUInteger i = 0; i < lead; i++) x -= widths[i].doubleValue + SGRActionSpacing;+ }+ CGFloat middle = CGRectGetMidY(container.bounds);for (NSUInteger i = 0; i < items.count; i++) {UIView *item = items[i];CGFloat slot = widths[i].doubleValue;@@ -414,6 +474,7 @@ static void applyActions(UIView *block, UIView *headerRoot) {if (!CGRectEqualToRect(capsule.frame, target)) capsule.frame = target;} else {place(item, target, container);+ watchParent(item, block, headerRoot);}x += slot + SGRActionSpacing;}@@ -439,7 +500,28 @@ static void applyToolbar(UIView *headerRoot) {for (UIView *v = toolbar; v && v != headerRoot; v = v.superview) {if (![NSStringFromClass(v.class) containsString:@"HeaderView"]) continue;conceal(v);- return;+ break;+ }+}++// Two scrims Spotify fades in under the navigation bar as the page scrolls, each tinted with its own colour+// for the page rather than the field's: LiquidGlass.gradientContainer (124pt, a child of HeaderLayout) and+// the HeaderNavigationBar's GradientView. On Liked Songs the first is Spotify's blue, a band across the top+// of a black page (trees/continuous/2.txt, 2026-09-18). UIKit's own scroll edge effect is still there under+// the bar and keeps the back button legible, as on Home, Search and Library. Concealed rather than faded:+// Spotify writes their alpha on every step of the scroll, and the navigation bar's with -setHidden:.+static void applyScrims(UIView *headerRoot) {+ conceal(SGRFindByIdentifier(headerRoot, @"LiquidGlass.gradientContainer", &kScrimKey));+ // A concealed view stays concealed, so the bar is looked for until it is found and then never again:+ // the header lays out on every step of its collapse.+ if (objc_getAssociatedObject(headerRoot, &kBarScrimKey)) return;+ static Class bar;+ if (!bar) bar = NSClassFromString(@"_TtC28EncoreConsumerMobile_BaseKit19HeaderNavigationBar");+ UIView *navigation = firstOfClass(headerRoot, bar);+ for (UIView *sub in navigation.subviews) {+ if (![NSStringFromClass(sub.class) containsString:@"GradientView"]) continue;+ conceal(sub);+ objc_setAssociatedObject(headerRoot, &kBarScrimKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);}}@@ -480,15 +562,13 @@ static void applyHeader(UIView *layout) {UIView *plane = applyBackground(layout);applyToolbar(headerRoot);+ applyScrims(headerRoot);if (cover) applyHero(layout, cover, plane, block);// The column and the action row lay their own children out after this pass; each is watched once so the// redesign has the last word on both.UIView *metadata = SGRFindByIdentifier(block, @"Components.Header.UI.Metadata", &kMetaKey);- UIView *column = nil;- for (UIView *v = metadata; v && v != block; v = v.superview) {- if ([NSStringFromClass(v.superview.class) containsString:@"AutoLayoutStackView"]) { column = v; break; }- }+ UIView *column = columnOf(metadata, block);if (column) {applyColumn(column);if (!objc_getAssociatedObject(column, &kColumnWatchedKey)) {