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 album page, the Music app's layout laid over Spotify's own, and nothing under the tracks but the album itself
Vojtěch Škopekdd8f4cdba7c3
diff --git a/AGENTS.md b/AGENTS.mdindex 4958f0ce..de9b2010 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -12,7 +12,8 @@ A Theos tweak (Objective-C + Logos) injected into the decrypted Spotify iOS app.- **Redesigned**: the mod's own Liquid Glass look, from a clean sheet. It includes the glass tab bar,search field and now playing bar, the redesigned player and lyrics page with Apple Music style lyricsalways on, a decluttered Home, Search's categories on tinted glass, a Library with one large title and no- filter pills, black throughout, and its own accent colour. No native tweak runs.+ filter pills, the playlist and album pages the way the Music app lays them out, black throughout, and its+ own accent colour. No native tweak runs.Anything that doesn't draw on Spotify's screens works the same under both: ads, privacy, lyricssources, gestures, blocked artists, flags.diff --git a/docs/tweaks.md b/docs/tweaks.mdindex 23ffe7b4..d0c16591 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -130,6 +130,14 @@ Redesigned:prominent Play capsule taking its glyph and its word from Spotify's own button, add, more), the findbar 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/+ Album/ the album page laid out the same way, on the page the Creative Work Platform builds rather than the+ playlist's, so it shares nothing with Playlist/ but the Kit: the cover full bleed dissolving into the+ field, the title, the artist and the kind and date centred under it, and the same row of glass+ controls -- play and shuffle float over the album page outside its header, so they are concealed+ there and the row carries the Kit's stand-ins, which draw their glyph and fire them. Under the tracks+ everything the server sends is dropped -- more by the artist, videos, concerts, merch, you might also+ like, and whatever it adds next -- but the album's own line and its copyright (Album.h lists its+ files). Laid out on the Mac against harness/album/Haptics/ Vibrations (Haptics.h lists its files): a tap of UIKit's feedback generators for the player's and the nowplaying bar's controls, the scrubber's tenths and ends, cover swipes, gestures and the lyrics page's tap toseek (ControlHaptics.x, SGRFeedback.m); and Music Haptics, Core Haptics playing along with the song:@@ -143,7 +151,7 @@ App:ModSettings.x the root page and the rows that open it from Spotify's settings and the side drawerPages.m the Appearance card with Redesigned UI, the Player and Lyrics pages, which Navbar page opensAbout/ the update check, backup, the signing warning and the Mod page with the reset- Onboarding/ the welcome tour over Home on the first launch, offered again from the Mod page+ Onboarding/ the welcome page over Home on the first launch, with Redesigned UI, offered again from the Mod pageEvery key a feature stores starts with `spotifyglass.`, whatever it holds: Reset all settings onthe Mod page removes by that prefix and has no list to keep up to date. It leaves `SGKeyStock` behind,diff --git a/harness/album/README.md b/harness/album/README.mdnew file mode 100644index 00000000..8c80f63e--- /dev/null+++ b/harness/album/README.md@@ -0,0 +1,38 @@+# Album harness++Spotify's album page mocked under its own class names and accessibility identifiers+(from `trees/clean/album/03.txt`), so `Redesigned/Album/` can be laid out and looked at+on the Mac without the phone.++ THEOS=$HOME/theos ./build.sh+ xcrun simctl install booted build/AlbumHarness.app+ xcrun simctl launch booted com.vojta.albumharness+ xcrun simctl io booted screenshot shot.png++`build.sh` runs `logos.pl -c generator=internal` over the four `.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`).++The mock is the page as Spotify builds it: the colour wash behind the header, the header itself down+its four stack views, the metadata row as a real collection view with its own cells, the action row of+explore, add, download and more, the two controls Spotify floats over the page outside the scroll+(shuffle and play), and a list of track cells followed by the footer Spotify sends — the album's own+line, the copyright, and the headings and carousels of more by, videos, merch and you might also like,+each with the 16pt spacer between them.++At 1.5 s it measures the footer the way the page's collection does, asking every cell+`preferredLayoutAttributesFittingAttributes:` and stacking the answers: that is where `AlbumSections.x`+answers 0 for what it drops, and the log says how much footer was left (108pt of 1230pt, the album's+own line and its copyright).++At 3.5 s it puts Spotify's own frames back on the title block, its stack and the action row and asks+both groups for a layout pass, which is what the redesign's `SGRObserveLayout` watches have to survive.+The log says what the redesign answered with.++`SGLog` goes to the unified log rather than stdout, so the redesign's own lines are read with++ xcrun simctl spawn booted log stream --predicate 'eventMessage CONTAINS "spotifyglass"' --style compact++What it does not cover: the real element framework's autolayout and the heights it measures, the page+scrolling (Spotify fades the header out by alpha as it goes, which the mock does not), and the flags+`AlbumField.x` forces.diff --git a/harness/album/build.sh b/harness/album/build.shnew file mode 100755index 00000000..dd4182ce--- /dev/null+++ b/harness/album/build.sh@@ -0,0 +1,43 @@+#!/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/AlbumHarness.app"++for f in Redesigned/Album/AlbumField.x Redesigned/Album/AlbumHeader.x Redesigned/Album/AlbumRows.x Redesigned/Album/AlbumSections.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/Album" -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/SGRActionRow.m \+ "$SRC"/Redesigned/Kit/SGRedesign.m \+ -framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols \+ -o "$OUT/AlbumHarness.app/AlbumHarness"++cat > "$OUT/AlbumHarness.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>AlbumHarness</string>+<key>CFBundleIdentifier</key><string>com.vojta.albumharness</string>+<key>CFBundleName</key><string>AlbumHarness</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/AlbumHarness.app"diff --git a/harness/album/main.m b/harness/album/main.mnew file mode 100644index 00000000..0e436c68--- /dev/null+++ b/harness/album/main.m@@ -0,0 +1,389 @@+// A mock of Spotify's album page under its own class names and accessibility identifiers, built from+// trees/clean/album/03.txt, so Redesigned/Album can be laid out and looked at on the Mac.+#import <UIKit/UIKit.h>++#pragma mark - Spotify's classes, by name++@interface _TtC28CreativeWorkPlatform_PageKit24CreativeWorkTemplateView : UIView @end+@implementation _TtC28CreativeWorkPlatform_PageKit24CreativeWorkTemplateView @end++@interface _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView : UIView @end+@implementation _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView @end++@interface _TtCO19LegacyUI_ECMCoreKit5Views10HeaderView : UIView @end+@implementation _TtCO19LegacyUI_ECMCoreKit5Views10HeaderView @end++@interface _TtC28EncoreConsumerMobile_BaseKit20HeaderNavigationBar : UIView @end+@implementation _TtC28EncoreConsumerMobile_BaseKit20HeaderNavigationBar @end++@interface _TtC19LegacyUI_ECMCoreKit12GradientView : UIView @end+@implementation _TtC19LegacyUI_ECMCoreKit12GradientView @end++@interface _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView : UIView @end+@implementation _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView @end++@interface _TtC12Element_List18CollectionViewCell : UICollectionViewCell @end+@implementation _TtC12Element_List18CollectionViewCell @end++// The element the cell's content is, which is the only thing that says what a cell holds.+@interface MockRetrievalListStructuredDataView : UIView @end+@implementation MockRetrievalListStructuredDataView @end++@interface MockAlbum_PageImpl20FooterStructuredDataView : UIView @end+@implementation MockAlbum_PageImpl20FooterStructuredDataView @end++@interface MockCondensedButton : UIControl @end+@implementation MockCondensedButton @end++@interface MockEncoreButton : UIControl @end+@implementation MockEncoreButton @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.autoresizingMask = UIViewAutoresizingFlexibleWidth;+ 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.16, 0.34, 0.62, 1, 0.07, 0.10, 0.22, 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.30] setFill];+ for (int i = 0; i < 4; i++) {+ [[UIBezierPath bezierPathWithRect:CGRectMake(24 + i * 62, 60 + (i % 2) * 90, 48, 150)] 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];+ }];+}++// One of the round buttons of the header's action row: the element view Spotify's stack arranges, the+// button inside it at the same size, and a glyph in the button.+static UIView *actionButton(UIView *row, CGRect frame, NSString *identifier, NSString *symbol, NSString *a11y) {+ UIView *element = box(row, UIView.class, frame, nil);+ UIView *button = box(element, MockEncoreButton.class, element.bounds, identifier);+ button.accessibilityLabel = a11y;+ UIImageView *glyph = [[UIImageView alloc] initWithFrame:CGRectInset(button.bounds, 12, 12)];+ glyph.image = [UIImage systemImageNamed:symbol];+ glyph.tintColor = UIColor.whiteColor;+ [button addSubview:glyph];+ return element;+}++#pragma mark - the metadata row's cells++@interface SGRMetaSource : NSObject <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>+@property (nonatomic, copy) NSArray<NSString *> *items;+@end++@implementation SGRMetaSource++- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {+ return self.items.count;+}++- (UICollectionViewCell *)collectionView:(UICollectionView *)view cellForItemAtIndexPath:(NSIndexPath *)path {+ UICollectionViewCell *cell = [view dequeueReusableCellWithReuseIdentifier:@"meta" forIndexPath:path];+ for (UIView *old in cell.contentView.subviews) [old removeFromSuperview];+ label(cell.contentView, cell.contentView.bounds, self.items[path.item], 11,+ [UIColor colorWithWhite:0.70 alpha:1], @"Encore.Label");+ return cell;+}++- (CGSize)collectionView:(UICollectionView *)view layout:(UICollectionViewLayout *)layout sizeForItemAtIndexPath:(NSIndexPath *)path {+ CGSize text = [self.items[path.item] sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:11]}];+ return CGSizeMake(ceil(text.width), 15.33);+}++@end++#pragma mark - the page++@interface SGRHarnessDelegate : UIResponder <UIApplicationDelegate>+@property (nonatomic, strong) UIWindow *window;+@property (nonatomic, strong) SGRMetaSource *meta;+@end++@implementation SGRHarnessDelegate {+ UIView *_titleBlock, *_titleStack, *_actionRow, *_metaCells;+ NSMutableArray<UIView *> *_actionItems;+ NSMutableArray<NSValue *> *_actionFrames;+ NSMutableArray<_TtC12Element_List18CollectionViewCell *> *_footerCells;+ UIView *_listView;+ CGFloat _tracksBottom;+}++- (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 *root = [UIViewController new];+ root.view.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];+ self.window.rootViewController = root;++ UIView *page = box(root.view, _TtC28CreativeWorkPlatform_PageKit24CreativeWorkTemplateView.class,+ CGRectMake(0, 0, W, H), @"CreativeWorkPlatform.CreativeWorkTemplateView");++ // Spotify's colour wash behind the header, the height of the header at rest.+ UIView *wash = box(page, _TtCO19LegacyUI_ECMCoreKit5Views10HeaderView.class, CGRectMake(0, 0, W, 486.67), nil);+ UIView *gradient = box(wash, _TtC19LegacyUI_ECMCoreKit12GradientView.class, wash.bounds, nil);+ gradient.backgroundColor = [UIColor colorWithRed:0.13 green:0.24 blue:0.44 alpha:1];++ // the tab, the scroll and the stack the header and the list sit in+ UIView *tab = box(page, UIView.class, CGRectMake(0, 0, W, H), @"CreativeWorkPlatform.Tab");+ UIScrollView *scroll = (UIScrollView *)box(tab, UIScrollView.class, CGRectMake(0, 0, W, H), @"PCFFTabLayoutViewController.containerScrollView");+ UIStackView *stack = (UIStackView *)box(scroll, UIStackView.class, CGRectMake(0, 0, W, 2200), nil);++ UIView *headerElement = box(stack, UIView.class, CGRectMake(0, 0, W, 486.67), @"CreativeWorkPlatform.Header");+ UIView *header = box(headerElement, UIView.class, headerElement.bounds, @"CreativeWorkPlatform.Components.UI.CreativeWorkHeader");+ UIView *inset = box(header, UIView.class, CGRectMake(0, 78, W, 400.67), nil);+ UIStackView *outer = (UIStackView *)box(inset, UIStackView.class, inset.bounds, nil);++ UIView *topGroup = box(outer, UIView.class, CGRectMake(0, 0, W, 321.33), nil);+ UIStackView *groupStack = (UIStackView *)box(topGroup, UIStackView.class, topGroup.bounds, nil);++ UIView *artRow = box(groupStack, UIView.class, CGRectMake(0, 0, W, 248), nil);+ UIView *coverElement = box(artRow, UIView.class, CGRectMake(round((W - 248) / 2), 0, 248, 248), nil);+ UIView *cover = box(coverElement, UIView.class, coverElement.bounds, @"CreativeWorkPlatform.Components.UI.ArtWorkElement.WithCoverArt");+ UIImageView *coverPicture = [[UIImageView alloc] initWithFrame:cover.bounds];+ coverPicture.image = artwork();+ coverPicture.contentMode = UIViewContentModeScaleAspectFill;+ coverPicture.clipsToBounds = YES;+ coverPicture.accessibilityIdentifier = @"Encore.ImageView";+ [cover addSubview:coverPicture];+ box(groupStack, UIView.class, CGRectMake(0, 256, 0, 0), nil);++ _titleBlock = box(groupStack, UIView.class, CGRectMake(0, 264, 215.33, 57.33), nil);+ _titleStack = box(_titleBlock, UIStackView.class, CGRectMake(16, 0, 183.33, 57.33), nil);+ label(_titleStack, CGRectZero, @"", 17, UIColor.whiteColor, @"CreativeWorkPlatform.Components.UI.PreTitleRow");+ label(_titleStack, CGRectMake(0, 0, 183.33, 25.33), @"Hurry Up Tomorrow", 21, UIColor.whiteColor,+ @"CreativeWorkPlatform.Components.UI.TitleRow");+ UIView *parentElement = box(_titleStack, UIView.class, CGRectMake(0, 33.33, 96, 24), nil);+ UIView *parentRow = box(parentElement, MockEncoreButton.class, parentElement.bounds, @"CreativeWorkPlatform.Components.UI.ParentRow");+ parentRow.accessibilityLabel = @"The Weeknd";+ UIView *avatar = box(parentRow, UIView.class, CGRectMake(0, 0, 24, 24), @"Encore.ImageView");+ avatar.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];+ avatar.layer.cornerRadius = 12;+ label(parentRow, CGRectMake(32, 4.33, 72, 15.33), @"The Weeknd", 11, UIColor.whiteColor, @"Encore.Label");++ UIView *bottomGroup = box(outer, UIView.class, CGRectMake(0, 329.33, W, 71.33), nil);+ UIStackView *bottomStack = (UIStackView *)box(bottomGroup, UIStackView.class, bottomGroup.bounds, nil);++ UIView *metaWrap = box(bottomStack, UIView.class, CGRectMake(0, 0, W, 15.33), nil);+ UIStackView *metaStack = (UIStackView *)box(metaWrap, UIStackView.class, CGRectMake(16, 0, W - 32, 15.33), nil);+ UIView *metaElement = box(metaStack, UIView.class, metaStack.bounds, nil);+ UIView *metadata = box(metaElement, UIView.class, metaElement.bounds, @"Components.UI.MetadataRow");+ UICollectionViewFlowLayout *flow = [UICollectionViewFlowLayout new];+ flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;+ flow.minimumInteritemSpacing = 4;+ UICollectionView *cells = [[UICollectionView alloc] initWithFrame:metadata.bounds collectionViewLayout:flow];+ cells.backgroundColor = UIColor.clearColor;+ [cells registerClass:UICollectionViewCell.class forCellWithReuseIdentifier:@"meta"];+ self.meta = [SGRMetaSource new];+ self.meta.items = @[@"Album", @"•", @"31. 1. 2025"];+ cells.dataSource = self.meta;+ cells.delegate = self.meta;+ [metadata addSubview:cells];+ _metaCells = cells;++ _actionRow = box(bottomStack, UIStackView.class, CGRectMake(0, 23.33, 206, 48), nil);+ _actionItems = [NSMutableArray array];+ _actionFrames = [NSMutableArray array];+ NSArray *actions = @[@[@"Components.UI.WatchFeedEntityExplorerButton", @"play.rectangle", @"Explore", @0, @4, @62, @40],+ @[@"Components.UI.AddToButton", @"plus", @"Add", @62, @0, @48, @48],+ @[@"DownloadButton.Granular.None", @"arrow.down.circle", @"Download", @110, @0, @48, @48],+ @[@"Components.UI.ContextMenuButton-3OxfaVgvTxUTy7276t7SPU", @"ellipsis", @"More options", @158, @0, @48, @48]];+ for (NSArray *action in actions) {+ CGRect frame = CGRectMake([action[3] doubleValue], [action[4] doubleValue], [action[5] doubleValue], [action[6] doubleValue]);+ [_actionItems addObject:actionButton(_actionRow, frame, action[0], action[1], action[2])];+ [_actionFrames addObject:[NSValue valueWithCGRect:frame]];+ }++ // the track list under the header+ _listView = box(stack, _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView.class,+ CGRectMake(0, 486.67, W, 700), nil);+ _listView.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];+ UIView *collection = box(_listView, UIView.class, _listView.bounds, nil);+ collection.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];++ NSArray<NSArray<NSString *> *> *tracks = @[@[@"Wake Me Up (feat. Justice)", @"The Weeknd, Justice"],+ @[@"Cry For Me", @"The Weeknd"],+ @[@"I Can't Fucking Sing", @"The Weeknd"],+ @[@"São Paulo (feat. Anitta)", @"The Weeknd, Anitta"],+ @[@"Until We're Skin & Bones", @"The Weeknd"],+ @[@"Baptized In Fear", @"The Weeknd"]];+ CGFloat y = 8;+ for (NSArray<NSString *> *track in tracks) {+ UICollectionViewCell *cell = [[_TtC12Element_List18CollectionViewCell alloc] initWithFrame:CGRectMake(0, y, W, 56)];+ cell.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];+ [collection addSubview:cell];+ UIView *content = box(cell.contentView, MockRetrievalListStructuredDataView.class, cell.contentView.bounds, nil);+ UIView *row = box(content, UIView.class, content.bounds, @"Components.UI.RetrievalRowElementUI");+ row.backgroundColor = [UIColor colorWithWhite:0.07 alpha:1];+ label(row, CGRectMake(16, 8, W - 90, 18), track[0], 13, UIColor.whiteColor, @"EncoreConsumerMobile.View.Granular.Title");+ label(row, CGRectMake(16, 30, W - 90, 15.33), track[1], 11, UIColor.whiteColor, @"EncoreConsumerMobile.View.Granular.Subtitle");+ actionButton(row, CGRectMake(W - 64, 4, 48, 48), @"Components.UI.ContextMenuButton-5673WA8EEUSPx1ir26lhGW", @"ellipsis", @"More options");+ y += 56;+ }+ _tracksBottom = y;++ // and under it the footer Spotify sends: the album's own line, the copyright, and the sections the+ // redesign drops -- each with the 16pt spacer Spotify puts between them.+ _footerCells = [NSMutableArray array];+ NSArray *footer = @[@[@"", @16], @[@"Album.ConsumptionExperience", @15.33], @[@"", @16],+ @[@"heading:More by The Weeknd", @52.67], @[@"cards", @194.33], @[@"", @16],+ @[@"heading:Related Music Videos", @52.67], @[@"cards", @235.67], @[@"", @16],+ @[@"heading:Merch", @52.67], @[@"cards", @197], @[@"", @16],+ @[@"heading:You might also like", @52.67], @[@"cards", @193.33], @[@"", @16],+ @[@"Album.Copyright", @60.67]];+ for (NSArray *item in footer) {+ NSString *kind = item[0];+ CGFloat height = [item[1] doubleValue];+ _TtC12Element_List18CollectionViewCell *cell =+ [[_TtC12Element_List18CollectionViewCell alloc] initWithFrame:CGRectMake(0, 0, W, height)];+ [collection addSubview:cell];+ UIView *content = box(cell.contentView, MockAlbum_PageImpl20FooterStructuredDataView.class, cell.contentView.bounds, nil);+ if ([kind isEqualToString:@"Album.ConsumptionExperience"]) {+ UIView *line = box(content, UIView.class, content.bounds, kind);+ label(line, CGRectMake(16, 0, W - 32, height), @"22 songs • 1hr 24min", 11, UIColor.whiteColor, @"Encore.Label");+ } else if ([kind isEqualToString:@"Album.Copyright"]) {+ UIView *line = box(content, UIView.class, content.bounds, kind);+ UILabel *text = label(line, CGRectMake(16, 0, W - 32, height),+ @"© 2025 The Weeknd XO Music ULC, marketed by Republic Records.\n℗ 2025 The Weeknd XO Music ULC, marketed by Republic Records.",+ 11, UIColor.whiteColor, @"Encore.Label");+ text.numberOfLines = 0;+ } else if ([kind hasPrefix:@"heading:"]) {+ UIView *heading = box(content, UIView.class, content.bounds, @"Components.UI.SectionHeadingHome");+ label(heading, CGRectMake(16, 16, W - 32, 20.67), [kind substringFromIndex:8], 17, UIColor.whiteColor, @"Encore.Label");+ } else if ([kind isEqualToString:@"cards"]) {+ for (int i = 0; i < 3; i++) {+ UIView *card = box(content, UIView.class, CGRectMake(16 + i * 161, 0, 153, height), @"Components.UI.ContentCardAlbum");+ card.backgroundColor = [UIColor colorWithWhite:0.12 alpha:1];+ card.layer.cornerRadius = 4;+ }+ }+ [_footerCells addObject:cell];+ }++ // the sticky navigation bar, its gradient hidden until the page scrolls+ UIView *navBar = box(page, _TtC28EncoreConsumerMobile_BaseKit20HeaderNavigationBar.class, CGRectMake(0, 0, W, 118), @"CreativeWorkPlatform.HeaderNavigationBar");+ UIView *navGradient = box(navBar, _TtC19LegacyUI_ECMCoreKit12GradientView.class, navBar.bounds, nil);+ navGradient.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];+ navGradient.hidden = YES;++ // the two controls Spotify floats over the page, outside the scroll+ UIView *shuffleElement = box(page, UIView.class, CGRectMake(282, 62, 48, 48), nil);+ UIView *shuffle = box(shuffleElement, MockEncoreButton.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];++ UIView *playElement = box(page, UIView.class, CGRectMake(338, 94, 48, 48), nil);+ UIView *playButton = box(playElement, _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView.class, playElement.bounds, @"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 list is measured the way the page's collection measures it: every cell is asked how tall it wants+ // to be, which is where AlbumSections.x answers 0 for what the redesign drops, and the answers are+ // stacked. Done a beat after launch, so the header has laid out at least once first.+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ [self measureFooter:W];+ NSLog(@"[harness] hero %@, title stack %@, action row %@",+ NSStringFromCGRect([cover.window convertRect:cover.bounds fromView:cover]),+ NSStringFromCGRect(self->_titleStack.frame), NSStringFromCGRect(self->_actionRow.frame));+ });++ // Spotify lays the header out again after the redesign has moved things: the title block, its stack and+ // the action row go back where its own layout puts them, and the redesign has to take them again from+ // its own watch on each.+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ self->_titleBlock.frame = CGRectMake(0, 264, 215.33, 57.33);+ self->_titleStack.frame = CGRectMake(16, 0, 183.33, 57.33);+ self->_actionRow.frame = CGRectMake(0, 23.33, 206, 48);+ for (NSUInteger i = 0; i < self->_actionItems.count; i++) {+ self->_actionItems[i].frame = self->_actionFrames[i].CGRectValue;+ }+ [groupStack setNeedsLayout];+ [groupStack layoutIfNeeded];+ [bottomStack setNeedsLayout];+ [bottomStack layoutIfNeeded];+ NSLog(@"[harness] Spotify's own frames put back; the redesign answered with title stack %@, action row %@",+ NSStringFromCGRect(self->_titleStack.frame), NSStringFromCGRect(self->_actionRow.frame));+ });+ return YES;+}++// Every footer cell asked for its height the way the collection's self-sizing asks, then stacked under the+// tracks with whatever each answered.+- (void)measureFooter:(CGFloat)width {+ CGFloat y = _tracksBottom;+ for (_TtC12Element_List18CollectionViewCell *cell in _footerCells) {+ CGFloat natural = cell.bounds.size.height;+ UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];+ attributes.frame = CGRectMake(0, y, width, natural);+ UICollectionViewLayoutAttributes *answer = [cell preferredLayoutAttributesFittingAttributes:attributes];+ cell.frame = CGRectMake(0, y, width, answer.size.height);+ [cell layoutIfNeeded];+ y += answer.size.height;+ }+ _listView.frame = CGRectMake(0, 486.67, width, y + 24);+ _listView.subviews.firstObject.frame = _listView.bounds;+ UIScrollView *scroll = (UIScrollView *)_listView.superview.superview;+ if ([scroll isKindOfClass:UIScrollView.class]) scroll.contentSize = CGSizeMake(width, CGRectGetMaxY(_listView.frame));+ NSLog(@"[harness] the footer measured %.0fpt under the tracks", y - _tracksBottom);+}++@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/album/stubs.m b/harness/album/stubs.mnew file mode 100644index 00000000..8c64e941--- /dev/null+++ b/harness/album/stubs.m@@ -0,0 +1,9 @@+// 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;+__weak UIView *sgr_albumRoot = nil;diff --git a/harness/playlist/build.sh b/harness/playlist/build.shindex 17901ff8..8dabb32c 100755--- a/harness/playlist/build.sh+++ b/harness/playlist/build.sh@@ -19,6 +19,7 @@ xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-ar"$SRC"/Core/SGBackdrop.m "$SRC"/Core/SGFlagForce.m "$SRC"/Core/SGUIMode.m \"$SRC"/Redesigned/Kit/SGRTokens.m "$SRC"/Redesigned/Kit/SGRPalette.m "$SRC"/Redesigned/Kit/SGRField.m \"$SRC"/Redesigned/Kit/SGRGlass.m "$SRC"/Redesigned/Kit/SGRGlyph.m "$SRC"/Redesigned/Kit/SGRRestyle.m \+ "$SRC"/Redesigned/Kit/SGRActionRow.m \"$SRC"/Redesigned/Kit/SGRedesign.m \-framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols \-o "$OUT/PlaylistHarness.app/PlaylistHarness"diff --git a/tweak/Sources/Redesigned/Album/Album.h b/tweak/Sources/Redesigned/Album/Album.hnew file mode 100644index 00000000..80bb0fbd--- /dev/null+++ b/tweak/Sources/Redesigned/Album/Album.h@@ -0,0 +1,35 @@+// The album redesign: Spotify's album page kept, with its header, its track list and its controls, and laid+// out the way the Music app lays an album out -- the same page the playlist redesign gives a playlist, so+// the two read as one app.+//+// The album page is not the playlist's. It is built by the Creative Work Platform out of the element+// framework (trees/clean/album/01.txt: CreativeWorkPlatform.CreativeWorkTemplateView, a header element over+// one list), its header is a column of stack views rather than a plain block, and its play and shuffle+// float over the page instead of scrolling with the header. So none of Redesigned/Playlist/ is shared: only+// the Kit is, which is what keeps the look the same.+//+// AlbumField.x the artwork field behind the whole page, the artwork it is read from, the flags the+// screen forces+// AlbumHeader.x the header: the cover full bleed at the top dissolving into the field, the title, the+// artist and the kind and date centred under it, and one row of glass controls --+// shuffle, a prominent Play capsule, add, and more where Spotify still has it+// AlbumRows.x the track rows on the field with no surface of their own and a hairline between them+// AlbumSections.x everything under the tracks dropped but the album's own line and its copyright: no+// more by the artist, no videos, no concerts, no merch, no you might also like+//+// 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 album page `view` is on, or nil: the CreativeWorkTemplateView that carries the header, the list and+// the two floating controls (trees/clean/album/01.txt:22).+UIView *SGRAlbumPageOf(UIView *view);++// AlbumField.x. The field belongs to the page `view` is on, found by walking up from it, so two album 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 *SGRAlbumFieldColor(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 SGRAlbumSetArtwork(UIView *view, UIImage *image);diff --git a/tweak/Sources/Redesigned/Album/AlbumField.x b/tweak/Sources/Redesigned/Album/AlbumField.xnew file mode 100644index 00000000..93765c9c--- /dev/null+++ b/tweak/Sources/Redesigned/Album/AlbumField.x@@ -0,0 +1,120 @@+// Album redesign: the artwork field behind the whole page, and what the switch forces.+//+// Tree (trees/clean/album/01.txt:22). The page is CreativeWorkPlatform.CreativeWorkTemplateView, and it+// holds, in this order: the header's colour wash (a LegacyUI HeaderView the height of the header, with+// Spotify's GradientView in it), CreativeWorkPlatform.Tab with the scrolling list inside it, the sticky+// HeaderNavigationBar, and the two controls Spotify floats over the page, shuffle and play. Nothing of it+// scrolls except what is inside the Tab, so a field put behind the lot 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 AlbumHeader.x fades it into+// exactly this field's colour, and conceals Spotify's wash so the field is what shows. What Spotify paints+// over the field -- the list and every row, all of them the base surface -- is kept clear by the Kit's+// repaint hook while sgr_albumRoot is this page, and by the list's own pass below, which paints itself+// rather than through a layer the repaint hook would hear about.+//+// The colour is read from the cover the header shows (AlbumHeader.x hands it over), and until that has+// loaded the field is the neutral one, as it is for an album with no cover at all.+//+// The page is the album's by its identifier, which is how Native/Album/Album.x has told it apart since it+// shipped: the artist page is TemplateKit's TemplateView instead, and podcasts are their own framework.+#import "Core/SGCore.h"+#import "Redesigned/Kit/SGRKit.h"+#import "Album.h"++static NSString *const kPageIdentifier = @"CreativeWorkPlatform.CreativeWorkTemplateView";++// 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++UIView *SGRAlbumPageOf(UIView *view) {+ for (UIView *v = view; v; v = v.superview) {+ if ([v.accessibilityIdentifier isEqualToString:kPageIdentifier]) return v;+ }+ return nil;+}++#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 *SGRAlbumFieldColor(UIView *view) {+ SGRArtworkField *field = fieldOn(view);+ return field.fieldColor ?: SGRNeutralField();+}++void SGRAlbumSetArtwork(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 album: field on the page %.0fx%.0f", page.bounds.size.width, page.bounds.size.height);+ return field;+}++%hook _TtC28CreativeWorkPlatform_PageKit24CreativeWorkTemplateView+- (void)layoutSubviews {+ %orig;+ UIView *page = (UIView *)self;+ if (page.bounds.size.height < 200) return;+ // The page the repaint hook keeps clear is the one laying out, which is the one on screen; an album+ // pushed over this one sets itself from its own pass, and this one sets itself again coming back.+ sgr_albumRoot = 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;+}+%end++// The list paints itself the base surface from its own pass. Its collection view is a private class whose+// name carries a build hash, so the list view around it -- one public name, one child -- is where it is+// cleared.+%hook _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView+- (void)layoutSubviews {+ %orig;+ UIView *list = (UIView *)self;+ if (!SGRAlbumPageOf(list)) return;+ if (list.backgroundColor && SGIsBaseSurface(list.backgroundColor.CGColor)) list.backgroundColor = UIColor.clearColor;+ for (UIView *sub in list.subviews) {+ if (sub.backgroundColor && SGIsBaseSurface(sub.backgroundColor.CGColor)) sub.backgroundColor = UIColor.clearColor;+ }+}+%end++%ctor {+ // Registered whatever the switch says: the flag rows elsewhere lock to these while it is on.+ SGRedesignForceFlags(@"album", @{+ // 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-album-albumfeatureproperties-impl.context_menu_in_navigation_bar_enabled": @YES,+ @"ios-album-albumfeatureproperties-impl.share_in_action_row_enabled": @NO,+ // A row is a title and its artists. The video badge is neither.+ @"ios-creativeworkcommons-retrievalrow-impl.track_video_indicator_enabled": @NO,+ // Spotify's cover square is concealed on both pages this covers, so there is nothing left to tilt.+ @"ios-creativeworkcommons-cover-art-tilt-configuration-kit.album_playlist_and_podcast_pages_enabled": @NO,+ });+ if (!SGRedesignedUI()) return;+ %init;+ SGRequireClasses(@[+ @"_TtC28CreativeWorkPlatform_PageKit24CreativeWorkTemplateView",+ @"_TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView",+ ]);+}diff --git a/tweak/Sources/Redesigned/Album/AlbumHeader.x b/tweak/Sources/Redesigned/Album/AlbumHeader.xnew file mode 100644index 00000000..f8346970--- /dev/null+++ b/tweak/Sources/Redesigned/Album/AlbumHeader.x@@ -0,0 +1,498 @@+// Album redesign: the header the Music app gives an album. The cover runs full bleed across the top of the+// page and dissolves into the field under it, with no seam and no card; the title, the artist and the kind+// and date are centred under it; and one row of glass controls sits below them -- shuffle, a prominent Play+// capsule, add, and more where Spotify still keeps it in the page.+//+// Tree (trees/clean/album/01.txt:39-152). The header is one element of the page's scrolling stack,+// id=CreativeWorkPlatform.Components.UI.CreativeWorkHeader, and everything in it is laid out by stack views+// down a chain of four:+//+// UIView {0, 78} the top inset, the status bar and the navigation bar's room+// UIStackView the two groups+// UIView 402x321 the top group+// UIStackView the cover row, a spacer, and the title block+// UIView 402x248 ArtWorkElement.WithCoverArt, the cover square centred in it+// UIView {0, 264} 215x57 the title block, its own stack inset 16pt from the leading edge:+// TitleRow, and ParentRow, the artist with a facepile+// UIView {0, 329} 402x71 the bottom group+// UIStackView the metadata row and the action row+// UIView 402x15 Components.UI.MetadataRow: the kind and the date+// UIStackView 206x48 explore, add, download and more+//+// Whose layout pass. A view lays its children out, so a frame set from an ancestor's layoutSubviews is the+// one that is overwritten a moment later: each view moved here is taken again from a watch on its own+// parent's pass (the Kit's SGRObserveLayout), and the header's pass only finds them and starts the watch.+// Only plain UIKit classes can be watched, which every one of those stacks is; Spotify's own Swift views+// further down are never moved, only read.+//+// Centring costs width. A view moved to the middle of the page but left inside a parent that hugs its+// content is drawn there and takes no touches there, so the title block and the action row are widened to+// the page first and their contents centred inside them. Nothing else about the header's geometry changes:+// its height is the element framework's, measured from what it holds, and the page collapses, snaps and+// scrolls exactly as Spotify laid it out.+//+// Play and shuffle are not in the header. The album page floats them over the page, pinned to the top+// trailing corner outside the scroll (01.txt:1431, :1436), where a frame of the header's cannot reach them:+// they are concealed where they are and the row carries the Kit's stand-ins, which draw their glyph and+// fire them. Every other control of Spotify's stays its own, moved by frame and never rebuilt.+#import "Core/SGCore.h"+#import "Redesigned/Kit/SGRKit.h"+#import "Album.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. The playlist's numbers: one page.+static const CGFloat kDissolve = 0.46, kTopScrim = 140, kTopScrimAlpha = 0.28;+// A header whose text begins nearer the top than this is one 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;++static char kHeaderKey, kCoverKey, kTitleKey, kParentKey, kMetaKey, kAddKey, kMoreKey, kPlayKey, kShuffleKey;+static char kGlassKey, kHeroKey, kHeroHeightKey, kCapsuleKey, kMirrorKey, kCoverWatchedKey;+static char kHeaderWatchedKey, kGroupWatchedKey, kBlockWatchedKey, kTitleWatchedKey;+static char kBottomWatchedKey, kActionsWatchedKey, kMetaWatchedKey;++#pragma mark - moving Spotify's views++// Invisible for good. Spotify fades the header and the two floating controls by alpha as the page scrolls,+// so a redesign that answers with alpha is in a fight it loses a frame of on every scroll. `hidden` on the+// layer cannot be undone by a write to alpha, costs nothing per frame, and, unlike -[UIView setHidden:],+// tells neither KVO nor the stack views of it, which is what makes it safe on Spotify's Encore layouts.+static void conceal(UIView *view) {+ if (!view) return;+ if (!view.layer.hidden) view.layer.hidden = YES;+ view.accessibilityElementsHidden = YES;+}++// Alpha 0, no touches, hidden from accessibility, set again on every pass: for the buttons of the action+// row, which Spotify arranges in a stack that traps when an arranged view hides, and which it leaves alone.+static void vanish(UIView *view) {+ if (!view) return;+ if (view.alpha != 0) view.alpha = 0;+ if (view.userInteractionEnabled) view.userInteractionEnabled = NO;+ view.accessibilityElementsHidden = YES;+}++// The outermost view that still wraps the control exactly: the element view Spotify's layout places, so+// concealing it leaves the control itself alone to be read and fired.+static UIView *wrapperFor(UIView *control, UIView *stop) {+ UIView *wrapper = control;+ for (UIView *v = control.superview; v && v != stop; v = v.superview) {+ if (fabs(v.bounds.size.width - control.bounds.size.width) > 4) break;+ if (fabs(v.bounds.size.height - control.bounds.size.height) > 4) break;+ wrapper = v;+ }+ return wrapper;+}++// One of the two controls Spotify floats over the page. They are direct children of the page and 48pt+// across, so only the small children are searched: the wash, the tab and the navigation bar are the width+// of the page, and walking into the tab would be walking the whole list on every pass that missed.+static UIView *floatingIn(UIView *page, NSString *identifier, const void *cacheKey) {+ for (UIView *sub in page.subviews) {+ if (sub.bounds.size.width > 120) continue;+ UIView *found = SGRFindByIdentifier(sub, identifier, cacheKey);+ if (found) return found;+ }+ return nil;+}++static void setFrame(UIView *view, CGRect frame) {+ if (view && !CGRectIsEmpty(frame) && !CGRectEqualToRect(view.frame, frame)) view.frame = frame;+}++// `view` moved to the middle of its parent's width, keeping its size and its y.+static void centre(UIView *view) {+ if (!view.superview || view.bounds.size.width <= 0) return;+ CGRect frame = view.frame;+ frame.origin.x = round((view.superview.bounds.size.width - frame.size.width) / 2);+ setFrame(view, frame);+}++static void styleLabels(UIView *root, UIColor *color, UIFont *font, NSTextAlignment alignment) {+ SGForEachView(root, ^(UIView *v) {+ if (![v isKindOfClass:UILabel.class]) return;+ UILabel *label = (UILabel *)v;+ if (color && ![label.textColor isEqual:color]) label.textColor = color;+ if (font && ![label.font isEqual:font]) label.font = font;+ if (label.textAlignment != alignment) label.textAlignment = alignment;+ });+}++// Installs `laidOut` on the view's own pass once, under `key`.+static void watch(UIView *view, const void *key, void (^laidOut)(UIView *view)) {+ if (!view || objc_getAssociatedObject(view, key)) return;+ objc_setAssociatedObject(view, key, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ SGRObserveLayout(view, laidOut);+}++#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 SGRAlbumHero : UIView+@property (nonatomic, readonly) UIImageView *picture;+@property (nonatomic, copy) UIColor *fieldColor;+@end++@implementation SGRAlbumHero {+ 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];++ _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 = SGRAlbumFieldColor(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;+}++static void showCover(SGRAlbumHero *hero, UIImageView *view, UIView *header) {+ UIImage *image = view.image;+ if (!image || view.bounds.size.width < kMinCover) return;+ if (hero.picture.image != image) hero.picture.image = image;+ SGRAlbumSetArtwork(header, image);+}++// The picture runs from the top of the header down to where its text begins, in the header's own space:+// below that the page's field is already drawing the very colour the picture dissolves into, so the hero+// simply stops there and there is no seam to see.+//+// The furthest down the text has been, rather than where it is: a header still loading puts its title+// higher than it will end up, and a header whose cover has not arrived puts it higher still. Both are+// answered by only ever letting the height grow, which settles once the cover and the artist are in.+static void applyHero(UIView *header, UIView *cover, UIView *titleBlock) {+ SGRAlbumHero *hero = objc_getAssociatedObject(header, &kHeroKey);+ if (!hero) {+ hero = [[SGRAlbumHero alloc] initWithFrame:CGRectZero];+ objc_setAssociatedObject(header, &kHeroKey, hero, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ if (hero.superview != header) [header insertSubview:hero atIndex:0];+ else if (header.subviews.firstObject != hero) [header sendSubviewToBack:hero];++ CGFloat height = [objc_getAssociatedObject(hero, &kHeroHeightKey) doubleValue];+ CGFloat top = [header convertPoint:CGPointZero fromView:titleBlock].y;+ if (top > height + 0.5) {+ height = top;+ objc_setAssociatedObject(hero, &kHeroHeightKey, @(height), OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ SGLog(@"redesign album: hero %.0fpt across the top of the header", height);+ }+ if (height < kMinHero) return;+ setFrame(hero, CGRectMake(0, 0, header.bounds.size.width, height));+ hero.fieldColor = SGRAlbumFieldColor(header);++ UIImageView *source = coverImageIn(cover);+ showCover(hero, source, header);+ // 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 SGRAlbumHero *weakHero = hero;+ __weak UIView *weakHeader = header;+ SGRObserveImage(source, ^(UIImageView *view) {+ if (weakHero && weakHeader) showCover(weakHero, view, weakHeader);+ });+ }+ conceal(cover);+}++#pragma mark - the title, the artist and the date++// The title block's stack hugs the widest thing in it and sits 16pt from the leading edge; centred in a+// block widened to the page, it is the column the Music app draws.+//+// The type is Spotify's own, colour and alignment apart. Unlike the playlist's, this header is measured+// from what it holds: the title's width is a constraint the element framework worked out for the font it+// was shown in, and a font of the Kit's a point larger is a title cut off at the end of it.+static void applyTitleStack(UIView *stack, UIView *title, UIView *parent) {+ styleLabels(title, SGRPrimary(), nil, NSTextAlignmentCenter);+ styleLabels(parent, SGRAccent(), nil, NSTextAlignmentCenter);+ for (UIView *row in stack.subviews) {+ if (row.bounds.size.height <= 0 || row.bounds.size.width <= 0) continue;+ centre(row);+ }+}++// The kind and the date ("Album • 31. 1. 2025") are cells of a collection view as wide as the page's text+// column, laid out from its leading edge. It is Spotify's own Swift class, so its pass cannot be watched+// and its cells are not moved: the row is centred by the inset the collection scrolls its content at,+// which no layout pass of Spotify's writes over.+static void applyMetadata(UIView *metadata) {+ __block UICollectionView *cells = nil;+ SGForEachView(metadata, ^(UIView *v) {+ if (!cells && [v isKindOfClass:UICollectionView.class]) cells = (UICollectionView *)v;+ });+ styleLabels(metadata, SGRTertiary(), nil, NSTextAlignmentCenter);+ // Asked of the layout rather than read off the scroll view: a pass runs top down, so every view whose+ // pass this can be watched from has already run by the time the cells lay themselves out, and+ // contentSize is a pass behind on every one of them (0 for as long as the header stands still).+ CGFloat room = cells.bounds.size.width;+ CGFloat content = MAX(cells.contentSize.width, cells.collectionViewLayout.collectionViewContentSize.width);+ if (room <= 0 || content <= 0 || content >= room) return;+ CGFloat lead = round((room - content) / 2);+ if (fabs(cells.contentInset.left - lead) > 0.5) cells.contentInset = UIEdgeInsetsMake(0, lead, 0, 0);+}++#pragma mark - the action row++// Shuffle, Play and add, centred, with more beside them when Spotify has not moved it into the navigation+// bar. Glass goes inside each of Spotify's round buttons (the Kit's way: the shape is the button's own+// subview, so it goes wherever the button is put); the capsule and the stand-in carry their own.+static void applyActions(UIView *row, UIView *header, UIView *page) {+ UIView *add = SGRFindByIdentifier(row, @"Components.UI.AddToButton", &kAddKey);+ UIView *more = SGRFindByIdentifier(row, @"Components.UI.ContextMenuButton*", &kMoreKey);+ // The Music app has neither on an album: a video entry point, and a download button the mod's own+ // downloads do not need beside it.+ for (NSString *identifier in @[@"Components.UI.WatchFeedEntityExplorerButton", @"DownloadButton.Granular*",+ @"Components.UI.ShareButton"]) {+ UIView *gone = SGRFindByIdentifier(row, identifier, NULL);+ if (gone) vanish(wrapperFor(gone, row));+ }++ UIView *play = floatingIn(page, @"header-play-button", &kPlayKey);+ UIView *shuffle = floatingIn(page, @"Components.UI.ShuffleButton", &kShuffleKey);++ SGRPlayCapsule *capsule = objc_getAssociatedObject(row, &kCapsuleKey);+ if (!capsule) {+ capsule = [[SGRPlayCapsule alloc] initWithFrame:CGRectZero];+ objc_setAssociatedObject(row, &kCapsuleKey, capsule, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ if (capsule.superview != row) [row addSubview:capsule];+ if (play) {+ [capsule feedFrom:play];+ // Only what the button draws goes: a concealed layer still sends the actions the capsule fires.+ conceal(wrapperFor(play, page));+ }+ capsule.hidden = play == nil;++ SGRMirrorButton *mirror = objc_getAssociatedObject(row, &kMirrorKey);+ if (!mirror) {+ mirror = [[SGRMirrorButton alloc] initWithFrame:CGRectZero];+ objc_setAssociatedObject(row, &kMirrorKey, mirror, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ if (mirror.superview != row) [row addSubview:mirror];+ if (shuffle) {+ [mirror feedFrom:shuffle];+ conceal(wrapperFor(shuffle, page));+ }+ mirror.hidden = shuffle == nil;++ NSMutableArray<UIView *> *items = [NSMutableArray array];+ NSMutableArray<NSNumber *> *widths = [NSMutableArray array];+ if (shuffle) { [items addObject:mirror]; [widths addObject:@(SGRActionHeight)]; }+ if (play) { [items addObject:capsule]; [widths addObject:@([capsule sgr_width])]; }+ if (add) { [items addObject:wrapperFor(add, row)]; [widths addObject:@(SGRActionHeight)]; }+ if (more) { [items addObject:wrapperFor(more, row)]; [widths addObject:@(SGRActionHeight)]; }+ if (!items.count) return;++ CGFloat total = (items.count - 1) * SGRActionSpacing;+ for (NSNumber *width in widths) total += width.doubleValue;+ CGFloat x = round((row.bounds.size.width - total) / 2), middle = CGRectGetMidY(row.bounds);+ for (NSUInteger i = 0; i < items.count; i++) {+ UIView *item = items[i];+ CGFloat slot = widths[i].doubleValue;+ BOOL ours = item == (UIView *)capsule || item == (UIView *)mirror;+ CGSize size = ours ? CGSizeMake(slot, SGRActionHeight) : item.bounds.size;+ setFrame(item, CGRectMake(round(x + (slot - size.width) / 2), round(middle - size.height / 2), size.width, size.height));+ x += slot + SGRActionSpacing;+ }+ for (UIView *button in @[add ?: NSNull.null, more ?: NSNull.null]) {+ if ([button isKindOfClass:UIView.class]) SGRGlassInside(button, &kGlassKey, SGRGlassCircleSize);+ }++ static BOOL logged;+ if (!logged && row.window) {+ logged = YES;+ SGLog(@"redesign album: action row %@, shuffle %@, play %@, add %@, more %@", NSStringFromCGRect(row.bounds),+ shuffle ? @"found" : @"missing", play ? @"found" : @"missing", add ? @"found" : @"missing",+ more ? @"in the row" : @"not in the page");+ }+}++#pragma mark - the header's pass++// Spotify's colour wash behind the header goes, so the page's field shows through. The sticky navigation+// bar above it keeps its own gradient: that one is hidden at rest and fades in under the title as the page+// scrolls, which is what makes the title legible over the list.+static void applyWash(UIView *page) {+ for (UIView *sub in page.subviews) {+ NSString *name = NSStringFromClass(sub.class);+ if (![name containsString:@"HeaderView"] || [name containsString:@"NavigationBar"]) continue;+ for (UIView *v in sub.subviews) {+ if ([NSStringFromClass(v.class) containsString:@"GradientView"]) conceal(v);+ }+ }+}++// The stack view `view` is arranged by, or nil: what has to lay out before `view` can be moved. Asked+// through -class, which a watch's runtime subclass answers with the class Spotify made.+static UIStackView *stackOver(UIView *view) {+ UIStackView *stack = (UIStackView *)view.superview;+ return [stack class] == UIStackView.class ? stack : nil;+}++static void applyHeader(UIView *header, UIView *page) {+ UIView *title = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.TitleRow", &kTitleKey);+ UIView *parent = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.ParentRow", &kParentKey);+ UIView *titleStack = title.superview;+ UIView *titleBlock = titleStack.superview;+ if (!titleBlock) return;++ applyWash(page);+ UIView *cover = SGRFindByIdentifier(header, @"CreativeWorkPlatform.Components.UI.ArtWorkElement.WithCoverArt", &kCoverKey);+ if (cover) applyHero(header, cover, titleBlock);++ // The title block hugs its text, so it is widened to the group it is arranged in before the stack+ // inside it is centred; the group lays the block out, so that is the pass it is taken from.+ UIStackView *group = stackOver(titleBlock);+ void (^widenBlock)(UIView *) = ^(UIView *view) {+ CGRect frame = titleBlock.frame;+ setFrame(titleBlock, CGRectMake(0, frame.origin.y, view.bounds.size.width, frame.size.height));+ };+ if (group) {+ widenBlock(group);+ watch(group, &kGroupWatchedKey, widenBlock);+ }+ centre(titleStack);+ watch(titleBlock, &kBlockWatchedKey, ^(UIView *view) { centre(titleStack); });+ applyTitleStack(titleStack, title, parent);+ watch(titleStack, &kTitleWatchedKey, ^(UIView *view) { applyTitleStack(view, title, parent); });++ UIView *metadata = SGRFindByIdentifier(header, @"Components.UI.MetadataRow", &kMetaKey);+ UIStackView *metaStack = stackOver(metadata.superview) ?: stackOver(metadata);+ if (metadata) {+ applyMetadata(metadata);+ watch(metaStack ?: metadata, &kMetaWatchedKey, ^(UIView *view) { applyMetadata(metadata); });+ }++ // The action row is whichever stack Spotify's own buttons are arranged in, found from the first of them+ // that is still in the page, and widened to its group the way the title block is.+ UIView *anyButton = SGRFindByIdentifier(header, @"Components.UI.AddToButton", &kAddKey)+ ?: SGRFindByIdentifier(header, @"DownloadButton.Granular*", NULL)+ ?: SGRFindByIdentifier(header, @"Components.UI.ContextMenuButton*", &kMoreKey);+ UIStackView *actions = (UIStackView *)wrapperFor(anyButton, header).superview;+ if (![actions isKindOfClass:UIStackView.class]) return;+ UIStackView *bottom = stackOver(actions);+ void (^widenRow)(UIView *) = ^(UIView *view) {+ CGRect frame = actions.frame;+ setFrame(actions, CGRectMake(0, frame.origin.y, view.bounds.size.width, frame.size.height));+ };+ if (bottom) {+ widenRow(bottom);+ watch(bottom, &kBottomWatchedKey, widenRow);+ }+ applyActions(actions, header, page);+ // Weakly: the row is the page's own descendant, and a block of its that held the page would keep the+ // whole page alive for as long as the row.+ __weak UIView *weakHeader = header, *weakPage = page;+ watch(actions, &kActionsWatchedKey, ^(UIView *view) {+ if (weakHeader && weakPage) applyActions(view, weakHeader, weakPage);+ });+}++static void applyPage(UIView *page) {+ UIView *header = SGRFindByIdentifier(page, @"CreativeWorkPlatform.Components.UI.CreativeWorkHeader", &kHeaderKey);+ if (!header) return;+ applyHeader(header, page);+ // The header lays itself out again whenever its cover, its artist or its buttons arrive, which the+ // page's own pass does not hear about. It is a plain UIView, so its pass can be watched.+ watch(header, &kHeaderWatchedKey, ^(UIView *view) {+ UIView *owner = SGRAlbumPageOf(view);+ if (owner) applyHeader(view, owner);+ });+}++%hook _TtC28CreativeWorkPlatform_PageKit24CreativeWorkTemplateView+- (void)layoutSubviews {+ %orig;+ applyPage((UIView *)self);+}+%end++// The play button arrives in the page after the row that replaces it has been laid out, so a page opening+// showed Spotify's green disc in the corner until something else laid the page out. Its own pass is where+// it goes, and the class is Spotify's own so nothing else pays for the check.+%hook _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView+- (void)layoutSubviews {+ %orig;+ UIView *button = (UIView *)self;+ if (button.layer.hidden || ![button.accessibilityIdentifier isEqualToString:@"header-play-button"]) return;+ UIView *page = SGRAlbumPageOf(button);+ if (!page) return;+ conceal(wrapperFor(button, page));+ applyPage(page);+}+%end++%ctor {+ if (!SGRedesignedUI()) return;+ %init;+ SGRequireClasses(@[+ @"_TtC28CreativeWorkPlatform_PageKit24CreativeWorkTemplateView",+ @"_TtC28EncoreConsumerMobile_BaseKit14PlayButtonView",+ ]);+}diff --git a/tweak/Sources/Redesigned/Album/AlbumRows.x b/tweak/Sources/Redesigned/Album/AlbumRows.xnew file mode 100644index 00000000..9714baa0--- /dev/null+++ b/tweak/Sources/Redesigned/Album/AlbumRows.x@@ -0,0 +1,99 @@+// Album redesign: the track rows on the field, the way the Music app has them -- no surface of their own+// and a hairline from the text's edge between one row and the next.+//+// Tree (trees/clean/album/03.txt:524-575): every row of the page is an Element_List.CollectionViewCell+// holding an Encore.ListRow, id=Components.UI.RetrievalRowElementUI, with the title+// (EncoreConsumerMobile.View.Granular.Title), the artists under it (…Granular.Subtitle) and, at the+// trailing edge, Components.UI.ContextMenuButton. An album row carries no artwork -- every track on the+// page shares the cover the header is already showing -- so the hairline runs from the page's own margin,+// where the text starts.+//+// The row's 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 56pt for a title of 13pt, and a larger font of+// the Kit's would be cut off by the box the element framework measured for it.+#import "Core/SGCore.h"+#import "Redesigned/Kit/SGRKit.h"+#import "Album.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;++static char kRowKey, kSubtitleKey, kLineKey;++static void clearSurface(UIView *view) {+ UIColor *color = view.backgroundColor;+ if (color && SGIsBaseSurface(color.CGColor)) view.backgroundColor = UIColor.clearColor;+}++static void applyHairline(UIView *row) {+ CALayer *line = objc_getAssociatedObject(row, &kLineKey);+ if (!line) {+ line = [CALayer layer];+ line.zPosition = 1;+ objc_setAssociatedObject(row, &kLineKey, line, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ line.backgroundColor = SGRHairline().CGColor;+ if (line.superlayer != row.layer) [row.layer addSublayer:line];+ CGRect bounds = row.bounds;+ CGRect frame = CGRectMake(SGRSideMargin, bounds.size.height - kHairline,+ MAX(0, bounds.size.width - 2 * 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 = SGRFindByIdentifier(cell, @"Components.UI.RetrievalRow*", &kRowKey);+ if (!row) return;+ // The row, and every box the element framework wraps it in on the way back up to the cell.+ for (UIView *v = row; v; v = v.superview) {+ clearSurface(v);+ if (v == cell) break;+ }++ UIView *subtitle = SGRFindByIdentifier(row, @"EncoreConsumerMobile.View.Granular.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);+}++// Which cells of Element_List belong to an album's track list, answered once per content class: the same+// cell class carries Home's sections and the album's footer too, and a walk up to the page on every pass of+// every cell is what the answer is cached to avoid.+static BOOL isTrackContent(UIView *content) {+ static NSMutableDictionary<id, NSNumber *> *answers;+ if (!answers) answers = [NSMutableDictionary dictionary];+ Class cls = object_getClass(content);+ if (!cls) return NO;+ NSNumber *answer = answers[(id<NSCopying>)cls];+ if (!answer) {+ answer = @([NSStringFromClass(cls) containsString:@"RetrievalListStructuredData"]);+ answers[(id<NSCopying>)cls] = answer;+ }+ return answer.boolValue;+}++%hook _TtC12Element_List18CollectionViewCell+- (void)layoutSubviews {+ %orig;+ UICollectionViewCell *cell = (UICollectionViewCell *)self;+ if (!isTrackContent(cell.contentView.subviews.firstObject)) return;+ if (SGRAlbumPageOf(cell)) applyRow(cell);+}+%end++%ctor {+ if (!SGRedesignedUI()) return;+ %init;+ SGRequireClasses(@[@"_TtC12Element_List18CollectionViewCell"]);+}diff --git a/tweak/Sources/Redesigned/Album/AlbumSections.x b/tweak/Sources/Redesigned/Album/AlbumSections.xnew file mode 100644index 00000000..3ccdbaeb--- /dev/null+++ b/tweak/Sources/Redesigned/Album/AlbumSections.x@@ -0,0 +1,131 @@+// Album redesign: everything under the track list dropped but what the album itself says.+//+// Spotify closes an album page with a run of sections the server sends -- more by the artist, related music+// videos, concerts, merch, you might also like -- and more of them whenever it likes. None of them is the+// album. So the rule is not a list of their names, which would be a list in one language that the next+// section walks past: every one of those cells reports no height, and only two are kept.+//+// Tree (trees/clean/album/04.txt:979-2576). Everything under the tracks comes as an Element_List cell whose+// content is an ElementContentView over Album_PageImpl.FooterStructuredData -- the headings, the carousels,+// the merch cards, the 16pt spacers between them, and the two worth keeping:+//+// Album.ConsumptionExperience "22 songs • 1hr 24min", the line the Music app puts under a track list+// Album.Copyright the © and ℗ lines, which are the label's and stay+//+// The tracks themselves are the same cell class over RetrievalListStructuredData and are never touched here.+//+// A dropped cell is 0 tall, but what it holds keeps the height it measured at, hidden and cut off by the+// cell: Spotify's content squeezed to 0 with the cell breaks its own required constraints on every layout+// pass, which is what held the main thread where dropped sections scrolled in on Home (2026-09-17). The two+// kept cells are given the gap the spacers used to draw and their content is pinned under it.+#import "Core/SGCore.h"+#import "Redesigned/Kit/SGRKit.h"+#import "Album.h"++// Over the album's own line, and between it and the copyright: the spacers they sat between are gone.+static const CGFloat kLead = 16;++static char kSettledKey;++static BOOL isFooterContent(UIView *content) {+ static NSMutableDictionary<id, NSNumber *> *answers;+ if (!answers) answers = [NSMutableDictionary dictionary];+ Class cls = object_getClass(content);+ if (!cls) return NO;+ NSNumber *answer = answers[(id<NSCopying>)cls];+ if (!answer) {+ answer = @([NSStringFromClass(cls) containsString:@"Album_PageImpl20FooterStructuredData"]);+ answers[(id<NSCopying>)cls] = answer;+ }+ return answer.boolValue;+}++// The two the album says about itself, restyled as it is kept: Spotify draws both in white, and under a+// track list they are a footnote, not a line to read.+static BOOL isKept(UIView *content) {+ UIView *kept = nil;+ for (NSString *identifier in @[@"Album.ConsumptionExperience", @"Album.Copyright"]) {+ kept = kept ?: SGRFindByIdentifier(content, identifier, NULL);+ }+ if (!kept) return NO;+ SGForEachView(kept, ^(UIView *v) {+ if (![v isKindOfClass:UILabel.class]) return;+ UILabel *label = (UILabel *)v;+ if (![label.textColor isEqual:SGRTertiary()]) label.textColor = SGRTertiary();+ });+ return YES;+}++// The content laid at `lead` down the cell, at the height it measured at, and the cell sized for both.+// Kept on the cell so its own passes, which size the content to the cell again, do not undo it.+static void settle(UICollectionViewCell *cell, CGFloat natural, CGFloat lead) {+ UIView *content = cell.contentView;+ objc_setAssociatedObject(cell, &kSettledKey, @[@(natural), @(lead)], OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ if (content.autoresizingMask & UIViewAutoresizingFlexibleHeight) content.autoresizingMask &= ~UIViewAutoresizingFlexibleHeight;+ CGRect frame = CGRectMake(0, lead, cell.bounds.size.width, natural);+ if (!CGRectEqualToRect(content.frame, frame)) content.frame = frame;+ BOOL dropped = lead == 0;+ if (content.hidden != dropped) content.hidden = dropped;+ if (!cell.clipsToBounds) cell.clipsToBounds = YES;+ cell.accessibilityElementsHidden = dropped;+}++static void unsettle(UICollectionViewCell *cell) {+ UIView *content = cell.contentView;+ objc_setAssociatedObject(cell, &kSettledKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ content.autoresizingMask |= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;+ content.frame = cell.bounds;+ content.hidden = NO;+ cell.clipsToBounds = NO;+ cell.accessibilityElementsHidden = NO;+}++static void logOnce(NSString *what) {+ static NSMutableSet<NSString *> *logged;+ if (!logged) logged = [NSMutableSet set];+ if ([logged containsObject:what]) return;+ [logged addObject:what];+ SGLog(@"redesign album: %@", what);+}++%hook _TtC12Element_List18CollectionViewCell+- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)attributes {+ UICollectionViewCell *cell = (UICollectionViewCell *)self;+ UIView *content = cell.contentView.subviews.firstObject;+ // Cells are reused across kinds, and one settled before can hold a track row now.+ if (!isFooterContent(content) || !SGRAlbumPageOf(cell)) {+ if (objc_getAssociatedObject(cell, &kSettledKey)) unsettle(cell);+ return %orig;+ }+ UICollectionViewLayoutAttributes *result = %orig;+ CGFloat natural = MAX(1, result.size.height);+ if (isKept(content)) {+ settle(cell, natural, kLead);+ result.size = CGSizeMake(result.size.width, natural + kLead);+ logOnce(@"the album's own line and its copyright kept under the tracks");+ } else {+ settle(cell, natural, 0);+ result.size = CGSizeMake(result.size.width, 0);+ logOnce(@"the sections under the tracks dropped");+ }+ return result;+}++// The cell's own passes size the content to the cell again.+- (void)layoutSubviews {+ %orig;+ NSArray<NSNumber *> *settled = objc_getAssociatedObject(self, &kSettledKey);+ if (settled) settle((UICollectionViewCell *)self, settled[0].doubleValue, settled[1].doubleValue);+}++- (void)prepareForReuse {+ %orig;+ if (objc_getAssociatedObject(self, &kSettledKey)) unsettle((UICollectionViewCell *)self);+}+%end++%ctor {+ if (!SGRedesignedUI()) return;+ %init;+ SGRequireClasses(@[@"_TtC12Element_List18CollectionViewCell"]);+}diff --git a/tweak/Sources/Redesigned/Kit/SGRActionRow.h b/tweak/Sources/Redesigned/Kit/SGRActionRow.hnew file mode 100644index 00000000..06f10785--- /dev/null+++ b/tweak/Sources/Redesigned/Kit/SGRActionRow.h@@ -0,0 +1,33 @@+// The controls a redesigned page puts in the row under its hero, where the Music app has them: the Play+// capsule it draws instead of a disc, and a round button standing in for one of Spotify's own where that+// one cannot be brought into the row.+//+// Neither is a control of its own making. Each takes what it shows from a button of Spotify's -- the glyph+// it draws, the word beside it in the app's own language, whether it reads play or pause -- and a tap on it+// fires that button, so the action, the state and the accessibility stay Spotify's and only the drawing is+// the redesign's. A page that can move Spotify's button into its row moves it and needs neither.+//+// Ownership: whoever adds them; each keeps a weak reference to Spotify's control.+// Threading: main thread only.+#import <UIKit/UIKit.h>++// A capsule the height of SGRActionHeight with a glyph and a word in it, on prominent glass: the one+// control of an action row that leads. `sgr_width` is the width the word it is showing asks for.+@interface SGRPlayCapsule : UIControl+// Spotify's play button, the one the capsule reads and fires. Set by -feedFrom:.+@property (nonatomic, weak, readonly) UIView *source;+// Takes the glyph, the word and the language from `source`, and follows the glyph as Spotify swaps it+// (play becoming pause) without the header laying out again. Cheap to call again on every pass.+- (void)feedFrom:(UIView *)source;+- (CGFloat)sgr_width;+@end++// A round glass button SGRActionHeight across showing the glyph of one of Spotify's round buttons and+// firing it, for a control the row cannot reach: the album page's shuffle floats over the page rather+// than scrolling with its header, so it is left where it is, concealed, and this stands in for it.+@interface SGRMirrorButton : UIControl+@property (nonatomic, weak, readonly) UIView *source;+// Takes the glyph, its colour and the label from `source`, and follows the glyph as Spotify swaps it+// (shuffle turning on). Cheap to call again on every pass.+- (void)feedFrom:(UIView *)source;+@enddiff --git a/tweak/Sources/Redesigned/Kit/SGRActionRow.m b/tweak/Sources/Redesigned/Kit/SGRActionRow.mnew file mode 100644index 00000000..5b4a68d0--- /dev/null+++ b/tweak/Sources/Redesigned/Kit/SGRActionRow.m@@ -0,0 +1,216 @@+// The action row's controls: the Play capsule and the button that stands in for one of Spotify's.+//+// Both are drawn from what Spotify's own button shows, and neither keeps state of its own. The glyph is+// looked for past what is hidden behind it -- a play button's glow ring is a hidden 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) -- and+// it is watched afterwards, because Spotify swaps play for pause without laying the header out again.+#import "Core/SGCore.h"+#import "SGRActionRow.h"+#import "SGRGlass.h"+#import "SGRRestyle.h"+#import "SGRTokens.h"+#import "SGRAccent.h"++// The 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;+// The mirrored glyph, the size Spotify draws one inside a 48pt round button.+static const CGFloat kMirrorGlyph = 24;++static char kCapsuleGlassKey, kMirrorGlassKey, kGlyphWatchedKey;++#pragma mark - firing Spotify's button++// The way a tap on Spotify's own button would: its first control, fired through its actions, and through+// accessibility for an Encore control that reads its touches from a gesture recognizer instead.+static void fire(UIView *source) {+ __block UIControl *control = nil;+ SGForEachView(source, ^(UIView *v) {+ if (!control && [v isKindOfClass:UIControl.class]) control = (UIControl *)v;+ });+ if (control && SGRFire(control)) return;+ id target = control ?: source;+ static dispatch_once_t once;+ dispatch_once(&once, ^{ SGLog(@"redesign kit: an action row control fired through accessibility on %@", [target class]); });+ [target accessibilityActivate];+}++// The glyph Spotify's button draws: an image view of the button's own size that nothing hidden is in the+// way of. `side` is the size to match, 0 for any image view that is showing.+static UIImageView *glyphIn(UIView *button, CGFloat side) {+ __block UIImageView *glyph = nil;+ SGForEachView(button, ^(UIView *v) {+ if (glyph || ![v isKindOfClass:UIImageView.class] || !((UIImageView *)v).image) return;+ if (side > 0 && (fabs(v.bounds.size.width - side) > 2 || fabs(v.bounds.size.height - side) > 2)) return;+ for (UIView *up = v; up && up != button; up = up.superview) {+ if (up.hidden || up.alpha <= 0.01) return;+ }+ glyph = (UIImageView *)v;+ });+ return glyph;+}++static NSString *wordIn(UIView *button) {+ __block NSString *word = nil;+ SGForEachView(button, ^(UIView *v) {+ if (!word && v.accessibilityLabel.length) word = v.accessibilityLabel;+ });+ return word;+}++#pragma mark - the Play capsule++@implementation SGRPlayCapsule {+ UIImageView *_glyph;+ UILabel *_title;+}++- (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)feedFrom:(UIView *)source {+ if (!source) return;+ _source = source;++ NSString *word = wordIn(source);+ UIImageView *glyph = glyphIn(source, source.bounds.size.width);++ UIFont *font = SGRFont(UIFontTextStyleSubheadline, UIFontWeightSemibold, UIContentSizeCategoryLarge);+ if (![_title.font isEqual:font]) _title.font = font;+ if (![_title.textColor isEqual:SGRAccent()]) _title.textColor = SGRAccent();+ if (word && ![_title.text isEqualToString:word]) {+ _title.text = word;+ self.accessibilityLabel = word;+ [self setNeedsLayout];+ }+ if (![_glyph.tintColor isEqual:SGRAccent()]) _glyph.tintColor = SGRAccent();++ if (glyph.image && _glyph.image != glyph.image) {+ _glyph.image = [glyph.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];+ static dispatch_once_t once;+ dispatch_once(&once, ^{+ SGLog(@"redesign kit: 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 *weakSelf = self;+ __weak UIView *weakSource = source;+ SGRObserveImage(glyph, ^(UIImageView *view) {+ if (weakSelf && weakSource) [weakSelf feedFrom:weakSource];+ });+ }+}++- (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 {+ fire(self.source);+}++@end++#pragma mark - a button standing in for Spotify's++@implementation SGRMirrorButton {+ UIImageView *_glyph;+}++- (instancetype)initWithFrame:(CGRect)frame {+ if (!(self = [super initWithFrame:frame])) return nil;+ _glyph = [UIImageView new];+ _glyph.contentMode = UIViewContentModeScaleAspectFit;+ _glyph.userInteractionEnabled = NO;+ [self addSubview:_glyph];++ 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;+}++- (void)layoutSubviews {+ [super layoutSubviews];+ CGRect bounds = self.bounds;+ SGRGlassInside(self, &kMirrorGlassKey, SGRGlassCircleSize);+ _glyph.frame = CGRectMake(round((bounds.size.width - kMirrorGlyph) / 2), round((bounds.size.height - kMirrorGlyph) / 2),+ kMirrorGlyph, kMirrorGlyph);+}++// The glyph is taken as Spotify drew it, colour and all: the shuffle button turns its own glyph the accent+// colour while shuffle is on, and a copy rendered as a template would lose that.+- (void)feedFrom:(UIView *)source {+ if (!source) return;+ _source = source;++ UIImageView *glyph = glyphIn(source, 0);+ NSString *word = source.accessibilityLabel ?: wordIn(source);+ if (word && ![self.accessibilityLabel isEqualToString:word]) self.accessibilityLabel = word;+ if (glyph.image && _glyph.image != glyph.image) _glyph.image = glyph.image;+ if (glyph.tintColor && ![_glyph.tintColor isEqual:glyph.tintColor]) _glyph.tintColor = glyph.tintColor;++ if (glyph && !objc_getAssociatedObject(glyph, &kGlyphWatchedKey)) {+ objc_setAssociatedObject(glyph, &kGlyphWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ __weak SGRMirrorButton *weakSelf = self;+ __weak UIView *weakSource = source;+ SGRObserveImage(glyph, ^(UIImageView *view) {+ if (weakSelf && weakSource) [weakSelf feedFrom:weakSource];+ });+ }+}++- (void)sgr_down {+ SGRAnimate(SGRMotionPress, ^{ self.transform = CGAffineTransformMakeScale(0.92, 0.92); }, nil);+}++- (void)sgr_up {+ SGRAnimate(SGRMotionPress, ^{ self.transform = CGAffineTransformIdentity; }, nil);+}++- (void)sgr_tap {+ fire(self.source);+}++@enddiff --git a/tweak/Sources/Redesigned/Kit/SGRKit.h b/tweak/Sources/Redesigned/Kit/SGRKit.hindex e736a107..344a9271 100644--- a/tweak/Sources/Redesigned/Kit/SGRKit.h+++ b/tweak/Sources/Redesigned/Kit/SGRKit.h@@ -7,6 +7,7 @@// SGRField.h the artwork field behind a page// SGRGlass.h glass inside Spotify's round controls// SGRGlyph.h bare glyph overlays and glyph buttons+// SGRActionRow.h the Play capsule and the stand-in button of a page's action row// SGRRestyle.h keeping Spotify's views restyled: suppress, digits, lookups, shadows, firing controls// SGRBridges.h player state, now playing artwork, the player's open and close// SGRRepaint.h the areas the redesign keeps transparent when Spotify repaints them@@ -20,6 +21,7 @@#import "SGRField.h"#import "SGRGlass.h"#import "SGRGlyph.h"+#import "SGRActionRow.h"#import "SGRRestyle.h"#import "SGRBridges.h"#import "SGRRepaint.h"diff --git a/tweak/Sources/Redesigned/Kit/SGRRepaint.h b/tweak/Sources/Redesigned/Kit/SGRRepaint.hindex 173c6f5c..46e3087c 100644--- a/tweak/Sources/Redesigned/Kit/SGRRepaint.h+++ b/tweak/Sources/Redesigned/Kit/SGRRepaint.h@@ -9,3 +9,5 @@ extern __weak UIView *sgr_lyricsPageRoot; // Redesigned/Lyrics/LyricsPage.x// 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;+// Redesigned/Album/AlbumField.x, the album page, kept clear the same way and for the same reason.+extern __weak UIView *sgr_albumRoot;diff --git a/tweak/Sources/Redesigned/Kit/SGRRepaint.x b/tweak/Sources/Redesigned/Kit/SGRRepaint.xindex 23fa5340..eba8b632 100644--- a/tweak/Sources/Redesigned/Kit/SGRRepaint.x+++ b/tweak/Sources/Redesigned/Kit/SGRRepaint.x@@ -7,10 +7,11 @@ __weak UIView *sgr_nowPlayingRoot = nil;__weak UIView *sgr_nowPlayingCard = nil;__weak UIView *sgr_lyricsPageRoot = nil;__weak UIView *sgr_playlistRoot = nil;+__weak UIView *sgr_albumRoot = nil;%hook CALayer- (void)setBackgroundColor:(CGColorRef)color {- if (color && (sgr_nowPlayingRoot || sgr_lyricsPageRoot || sgr_playlistRoot)) {+ if (color && (sgr_nowPlayingRoot || sgr_lyricsPageRoot || sgr_playlistRoot || sgr_albumRoot)) {UIView *view = (UIView *)self.delegate;if ([view isKindOfClass:UIView.class] && view.layer == self && !SGKeepsColor(view)) {if (SGIsInside(view, sgr_nowPlayingRoot)) {@@ -22,7 +23,7 @@ __weak UIView *sgr_playlistRoot = nil;color = NULL;} else if (SGIsInside(view, sgr_lyricsPageRoot)) {color = NULL;- } else if (SGIsBaseSurface(color) && SGIsInside(view, sgr_playlistRoot)) {+ } else if (SGIsBaseSurface(color) && (SGIsInside(view, sgr_playlistRoot) || SGIsInside(view, sgr_albumRoot))) {color = NULL;}}diff --git a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.xindex 1e59d7bf..66c1cd07 100644--- a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x+++ b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x@@ -35,13 +35,10 @@ 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 kCoverKey, kRowKey, kMetaKey, kPlayKey, kGlassKey, kLayoutKey;static char kShuffleKey, kAddKey, kMoreKey, kToolbarKey;-static char kHeroKey, kHeroHeightKey, kCapsuleKey, kColumnWatchedKey, kRowWatchedKey, kCoverWatchedKey, kGlyphWatchedKey;+static char kHeroKey, kHeroHeightKey, kCapsuleKey, kColumnWatchedKey, kRowWatchedKey, kCoverWatchedKey;#pragma mark - finding things@@ -348,123 +345,6 @@ static void applyColumn(UIView *column) {}}-#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@@ -501,7 +381,7 @@ static void applyActions(UIView *block, UIView *headerRoot) {if (capsule.superview != container) [container addSubview:capsule];UIView *playButton = SGRFindByIdentifier(headerRoot, @"header-play-button", &kPlayKey);if (playButton) {- feedCapsule(capsule, playButton);+ [capsule feedFrom:playButton];// Only what the button draws goes: a concealed layer still sends the actions the capsule fires.conceal(playButton);}