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

feat: the redesigned playlist page, the Music app's layout laid over Spotify's own header

Vojtěch Škopek87a8cd92192c
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 535c6ab9..37faeb2b 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -118,6 +118,12 @@ Redesigned:
carousels and promos collapse, and the cards move up by the spacing they leave), the header the way Home
has it without the camera, and each card as Liquid Glass tinted by its own colour, read off the Box's
shape layer (Search.h lists its files)
+ Playlist/ the playlist page (Liked Songs and one's own too, all three being the same page) the way the Music
+ app lays one out: the cover full bleed across the top dissolving into the page's field with no seam,
+ the title, the creator and the length centred under it, one row of glass controls (shuffle, a
+ prominent Play capsule taking its glyph and its word from Spotify's own button, add, more), the find
+ bar and the curation pills gone, and the track rows on the field with a hairline between them
+ (Playlist.h lists its files). Laid out on the Mac against harness/playlist/
Haptics/ Vibrations (Haptics.h lists its files): a tap of UIKit's feedback generators for the player's and the now
playing bar's controls, the scrubber's tenths and ends, cover swipes, gestures and the lyrics page's tap to
seek (ControlHaptics.x, SGRFeedback.m); and Music Haptics, Core Haptics playing along with the song:
diff --git a/harness/playlist/README.md b/harness/playlist/README.md
new file mode 100644
index 00000000..e2f95513
--- /dev/null
+++ b/harness/playlist/README.md
@@ -0,0 +1,25 @@
+# Playlist harness
+
+Spotify's playlist page mocked under its own class names and accessibility identifiers
+(from `trees/clean/playlist/01.txt`), so `Redesigned/Playlist/` can be laid out and looked at
+on the Mac without the phone.
+
+ THEOS=$HOME/theos ./build.sh
+ xcrun simctl install booted build/PlaylistHarness.app
+ xcrun simctl launch booted com.vojta.playlistharness
+ xcrun simctl io booted screenshot shot.png
+
+`build.sh` runs `logos.pl -c generator=internal` over the three `.x` files and links them with the
+real `Core/` and `Redesigned/Kit/` sources; `stubs.m` stands in for the two hook files the harness
+does not compile (`SGRAccent.x`, `SGRRepaint.x`).
+
+Two seconds after launch the mock puts Spotify's own frames back on the column and the action row
+and asks both for a layout pass, which is what the redesign's `SGRObserveLayout` watch has to survive.
+
+Then it plays the three states the header is ever in, with the frames Spotify sets in each
+(`trees/continuous/1.txt`, `2.txt` and `4.txt`): at rest at 4 s, collapsed at 8 s, pulled down past the
+top at 12 s. Each logs where the hero landed in the window; collapsed it belongs off the top of the
+screen, not pinned to it. At 16 s it fades Spotify's cover square and colour wash back in the way a
+scroll 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.
diff --git a/harness/playlist/build.sh b/harness/playlist/build.sh
new file mode 100755
index 00000000..17901ff8
--- /dev/null
+++ b/harness/playlist/build.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+set -e
+SRC=/Users/vojta/Documents/quick/custom_spotify/custom_spotify/tweak/Sources
+OUT=$(dirname "$0")/build
+rm -rf "$OUT"; mkdir -p "$OUT/gen" "$OUT/PlaylistHarness.app"
+
+for f in Redesigned/Playlist/PlaylistField.x Redesigned/Playlist/PlaylistHeader.x Redesigned/Playlist/PlaylistRows.x; do
+ name=$(basename "$f" .x)
+ "$THEOS/bin/logos.pl" -c generator=internal "$SRC/$f" > "$OUT/gen/$name.m"
+done
+
+SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)
+xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-arc -g -O0 \
+ -I"$SRC" -I"$SRC/Redesigned/Playlist" -I"$OUT/gen" -isysroot "$SDK" \
+ -Wno-deprecated-declarations \
+ "$(dirname "$0")/main.m" "$(dirname "$0")/stubs.m" \
+ "$OUT"/gen/*.m \
+ "$SRC"/Core/SGLog.m "$SRC"/Core/SGPrefs.m "$SRC"/Core/SGViewTree.m "$SRC"/Core/SGGlass.m \
+ "$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/SGRedesign.m \
+ -framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols \
+ -o "$OUT/PlaylistHarness.app/PlaylistHarness"
+
+cat > "$OUT/PlaylistHarness.app/Info.plist" <<'PLIST'
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0"><dict>
+<key>CFBundleExecutable</key><string>PlaylistHarness</string>
+<key>CFBundleIdentifier</key><string>com.vojta.playlistharness</string>
+<key>CFBundleName</key><string>PlaylistHarness</string>
+<key>CFBundleVersion</key><string>1</string>
+<key>CFBundleShortVersionString</key><string>1.0</string>
+<key>UIUserInterfaceStyle</key><string>Dark</string>
+<key>UILaunchScreen</key><dict/>
+<key>UIApplicationSceneManifest</key><dict>
+ <key>UIApplicationSupportsMultipleScenes</key><false/>
+</dict>
+</dict></plist>
+PLIST
+echo "built $OUT/PlaylistHarness.app"
diff --git a/harness/playlist/main.m b/harness/playlist/main.m
new file mode 100644
index 00000000..5555315d
--- /dev/null
+++ b/harness/playlist/main.m
@@ -0,0 +1,329 @@
+// A mock of Spotify's playlist page under its own class names and accessibility identifiers, built from
+// trees/clean/playlist/01.txt, so Redesigned/Playlist can be laid out and looked at on the Mac.
+#import <UIKit/UIKit.h>
+
+#pragma mark - Spotify's classes, by name
+
+@interface _TtC35ListUXPlatform_FreeTierPlaylistImpl17FTPViewController : UIViewController @end
+@implementation _TtC35ListUXPlatform_FreeTierPlaylistImpl17FTPViewController @end
+
+@interface _TtC35ListUXPlatform_FreeTierPlaylistImpl32FTPTouchCancellingCollectionView : UIScrollView @end
+@implementation _TtC35ListUXPlatform_FreeTierPlaylistImpl32FTPTouchCancellingCollectionView @end
+
+@interface SPTFreeTierPlaylistEncoreHeaderViewController : UIViewController
+- (void)entityHeaderViewController:(id)controller didUpdateVisibleRect:(CGRect)rect;
+@end
+@implementation SPTFreeTierPlaylistEncoreHeaderViewController
+// Spotify's own is what reports a scroll to the header; here it only gives the hook something to run after.
+- (void)entityHeaderViewController:(id)controller didUpdateVisibleRect:(CGRect)rect {}
+@end
+
+@interface _TtC28EncoreConsumerMobile_BaseKit19HeaderContentLayout : UIView @end
+@implementation _TtC28EncoreConsumerMobile_BaseKit19HeaderContentLayout @end
+
+@interface _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView : UIView @end
+@implementation _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView @end
+
+@interface _TtC19LegacyUI_ECMCoreKit13GradientView : UIView @end
+@implementation _TtC19LegacyUI_ECMCoreKit13GradientView @end
+
+@interface _TtC44PlaylistCuration_ExpandableTextElementKit18ExpandableTextView : UITextView @end
+@implementation _TtC44PlaylistCuration_ExpandableTextElementKit18ExpandableTextView @end
+
+@interface _TtCE13Encore_FaceKitO16EncoreFoundation6Encore12FacepileView : UIView @end
+@implementation _TtCE13Encore_FaceKitO16EncoreFoundation6Encore12FacepileView @end
+
+@interface _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView : UIView @end
+@implementation _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView @end
+
+@interface _TtC35ListUXPlatform_FreeTierPlaylistImpl25ElementCollectionViewCell : UICollectionViewCell @end
+@implementation _TtC35ListUXPlatform_FreeTierPlaylistImpl25ElementCollectionViewCell @end
+
+@interface _TtGC13Element_UIKit11ElementViewT_P_P__ : UIView @end
+@implementation _TtGC13Element_UIKit11ElementViewT_P_P__ @end
+
+@interface MockCondensedButton : UIControl @end
+@implementation MockCondensedButton @end
+
+#pragma mark - building the tree
+
+static UIView *box(UIView *parent, Class cls, CGRect frame, NSString *identifier) {
+ UIView *view = [[cls alloc] initWithFrame:frame];
+ view.accessibilityIdentifier = identifier;
+ [parent addSubview:view];
+ return view;
+}
+
+static UILabel *label(UIView *parent, CGRect frame, NSString *text, CGFloat size, UIColor *color, NSString *identifier) {
+ UIView *encore = box(parent, UIView.class, frame, identifier);
+ UILabel *inner = [[UILabel alloc] initWithFrame:encore.bounds];
+ inner.text = text;
+ inner.font = [UIFont systemFontOfSize:size];
+ inner.textColor = color;
+ inner.accessibilityIdentifier = [identifier stringByAppendingString:@"-internal"];
+ [encore addSubview:inner];
+ return inner;
+}
+
+static UIImage *artwork(void) {
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(300, 300)];
+ return [renderer imageWithActions:^(UIGraphicsImageRendererContext *ctx) {
+ CGContextRef c = ctx.CGContext;
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+ CGFloat components[] = {0.93, 0.30, 0.47, 1, 0.28, 0.12, 0.42, 1};
+ CGGradientRef gradient = CGGradientCreateWithColorComponents(space, components, NULL, 2);
+ CGContextDrawLinearGradient(c, gradient, CGPointZero, CGPointMake(300, 300), 0);
+ CGGradientRelease(gradient);
+ CGColorSpaceRelease(space);
+ [[UIColor colorWithWhite:1 alpha:0.35] setFill];
+ for (int i = 0; i < 5; i++) {
+ [[UIBezierPath bezierPathWithOvalInRect:CGRectMake(30 + i * 50, 40 + (i % 3) * 60, 70, 70)] fill];
+ }
+ }];
+}
+
+static UIImage *playGlyph(void) {
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(48, 48)];
+ return [renderer imageWithActions:^(UIGraphicsImageRendererContext *ctx) {
+ UIBezierPath *path = [UIBezierPath bezierPath];
+ [path moveToPoint:CGPointMake(19, 15)];
+ [path addLineToPoint:CGPointMake(33, 24)];
+ [path addLineToPoint:CGPointMake(19, 33)];
+ [path closePath];
+ [UIColor.blackColor setFill];
+ [path fill];
+ }];
+}
+
+static UIView *actionButton(UIView *row, CGRect frame, NSString *identifier, NSString *a11y) {
+ UIView *action = box(row, UIView.class, frame, nil);
+ UIView *element = box(action, UIView.class, action.bounds, nil);
+ UIView *button = box(element, UIButton.class, element.bounds, identifier);
+ button.accessibilityLabel = a11y;
+ UIImageView *glyph = [[UIImageView alloc] initWithFrame:CGRectInset(button.bounds, 12, 12)];
+ NSDictionary *glyphs = @{@"Components.UI.AddToButton": @"plus", @"Components.UI.ContextMenuButton": @"ellipsis",
+ @"DownloadButton.Granular.None": @"arrow.down.circle", @"Components.UI.WatchFeedEntityExplorerButton": @"play.rectangle"};
+ glyph.image = [UIImage systemImageNamed:glyphs[identifier] ?: @"circle"];
+ glyph.tintColor = UIColor.whiteColor;
+ [button addSubview:glyph];
+ return action;
+}
+
+@interface SGRHarnessDelegate : UIResponder <UIApplicationDelegate>
+@property (nonatomic, strong) UIWindow *window;
+@end
+
+@implementation SGRHarnessDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options {
+ self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
+ CGFloat W = self.window.bounds.size.width, H = self.window.bounds.size.height;
+
+ UIViewController *page = [_TtC35ListUXPlatform_FreeTierPlaylistImpl17FTPViewController new];
+ page.view.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];
+ self.window.rootViewController = page;
+
+ // the list
+ UIScrollView *list = (UIScrollView *)box(page.view, _TtC35ListUXPlatform_FreeTierPlaylistImpl32FTPTouchCancellingCollectionView.class,
+ CGRectMake(0, 0, W, H), @"SPTFreeTierPlaylistTableView");
+ list.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];
+ NSArray<NSArray<NSString *> *> *tracks = @[@[@"Cry For Me", @"The Weeknd"], @[@"I Can't Fucking Sing", @"The Weeknd"],
+ @[@"São Paulo", @"The Weeknd, Anitta"], @[@"Until We're Skin & Bones", @"The Weeknd"],
+ @[@"Baptized In Fear", @"The Weeknd"]];
+ for (NSUInteger i = 0; i < tracks.count; i++) {
+ UIView *cell = box(list, _TtC35ListUXPlatform_FreeTierPlaylistImpl25ElementCollectionViewCell.class,
+ CGRectMake(0, 512 + i * 64, W, 64), @"Playlist.ItemCell");
+ cell.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];
+ UIView *row = box(cell, UIView.class, cell.bounds, @"Encore.ListRow");
+ row.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];
+ UIView *art = box(row, UIView.class, CGRectMake(16, 8, 48, 48), @"Encore.ImageView");
+ UIImageView *picture = [[UIImageView alloc] initWithFrame:art.bounds];
+ picture.image = artwork();
+ [art addSubview:picture];
+ label(row, CGRectMake(76, 12, W - 130, 20), tracks[i][0], 16, UIColor.whiteColor, @"Track.Row.Content.Title");
+ label(row, CGRectMake(76, 32, W - 130, 18), tracks[i][1], 14, [UIColor colorWithWhite:1 alpha:0.7], @"Track.Row.Content.Subtitle");
+ }
+
+ // the header
+ UIViewController *headerVC = [SPTFreeTierPlaylistEncoreHeaderViewController new];
+ [page addChildViewController:headerVC];
+ UIView *header = headerVC.view;
+ header.frame = CGRectMake(0, -134, W, 639.33);
+ header.accessibilityIdentifier = @"PL.Header";
+ header.backgroundColor = UIColor.clearColor;
+ [page.view addSubview:header];
+ [headerVC didMoveToParentViewController:page];
+
+ UIView *headerLayout = box(header, UIView.class, CGRectMake(0, 134, W, 505.33), 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);
+ wash.clipsToBounds = YES;
+ UIView *gradient = box(wash, _TtC19LegacyUI_ECMCoreKit13GradientView.class, wash.bounds, nil);
+ gradient.backgroundColor = [UIColor colorWithRed:0.5 green:0.1 blue:0.3 alpha:1];
+
+ UIView *safeArea = box(clipping, UIView.class, clipping.bounds, @"_safeAreaView");
+ UIView *contentContainer = box(safeArea, UIView.class, CGRectMake(0, -134, W, 639.33), @"_headerContentContainer");
+ UIView *contentView = box(contentContainer, UIView.class, CGRectMake(0, 134, W, 505.33), @"_contentViewContainer");
+ UIView *layout = box(contentView, _TtC28EncoreConsumerMobile_BaseKit19HeaderContentLayout.class, contentView.bounds, nil);
+
+ // the cover square
+ UIView *cover = box(layout, UIView.class, CGRectMake(round((W - 243) / 2), 68, 243, 243), @"Components.Header.UI.ArtworkImage");
+ UIView *coverImage = box(cover, UIView.class, cover.bounds, @"Encore.ImageView");
+ UIImageView *coverPicture = [[UIImageView alloc] initWithFrame:coverImage.bounds];
+ coverPicture.image = artwork();
+ coverPicture.contentMode = UIViewContentModeScaleAspectFill;
+ [coverImage addSubview:coverPicture];
+
+ // the block: the column, then the action row
+ UIView *block = box(layout, UIView.class, CGRectMake(0, 327, W - 16, 178.33), nil);
+ UIView *blockStack = box(block, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class, block.bounds, nil);
+ UIView *blockInner = box(blockStack, UIView.class, blockStack.bounds, nil);
+
+ UIView *columnHost = box(blockInner, UIView.class, CGRectMake(0, 0, block.bounds.size.width, 122.33), nil);
+ UIView *columnStack = box(columnHost, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class,
+ CGRectMake(16, 0, columnHost.bounds.size.width - 16, 122.33), nil);
+ UIView *column = box(columnStack, UIView.class, columnStack.bounds, nil);
+ CGFloat columnWidth = column.bounds.size.width;
+
+ label(column, CGRectMake(0, 0, columnWidth, 29.67), @"Hurry Up Tomorrow", 21, UIColor.whiteColor, @"Encore.Label");
+
+ UIView *descriptionRow = box(column, UIView.class, CGRectMake(0, 33.67, columnWidth, 31.33), nil);
+ UITextView *description = (UITextView *)box(descriptionRow, _TtC44PlaylistCuration_ExpandableTextElementKit18ExpandableTextView.class,
+ descriptionRow.bounds, nil);
+ description.text = @"On what was meant to be the last date of his 2022 tour, The Weeknd took the stage.";
+ description.font = [UIFont systemFontOfSize:14];
+ description.textColor = UIColor.whiteColor;
+ description.backgroundColor = UIColor.clearColor;
+ description.textContainerInset = UIEdgeInsetsZero;
+ description.textContainer.lineFragmentPadding = 0;
+
+ UIView *creatorRow = box(column, UIView.class, CGRectMake(0, 69, columnWidth, 34), nil);
+ UIView *creator = box(creatorRow, UIView.class, CGRectMake(0, 0, 109.67, 34), nil);
+ UIView *face = box(creator, _TtCE13Encore_FaceKitO16EncoreFoundation6Encore12FacepileView.class, CGRectMake(0, 5, 24, 24), nil);
+ face.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
+ face.layer.cornerRadius = 12;
+ label(creator, CGRectMake(32, 9, 77, 16), @"The Weeknd", 13, UIColor.whiteColor, @"Encore.Label");
+ box(creatorRow, UIView.class, CGRectMake(109.67, 0, columnWidth - 109.67, 34), nil);
+
+ UIView *lengthRow = box(column, UIView.class, CGRectMake(0, 107, columnWidth, 15.33), nil);
+ UIView *length = box(lengthRow, UIView.class, CGRectMake(0, 0, 126.33, 15.33), nil);
+ label(length, CGRectMake(0, 0, 126.33, 15.33), @"4 637 saves • 20h 28m", 11, [UIColor colorWithWhite:1 alpha:0.7],
+ @"Components.Header.UI.Metadata");
+ box(lengthRow, UIView.class, CGRectMake(126.33, 0, columnWidth - 126.33, 15.33), nil);
+
+ UIView *actionHost = box(blockInner, UIView.class, CGRectMake(0, 130.33, block.bounds.size.width, 48), nil);
+ UIView *actionStack = box(actionHost, _TtC19LegacyUI_ECMCoreKit19AutoLayoutStackView.class,
+ CGRectMake(4, 0, actionHost.bounds.size.width - 4, 48), nil);
+ UIView *container = box(actionStack, UIView.class, actionStack.bounds, nil);
+ UIView *rowElement = box(container, _TtGC13Element_UIKit11ElementViewT_P_P__.class, CGRectMake(0, 0, 198, 48), nil);
+ UIStackView *actions = (UIStackView *)box(rowElement, UIStackView.class, rowElement.bounds, @"HeaderActionsRow");
+ actionButton(actions, CGRectMake(0, 4, 58, 40), @"Components.UI.WatchFeedEntityExplorerButton", @"Explore");
+ actionButton(actions, CGRectMake(58, 0, 48, 48), @"Components.UI.AddToButton", @"Like");
+ actionButton(actions, CGRectMake(106, 0, 48, 48), @"DownloadButton.Granular.None", @"Download");
+ actionButton(actions, CGRectMake(154, 2, 44, 44), @"Components.UI.ContextMenuButton", @"More options");
+
+ UIView *mixShuffle = box(container, UIView.class, CGRectMake(container.bounds.size.width - 124, 0, 124, 48), nil);
+ UIView *mixShuffleStack = box(mixShuffle, UIStackView.class, CGRectMake(0, 0, 68, 48), nil);
+ box(mixShuffleStack, UIView.class, CGRectMake(0, 0, 20, 48), @"MixAndShuffleComposedUI.mixView");
+ UIView *shuffleView = box(mixShuffleStack, UIView.class, CGRectMake(20, 0, 48, 48), @"MixAndShuffleComposedUI.shuffleView");
+ UIView *shuffleElement = box(shuffleView, UIView.class, shuffleView.bounds, nil);
+ UIView *shuffle = box(shuffleElement, UIButton.class, shuffleElement.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.whiteColor;
+ [shuffle addSubview:shuffleGlyph];
+
+ // the play button, in the header's foreground plane
+ UIView *foreground = box(headerLayout, UIView.class, headerLayout.bounds, @"_foregroundViewContainer");
+ UIView *playHost = box(foreground, UIView.class, CGRectMake(W - 64, 457.33, 64, 48), nil);
+ UIView *playButton = box(playHost, _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView.class, CGRectMake(0, 0, 48, 48), @"header-play-button");
+ UIControl *condensed = (UIControl *)box(playButton, MockCondensedButton.class, playButton.bounds, nil);
+ condensed.accessibilityLabel = @"Play";
+ UIImageView *disc = [[UIImageView alloc] initWithFrame:condensed.bounds];
+ disc.image = playGlyph();
+ disc.backgroundColor = [UIColor colorWithRed:0.12 green:0.84 blue:0.38 alpha:1];
+ disc.layer.cornerRadius = 24;
+ disc.clipsToBounds = YES;
+ [condensed addSubview:disc];
+
+ [self.window makeKeyAndVisible];
+
+ // The header collapsing, and the page pulled down past the top, with the frames Spotify sets in each
+ // (trees/continuous/2.txt and 4.txt). The hero has to slide up out of the clipping view with the plane
+ // the wash is on, not be resized into a strip at the top of the screen.
+ void (^setState)(NSString *) = ^(NSString *state) {
+ BOOL collapsed = [state isEqualToString:@"collapsed"];
+ BOOL pulled = [state isEqualToString:@"pulled"];
+ CGFloat layoutHeight = collapsed ? 110 : (pulled ? 608 : 474);
+ header.frame = CGRectMake(0, collapsed ? -498 : (pulled ? 0 : -134), W, 608);
+ headerLayout.frame = CGRectMake(0, collapsed ? 498 : (pulled ? 0 : 134), W, layoutHeight);
+ clipping.frame = CGRectMake(0, 0, W, layoutHeight);
+ background.frame = CGRectMake(0, 0, W, layoutHeight);
+ background.alpha = collapsed ? 0 : 1;
+ wash.frame = collapsed ? CGRectMake(0, -364, W, 474) : CGRectMake(0, 0, W, layoutHeight);
+ safeArea.frame = CGRectMake(0, 0, W, layoutHeight);
+ contentContainer.frame = CGRectMake(0, pulled ? 0 : -134, W, collapsed ? 244 : 608);
+ contentView.frame = CGRectMake(0, 134, W, collapsed ? 110 : 474);
+ layout.frame = CGRectMake(0, 0, W, collapsed ? 110 : 474);
+ cover.frame = collapsed ? CGRectMake(148.67, 68, 104.67, 104.67) : CGRectMake(round((W - 243) / 2), 68, 243, 243);
+ block.frame = collapsed ? CGRectMake(0, -26.33, W - 16, 136.33) : CGRectMake(0, 327, W - 16, 178.33);
+ [layout setNeedsLayout];
+ [layout layoutIfNeeded];
+ UIView *hero = wash.subviews.firstObject;
+ NSLog(@"[harness] state %@: hero %@ in the plane, %@ in the window", state,
+ NSStringFromCGRect(hero.frame), NSStringFromCGRect([wash convertRect:hero.frame toView:nil]));
+ };
+ for (NSUInteger i = 0; i < 3; i++) {
+ NSString *state = @[@"rest", @"collapsed", @"pulled"][i];
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((4 + i * 4) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ setState(state);
+ });
+ }
+
+ // Spotify fading its cover square and its colour wash back in as the header opens, which it does on the
+ // scroll itself with nothing laid out: only the hook on that scroll sees it.
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(16 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ setState(@"rest");
+ cover.alpha = 1;
+ gradient.alpha = 1;
+ NSLog(@"[harness] Spotify's cover and wash faded back in");
+ [(SPTFreeTierPlaylistEncoreHeaderViewController *)headerVC entityHeaderViewController:nil didUpdateVisibleRect:CGRectZero];
+ NSLog(@"[harness] after Spotify's fade back in: cover a=%.2f layer.hidden=%d, wash a=%.2f layer.hidden=%d",
+ cover.alpha, cover.layer.hidden, gradient.alpha, gradient.layer.hidden);
+ });
+
+ // Spotify lays the column and the action row out again after the header's pass: their children go back
+ // where its own layout put them, and the redesign has to take them again from its own watch on each.
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ NSArray<NSValue *> *columnFrames = @[[NSValue valueWithCGRect:CGRectMake(0, 0, columnWidth, 29.67)],
+ [NSValue valueWithCGRect:CGRectMake(0, 33.67, columnWidth, 31.33)],
+ [NSValue valueWithCGRect:CGRectMake(0, 69, columnWidth, 34)],
+ [NSValue valueWithCGRect:CGRectMake(0, 107, columnWidth, 15.33)]];
+ for (NSUInteger i = 0; i < columnFrames.count && i < column.subviews.count; i++) {
+ column.subviews[i].frame = columnFrames[i].CGRectValue;
+ }
+ shuffleView.frame = CGRectMake(20, 0, 48, 48);
+ for (NSUInteger i = 0; i < actions.subviews.count; i++) {
+ actions.subviews[i].frame = CGRectMake(i * 48, i == 0 ? 4 : 0, i == 0 ? 58 : 48, i == 0 ? 40 : 48);
+ }
+ [column setNeedsLayout];
+ [actions setNeedsLayout];
+ NSLog(@"[harness] Spotify's own frames put back");
+ });
+ return YES;
+}
+
+@end
+
+// Before every %ctor, so the redesign's gate reads on.
+__attribute__((constructor(101))) static void sgr_harnessDefaults(void) {
+ [NSUserDefaults.standardUserDefaults setBool:YES forKey:@"spotifyglass.redesign"];
+}
+
+int main(int argc, char *argv[]) {
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass(SGRHarnessDelegate.class));
+ }
+}
diff --git a/harness/playlist/stubs.m b/harness/playlist/stubs.m
new file mode 100644
index 00000000..52541606
--- /dev/null
+++ b/harness/playlist/stubs.m
@@ -0,0 +1,8 @@
+// What the harness does not compile: the accent hook (SGRAccent.x) and the repaint hook (SGRRepaint.x).
+#import <UIKit/UIKit.h>
+UIColor *SGRAccentColor(void) { return nil; }
+__weak UIView *sgr_nowPlayingRoot = nil;
+__weak UIView *sgr_nowPlayingCard = nil;
+__weak UIView *sgr_lyricsCardRoot = nil;
+__weak UIView *sgr_lyricsPageRoot = nil;
+__weak UIView *sgr_playlistRoot = nil;
diff --git a/tweak/Sources/Redesigned/Kit/SGRGlass.h b/tweak/Sources/Redesigned/Kit/SGRGlass.h
index 6bc78b0f..df7c659d 100644
--- a/tweak/Sources/Redesigned/Kit/SGRGlass.h
+++ b/tweak/Sources/Redesigned/Kit/SGRGlass.h
@@ -14,3 +14,8 @@
// laid the unit out again, trees/continuous/1.txt 2026-09-17). Takes no touches; made once per control
// under `key`, and made again when Reduce Transparency changes the kind of shape.
UIView *SGRGlassInside(UIView *control, const void *key, CGFloat side);
+
+// The same, in a capsule `size` across rather than a circle: for the one control of an action row that
+// leads (the playlist header's Play). `prominent` lays a white film inside the shape, so that control
+// reads a step brighter than the circles beside it without leaving the same material.
+UIView *SGRGlassCapsuleInside(UIView *control, const void *key, CGSize size, BOOL prominent);
diff --git a/tweak/Sources/Redesigned/Kit/SGRGlass.m b/tweak/Sources/Redesigned/Kit/SGRGlass.m
index edff4de8..5cd24da4 100644
--- a/tweak/Sources/Redesigned/Kit/SGRGlass.m
+++ b/tweak/Sources/Redesigned/Kit/SGRGlass.m
@@ -34,9 +34,39 @@ static UIView *newShape(SGRGlassMode mode) {
#pragma mark - inside a control
-static char kInsideModeKey;
+static char kInsideModeKey, kFilmKey;
-UIView *SGRGlassInside(UIView *control, const void *key, CGFloat side) {
+// The film that makes a shape prominent, inside the effect's own content view so the corners clip it.
+static void keepFilm(UIView *shape, BOOL prominent, SGRGlassMode mode) {
+ if (mode == SGRGlassModeSolid) {
+ shape.backgroundColor = prominent ? [SGRSolidGlassFill() colorWithAlphaComponent:0.26] : SGRSolidGlassFill();
+ return;
+ }
+ UIView *film = objc_getAssociatedObject(shape, &kFilmKey);
+ if (!prominent) {
+ film.hidden = YES;
+ return;
+ }
+ UIView *content = [shape isKindOfClass:UIVisualEffectView.class] ? ((UIVisualEffectView *)shape).contentView : shape;
+ if (!film) {
+ film = [UIView new];
+ film.backgroundColor = [UIColor colorWithWhite:1 alpha:0.14];
+ film.userInteractionEnabled = NO;
+ film.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ objc_setAssociatedObject(shape, &kFilmKey, film, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ film.hidden = NO;
+ if (film.superview != content) [content addSubview:film];
+ // The effect's content view does not clip, so the film carries the shape's corners itself; square ones
+ // drew a lighter rectangle around the playlist's Play capsule (harness, 2026-09-17).
+ if (!CGRectEqualToRect(film.frame, content.bounds)) {
+ film.frame = content.bounds;
+ film.layer.cornerRadius = MIN(content.bounds.size.width, content.bounds.size.height) / 2;
+ film.layer.cornerCurve = kCACornerCurveContinuous;
+ }
+}
+
+static UIView *glassInside(UIView *control, const void *key, CGSize size, BOOL capsule, BOOL prominent) {
if (!control || !key) return nil;
SGRGlassMode mode = glassMode();
UIView *shape = objc_getAssociatedObject(control, key);
@@ -56,13 +86,22 @@ UIView *SGRGlassInside(UIView *control, const void *key, CGFloat side) {
objc_setAssociatedObject(control, key, shape, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
if (shape.superview != control) [control addSubview:shape];
- shape.hidden = side <= 0;
- CGRect bounds = CGRectMake(0, 0, side, side);
+ shape.hidden = size.width <= 0 || size.height <= 0;
+ CGRect bounds = CGRectMake(0, 0, size.width, size.height);
if (!CGRectEqualToRect(shape.bounds, bounds)) {
shape.bounds = bounds;
- SGShapeGlass(shape, side / 2, YES);
+ SGShapeGlass(shape, MIN(size.width, size.height) / 2, capsule);
}
+ keepFilm(shape, prominent, mode);
CGPoint middle = CGPointMake(CGRectGetMidX(control.bounds), CGRectGetMidY(control.bounds));
if (!CGPointEqualToPoint(shape.center, middle)) shape.center = middle;
return shape;
}
+
+UIView *SGRGlassInside(UIView *control, const void *key, CGFloat side) {
+ return glassInside(control, key, CGSizeMake(side, side), YES, NO);
+}
+
+UIView *SGRGlassCapsuleInside(UIView *control, const void *key, CGSize size, BOOL prominent) {
+ return glassInside(control, key, size, YES, prominent);
+}
diff --git a/tweak/Sources/Redesigned/Kit/SGRRepaint.h b/tweak/Sources/Redesigned/Kit/SGRRepaint.h
index 70a9df01..173c6f5c 100644
--- a/tweak/Sources/Redesigned/Kit/SGRRepaint.h
+++ b/tweak/Sources/Redesigned/Kit/SGRRepaint.h
@@ -5,3 +5,7 @@
extern __weak UIView *sgr_nowPlayingRoot; // Redesigned/NowPlayingBar/NowPlayingBar.x, the bar
extern __weak UIView *sgr_nowPlayingCard; // the bar's painted card, learnt from the album-colour paint
extern __weak UIView *sgr_lyricsPageRoot; // Redesigned/Lyrics/LyricsPage.x
+// Redesigned/Playlist/PlaylistField.x, the playlist page. Only the base surface Spotify paints the page,
+// its list and its rows with goes clear here: the artwork field is underneath, and the greys of a
+// placeholder or a badge are what still has to read against it.
+extern __weak UIView *sgr_playlistRoot;
diff --git a/tweak/Sources/Redesigned/Kit/SGRRepaint.x b/tweak/Sources/Redesigned/Kit/SGRRepaint.x
index afd4d3f0..23fa5340 100644
--- a/tweak/Sources/Redesigned/Kit/SGRRepaint.x
+++ b/tweak/Sources/Redesigned/Kit/SGRRepaint.x
@@ -6,10 +6,11 @@
__weak UIView *sgr_nowPlayingRoot = nil;
__weak UIView *sgr_nowPlayingCard = nil;
__weak UIView *sgr_lyricsPageRoot = nil;
+__weak UIView *sgr_playlistRoot = nil;
%hook CALayer
- (void)setBackgroundColor:(CGColorRef)color {
- if (color && (sgr_nowPlayingRoot || sgr_lyricsPageRoot)) {
+ if (color && (sgr_nowPlayingRoot || sgr_lyricsPageRoot || sgr_playlistRoot)) {
UIView *view = (UIView *)self.delegate;
if ([view isKindOfClass:UIView.class] && view.layer == self && !SGKeepsColor(view)) {
if (SGIsInside(view, sgr_nowPlayingRoot)) {
@@ -21,6 +22,8 @@ __weak UIView *sgr_lyricsPageRoot = nil;
color = NULL;
} else if (SGIsInside(view, sgr_lyricsPageRoot)) {
color = NULL;
+ } else if (SGIsBaseSurface(color) && SGIsInside(view, sgr_playlistRoot)) {
+ color = NULL;
}
}
}
diff --git a/tweak/Sources/Redesigned/Kit/SGRRestyle.h b/tweak/Sources/Redesigned/Kit/SGRRestyle.h
index 14af977e..64e8962c 100644
--- a/tweak/Sources/Redesigned/Kit/SGRRestyle.h
+++ b/tweak/Sources/Redesigned/Kit/SGRRestyle.h
@@ -27,6 +27,15 @@ void SGRMonospacedDigits(UILabel *label);
// cannot be subclassed (a KVO-observed instance): the caller then only sees what its own passes read.
BOOL SGRObserveImage(UIImageView *view, void (^changed)(UIImageView *view));
+// `laidOut` after every layoutSubviews of the view, Spotify's included, for as long as the view lives, by
+// a runtime subclass of the instance like SGRSuppress. A second call replaces the block, and a pass started
+// from inside the block is not reported again. NO when the view cannot be subclassed (one of Spotify's Swift
+// classes, a KVO-observed instance): the caller then has only the passes it hooks itself to work from.
+//
+// For a screen that arranges Spotify's controls its own way: a parent lays its children out after the
+// hook that placed them has returned, so frames set from an ancestor's pass are the ones overwritten.
+BOOL SGRObserveLayout(UIView *view, void (^laidOut)(UIView *view));
+
// The first view under `root` (itself included) with the accessibility identifier, depth first. The
// answer is kept weakly on `root` under `cacheKey` and searched for again only when it is gone, has
// left `root` or changed its identifier. nil when there is none; a miss is not cached.
diff --git a/tweak/Sources/Redesigned/Kit/SGRRestyle.m b/tweak/Sources/Redesigned/Kit/SGRRestyle.m
index 342418b0..14095b74 100644
--- a/tweak/Sources/Redesigned/Kit/SGRRestyle.m
+++ b/tweak/Sources/Redesigned/Kit/SGRRestyle.m
@@ -4,7 +4,7 @@
#import "SGRRestyle.h"
#import "SGRTokens.h"
-static char kPlateKey, kImageObserverKey;
+static char kPlateKey, kImageObserverKey, kLayoutObserverKey;
@interface SGRWeakBox : NSObject
@property (nonatomic, weak) id value;
@@ -158,6 +158,37 @@ BOOL SGRObserveImage(UIImageView *view, void (^changed)(UIImageView *view)) {
return kept;
}
+// A pass the block itself sets off (a frame it moves) reaches layoutSubviews again before the block has
+// returned; one level is enough to settle, and re-entering would not end.
+static BOOL sg_reportingLayout = NO;
+
+BOOL SGRObserveLayout(UIView *view, void (^laidOut)(UIView *view)) {
+ if (![view isKindOfClass:UIView.class]) return NO;
+ objc_setAssociatedObject(view, &kLayoutObserverKey, laidOut, OBJC_ASSOCIATION_COPY_NONATOMIC);
+ BOOL kept = adopt(view, "SGRLayoutObserved_", ^(Class subclass, Class original) {
+ addOverride(subclass, original, @selector(layoutSubviews), ^(UIView *self) {
+ struct objc_super parent = {self, original};
+ ((void (*)(struct objc_super *, SEL))objc_msgSendSuper)(&parent, @selector(layoutSubviews));
+ if (sg_reportingLayout) return;
+ void (^block)(UIView *) = objc_getAssociatedObject(self, &kLayoutObserverKey);
+ if (!block) return;
+ sg_reportingLayout = YES;
+ block(self);
+ sg_reportingLayout = NO;
+ });
+ });
+ if (!kept) {
+ static NSMutableSet<NSString *> *logged;
+ if (!logged) logged = [NSMutableSet set];
+ NSString *name = NSStringFromClass(object_getClass(view));
+ if (![logged containsObject:name]) {
+ [logged addObject:name];
+ SGLog(@"redesign kit: %@ cannot be watched for its layout", name);
+ }
+ }
+ return kept;
+}
+
// An identifier ending in * matches by prefix, for Spotify's ids that carry an entity after a dash.
static BOOL identifierMatches(NSString *identifier, NSString *wanted) {
if (!identifier) return NO;
diff --git a/tweak/Sources/Redesigned/Playlist/Playlist.h b/tweak/Sources/Redesigned/Playlist/Playlist.h
new file mode 100644
index 00000000..6ba8bfda
--- /dev/null
+++ b/tweak/Sources/Redesigned/Playlist/Playlist.h
@@ -0,0 +1,33 @@
+// The playlist redesign: Spotify's playlist page kept, with its controllers, its header and its list, and
+// laid out the way the Music app lays a playlist out. Liked Songs and a playlist of the user's own are the
+// same page (trees/clean/liked-songs/01.txt, own-playlist/01.txt: one FTPViewController, one
+// SPTFreeTierPlaylistEncoreHeaderViewController), so one redesign covers all three. Album and artist pages
+// are built by another framework and are left alone.
+//
+// PlaylistField.x the artwork field behind the whole page, the artwork it is read from, the flags
+// the screen forces
+// PlaylistHeader.x the header: the cover full bleed at the top dissolving into the field, the title,
+// the creator and the length centred under it, and one row of glass controls --
+// shuffle, a prominent Play capsule, add, and more where Spotify still has it
+// PlaylistRows.x the track rows on the field with no surface of their own, rounded artwork, a
+// hairline between them, and the curation pills collapsed
+//
+// Every hook installs only while Redesigned UI is on (SGRedesignedUI); the native look's do not then.
+// Threading: main thread only.
+#import <UIKit/UIKit.h>
+
+// The page's list (trees/clean/playlist/02.txt:23).
+extern NSString *const SGRPlaylistListIdentifier;
+
+// The playlist page `view` is on, or nil: SPTFreeTierPlaylistEncoreHeaderViewController's own view, the one
+// the tree names PL.Header, for anything under the header, and FTPViewController's view for the list.
+UIViewController *SGRPlaylistHeaderOf(UIView *view);
+
+// PlaylistField.x. The field belongs to the page `view` is on, found by walking up from it, so two playlist
+// pages on the navigation stack keep a field each.
+//
+// The colour the page's field is showing, SGRNeutralField() before one has been read: what the header's
+// cover has to dissolve into for there to be no seam.
+UIColor *SGRPlaylistFieldColor(UIView *view);
+// The cover of the page `view` is on, for its field to take its colour from. The same image again is a no-op.
+void SGRPlaylistSetArtwork(UIView *view, UIImage *image);
diff --git a/tweak/Sources/Redesigned/Playlist/PlaylistField.x b/tweak/Sources/Redesigned/Playlist/PlaylistField.x
new file mode 100644
index 00000000..620847bc
--- /dev/null
+++ b/tweak/Sources/Redesigned/Playlist/PlaylistField.x
@@ -0,0 +1,108 @@
+// Playlist redesign: the artwork field behind the whole page, and what the switch forces.
+//
+// Tree (trees/clean/playlist/02.txt:23 and :1096): FTPViewController's view holds the list
+// (ListUXPlatform_FreeTierPlaylistImpl.FTPTouchCancellingCollectionView, id=SPTFreeTierPlaylistTableView,
+// the size of the window) and, after it and so over it, the header (id=PL.Header). Neither scrolls the
+// other: the list keeps its frame and the header's y runs from -134 at rest to -529 scrolled, so a field
+// put behind both stays still while the cover at the top of the header slides up over it -- which is what
+// the Music app does with the page colour.
+//
+// So the field is the page's bottom-most view, the size of the view and bleeding past it, with no backdrop
+// of its own: the sharp cover at the top of the header is the picture, and PlaylistHeader.x fades it into
+// exactly this field's colour. What Spotify paints over the field -- the page, the list and every row, all
+// of them the base surface -- is kept clear by the Kit's repaint hook while sgr_playlistRoot is this page.
+//
+// The colour is read from the cover the header shows (PlaylistHeader.x hands it over), and until that has
+// loaded the field is the neutral one, as it is for a playlist with no cover at all.
+#import "Core/SGCore.h"
+#import "Redesigned/Kit/SGRKit.h"
+#import "Playlist.h"
+
+NSString *const SGRPlaylistListIdentifier = @"SPTFreeTierPlaylistTableView";
+
+// Above for the bounce at the top of the list, below for the one at the end of it.
+static const UIEdgeInsets kBleed = {600, 0, 600, 0};
+
+static char kFieldKey;
+
+#pragma mark - the page's field
+
+static SGRArtworkField *fieldOn(UIView *view) {
+ for (UIView *v = view; v; v = v.superview) {
+ SGRArtworkField *field = objc_getAssociatedObject(v, &kFieldKey);
+ if (field) return field;
+ }
+ return nil;
+}
+
+UIColor *SGRPlaylistFieldColor(UIView *view) {
+ SGRArtworkField *field = fieldOn(view);
+ return field.fieldColor ?: SGRNeutralField();
+}
+
+void SGRPlaylistSetArtwork(UIView *view, UIImage *image) {
+ if (image) [fieldOn(view) setArtwork:image identity:nil animated:YES];
+}
+
+static SGRArtworkField *fieldIn(UIView *page) {
+ SGRArtworkField *field = objc_getAssociatedObject(page, &kFieldKey);
+ if (field) return field;
+ field = [[SGRArtworkField alloc] initWithFrame:page.bounds];
+ field.bleed = kBleed;
+ objc_setAssociatedObject(page, &kFieldKey, field, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ SGLog(@"redesign playlist: field on the page %.0fx%.0f", page.bounds.size.width, page.bounds.size.height);
+ return field;
+}
+
+%hook _TtC35ListUXPlatform_FreeTierPlaylistImpl17FTPViewController
+- (void)viewDidLayoutSubviews {
+ %orig;
+ UIView *page = ((UIViewController *)self).viewIfLoaded;
+ if (!page || page.bounds.size.height < 200) return;
+ sgr_playlistRoot = page;
+ SGRArtworkField *field = fieldIn(page);
+ if (field.superview != page) [page insertSubview:field atIndex:0];
+ else if (page.subviews.firstObject != field) [page sendSubviewToBack:field];
+ if (!CGRectEqualToRect(field.frame, page.bounds)) field.frame = page.bounds;
+}
+
+// The page the repaint hook keeps clear is the one on screen; another playlist pushed over this one sets
+// itself from its own pass, and this one sets itself again when it comes back.
+- (void)viewWillAppear:(BOOL)animated {
+ %orig;
+ UIView *page = ((UIViewController *)self).viewIfLoaded;
+ if (page) sgr_playlistRoot = page;
+}
+%end
+
+// The list paints itself the base surface from its own pass rather than through a layer that the repaint
+// hook would hear about, so it is cleared where it is laid out.
+%hook _TtC35ListUXPlatform_FreeTierPlaylistImpl32FTPTouchCancellingCollectionView
+- (void)layoutSubviews {
+ %orig;
+ UIScrollView *list = (UIScrollView *)self;
+ if (list.backgroundColor && SGIsBaseSurface(list.backgroundColor.CGColor)) list.backgroundColor = UIColor.clearColor;
+}
+%end
+
+%ctor {
+ // Registered whatever the switch says: the flag rows elsewhere lock to these while it is on.
+ SGRedesignForceFlags(@"playlist", @{
+ // The page the trees were recorded with (trees/clean/playlist/02.txt).
+ @"ios-feature-freetierplaylist.use_collection_view": @YES,
+ // The Music app keeps share and more out of the row under the cover; this is Spotify's own way of
+ // moving the more button up into the navigation bar, and the action row is laid out from whichever
+ // of the buttons it still finds, so it reads either way.
+ @"ios-feature-freetierplaylist.context_menu_in_navigation_bar_enabled": @YES,
+ // A row is a cover, a title and an artist. The video badge is none of them.
+ @"ios-feature-freetierplaylist.hide_video_badge_for_tracks": @YES,
+ // The curation pills are collapsed (PlaylistRows.x); pinned they would be collapsed on every scroll.
+ @"ios-feature-freetierplaylist.pin_curation_actions": @NO,
+ });
+ if (!SGRedesignedUI()) return;
+ %init;
+ SGRequireClasses(@[
+ @"_TtC35ListUXPlatform_FreeTierPlaylistImpl17FTPViewController",
+ @"_TtC35ListUXPlatform_FreeTierPlaylistImpl32FTPTouchCancellingCollectionView",
+ ]);
+}
diff --git a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x
new file mode 100644
index 00000000..11ced184
--- /dev/null
+++ b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x
@@ -0,0 +1,660 @@
+// Playlist redesign: the header the Music app gives a playlist. 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 creator and the
+// length 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.
+//
+// Tree (trees/clean/playlist/01.txt:640-869). Spotify's header is id=PL.Header, and at rest its
+// HeaderContentLayout starts at the very top of the page. It holds exactly two things:
+//
+// Components.Header.UI.ArtworkImage a ShadowContainer, the cover square, centred at {80, 68} 243x243
+// the block a plain UIView at {0, 327} 386x178: a column of title, description,
+// creator row and length, and under it the action row
+//
+// Nothing is measured from what the header shows: -[SPTFreeTierPlaylistEncoreHeaderViewController update]
+// counts a stored fullHeaderHeight and pins headerViewHeightConstraint to it. So the redesign changes no
+// height and moves nothing between the two: the cover's square is where the full bleed picture goes, and
+// the block keeps its place with its own contents rearranged. The header then collapses, snaps and scrolls
+// exactly as Spotify laid it out.
+//
+// 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 -- the column and the action row are both laid out by Spotify
+// after HeaderContentLayout's pass has returned. Both of them are plain UIViews, so each is watched for its
+// own pass with the Kit's SGRObserveLayout, and the header's pass only finds them and starts the watch.
+//
+// Every one of Spotify's controls stays Spotify's own, with its action, its state and its accessibility:
+// they are moved by frame, never rebuilt. The one exception is Play, which the Music app draws as a capsule
+// with a word in it rather than a disc: the capsule is the Kit's, it takes the glyph and the word from
+// Spotify's own button (so play, pause and the language are Spotify's), and a tap on it fires that button.
+#import "Core/SGCore.h"
+#import "Redesigned/Kit/SGRKit.h"
+#import "Playlist.h"
+
+// How much of the cover's height the dissolve into the field covers, and the scrim over the top of it that
+// keeps the status bar and the back button legible on a bright picture.
+static const CGFloat kDissolve = 0.46, kTopScrim = 140, kTopScrimAlpha = 0.28;
+// A header whose cover square is smaller than this is one mid collapse or mid load, not one to measure
+// the hero from; and an artwork view narrower than this is a placeholder glyph rather than the cover.
+static const CGFloat kMinHero = 120, kMinCover = 80;
+// The play capsule: the glyph is Spotify's own 48pt canvas with the triangle small in the middle of it, so
+// the lead is short and the gap to the word comes out of the canvas itself.
+static const CGFloat kGlyphSide = 44, kCapsuleLead = 4, kCapsuleTrail = 20;
+
+static char kCoverKey, kRowKey, kMetaKey, kPlayKey, kGlassKey, kCapsuleGlassKey, kLayoutKey;
+static char kShuffleKey, kAddKey, kMoreKey, kToolbarKey;
+static char kHeroKey, kHeroHeightKey, kCapsuleKey, kColumnWatchedKey, kRowWatchedKey, kCoverWatchedKey, kGlyphWatchedKey;
+
+#pragma mark - finding things
+
+@interface SGRWeakView : NSObject
+@property (nonatomic, weak) UIView *view;
+@end
+@implementation SGRWeakView
+@end
+
+UIViewController *SGRPlaylistHeaderOf(UIView *view) {
+ for (UIResponder *r = view; r; r = r.nextResponder) {
+ if (![r isKindOfClass:UIViewController.class]) continue;
+ return [NSStringFromClass(r.class) containsString:@"FreeTierPlaylist"] ? (UIViewController *)r : nil;
+ }
+ return nil;
+}
+
+// Invisible for good. Spotify fades its cover square and its colour wash back in from the scroll itself,
+// with nothing laid out (trees/continuous/1.txt, 2026-09-17), so a redesign that answers with alpha is in a
+// fight it loses a frame of on every scroll -- which is what the flicker was. `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.
+static void conceal(UIView *view) {
+ if (!view) return;
+ if (!view.layer.hidden) view.layer.hidden = YES;
+ 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 stacks that trap when an arranged view is hidden, and which it leaves alone.
+static void vanish(UIView *view) {
+ if (!view) return;
+ if (view.alpha != 0) view.alpha = 0;
+ if (view.userInteractionEnabled) view.userInteractionEnabled = NO;
+ view.accessibilityElementsHidden = YES;
+}
+
+static UIView *firstOfClass(UIView *root, Class wanted) {
+ __block UIView *found = nil;
+ SGForEachView(root, ^(UIView *v) {
+ if (!found && [v isKindOfClass:wanted]) found = v;
+ });
+ return found;
+}
+
+// The outermost view that still wraps the button exactly: what Spotify's stack arranges, and so what moves
+// without the button coming loose from whatever draws around it.
+static UIView *wrapperFor(UIView *button, UIView *stop) {
+ UIView *wrapper = button;
+ for (UIView *v = button.superview; v && v != stop; v = v.superview) {
+ if (fabs(v.bounds.size.width - button.bounds.size.width) > 4) break;
+ if (fabs(v.bounds.size.height - button.bounds.size.height) > 4) break;
+ wrapper = v;
+ }
+ return wrapper;
+}
+
+// A rect of `container`'s, set on a view that hangs somewhere else in the header. Nothing on the way down to
+// the action row clips, so a control placed from its own parent lands where the row wants it.
+static void place(UIView *view, CGRect target, UIView *container) {
+ if (!view.superview || CGRectIsEmpty(target)) return;
+ CGRect local = [view.superview convertRect:target fromView:container];
+ if (!CGRectEqualToRect(view.frame, local)) view.frame = local;
+}
+
+static void styleLabels(UIView *root, UIColor *color, UIFont *font, NSTextAlignment alignment) {
+ SGForEachView(root, ^(UIView *v) {
+ if ([v isKindOfClass:UILabel.class]) {
+ 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;
+ } else if ([v isKindOfClass:UITextView.class]) {
+ UITextView *text = (UITextView *)v;
+ if (color && ![text.textColor isEqual:color]) text.textColor = color;
+ if (text.textAlignment != alignment) text.textAlignment = alignment;
+ }
+ });
+}
+
+#pragma mark - the cover, full bleed
+
+// The picture across the top of the page with the field showing through the bottom of it. Two gradients
+// rather than a mask or a blur: a scrim over the top for the status bar, and under it a fade from the
+// picture to the very colour the page's field is drawing, so the two meet with nothing to see.
+@interface SGRPlaylistHero : UIView
+@property (nonatomic, readonly) UIImageView *picture;
+@property (nonatomic, copy) UIColor *fieldColor;
+@property (nonatomic) CGFloat coverPixels; // the widest copy of the artwork it has been shown
+@end
+
+@implementation SGRPlaylistHero {
+ CAGradientLayer *_scrim, *_dissolve;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ if (!(self = [super initWithFrame:frame])) return nil;
+ self.userInteractionEnabled = NO;
+ self.accessibilityElementsHidden = YES;
+ self.clipsToBounds = YES;
+
+ _picture = [[UIImageView alloc] initWithFrame:self.bounds];
+ _picture.contentMode = UIViewContentModeScaleAspectFill;
+ _picture.clipsToBounds = YES;
+ _picture.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ [self addSubview:_picture];
+
+ // Above the picture's own layer whatever else is added to the view later.
+ _scrim = [CAGradientLayer layer];
+ _scrim.zPosition = 1;
+ _scrim.colors = @[(id)[UIColor colorWithWhite:0 alpha:kTopScrimAlpha].CGColor, (id)UIColor.clearColor.CGColor];
+ [self.layer addSublayer:_scrim];
+
+ _dissolve = [CAGradientLayer layer];
+ _dissolve.zPosition = 2;
+ [self.layer addSublayer:_dissolve];
+ self.fieldColor = SGRNeutralField();
+ // The colour is read off the main thread, so it can land after the last layout pass of the page.
+ [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(sgr_fieldColorDidChange)
+ name:SGRFieldColorDidChangeNotification object:nil];
+ return self;
+}
+
+- (void)dealloc {
+ [NSNotificationCenter.defaultCenter removeObserver:self];
+}
+
+- (void)sgr_fieldColorDidChange {
+ if (self.superview) self.fieldColor = SGRPlaylistFieldColor(self);
+}
+
+- (void)setFieldColor:(UIColor *)color {
+ if (!color || [_fieldColor isEqual:color]) return;
+ _fieldColor = [color copy];
+ // The clear end is the same colour with no alpha rather than +clearColor, so the fade keeps its hue
+ // instead of going through grey.
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ _dissolve.colors = @[(id)[color colorWithAlphaComponent:0].CGColor,
+ (id)[color colorWithAlphaComponent:0.72].CGColor,
+ (id)color.CGColor];
+ _dissolve.locations = @[@0, @0.62, @1];
+ [CATransaction commit];
+}
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ CGRect bounds = self.bounds;
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ _scrim.frame = CGRectMake(0, 0, bounds.size.width, MIN(kTopScrim, bounds.size.height));
+ CGFloat fade = round(bounds.size.height * kDissolve);
+ _dissolve.frame = CGRectMake(0, bounds.size.height - fade, bounds.size.width, fade);
+ [CATransaction commit];
+}
+
+@end
+
+// The cover Spotify loaded, read from the image view of its artwork square.
+static UIImageView *coverImageIn(UIView *cover) {
+ __block UIImageView *found = nil;
+ SGForEachView(cover, ^(UIView *v) {
+ if (found || ![v isKindOfClass:UIImageView.class]) return;
+ UIImageView *image = (UIImageView *)v;
+ if (image.image && image.bounds.size.width >= kMinCover) found = image;
+ });
+ return found;
+}
+
+// Spotify loads the artwork at the size the cover square is asking for, and the square shrinks as the
+// header collapses: scrolled down it swapped a 105px copy in for the 254px one and the picture across the
+// top of the page went soft with it (trees/continuous/2.txt, 2026-09-17). So a copy is taken only while the
+// square is still at full size, which is the only time Spotify asks for one worth showing.
+static void showCover(SGRPlaylistHero *hero, UIImageView *view, UIView *layout) {
+ UIImage *image = view.image;
+ if (!image || view.bounds.size.width < kMinHero) return;
+
+ hero.coverPixels = image.size.width;
+ if (hero.picture.image != image) hero.picture.image = image;
+ SGRPlaylistSetArtwork(layout, image);
+}
+
+// The hero belongs in the plane Spotify's own colour wash is drawn on: that plane keeps its full height and
+// slides up out of the clipping view as the header collapses, and the container above it fades it out as the
+// navigation bar takes over (trees/continuous/2.txt: the wash at {0, -364} 402x474 inside a 110pt container
+// at a=0.00). So the picture needs no help to move -- Core Animation carries it with the plane, in the same
+// frame, with nothing to recompute and so nothing to flicker.
+//
+// Which is the whole design: the hero is measured once, when the header is first laid out whole, and its
+// frame never changes again. Everything else the page does to it -- the collapse, the snap, the bounce at
+// the top -- is the plane's movement, which is Spotify's to make and ours to sit still inside. Reading the
+// header's geometry on every frame instead is what made it flicker: the numbers it is built from move under
+// their own animations, and a redesign reading them is always a frame behind.
+//
+// Its height is where the header's text begins, taken in the plane'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: pulled down
+// past the top, where Spotify moves its text down and leaves a gap, that gap is the same colour and there is
+// no seam to see.
+static void applyHero(UIView *layout, UIView *cover, UIView *plane, UIView *block) {
+ if (!plane || !block) return;
+ SGRPlaylistHero *hero = objc_getAssociatedObject(plane, &kHeroKey);
+ if (!hero) {
+ hero = [[SGRPlaylistHero alloc] initWithFrame:CGRectZero];
+ objc_setAssociatedObject(plane, &kHeroKey, hero, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ if (hero.superview != plane) [plane insertSubview:hero atIndex:0];
+ else if (plane.subviews.firstObject != hero) [plane sendSubviewToBack:hero];
+
+ CGFloat height = [objc_getAssociatedObject(hero, &kHeroHeightKey) doubleValue];
+ if (height <= 0) {
+ // The first pass with the header whole. The block sits where the header put it while the header is
+ // whole and climbs out of its place while it collapses, so a page opened already scrolled waits.
+ CGFloat measured = [plane convertPoint:CGPointMake(0, CGRectGetMinY(block.frame)) fromView:layout].y;
+ if (measured < kMinHero) return;
+ height = measured;
+ objc_setAssociatedObject(hero, &kHeroHeightKey, @(height), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ SGLog(@"redesign playlist: hero %.0fpt across the top of the plane, for good", height);
+ }
+ CGRect frame = CGRectMake(0, 0, plane.bounds.size.width, height);
+ if (!CGRectEqualToRect(hero.frame, frame)) hero.frame = frame;
+ hero.fieldColor = SGRPlaylistFieldColor(layout);
+
+ UIImageView *source = coverImageIn(cover);
+ showCover(hero, source, layout);
+ // The cover loads after the header is laid out, and a new image lays nothing out again.
+ if (source && !objc_getAssociatedObject(source, &kCoverWatchedKey)) {
+ objc_setAssociatedObject(source, &kCoverWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ __weak SGRPlaylistHero *weakHero = hero;
+ __weak UIView *weakLayout = layout;
+ SGRObserveImage(source, ^(UIImageView *view) {
+ if (weakHero && weakLayout) showCover(weakHero, view, weakLayout);
+ });
+ }
+ conceal(cover);
+}
+
+#pragma mark - the column
+
+// Title, creator and length centred under the cover, the description last, the way the Music app reads. The
+// four sit as frames in a plain UIView, so the order is the order they are given, and the column keeps the
+// height Spotify measured for it: what is laid out here never grows past it.
+static void applyColumn(UIView *column) {
+ UIView *title = nil, *description = nil, *creator = nil, *length = nil;
+ for (UIView *row in column.subviews) {
+ if (SGHasClass(row, @"ExpandableTextView")) description = row;
+ else if (SGHasClass(row, @"FacepileView")) creator = row;
+ else if (SGRFindByIdentifier(row, @"Components.Header.UI.Metadata", &kMetaKey)) length = row;
+ else if (!title) title = row;
+ }
+ if (!title) return;
+
+ styleLabels(title, SGRPrimary(), SGRFont(UIFontTextStyleTitle2, UIFontWeightSemibold, UIContentSizeCategoryLarge), NSTextAlignmentCenter);
+ styleLabels(creator, SGRAccent(), nil, NSTextAlignmentCenter);
+ styleLabels(length, SGRTertiary(), nil, NSTextAlignmentCenter);
+ styleLabels(description, SGRSecondary(), nil, NSTextAlignmentCenter);
+
+ NSMutableArray<UIView *> *rows = [NSMutableArray array];
+ NSMutableArray<NSNumber *> *gaps = [NSMutableArray array];
+ NSArray *order = @[title, creator ?: NSNull.null, length ?: NSNull.null, description ?: NSNull.null];
+ NSArray<NSNumber *> *after = @[@6, @2, @8, @0];
+ for (NSUInteger i = 0; i < order.count; i++) {
+ UIView *row = (UIView *)order[i];
+ if (![row isKindOfClass:UIView.class] || row.hidden || row.bounds.size.height <= 0) continue;
+ [rows addObject:row];
+ [gaps addObject:after[i]];
+ }
+
+ CGFloat width = column.bounds.size.width, room = column.bounds.size.height;
+ CGFloat bare = 0;
+ for (UIView *row in rows) bare += row.bounds.size.height;
+ 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;
+ if (bare > room && description && [rows containsObject:description]) {
+ [rows removeObject:description];
+ vanish(description);
+ }
+
+ CGFloat y = 0;
+ for (NSUInteger i = 0; i < rows.count; i++) {
+ UIView *row = rows[i];
+ CGSize size = row.bounds.size;
+ // A row Spotify fills the width with centres its own text; one that holds a narrow stack of its own
+ // is moved instead, keeping its width so the stack inside it is not laid out differently.
+ CGFloat content = size.width;
+ for (UIView *part in row.subviews) {
+ 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;
+ 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);
+ }
+}
+
+#pragma mark - the Play capsule
+
+@interface SGRPlayCapsule : UIControl
+@property (nonatomic, readonly) UIImageView *glyph;
+@property (nonatomic, readonly) UILabel *title;
+@property (nonatomic, weak) UIView *source; // Spotify's own play button, fired by a tap
+@end
+
+@implementation SGRPlayCapsule
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ if (!(self = [super initWithFrame:frame])) return nil;
+ _glyph = [UIImageView new];
+ _glyph.contentMode = UIViewContentModeScaleAspectFit;
+ _glyph.userInteractionEnabled = NO;
+ [self addSubview:_glyph];
+
+ _title = [UILabel new];
+ _title.userInteractionEnabled = NO;
+ [self addSubview:_title];
+
+ self.isAccessibilityElement = YES;
+ self.accessibilityTraits = UIAccessibilityTraitButton;
+ [self addTarget:self action:@selector(sgr_down) forControlEvents:UIControlEventTouchDown];
+ [self addTarget:self action:@selector(sgr_up) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside | UIControlEventTouchCancel];
+ [self addTarget:self action:@selector(sgr_tap) forControlEvents:UIControlEventTouchUpInside];
+ return self;
+}
+
+- (CGFloat)sgr_width {
+ [_title sizeToFit];
+ return kCapsuleLead + kGlyphSide + ceil(_title.bounds.size.width) + kCapsuleTrail;
+}
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ CGRect bounds = self.bounds;
+ SGRGlassCapsuleInside(self, &kCapsuleGlassKey, bounds.size, YES);
+ _glyph.frame = CGRectMake(kCapsuleLead, round((bounds.size.height - kGlyphSide) / 2), kGlyphSide, kGlyphSide);
+ [_title sizeToFit];
+ CGSize text = _title.bounds.size;
+ _title.frame = CGRectMake(CGRectGetMaxX(_glyph.frame), round((bounds.size.height - text.height) / 2),
+ MAX(0, bounds.size.width - kCapsuleTrail - CGRectGetMaxX(_glyph.frame)), text.height);
+}
+
+- (void)sgr_down {
+ SGRAnimate(SGRMotionPress, ^{ self.transform = CGAffineTransformMakeScale(0.94, 0.94); }, nil);
+}
+
+- (void)sgr_up {
+ SGRAnimate(SGRMotionPress, ^{ self.transform = CGAffineTransformIdentity; }, nil);
+}
+
+- (void)sgr_tap {
+ __block UIControl *control = nil;
+ SGForEachView(self.source, ^(UIView *v) {
+ if (!control && [v isKindOfClass:UIControl.class]) control = (UIControl *)v;
+ });
+ if (control && SGRFire(control)) return;
+ id target = control ?: self.source;
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{ SGLog(@"redesign playlist: play fired through accessibility on %@", [target class]); });
+ [target accessibilityActivate];
+}
+
+@end
+
+// The capsule takes what it shows from Spotify's button: the glyph it draws, whichever of play and pause
+// that is, and the word beside it in the app's own language.
+static void feedCapsule(SGRPlayCapsule *capsule, UIView *playButton) {
+ capsule.source = playButton;
+
+ // The glyph is the disc the button draws, the size of the button itself, and it has to be looked for
+ // past what is hidden behind it: the play button's glow ring is a hidden 78pt view holding an image of
+ // its own, and taken for the glyph it put a soft green ring in the capsule (device, 2026-09-17).
+ __block NSString *word = nil;
+ __block UIImageView *glyph = nil;
+ CGFloat side = playButton.bounds.size.width;
+ SGForEachView(playButton, ^(UIView *v) {
+ if (!word && v.accessibilityLabel.length) word = v.accessibilityLabel;
+ if (glyph || ![v isKindOfClass:UIImageView.class] || !((UIImageView *)v).image) return;
+ if (fabs(v.bounds.size.width - side) > 2 || fabs(v.bounds.size.height - side) > 2) return;
+ for (UIView *up = v; up && up != playButton; up = up.superview) {
+ if (up.hidden || up.alpha <= 0.01) return;
+ }
+ glyph = (UIImageView *)v;
+ });
+
+ UIFont *font = SGRFont(UIFontTextStyleSubheadline, UIFontWeightSemibold, UIContentSizeCategoryLarge);
+ if (![capsule.title.font isEqual:font]) capsule.title.font = font;
+ if (![capsule.title.textColor isEqual:SGRAccent()]) capsule.title.textColor = SGRAccent();
+ if (word && ![capsule.title.text isEqualToString:word]) {
+ capsule.title.text = word;
+ capsule.accessibilityLabel = word;
+ [capsule setNeedsLayout];
+ }
+ if (![capsule.glyph.tintColor isEqual:SGRAccent()]) capsule.glyph.tintColor = SGRAccent();
+
+ if (glyph.image && capsule.glyph.image != glyph.image) {
+ capsule.glyph.image = [glyph.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{
+ SGLog(@"redesign playlist: play glyph %@ from %@, word \"%@\"", NSStringFromCGSize(glyph.image.size),
+ NSStringFromClass(glyph.class), word);
+ });
+ }
+ // Play becomes pause without the header laying out again.
+ if (glyph && !objc_getAssociatedObject(glyph, &kGlyphWatchedKey)) {
+ objc_setAssociatedObject(glyph, &kGlyphWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ __weak SGRPlayCapsule *weakCapsule = capsule;
+ __weak UIView *weakButton = playButton;
+ SGRObserveImage(glyph, ^(UIImageView *view) {
+ if (weakCapsule && weakButton) feedCapsule(weakCapsule, weakButton);
+ });
+ }
+}
+
+#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 carries its own.
+static void applyActions(UIView *block, UIView *headerRoot) {
+ UIView *row = SGRFindByIdentifier(block, @"HeaderActionsRow", &kRowKey);
+ // The row of the block, not the box Spotify wraps its own half of it in: a plain UIView as wide as the
+ // block itself, which is the one the centred row is measured against (the harness placed the group 90pt
+ // off centre when the narrower wrapper was taken for it, 2026-09-17).
+ UIView *container = nil;
+ for (UIView *v = row.superview; v && v != block; v = v.superview) {
+ if (object_getClass(v) != UIView.class || v.bounds.size.height > 80) continue;
+ if (v.bounds.size.width < block.bounds.size.width - 24) continue;
+ container = v;
+ break;
+ }
+ if (!container) return;
+
+ UIView *shuffle = SGRFindByIdentifier(block, @"Components.UI.ShuffleButton", &kShuffleKey);
+ UIView *add = SGRFindByIdentifier(block, @"Components.UI.AddToButton", &kAddKey);
+ UIView *more = SGRFindByIdentifier(block, @"Components.UI.ContextMenuButton", &kMoreKey);
+ for (NSString *identifier in @[@"Components.UI.WatchFeedEntityExplorerButton", @"DownloadButton.Granular*",
+ @"Components.UI.ShareButton", @"MixAndShuffleComposedUI.mixView"]) {
+ UIView *gone = SGRFindByIdentifier(block, identifier, NULL);
+ if (gone) vanish(wrapperFor(gone, container));
+ }
+
+ SGRPlayCapsule *capsule = objc_getAssociatedObject(container, &kCapsuleKey);
+ if (!capsule) {
+ capsule = [[SGRPlayCapsule alloc] initWithFrame:CGRectZero];
+ objc_setAssociatedObject(container, &kCapsuleKey, capsule, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ if (capsule.superview != container) [container addSubview:capsule];
+ UIView *playButton = SGRFindByIdentifier(headerRoot, @"header-play-button", &kPlayKey);
+ if (playButton) {
+ feedCapsule(capsule, playButton);
+ // Only what the button draws goes: a concealed layer still sends the actions the capsule fires.
+ conceal(playButton);
+ }
+ capsule.hidden = playButton == nil;
+
+ NSMutableArray<UIView *> *items = [NSMutableArray array];
+ NSMutableArray<NSNumber *> *widths = [NSMutableArray array];
+ if (shuffle) { [items addObject:wrapperFor(shuffle, container)]; [widths addObject:@(SGRActionHeight)]; }
+ if (playButton) { [items addObject:capsule]; [widths addObject:@([capsule sgr_width])]; }
+ if (add) { [items addObject:wrapperFor(add, container)]; [widths addObject:@(SGRActionHeight)]; }
+ 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);
+ for (NSUInteger i = 0; i < items.count; i++) {
+ UIView *item = items[i];
+ CGFloat slot = widths[i].doubleValue;
+ CGSize size = item == capsule ? CGSizeMake(slot, SGRActionHeight) : item.bounds.size;
+ CGRect target = CGRectMake(round(x + (slot - size.width) / 2), round(middle - size.height / 2), size.width, size.height);
+ if (item == capsule) {
+ if (!CGRectEqualToRect(capsule.frame, target)) capsule.frame = target;
+ } else {
+ place(item, target, container);
+ }
+ x += slot + SGRActionSpacing;
+ }
+ for (UIView *button in @[shuffle ?: NSNull.null, add ?: NSNull.null, more ?: NSNull.null]) {
+ if ([button isKindOfClass:UIView.class]) SGRGlassInside(button, &kGlassKey, SGRGlassCircleSize);
+ }
+
+ static BOOL logged;
+ if (!logged && container.window) {
+ logged = YES;
+ SGLog(@"redesign playlist: action row %@, shuffle %@, play %@, add %@, more %@", NSStringFromCGRect(container.bounds),
+ shuffle ? @"found" : @"missing", playButton ? @"found" : @"missing", add ? @"found" : @"missing",
+ more ? @"in the row" : @"not in the page");
+ }
+}
+
+#pragma mark - the header's pass
+
+// Find on this page and Sort sit in a header view of their own above the cover, invisible until the page is
+// scrolled; the Music app has neither.
+static void applyToolbar(UIView *headerRoot) {
+ UIView *toolbar = SGRFindByIdentifier(headerRoot, @"Components.Header.UI.Toolbar.Content", &kToolbarKey);
+ for (UIView *v = toolbar; v && v != headerRoot; v = v.superview) {
+ if (![NSStringFromClass(v.class) containsString:@"HeaderView"]) continue;
+ conceal(v);
+ return;
+ }
+}
+
+// Spotify's colour wash goes, so the page's field shows through, and the plane it was drawn on is handed
+// back: it is where the hero belongs (applyHero).
+static UIView *applyBackground(UIView *layout) {
+ UIView *container = nil;
+ for (UIView *v = layout.superview; v && !container; v = v.superview) {
+ for (UIView *sub in v.subviews) {
+ if ([sub.accessibilityIdentifier isEqualToString:@"_backgroundViewContainer"]) container = sub;
+ }
+ }
+ UIView *plane = container.subviews.firstObject;
+ SGForEachView(container, ^(UIView *v) {
+ if ([NSStringFromClass(v.class) containsString:@"GradientView"]) conceal(v);
+ });
+ return plane;
+}
+
+// The layout holds the cover square and, under it, the block of text and controls.
+static UIView *blockIn(UIView *layout, UIView *cover) {
+ UIView *block = nil;
+ for (UIView *sub in layout.subviews) {
+ if (sub == cover || [sub isKindOfClass:SGRPlaylistHero.class]) continue;
+ if (!block || CGRectGetMinY(sub.frame) > CGRectGetMinY(block.frame)) block = sub;
+ }
+ return block;
+}
+
+static void applyHeader(UIView *layout) {
+ UIViewController *headerVC = SGRPlaylistHeaderOf(layout);
+ UIView *headerRoot = headerVC.viewIfLoaded;
+ if (!headerRoot) return;
+
+ UIView *cover = SGRFindByIdentifier(layout, @"Components.Header.UI.ArtworkImage", &kCoverKey);
+ UIView *block = blockIn(layout, cover);
+ if (!block) return;
+
+ UIView *plane = applyBackground(layout);
+ applyToolbar(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; }
+ }
+ if (column) {
+ applyColumn(column);
+ if (!objc_getAssociatedObject(column, &kColumnWatchedKey)) {
+ objc_setAssociatedObject(column, &kColumnWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ SGRObserveLayout(column, ^(UIView *view) { applyColumn(view); });
+ }
+ }
+
+ applyActions(block, headerRoot);
+ UIView *row = SGRFindByIdentifier(block, @"HeaderActionsRow", &kRowKey);
+ if (row && !objc_getAssociatedObject(row, &kRowWatchedKey)) {
+ objc_setAssociatedObject(row, &kRowWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ __weak UIView *weakBlock = block, *weakRoot = headerRoot;
+ SGRObserveLayout(row, ^(UIView *view) {
+ if (weakBlock && weakRoot) applyActions(weakBlock, weakRoot);
+ });
+ }
+}
+
+// The content layout of the page `root` belongs to, kept weakly on it: the header lays out on every step of
+// its collapse and a walk of its tree each time would be the redesign's own cost.
+static UIView *layoutIn(UIView *root) {
+ if (!root) return nil;
+ SGRWeakView *box = objc_getAssociatedObject(root, &kLayoutKey);
+ UIView *layout = box.view;
+ if (layout && [layout isDescendantOfView:root]) return layout;
+ static Class content;
+ if (!content) content = NSClassFromString(@"_TtC28EncoreConsumerMobile_BaseKit19HeaderContentLayout");
+ layout = firstOfClass(root, content);
+ if (!layout) return nil;
+ if (!box) {
+ box = [SGRWeakView new];
+ objc_setAssociatedObject(root, &kLayoutKey, box, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ box.view = layout;
+ return layout;
+}
+
+%hook _TtC28EncoreConsumerMobile_BaseKit19HeaderContentLayout
+- (void)layoutSubviews {
+ %orig;
+ if (SGRPlaylistHeaderOf((UIView *)self)) applyHeader((UIView *)self);
+}
+%end
+
+// The header's own pass catches the parts that fade in rather than being laid out: the find bar, and the
+// action buttons as they arrive. The scroll's is where what Spotify fades back in is taken again.
+%hook SPTFreeTierPlaylistEncoreHeaderViewController
+- (void)viewDidLayoutSubviews {
+ %orig;
+ UIView *layout = layoutIn(((UIViewController *)self).viewIfLoaded);
+ if (layout) applyHeader(layout);
+}
+
+%end
+
+%ctor {
+ if (!SGRedesignedUI()) return;
+ %init;
+ SGRequireClasses(@[
+ @"_TtC28EncoreConsumerMobile_BaseKit19HeaderContentLayout",
+ @"SPTFreeTierPlaylistEncoreHeaderViewController",
+ ]);
+}
diff --git a/tweak/Sources/Redesigned/Playlist/PlaylistRows.x b/tweak/Sources/Redesigned/Playlist/PlaylistRows.x
new file mode 100644
index 00000000..e086359b
--- /dev/null
+++ b/tweak/Sources/Redesigned/Playlist/PlaylistRows.x
@@ -0,0 +1,102 @@
+// Playlist redesign: the track rows on the field, the way the Music app has them -- no surface of their own,
+// artwork with rounded corners, and a hairline from the text's edge between one row and the next.
+//
+// Tree (trees/clean/playlist/02.txt:164-247): a cell id=Playlist.ItemCell holds an Encore.ListRow painted the
+// base surface, and in it Encore.ImageView 48x48 (the artwork), Track.Row.Content.Title,
+// Track.Row.Content.Subtitle and, at the trailing edge, Components.UI.ContextMenuButton. The row's own paint
+// is cleared here rather than left to the Kit's repaint hook, which only hears about a colour when Spotify
+// sets it and not when a reused cell already carries one.
+//
+// Spotify's type and its spacing are left alone: the row is 64pt for a title of 18pt, and a larger font of
+// the Kit's would be cut off by the box the element framework measured for it.
+//
+// The pills over the first row of a playlist of one's own (Add, Mix, Notes, Video, Edit, Sort, Name &
+// details -- own-playlist/01.txt:33) are a cell of the list. ListUXPlatform_LayoutKit.ListLayout gives every
+// item its height, so the cell can only close up where the layout asks it how tall it wants to be.
+#import "Core/SGCore.h"
+#import "Redesigned/Kit/SGRKit.h"
+#import "Playlist.h"
+
+// Under the text rather than the whole row, as the Music app draws it; the trailing end clears the page margin.
+static const CGFloat kHairline = 0.5, kHairlineGap = 12;
+
+static char kRowKey, kArtKey, kSubtitleKey, kLineKey;
+
+static UIView *identified(UIView *root, NSString *identifier, const void *cacheKey) {
+ return SGRFindByIdentifier(root, identifier, cacheKey);
+}
+
+static void clearSurface(UIView *view) {
+ UIColor *color = view.backgroundColor;
+ if (color && SGIsBaseSurface(color.CGColor)) view.backgroundColor = UIColor.clearColor;
+}
+
+static void applyHairline(UIView *row, CGFloat leading) {
+ CALayer *line = objc_getAssociatedObject(row, &kLineKey);
+ if (!line) {
+ line = [CALayer layer];
+ line.backgroundColor = [UIColor colorWithWhite:1 alpha:0.12].CGColor;
+ line.zPosition = 1;
+ objc_setAssociatedObject(row, &kLineKey, line, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ if (line.superlayer != row.layer) [row.layer addSublayer:line];
+ CGRect bounds = row.bounds;
+ CGRect frame = CGRectMake(leading, bounds.size.height - kHairline,
+ MAX(0, bounds.size.width - leading - SGRSideMargin), kHairline);
+ if (CGRectEqualToRect(line.frame, frame)) return;
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ line.frame = frame;
+ [CATransaction commit];
+}
+
+static void applyRow(UIView *cell) {
+ clearSurface(cell);
+ UIView *row = identified(cell, @"Encore.ListRow", &kRowKey);
+ if (!row) return;
+ clearSurface(row);
+
+ CGFloat leading = SGRSideMargin + 48 + kHairlineGap;
+ UIView *art = identified(row, @"Encore.ImageView", &kArtKey);
+ if (art) {
+ if (art.layer.cornerRadius != SGRRadiusThumb) {
+ art.layer.cornerRadius = SGRRadiusThumb;
+ art.layer.cornerCurve = kCACornerCurveContinuous;
+ art.clipsToBounds = YES;
+ }
+ CGRect frame = [row convertRect:art.bounds fromView:art];
+ if (frame.size.width > 0) leading = CGRectGetMaxX(frame) + kHairlineGap;
+ }
+
+ UIView *subtitle = identified(row, @"Track.Row.Content.Subtitle", &kSubtitleKey);
+ SGForEachView(subtitle, ^(UIView *v) {
+ if (![v isKindOfClass:UILabel.class]) return;
+ UILabel *label = (UILabel *)v;
+ if (![label.textColor isEqual:SGRSecondary()]) label.textColor = SGRSecondary();
+ });
+
+ applyHairline(row, leading);
+}
+
+%hook _TtC35ListUXPlatform_FreeTierPlaylistImpl25ElementCollectionViewCell
+- (void)layoutSubviews {
+ %orig;
+ if (SGRPlaylistHeaderOf((UIView *)self)) applyRow((UIView *)self);
+}
+
+- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)attributes {
+ UICollectionViewLayoutAttributes *result = %orig;
+ if (!SGRFindByIdentifier((UIView *)self, @"PlaylistCuration.Row.CurationActionsToolbar", NULL)) return result;
+ result.size = CGSizeMake(result.size.width, 0);
+ ((UIView *)self).clipsToBounds = YES;
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{ SGLog(@"redesign playlist: curation pills asked for a height, answered 0"); });
+ return result;
+}
+%end
+
+%ctor {
+ if (!SGRedesignedUI()) return;
+ %init;
+ SGRequireClasses(@[@"_TtC35ListUXPlatform_FreeTierPlaylistImpl25ElementCollectionViewCell"]);
+}