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 artist page gets the playlist's and album's header and loses its videos and tab strip
Vojtěch Škopek57a28330325c
diff --git a/AGENTS.md b/AGENTS.mdindex d2b433dd..ab6f21b8 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -12,7 +12,7 @@ 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, the playlist and album pages the way the Music app lays them out, black throughout, and its+ filter pills, the playlist, album and artist pages the way the Music app lays them out, black throughout, and itsown accent colour. No native tweak runs.Anything that doesn't draw on Spotify's screens works the same under both: ads, privacy, lyricsdiff --git a/harness/artist/README.md b/harness/artist/README.mdnew file mode 100644index 00000000..ce62bfcd--- /dev/null+++ b/harness/artist/README.md@@ -0,0 +1,17 @@+# Artist harness++Spotify's artist page mocked under its own class names and accessibility identifiers (from+`trees/clean/artist/01.txt` and `05.txt`, recorded 2026-09-16), so `Redesigned/Artist/` can be laid out and+looked at on the Mac without the phone.++ THEOS=$HOME/theos ./build.sh+ xcrun simctl install booted build/ArtistHarness.app+ xcrun simctl launch booted com.vojta.artistharness # at rest+ xcrun simctl launch booted com.vojta.artistharness collapsed # the header scrolled into its 100pt bar++The Music list is a real self-sizing collection view holding the sections in the order the tree has them,+the two video sections included, so `ArtistSections.x` drops them the way it does on the phone: the shelf+first, then its heading and spacer once the list lays out again. At 2 s the log lists every cell's height.++What it does not cover: the repaint hook (so the mock's cells are left unpainted), the real z-order of the+pinned header bar against the list, and the element framework's own sizing.diff --git a/harness/artist/build.sh b/harness/artist/build.shnew file mode 100755index 00000000..1f5e20c4--- /dev/null+++ b/harness/artist/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/ArtistHarness.app"++for f in Redesigned/Artist/ArtistField.x Redesigned/Artist/ArtistHeader.x Redesigned/Artist/ArtistSections.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/Artist" -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/SGRHeaderInfo.m \+ "$SRC"/Redesigned/Kit/SGRedesign.m \+ -framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols \+ -o "$OUT/ArtistHarness.app/ArtistHarness"++cat > "$OUT/ArtistHarness.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>ArtistHarness</string>+<key>CFBundleIdentifier</key><string>com.vojta.artistharness</string>+<key>CFBundleName</key><string>ArtistHarness</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/ArtistHarness.app"diff --git a/harness/artist/main.m b/harness/artist/main.mnew file mode 100644index 00000000..a758515e--- /dev/null+++ b/harness/artist/main.m@@ -0,0 +1,301 @@+// A mock of Spotify's artist page under its own class names and accessibility identifiers, built from+// trees/clean/artist/01.txt and 05.txt (recorded 2026-09-16), so Redesigned/Artist can be laid out and looked+// at on the Mac. `collapsed` on the launch line shows the header scrolled into its 100pt bar.+#import <UIKit/UIKit.h>++#pragma mark - Spotify's classes, by name++@interface _TtC32CreativeWorkPlatform_TemplateKit12TemplateView : UIView @end+@implementation _TtC32CreativeWorkPlatform_TemplateKit12TemplateView @end++@interface _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView : UIView @end+@implementation _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView @end++// TemplateKit's private HeaderContainer; the redesign finds it by the words in its name.+@interface MockTemplateKitHeaderContainer : UIView @end+@implementation MockTemplateKitHeaderContainer @end++@interface _TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView : UIView @end+@implementation _TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView @end++@interface MockHeaderForegroundView : UIView @end+@implementation MockHeaderForegroundView @end++@interface MockGradientView : UIView @end+@implementation MockGradientView @end++@interface _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView : UIView @end+@implementation _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView @end++@interface _TtCOOOE16PodcastUI_ECMKitO19LegacyUI_ECMCoreKit10Components18TabsSectionHeading2UI7Private9TabButton : UIView @end+@implementation _TtCOOOE16PodcastUI_ECMKitO19LegacyUI_ECMCoreKit10Components18TabsSectionHeading2UI7Private9TabButton @end++// The list's cell. Spotify's sizes itself from its element; the mock answers the height it was built for.+@interface _TtC12Element_List18CollectionViewCell : UICollectionViewCell+@property (nonatomic) CGFloat natural;+@end+@implementation _TtC12Element_List18CollectionViewCell+- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)attributes {+ UICollectionViewLayoutAttributes *result = [attributes copy];+ result.size = CGSizeMake(attributes.size.width, self.natural);+ return result;+}+@end++@interface MockButton : UIControl @end+@implementation MockButton @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 boldSystemFontOfSize:size];+ inner.textColor = color;+ inner.accessibilityIdentifier = [identifier stringByAppendingString:@"-internal"];+ [encore addSubview:inner];+ return inner;+}++// A portrait: warm light from the top left over a dark ground, a head and shoulders.+static UIImage *photo(void) {+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(213, 213)];+ return [renderer imageWithActions:^(UIGraphicsImageRendererContext *ctx) {+ CGContextRef c = ctx.CGContext;+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();+ CGFloat components[] = {0.78, 0.52, 0.38, 1, 0.18, 0.12, 0.14, 1};+ CGGradientRef gradient = CGGradientCreateWithColorComponents(space, components, NULL, 2);+ CGContextDrawLinearGradient(c, gradient, CGPointZero, CGPointMake(213, 213), 0);+ CGGradientRelease(gradient);+ CGColorSpaceRelease(space);+ [[UIColor colorWithRed:0.35 green:0.24 blue:0.22 alpha:1] setFill];+ [[UIBezierPath bezierPathWithOvalInRect:CGRectMake(72, 40, 70, 84)] fill];+ [[UIBezierPath bezierPathWithRoundedRect:CGRectMake(36, 128, 142, 120) cornerRadius:50] fill];+ }];+}++static UIImageView *glyph(UIView *button, NSString *symbol, CGFloat inset) {+ UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectInset(button.bounds, inset, inset)];+ image.image = [UIImage systemImageNamed:symbol];+ image.tintColor = UIColor.whiteColor;+ [button addSubview:image];+ return image;+}++#pragma mark - the list++// What each cell of the Music list holds, top to bottom (05.txt): its identifier and its height.+static NSArray<NSArray *> *musicList(void) {+ NSMutableArray *items = [NSMutableArray array];+ void (^section)(NSString *, NSArray *) = ^(NSString *heading, NSArray *content) {+ [items addObject:@[@"", @16]];+ [items addObject:@[@"Components.UI.SectionHeadingHome", @36.67, heading]];+ [items addObjectsFromArray:content];+ };+ NSArray *tracks = @[@[@"Components.UI.RetrievalRowElementUI", @64, @"Stitches"], @[@"Components.UI.RetrievalRowElementUI", @64, @"Treat You Better"],+ @[@"Components.UI.RetrievalRowElementUI", @64, @"Mercy"], @[@"Components.UI.RetrievalRowElementUI", @64, @"There's Nothing Holdin' Me Back"]];+ [items addObject:@[@"Components.UI.SectionHeadingHome", @36.67, @"Popular"]];+ [items addObjectsFromArray:tracks];+ section(@"Artist pick", @[@[@"Components.UI.PinnedItemUI", @120]]);+ section(@"Popular Releases", @[@[@"Components.UI.RetrievalRowElementUI", @104, @"Shawn"], @[@"Components.UI.RetrievalRowElementUI", @104, @"Wonder"]]);+ section(@"Music videos", @[@[@"Components.UI.MusicVideoShelfHeader", @224]]);+ section(@"Watch more from Shawn Mendes", @[@[@"WatchFeedCarouselEntryPointElement", @208]]);+ section(@"About", @[@[@"Components.UI.CreatorBiographyCard", @180]]);+ section(@"Fans Also Like", @[@[@"Components.UI.HomeCard", @178]]);+ return items;+}++@interface SGRListSource : NSObject <UICollectionViewDataSource>+@property (nonatomic, copy) NSArray<NSArray *> *items;+@end++@implementation SGRListSource+- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {+ return self.items.count;+}++- (UICollectionViewCell *)collectionView:(UICollectionView *)view cellForItemAtIndexPath:(NSIndexPath *)path {+ _TtC12Element_List18CollectionViewCell *cell = [view dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:path];+ for (UIView *old in cell.contentView.subviews) [old removeFromSuperview];+ NSArray *item = self.items[path.item];+ NSString *kind = item[0];+ CGFloat height = [item[1] doubleValue];+ cell.natural = height;+ // Left unpainted: on the phone the repaint hook clears the base surface, which the harness does not compile.+ cell.backgroundColor = UIColor.clearColor;+ UIView *content = box(cell.contentView, UIView.class, CGRectMake(0, 0, view.bounds.size.width, height), nil);+ if (!kind.length) return cell;+ UIView *element = box(content, UIView.class, content.bounds, kind);+ CGFloat W = view.bounds.size.width;+ if ([kind isEqualToString:@"Components.UI.SectionHeadingHome"]) {+ label(element, CGRectMake(16, 8, W - 32, 22), item[2], 19, UIColor.whiteColor, @"Encore.Label");+ } else if ([kind isEqualToString:@"Components.UI.RetrievalRowElementUI"]) {+ UIView *art = box(element, UIView.class, CGRectMake(16, 8, height - 16, height - 16), nil);+ art.backgroundColor = [UIColor colorWithRed:0.45 green:0.35 blue:0.30 alpha:1];+ art.layer.cornerRadius = 4;+ label(element, CGRectMake(height + 8, height / 2 - 18, W - height - 40, 18), item[2], 14, UIColor.whiteColor, @"EncoreConsumerMobile.View.Granular.Title");+ UILabel *sub = label(element, CGRectMake(height + 8, height / 2 + 2, W - height - 40, 16), @"Shawn Mendes", 12,+ [UIColor colorWithWhite:1 alpha:0.6], @"EncoreConsumerMobile.View.Granular.Subtitle");+ sub.font = [UIFont systemFontOfSize:12];+ } else {+ UIView *card = box(element, UIView.class, CGRectMake(16, 4, W - 32, height - 8), nil);+ card.backgroundColor = [UIColor colorWithWhite:0.16 alpha:1];+ card.layer.cornerRadius = 8;+ label(card, CGRectMake(12, 12, W - 60, 18), [kind componentsSeparatedByString:@"."].lastObject, 13,+ [UIColor colorWithWhite:1 alpha:0.7], @"Encore.Label");+ }+ return cell;+}+@end++#pragma mark - the page++@interface SGRHarnessDelegate : UIResponder <UIApplicationDelegate>+@property (nonatomic, strong) UIWindow *window;+@property (nonatomic, strong) SGRListSource *source;+@end++@implementation SGRHarnessDelegate++- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options {+ self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];+ CGFloat W = self.window.bounds.size.width, H = self.window.bounds.size.height;+ BOOL collapsed = [NSProcessInfo.processInfo.arguments containsObject:@"collapsed"];++ UIViewController *root = [UIViewController new];+ root.view.backgroundColor = [UIColor colorWithRed:0.07 green:0.07 blue:0.07 alpha:1];+ self.window.rootViewController = root;++ UIView *page = box(root.view, _TtC32CreativeWorkPlatform_TemplateKit12TemplateView.class, CGRectMake(0, 0, W, H), @"creator-page");+ UIScrollView *scroll = (UIScrollView *)box(page, UIScrollView.class, page.bounds, @"PCFFTabLayoutViewController.containerScrollView");+ scroll.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;+ UIView *stack = box(scroll, UIView.class, CGRectMake(0, 0, W, 3000), nil);++ // the header, 568pt with the headline+ UIView *container = box(stack, MockTemplateKitHeaderContainer.class, CGRectMake(0, 0, W, 568), nil);+ UIView *element = box(container, UIView.class, collapsed ? CGRectMake(0, 468, W, 100) : container.bounds, nil);+ UIView *header = box(element, _TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView.class, element.bounds, nil);++ UIView *clip = box(header, UIView.class, CGRectMake(0, 0, W, collapsed ? 0 : 424.67), nil);+ clip.clipsToBounds = YES;+ UIView *artwork = box(clip, UIView.class, CGRectMake(-11.33, 0, 424.67, 424.67), @"Components.Header.UI.ArtworkImage");+ UIImageView *picture = [[UIImageView alloc] initWithFrame:artwork.bounds];+ picture.image = photo();+ picture.accessibilityIdentifier = @"Components.Header.UI.ArtworkImage.ImageView";+ [artwork addSubview:picture];+ UIView *wash = box(clip, MockGradientView.class, CGRectMake(-11.33, 310.67, 424.67, 257.33), nil);+ wash.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];++ UIView *titleBox = box(header, UIView.class, CGRectMake(16, 334.67, 370, 54), nil);+ label(titleBox, CGRectMake(0, 0, 370, 54), @"Shawn Mendes", 45, UIColor.whiteColor, @"Encore.AdaptiveTitle");+ UIView *badge = box(header, UIStackView.class, CGRectMake(16, 390.67, 114.67, 24), @"ImageHeaderView.VerifiedBadge");+ label(badge, CGRectMake(20, 4, 94, 15), @"Verified by Spotify", 11, UIColor.whiteColor, @"Encore.Label");+ UIView *meta = box(header, UIView.class, CGRectMake(16, 432.67, 370, 15.33), nil);+ label(meta, CGRectMake(0, 0, 314, 15.33), @"58,4M monthly listeners", 11, [UIColor colorWithWhite:1 alpha:0.7],+ @"Components.Header.UI.Metadata");++ UIView *row = box(header, UIStackView.class, CGRectMake(4, 456, 394, 48), nil);+ UIView *follow = box(row, MockButton.class, CGRectMake(70, 8, 66, 32), @"Curation.FollowButtonElementKit.FollowButton");+ follow.accessibilityLabel = @"Follow";+ follow.layer.borderColor = UIColor.grayColor.CGColor;+ follow.layer.borderWidth = 1;+ follow.layer.cornerRadius = 16;+ label(follow, CGRectMake(16, 8, 40, 16), @"Follow", 11, UIColor.whiteColor, @"Encore.Label");+ [(UIControl *)follow addTarget:self action:@selector(toggleFollow:) forControlEvents:UIControlEventTouchUpInside];+ glyph(box(row, MockButton.class, CGRectMake(148, 0, 48, 48), @"Components.UI.ContextMenuButton-7n2wHs1TKAczGzO7Dd2rGr"), @"ellipsis", 12);+ glyph(box(row, MockButton.class, CGRectMake(278, 0, 48, 48), @"Components.UI.ShuffleButton"), @"shuffle", 12);+ UIView *play = box(row, _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView.class, CGRectMake(334, 0, 48, 48), @"header-play-button");+ UIControl *condensed = (UIControl *)box(play, MockButton.class, play.bounds, nil);+ condensed.accessibilityLabel = @"Play";+ UIImageView *disc = glyph(condensed, @"play.fill", 0);+ disc.contentMode = UIViewContentModeCenter;+ disc.backgroundColor = [UIColor colorWithRed:0.12 green:0.84 blue:0.38 alpha:1];+ disc.layer.cornerRadius = 24;+ disc.clipsToBounds = YES;++ UIView *headline = box(header, UIStackView.class, CGRectMake(0, 504, W, 64), nil);+ UIView *banner = box(headline, UIView.class, CGRectMake(16, 16, W - 32, 40), @"Components.UI.ArtistHeadline");+ banner.backgroundColor = [UIColor colorWithWhite:1 alpha:0.1];+ label(banner, CGRectMake(40, 12, 280, 16), @"Pre-save the upcoming album", 11, UIColor.whiteColor, @"Encore.Label");++ UIView *foreground = box(header, MockHeaderForegroundView.class, CGRectMake(0, 0, W, 0), nil);+ UIView *bar = box(foreground, UIView.class, CGRectMake(0, 0, W, 100), nil);+ bar.hidden = !collapsed;+ UIView *barGradient = box(bar, MockGradientView.class, bar.bounds, nil);+ barGradient.backgroundColor = [UIColor colorWithWhite:0.03 alpha:1];+ UILabel *barName = label(bar, CGRectMake(80, 62, 242, 20), @"Shawn Mendes", 13, UIColor.whiteColor, @"Encore.Label");+ barName.textAlignment = NSTextAlignmentCenter;++ // the tabs and, under them, the Music list+ UIView *tabs = box(stack, UIView.class, CGRectMake(0, 568, W, 2400), @"PCFFTabLayoutViewController.tabsViewAccessibilityID");+ UIView *strip = box(tabs, UIView.class, CGRectMake(0, 0, W, 44), @"Components.UI.TabsSectionHeading");+ for (int i = 0; i < 3; i++) {+ UIView *tab = box(strip, _TtCOOOE16PodcastUI_ECMKitO19LegacyUI_ECMCoreKit10Components18TabsSectionHeading2UI7Private9TabButton.class,+ CGRectMake(16 + i * 64, 6, 56, 32), nil);+ label(tab, tab.bounds, @[@"Music", @"Video", @"Merch"][i], 13, UIColor.whiteColor, @"Encore.Label");+ }+ UIScrollView *pages = (UIScrollView *)box(tabs, UIScrollView.class, CGRectMake(0, 44, W, 2356), nil);+ UIView *listView = box(pages, _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView.class, pages.bounds, nil);+ listView.backgroundColor = [UIColor colorWithRed:0.07 green:0.07 blue:0.07 alpha:1];+ UICollectionViewFlowLayout *flow = [UICollectionViewFlowLayout new];+ flow.minimumLineSpacing = 0;+ flow.estimatedItemSize = CGSizeMake(W, 60);+ UICollectionView *list = [[UICollectionView alloc] initWithFrame:listView.bounds collectionViewLayout:flow];+ list.backgroundColor = [UIColor colorWithRed:0.07 green:0.07 blue:0.07 alpha:1];+ list.scrollEnabled = NO;+ [list registerClass:_TtC12Element_List18CollectionViewCell.class forCellWithReuseIdentifier:@"cell"];+ self.source = [SGRListSource new];+ self.source.items = musicList();+ list.dataSource = self.source;+ [listView addSubview:list];+ scroll.contentSize = CGSizeMake(W, 3000);+ if (collapsed) scroll.contentOffset = CGPointMake(0, 468);++ [self.window makeKeyAndVisible];++ // What the Music list came to once every cell answered for itself and the dropped headings were asked+ // again: each cell's kind and height, top to bottom.+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ NSMutableArray *lines = [NSMutableArray array];+ for (NSUInteger i = 0; i < self.source.items.count; i++) {+ UICollectionViewLayoutAttributes *a = [list layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];+ NSArray *item = self.source.items[i];+ NSString *name = item.count > 2 ? item[2] : [item[0] length] ? [item[0] componentsSeparatedByString:@"."].lastObject : @"spacer";+ [lines addObject:[NSString stringWithFormat:@"%@ %.0f", name, a.size.height]];+ }+ NSLog(@"[harness] Music list: %@", [lines componentsJoinedByString:@" | "]);+ NSLog(@"[harness] strip a=%.2f, pages moved %.0f, list bg %@", strip.alpha, pages.transform.ty, list.backgroundColor);+ });+ return YES;+}++// Spotify's Follow turns into Following, which the redesign's word has to follow.+- (void)toggleFollow:(UIControl *)follow {+ UILabel *word = nil;+ for (UIView *v in follow.subviews) {+ if (v.subviews.firstObject && [v.subviews.firstObject isKindOfClass:UILabel.class]) word = (UILabel *)v.subviews.firstObject;+ }+ word.text = [word.text isEqualToString:@"Follow"] ? @"Following" : @"Follow";+ NSLog(@"[harness] Spotify's Follow fired, now \"%@\"", word.text);+}++@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/artist/stubs.m b/harness/artist/stubs.mnew file mode 100644index 00000000..9e2549ce--- /dev/null+++ b/harness/artist/stubs.m@@ -0,0 +1,10 @@+// 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;+__weak UIView *sgr_artistRoot = nil;diff --git a/tweak/Sources/Redesigned/Artist/Artist.h b/tweak/Sources/Redesigned/Artist/Artist.hnew file mode 100644index 00000000..6501ce25--- /dev/null+++ b/tweak/Sources/Redesigned/Artist/Artist.h@@ -0,0 +1,27 @@+// The artist redesign: Spotify's artist page kept, with its list and its controls, decluttered and given the+// header the playlist and album pages have, so the three read as one app.+//+// The page is TemplateKit's TemplateView, id=creator-page (trees/clean/artist/01.txt:26, recorded+// 2026-09-16), not the album's CreativeWorkTemplateView: its header is an ImageHeaderView, the photo, the+// name, the listeners and a row of explore, follow, more, shuffle and play, which Spotify shrinks to a 100pt+// bar pinned at the top as the page scrolls; under it a strip of Music / Video / Merch tabs, each a list.+//+// ArtistField.x the photo's field behind the whole page, the page kept clear on it, the tab strip+// gone (the Music list is the page), the flags the screen forces+// ArtistHeader.x the header: the photo full bleed dissolving into the field, and the Kit's+// SGRHeaderInfo over it -- the name, the listeners, shuffle, a white Play and Follow+// ArtistSections.x the sections the Music list carries that are not the artist's music: its videos+//+// 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 artist page `view` is on, or nil: the TemplateView with the identifier creator-page.+UIView *SGRArtistPageOf(UIView *view);++// ArtistField.x. The field belongs to the page `view` is on.+//+// The colour the page's field is showing, SGRNeutralField() before one has been read.+UIColor *SGRArtistFieldColor(UIView *view);+// The artist's photo, for the page's field to take its colour from. The same image again is a no-op.+void SGRArtistSetArtwork(UIView *view, UIImage *image);diff --git a/tweak/Sources/Redesigned/Artist/ArtistField.x b/tweak/Sources/Redesigned/Artist/ArtistField.xnew file mode 100644index 00000000..f40e77f4--- /dev/null+++ b/tweak/Sources/Redesigned/Artist/ArtistField.x@@ -0,0 +1,140 @@+// Artist redesign: the photo's field behind the whole page, and the tab strip gone.+//+// Tree (trees/clean/artist/01.txt:26-40). The page is a TemplateView holding two scroll views of the page's+// size -- PCFFTabLayoutViewController.overlayScrollView and .containerScrollView -- and the container's stack:+// the header, then PCFFTabLayoutViewController.tabsViewAccessibilityID, the strip of tabs+// (Components.UI.TabsSectionHeading, 44pt) over a paging scroll view with one list per tab. The field goes+// under all of it, as the page's bottom-most view, and what Spotify paints the page, its lists and its rows+// with -- the base surface -- is kept clear by the Kit's repaint hook while sgr_artistRoot is this page.+//+// The strip is Music, Video and Merch. The Music list is the page the Music app gives an artist: the videos+// and the merch have their own tabs only so that they can be left out, so the strip goes and the Music list+// stays. The strip sits in an AutoLayoutStackView, which traps when a view in it hides, so it goes invisible+// and the pages under it move up into its place and stop paging, the way the native look's switch does it+// (Native/Artist/Artist.x).+#import "Core/SGCore.h"+#import "Redesigned/Kit/SGRKit.h"+#import "Artist.h"++static NSString *const kPageIdentifier = @"creator-page";++// Above for the bounce at the top of the page, 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 *SGRArtistPageOf(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 *SGRArtistFieldColor(UIView *view) {+ SGRArtworkField *field = fieldOn(view);+ return field.fieldColor ?: SGRNeutralField();+}++void SGRArtistSetArtwork(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 artist: field on the page %.0fx%.0f", page.bounds.size.width, page.bounds.size.height);+ return field;+}++%hook _TtC32CreativeWorkPlatform_TemplateKit12TemplateView+- (void)layoutSubviews {+ %orig;+ UIView *page = (UIView *)self;+ if (![page.accessibilityIdentifier isEqualToString:kPageIdentifier] || page.bounds.size.height < 200) return;+ // The page the repaint hook keeps clear is the one laying out, which is the one on screen.+ sgr_artistRoot = 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++// Each tab's list paints itself the base surface from its own pass, and may have before the page first laid+// out and the repaint hook knew the page; 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, as the album's is.+%hook _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView+- (void)layoutSubviews {+ %orig;+ UIView *list = (UIView *)self;+ if (!SGRArtistPageOf(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++#pragma mark - the tab strip++static void hideStrip(UIView *strip) {+ if (strip.alpha != 0) strip.alpha = 0;+ if (strip.userInteractionEnabled) strip.userInteractionEnabled = NO;+ strip.accessibilityElementsHidden = YES;+ CGFloat lift = CGRectGetHeight(strip.bounds);+ for (UIView *v in strip.superview.subviews) {+ if (![v isKindOfClass:UIScrollView.class]) continue;+ UIScrollView *pages = (UIScrollView *)v;+ if (pages.scrollEnabled) pages.scrollEnabled = NO;+ CGAffineTransform move = CGAffineTransformMakeTranslation(0, -lift);+ if (!CGAffineTransformEqualToTransform(pages.transform, move)) pages.transform = move;+ }+ static BOOL logged;+ if (!logged) {+ logged = YES;+ SGLog(@"redesign artist: the tab strip gone, the Music list up %.0fpt into its place", lift);+ }+}++// The strip's buttons are the one class of it Spotify names, and they lay out whenever the strip does.+%hook _TtCOOOE16PodcastUI_ECMKitO19LegacyUI_ECMCoreKit10Components18TabsSectionHeading2UI7Private9TabButton+- (void)layoutSubviews {+ %orig;+ for (UIView *v = ((UIView *)self).superview; v; v = v.superview) {+ if (![v.accessibilityIdentifier isEqualToString:@"Components.UI.TabsSectionHeading"]) continue;+ if (SGRArtistPageOf(v)) hideStrip(v);+ return;+ }+}+%end++%ctor {+ // Registered whatever the switch says: the flag rows elsewhere lock to these while it is on.+ SGRedesignForceFlags(@"artist", @{+ // Spotify's own way of moving more up into the navigation bar, as the playlist and album pages do: the+ // row under the photo is shuffle, Play and Follow.+ @"ios-creator-impl.context_menu_in_navigation_bar_enabled_artist": @YES,+ });+ if (!SGRedesignedUI()) return;+ %init;+ SGRequireClasses(@[+ @"_TtC32CreativeWorkPlatform_TemplateKit12TemplateView",+ @"_TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView",+ @"_TtCOOOE16PodcastUI_ECMKitO19LegacyUI_ECMCoreKit10Components18TabsSectionHeading2UI7Private9TabButton",+ ]);+}diff --git a/tweak/Sources/Redesigned/Artist/ArtistHeader.x b/tweak/Sources/Redesigned/Artist/ArtistHeader.xnew file mode 100644index 00000000..1ce18dcc--- /dev/null+++ b/tweak/Sources/Redesigned/Artist/ArtistHeader.x@@ -0,0 +1,304 @@+// Artist redesign: the header the playlist and album pages have. The photo runs full bleed across the top+// of the page and dissolves into the page's colour; the name and the monthly listeners are centred on the+// bottom of that dissolve; and under them one row -- shuffle, a white Play capsule, and Follow.+//+// Tree (trees/clean/artist/01.txt:37-170). The header is TemplateKit's HeaderContainer, 568pt, the first view+// of the page's stack, holding an element view that holds the ImageHeaderView:+//+// UIView 402x424 clips the photo (Components.Header.UI.ArtworkImage) and a gradient+// UIView {16, 334} the name, Encore.AdaptiveTitle, 45pt+// ImageHeaderView.VerifiedBadge "Verified by Spotify"+// Components.Header.UI.Metadata "58,4M monthly listeners"+// UIStackView {4, 456} 394x48 explore, Follow (Curation.FollowButtonElementKit.FollowButton,+// a text button), more, Components.UI.ShuffleButton, and+// header-play-button+// UIStackView {0, 504} 402x64 Components.UI.ArtistHeadline, "Pre-save the upcoming album"+// HeaderForegroundView the 100pt navigation bar with the name, shown collapsed+//+// Scrolled (02.txt:26-30), the container keeps its 568pt and scrolls away with the page, while the element+// view slides down inside it and the ImageHeaderView shrinks to the 100pt bar, pinned at the top of the+// screen. So the photo and the redesign's text are the container's, not the ImageHeaderView's: in the header+// view they would be pinned at the top with it. The bar stays Spotify's, drawing the name once the page is+// scrolled, with its gradient masked out as the album's is.+//+// Everything else of the ImageHeaderView is drawn by nothing (an empty mask) and takes no touches: the badge,+// Explore, and the headline go with it -- the headline's pre-save is also the list's own Release Countdown+// section. The Kit's SGRHeaderInfo reads the name and the listeners off Spotify's concealed labels and draws+// and fires Spotify's shuffle, play and Follow, whose word ("Follow", "Following") is its state in the app's+// language. More is moved up into the navigation bar by a flag (ArtistField.x).+#import "Core/SGCore.h"+#import "Redesigned/Kit/SGRKit.h"+#import "Artist.h"++// How much of the photo'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 and the album's.+static const CGFloat kDissolve = 0.46, kTopScrim = 140, kTopScrimAlpha = 0.28;+// A photo view narrower than this is a placeholder glyph, and a picture shorter than this one mid load.+static const CGFloat kMinCover = 80, kMinHero = 120;+// The collapsed ImageHeaderView, Spotify's navigation bar; the text fades out over the last kFade before it.+static const CGFloat kBar = 100, kFade = 150;++static char kInfoKey, kHeroKey, kHeroHeightKey, kContainerHeightKey, kCoverWatchedKey, kRowWatchedKey;+static char kTitleKey, kMetaKey, kShuffleKey, kPlayKey, kFollowKey, kArtworkKey, kBarKey;++#pragma mark - Spotify's views++// Drawn by nothing and out of the way of touches, whatever Spotify does to it: an empty mask. Not hidden --+// the header's OverflowStackView traps when a view in it hides, and a hidden view is one the redesign still+// has to read and fire.+static void blank(UIView *view) {+ if (!view) return;+ if (!view.layer.mask) view.layer.mask = [CALayer layer];+ if (view.userInteractionEnabled) view.userInteractionEnabled = NO;+ view.accessibilityElementsHidden = YES;+}++static void setFrame(UIView *view, CGRect frame) {+ if (view && !CGRectIsEmpty(frame) && !CGRectEqualToRect(view.frame, frame)) view.frame = frame;+}++static NSString *trimmed(NSString *text) {+ NSString *clean = [text stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];+ return clean.length ? clean : nil;+}++static NSString *firstText(UIView *root) {+ __block NSString *found = nil;+ SGForEachView(root, ^(UIView *v) {+ if (found || ![v isKindOfClass:UILabel.class]) return;+ found = trimmed(((UILabel *)v).text);+ });+ return found;+}++// The TemplateKit container the header sits in, which scrolls with the page.+static UIView *containerOf(UIView *header) {+ for (UIView *v = header.superview; v; v = v.superview) {+ if ([NSStringFromClass(v.class) containsString:@"HeaderContainer"]) return v;+ }+ return nil;+}++#pragma mark - the photo, full bleed++// The picture across the top of the page with the field showing through the bottom of it: a scrim over the+// top for the status bar, and under it a fade to the very colour the page's field is drawing.+@interface SGRArtistHero : UIView+@property (nonatomic, readonly) UIImageView *picture;+@property (nonatomic, copy) UIColor *fieldColor;+@end++@implementation SGRArtistHero {+ 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 = SGRArtistFieldColor(self);+}++- (void)setFieldColor:(UIColor *)color {+ if (!color || [_fieldColor isEqual:color]) return;+ _fieldColor = [color copy];+ // The clear end is the same colour with no alpha, 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 photo Spotify loaded, read from the image view of its artwork.+static UIImageView *photoIn(UIView *artwork) {+ __block UIImageView *found = nil;+ SGForEachView(artwork, ^(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 showPhoto(SGRArtistHero *hero, UIImageView *view, UIView *container) {+ UIImage *image = view.image;+ if (!image || view.bounds.size.width < kMinCover) return;+ if (hero.picture.image != image) hero.picture.image = image;+ SGRArtistSetArtwork(container, image);+}++// The picture from the top of the container down to `bottom`, which comes from the container at rest and only+// ever grows, so it does not change size while the page loads or scrolls.+static void applyHero(UIView *container, UIView *artwork, CGFloat bottom) {+ SGRArtistHero *hero = objc_getAssociatedObject(container, &kHeroKey);+ if (!hero) {+ hero = [[SGRArtistHero alloc] initWithFrame:CGRectZero];+ objc_setAssociatedObject(container, &kHeroKey, hero, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ if (hero.superview != container) [container insertSubview:hero atIndex:0];+ else if (container.subviews.firstObject != hero) [container sendSubviewToBack:hero];++ CGFloat height = [objc_getAssociatedObject(hero, &kHeroHeightKey) doubleValue];+ if (bottom > height + 0.5) {+ height = round(bottom);+ objc_setAssociatedObject(hero, &kHeroHeightKey, @(height), OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ SGLog(@"redesign artist: hero %.0fpt across the top of the page", height);+ }+ if (height < kMinHero) return;+ setFrame(hero, CGRectMake(0, 0, container.bounds.size.width, height));+ hero.fieldColor = SGRArtistFieldColor(container);++ UIImageView *source = photoIn(artwork);+ showPhoto(hero, source, container);+ // The photo 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 SGRArtistHero *weakHero = hero;+ __weak UIView *weakContainer = container;+ SGRObserveImage(source, ^(UIImageView *view) {+ if (weakHero && weakContainer) showPhoto(weakHero, view, weakContainer);+ });+ }+}++#pragma mark - the header's pass++static void applyHeader(UIView *header);++// Spotify's navigation bar, the one part of the header kept: collapsed, it is where the name is. Its gradient+// is a flat dark band over the field, as the album's was (Album/AlbumHeader.x); the soft top edge every+// redesigned page has keeps the name legible instead.+static UIView *keepBar(UIView *header) {+ UIView *foreground = nil;+ for (UIView *sub in header.subviews) {+ if ([NSStringFromClass(sub.class) containsString:@"HeaderForegroundView"]) foreground = sub;+ }+ if (foreground && !objc_getAssociatedObject(header, &kBarKey)) {+ SGForEachView(foreground, ^(UIView *v) {+ if ([NSStringFromClass(v.class) containsString:@"GradientView"] && !v.layer.mask) v.layer.mask = [CALayer layer];+ });+ objc_setAssociatedObject(header, &kBarKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ return foreground;+}++static void applyHeader(UIView *header) {+ UIView *container = containerOf(header);+ UIView *artwork = SGRFindByIdentifier(header, @"Components.Header.UI.ArtworkImage", &kArtworkKey);+ if (!container || !artwork || !SGRArtistPageOf(container)) return;++ UIView *bar = keepBar(header);+ for (UIView *sub in header.subviews) {+ if (sub != bar) blank(sub);+ }++ SGRHeaderInfo *info = objc_getAssociatedObject(container, &kInfoKey);+ if (!info) {+ info = [[SGRHeaderInfo alloc] initWithFrame:CGRectZero];+ info.trailingShowsWord = YES;+ objc_setAssociatedObject(container, &kInfoKey, info, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ if (info.superview != container) [container addSubview:info];+ else if (container.subviews.lastObject != info) [container bringSubviewToFront:info];+ setFrame(info, container.bounds);++ UIView *title = SGRFindByIdentifier(header, @"Encore.AdaptiveTitle", &kTitleKey);+ UIView *listeners = SGRFindByIdentifier(header, @"Components.Header.UI.Metadata", &kMetaKey);+ NSString *name = firstText(title) ?: firstText(bar);+ [info showTitle:name creator:nil length:firstText(listeners) about:nil];++ UIView *shuffle = SGRFindByIdentifier(header, @"Components.UI.ShuffleButton", &kShuffleKey);+ UIView *play = SGRFindByIdentifier(header, @"header-play-button", &kPlayKey);+ UIView *follow = SGRFindByIdentifier(header, @"Curation.FollowButtonElementKit.FollowButton", &kFollowKey);+ [info showShuffle:shuffle play:play trailing:follow trailingFallback:[UIImage systemImageNamed:@"person.badge.plus"]+ playColor:SGRArtistFieldColor(container)];++ // Collapsing, the text would pass over Spotify's bar with the name in it: it goes over the last kFade of+ // the collapse, from the header's own height, which this pass runs on every step of.+ CGFloat alpha = MAX(0, MIN(1, (header.bounds.size.height - kBar) / kFade));+ if (fabs(info.alpha - alpha) > 0.01) info.alpha = alpha;++ // The picture reaches to where the content's top is at rest, plus the name. The container keeps its+ // height as the header collapses, and only ever grows as the page loads.+ CGFloat rest = MAX([objc_getAssociatedObject(container, &kContainerHeightKey) doubleValue], container.bounds.size.height);+ objc_setAssociatedObject(container, &kContainerHeightKey, @(rest), OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ CGFloat bottom = rest - SGRHeaderInfoBottom - [info contentHeightForWidth:container.bounds.size.width] + SGRHeaderInfoTitleRise;+ applyHero(container, artwork, bottom);++ // The buttons arrive after the header has laid out, in a row that keeps its size and so lays nothing out+ // again (Native/Artist/Artist.x): the row's own pass is watched, a plain UIStackView.+ UIView *row = shuffle ?: play ?: follow;+ while (row && row.superview != header) row = row.superview;+ if (row && [row class] == UIStackView.class && !objc_getAssociatedObject(row, &kRowWatchedKey)) {+ objc_setAssociatedObject(row, &kRowWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ __weak UIView *weakHeader = header;+ SGRObserveLayout(row, ^(UIView *view) {+ if (weakHeader) applyHeader(weakHeader);+ });+ }++ static BOOL logged;+ if (!logged && header.window && name) {+ logged = YES;+ SGLog(@"redesign artist: own block \"%@\", \"%@\"; shuffle %@, play %@, follow %@", name,+ firstText(listeners) ?: @"no listeners", shuffle ? @"found" : @"missing", play ? @"found" : @"missing",+ follow ? firstText(follow) ?: @"found" : @"missing");+ }+}++%hook _TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView+- (void)layoutSubviews {+ %orig;+ applyHeader((UIView *)self);+}+%end++%ctor {+ if (!SGRedesignedUI()) return;+ %init;+ SGRequireClasses(@[@"_TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView"]);+}diff --git a/tweak/Sources/Redesigned/Artist/ArtistSections.x b/tweak/Sources/Redesigned/Artist/ArtistSections.xnew file mode 100644index 00000000..56193225--- /dev/null+++ b/tweak/Sources/Redesigned/Artist/ArtistSections.x@@ -0,0 +1,179 @@+// Artist redesign: the Music list without the artist's videos.+//+// Tree (trees/clean/artist/05.txt, the Music list top to bottom): Popular, Artist pick, Popular releases and+// its Show all, Featuring, Release Countdown, Music videos, Watch more from…, About, Artist playlists, Fans+// also like, Appears on. Every section is three Element_List cells in a row -- a 16pt spacer, a heading+// (Components.UI.SectionHeadingHome) and what the section holds -- and every kind of content carries an+// identifier of its own, in any language: Components.UI.RetrievalRowElementUI (tracks), PinnedItemUI (the+// pick), HomeCard (a carousel), UpcomingReleaseRow, CreatorBiographyCard (About),+// Components.UI.MusicVideoShelfHeader and WatchFeedCarouselEntryPointElement (videos).+//+// So the rule is by kind, never by the heading's words, which are the app's language: a video shelf reports+// no height, and so do the heading and the spacer in the two cells before it. They were sized before it, so+// the list is asked to lay out again once they are known. Every carousel is the same kind whatever it holds,+// so the carousels all stay; merch has a tab of its own, which ArtistField.x takes away.+//+// A dropped cell is 0 tall but what it holds keeps the height it measured at, hidden and cut off by the+// cell: content squeezed to 0 breaks Spotify's required constraints on every pass (Album/AlbumSections.x).+#import "Core/SGCore.h"+#import "Redesigned/Kit/SGRKit.h"+#import "Artist.h"++static char kSettledKey, kKindsKey, kDroppedKey;++typedef NS_ENUM(NSInteger, SGRArtistCell) {+ SGRArtistCellOther,+ SGRArtistCellSpacer,+ SGRArtistCellHeading,+ SGRArtistCellVideos,+};++static SGRArtistCell kindOf(UIView *content, CGFloat height) {+ __block SGRArtistCell kind = SGRArtistCellOther;+ SGForEachView(content, ^(UIView *v) {+ NSString *identifier = v.accessibilityIdentifier;+ if (kind != SGRArtistCellOther || !identifier.length) return;+ if ([identifier isEqualToString:@"Components.UI.MusicVideoShelfHeader"] ||+ [identifier isEqualToString:@"Music-Videos.Video-Card-Carousel"] ||+ [identifier isEqualToString:@"WatchFeedCarouselEntryPointElement"]) kind = SGRArtistCellVideos;+ else if ([identifier isEqualToString:@"Components.UI.SectionHeadingHome"]) kind = SGRArtistCellHeading;+ });+ if (kind == SGRArtistCellOther && height <= 16.5 && content.subviews.count <= 1) {+ __block BOOL empty = YES;+ SGForEachView(content, ^(UIView *v) { if (v.accessibilityIdentifier.length) empty = NO; });+ if (empty) kind = SGRArtistCellSpacer;+ }+ return kind;+}++static NSMutableDictionary<NSIndexPath *, NSNumber *> *kindsOf(UICollectionView *list) {+ NSMutableDictionary *kinds = objc_getAssociatedObject(list, &kKindsKey);+ if (!kinds) {+ kinds = [NSMutableDictionary dictionary];+ objc_setAssociatedObject(list, &kKindsKey, kinds, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ return kinds;+}++static NSMutableSet<NSIndexPath *> *droppedOf(UICollectionView *list) {+ NSMutableSet *dropped = objc_getAssociatedObject(list, &kDroppedKey);+ if (!dropped) {+ dropped = [NSMutableSet set];+ objc_setAssociatedObject(list, &kDroppedKey, dropped, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ return dropped;+}++static UICollectionView *listOf(UIView *cell) {+ for (UIView *v = cell.superview; v; v = v.superview) {+ if ([v isKindOfClass:UICollectionView.class]) return (UICollectionView *)v;+ }+ return nil;+}++static void settle(UICollectionViewCell *cell, CGFloat natural) {+ UIView *content = cell.contentView;+ objc_setAssociatedObject(cell, &kSettledKey, @(natural), OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ if (content.autoresizingMask & UIViewAutoresizingFlexibleHeight) content.autoresizingMask &= ~UIViewAutoresizingFlexibleHeight;+ CGRect frame = CGRectMake(0, 0, cell.bounds.size.width, natural);+ if (!CGRectEqualToRect(content.frame, frame)) content.frame = frame;+ if (!content.hidden) content.hidden = YES;+ if (!cell.clipsToBounds) cell.clipsToBounds = YES;+ cell.accessibilityElementsHidden = YES;+}++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;+}++// The cell `back` items before `path` in the list, across the end of a section if it has to.+static NSIndexPath *before(UICollectionView *list, NSIndexPath *path, NSInteger back) {+ NSInteger section = path.section, item = path.item - back;+ while (item < 0 && section > 0) {+ section--;+ item += [list numberOfItemsInSection:section];+ }+ return item >= 0 ? [NSIndexPath indexPathForItem:item inSection:section] : nil;+}++// A video shelf takes its heading and the spacer over it with it. Those were sized before it, so the list lays+// out again, once, to ask them again.+static void dropHeadingOf(UICollectionView *list, NSIndexPath *path) {+ NSMutableDictionary *kinds = kindsOf(list);+ NSMutableSet *dropped = droppedOf(list);+ BOOL added = NO;+ NSIndexPath *heading = before(list, path, 1);+ if (heading && [kinds[heading] integerValue] == SGRArtistCellHeading && ![dropped containsObject:heading]) {+ [dropped addObject:heading];+ added = YES;+ NSIndexPath *spacer = before(list, path, 2);+ if (spacer && [kinds[spacer] integerValue] == SGRArtistCellSpacer) [dropped addObject:spacer];+ }+ if (!added) return;+ __weak UICollectionView *weakList = list;+ dispatch_async(dispatch_get_main_queue(), ^{ [weakList.collectionViewLayout invalidateLayout]; });+}++static void logOnce(NSString *what) {+ static NSMutableSet<NSString *> *logged;+ if (!logged) logged = [NSMutableSet set];+ if ([logged containsObject:what]) return;+ [logged addObject:what];+ SGLog(@"redesign artist: %@", what);+}++%hook _TtC12Element_List18CollectionViewCell+- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)attributes {+ UICollectionViewCell *cell = (UICollectionViewCell *)self;+ UICollectionView *list = listOf(cell);+ // Only the page's own list: a card inside a carousel is a cell of the same class, and its row decides.+ BOOL page = list && ![listOf(list) isKindOfClass:UICollectionView.class] && SGRArtistPageOf(cell) && attributes.indexPath;+ if (!page) {+ if (objc_getAssociatedObject(cell, &kSettledKey)) unsettle(cell);+ return %orig;+ }+ UICollectionViewLayoutAttributes *result = %orig;+ NSIndexPath *path = attributes.indexPath;+ UIView *content = cell.contentView.subviews.firstObject ?: cell.contentView;+ SGRArtistCell kind = kindOf(content, result.size.height);+ kindsOf(list)[path] = @(kind);++ BOOL drop = kind == SGRArtistCellVideos || [droppedOf(list) containsObject:path];+ if (kind == SGRArtistCellVideos) {+ [droppedOf(list) addObject:path];+ dropHeadingOf(list, path);+ }+ if (!drop) {+ if (objc_getAssociatedObject(cell, &kSettledKey)) unsettle(cell);+ return result;+ }+ settle(cell, MAX(1, result.size.height));+ result.size = CGSizeMake(result.size.width, 0);+ logOnce(@"the videos dropped from the Music list");+ return result;+}++// The cell's own passes size the content to the cell again.+- (void)layoutSubviews {+ %orig;+ NSNumber *settled = objc_getAssociatedObject(self, &kSettledKey);+ if (settled) settle((UICollectionViewCell *)self, settled.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.hindex 5e59fe8d..4196051a 100644--- a/tweak/Sources/Redesigned/Kit/SGRActionRow.h+++ b/tweak/Sources/Redesigned/Kit/SGRActionRow.h@@ -34,6 +34,12 @@@property (nonatomic, weak, readonly) UIView *source;// Drawn, in white, when Spotify's button has no image view to copy (a glyph it draws itself).@property (nonatomic, strong) UIImage *fallbackGlyph;+// The word on Spotify's button instead of a glyph, in a glass capsule as wide as the word asks for: for a+// text button such as the artist's Follow, whose word is its state ("Follow", "Following") in the app's+// language. Set before the first -feedFrom:.+@property (nonatomic) BOOL showsWord;+// The width the button wants: SGRActionHeight for a glyph, the word and its padding for a word.+- (CGFloat)sgr_width;// 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;diff --git a/tweak/Sources/Redesigned/Kit/SGRActionRow.m b/tweak/Sources/Redesigned/Kit/SGRActionRow.mindex a2c62c4a..71c78164 100644--- a/tweak/Sources/Redesigned/Kit/SGRActionRow.m+++ b/tweak/Sources/Redesigned/Kit/SGRActionRow.m@@ -17,7 +17,10 @@ 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;+static char kCapsuleGlassKey, kMirrorGlassKey, kWordGlassKey, kGlyphWatchedKey;++// A word button's padding either side of the word.+static const CGFloat kWordPadding = 18;#pragma mark - firing Spotify's button@@ -169,8 +172,20 @@ static NSString *wordIn(UIView *button) {#pragma mark - a button standing in for Spotify's+// The text a button shows: the first label under it with something in it.+static NSString *labelTextIn(UIView *button) {+ __block NSString *text = nil;+ SGForEachView(button, ^(UIView *v) {+ if (text || ![v isKindOfClass:UILabel.class]) return;+ NSString *candidate = [((UILabel *)v).text stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];+ if (candidate.length) text = candidate;+ });+ return text;+}+@implementation SGRMirrorButton {UIImageView *_glyph;+ UILabel *_word;}- (instancetype)initWithFrame:(CGRect)frame {@@ -188,9 +203,23 @@ static NSString *wordIn(UIView *button) {return self;}+- (CGFloat)sgr_width {+ if (!self.showsWord || !_word.text.length) return SGRActionHeight;+ [_word sizeToFit];+ return MAX(SGRActionHeight, ceil(_word.bounds.size.width) + 2 * kWordPadding);+}+- (void)layoutSubviews {[super layoutSubviews];CGRect bounds = self.bounds;+ if (self.showsWord && _word.text.length) {+ SGRGlassCapsuleInside(self, &kWordGlassKey, bounds.size, NO);+ [_word sizeToFit];+ CGSize text = _word.bounds.size;+ _word.frame = CGRectMake(kWordPadding, round((bounds.size.height - text.height) / 2),+ MAX(0, bounds.size.width - 2 * kWordPadding), text.height);+ return;+ }SGRGlassInside(self, &kMirrorGlassKey, SGRGlassCircleSize);_glyph.frame = CGRectMake(round((bounds.size.width - kMirrorGlyph) / 2), round((bounds.size.height - kMirrorGlyph) / 2),kMirrorGlyph, kMirrorGlyph);@@ -202,6 +231,26 @@ static NSString *wordIn(UIView *button) {if (!source) return;_source = source;+ if (self.showsWord) {+ if (!_word) {+ _word = [UILabel new];+ _word.userInteractionEnabled = NO;+ _word.textAlignment = NSTextAlignmentCenter;+ _word.font = SGRFont(UIFontTextStyleSubheadline, UIFontWeightSemibold, UIContentSizeCategoryExtraLarge);+ _word.textColor = SGRPrimary();+ [self addSubview:_word];+ _glyph.hidden = YES;+ }+ NSString *text = labelTextIn(source);+ if (text && ![_word.text isEqualToString:text]) {+ _word.text = text;+ self.accessibilityLabel = source.accessibilityLabel ?: text;+ [self setNeedsLayout];+ [self.superview setNeedsLayout];+ }+ return;+ }+UIImageView *glyph = glyphIn(source, 0);NSString *word = source.accessibilityLabel ?: wordIn(source);if (word && ![self.accessibilityLabel isEqualToString:word]) self.accessibilityLabel = word;@@ -232,6 +281,15 @@ static NSString *wordIn(UIView *button) {- (void)sgr_tap {fire(self.source);+ // A word is the button's state, and Spotify changes it without laying out anything the page hears.+ if (!self.showsWord) return;+ __weak SGRMirrorButton *weakSelf = self;+ for (NSNumber *delay in @[@0.3, @1.0]) {+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay.doubleValue * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ SGRMirrorButton *button = weakSelf;+ if (button.source) [button feedFrom:button.source];+ });+ }}@enddiff --git a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.hindex 7f2c77f2..984d24de 100644--- a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h+++ b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.h@@ -22,6 +22,8 @@ extern const CGFloat SGRHeaderInfoTitleRise; // 56, of the content over the pic@interface SGRHeaderInfo : UIView// YES when anything shown changed. nil or empty hides that line.- (BOOL)showTitle:(NSString *)title creator:(NSString *)creator length:(NSString *)length about:(NSString *)about;+// Spotify's own trailing control is a text button (the artist's Follow): drawn as its word in a capsule.+@property (nonatomic) BOOL trailingShowsWord;// Spotify's controls, each drawn from and fired; nil hides that button. Play stays in the middle of the// page whether the other two are there or not. `trailingFallback` is drawn when Spotify's trailing control// has no image to copy. `playColor` is the colour of the capsule's glyph and word.diff --git a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.mindex 21b9422c..e29faecc 100644--- a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m+++ b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m@@ -79,6 +79,7 @@ static BOOL setText(UILabel *label, NSString *text) {- (void)showShuffle:(UIView *)shuffle play:(UIView *)play trailing:(UIView *)trailingtrailingFallback:(UIImage *)trailingFallback playColor:(UIColor *)playColor {_trailing.fallbackGlyph = trailingFallback;+ _trailing.showsWord = self.trailingShowsWord;if (shuffle) [_shuffle feedFrom:shuffle];if (play) {if (playColor) _play.contentColor = playColor;@@ -137,7 +138,9 @@ static BOOL setText(UILabel *label, NSString *text) {CGRect play = CGRectMake(round((width - playWidth) / 2), y, playWidth, side);_play.frame = play;_shuffle.frame = CGRectMake(CGRectGetMinX(play) - kRowSpacing - side, y, side, side);- _trailing.frame = CGRectMake(CGRectGetMaxX(play) + kRowSpacing, y, side, side);+ // A word button is as wide as its word, up to what is left of the page after Play.+ CGFloat trailing = MIN([_trailing sgr_width], MAX(side, width - CGRectGetMaxX(play) - kRowSpacing - kSide));+ _trailing.frame = CGRectMake(CGRectGetMaxX(play) + kRowSpacing, y, trailing, side);y += side;if (!_about.hidden) {diff --git a/tweak/Sources/Redesigned/Kit/SGRRepaint.h b/tweak/Sources/Redesigned/Kit/SGRRepaint.hindex 46e3087c..d3eaf3f9 100644--- a/tweak/Sources/Redesigned/Kit/SGRRepaint.h+++ b/tweak/Sources/Redesigned/Kit/SGRRepaint.h@@ -11,3 +11,5 @@ extern __weak UIView *sgr_lyricsPageRoot; // Redesigned/Lyrics/LyricsPage.xextern __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;+// Redesigned/Artist/ArtistField.x, the artist page, kept clear the same way and for the same reason.+extern __weak UIView *sgr_artistRoot;diff --git a/tweak/Sources/Redesigned/Kit/SGRRepaint.x b/tweak/Sources/Redesigned/Kit/SGRRepaint.xindex eba8b632..821fef10 100644--- a/tweak/Sources/Redesigned/Kit/SGRRepaint.x+++ b/tweak/Sources/Redesigned/Kit/SGRRepaint.x@@ -8,10 +8,11 @@ __weak UIView *sgr_nowPlayingCard = nil;__weak UIView *sgr_lyricsPageRoot = nil;__weak UIView *sgr_playlistRoot = nil;__weak UIView *sgr_albumRoot = nil;+__weak UIView *sgr_artistRoot = nil;%hook CALayer- (void)setBackgroundColor:(CGColorRef)color {- if (color && (sgr_nowPlayingRoot || sgr_lyricsPageRoot || sgr_playlistRoot || sgr_albumRoot)) {+ if (color && (sgr_nowPlayingRoot || sgr_lyricsPageRoot || sgr_playlistRoot || sgr_albumRoot || sgr_artistRoot)) {UIView *view = (UIView *)self.delegate;if ([view isKindOfClass:UIView.class] && view.layer == self && !SGKeepsColor(view)) {if (SGIsInside(view, sgr_nowPlayingRoot)) {@@ -23,7 +24,7 @@ __weak UIView *sgr_albumRoot = nil;color = NULL;} else if (SGIsInside(view, sgr_lyricsPageRoot)) {color = NULL;- } else if (SGIsBaseSurface(color) && (SGIsInside(view, sgr_playlistRoot) || SGIsInside(view, sgr_albumRoot))) {+ } else if (SGIsBaseSurface(color) && (SGIsInside(view, sgr_playlistRoot) || SGIsInside(view, sgr_albumRoot) || SGIsInside(view, sgr_artistRoot))) {color = NULL;}}