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 songs liked by one artist get the redesigned playlist page
Andrew0a435c2970fb
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex 6ddec43d..02ada4db 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -613,6 +613,12 @@ Redesigned:and the curation pills gone, and the track rows on the field with a hairline between them(Playlist.h lists its files). Sort and Mix, the two of those pills the ⋯ menu does not already offer,are put on that menu's own sheet instead, above Spotify's rows, and fire Spotify's own buttons.+ The page of the songs the user liked by one artist (CollectionArtist) is Liked Songs' header kit+ with no cover and goes through the same files: the neutral field, the wash and the bar's scrim+ gone, the one row of shuffle, Play and download, and its rows as the playlist's are. Its pinned ⋯+ opens the system menu, as every other redesigned page's does. Its download button is the plain one, not the Granular one, so its state is read from its+ owner's `currentStatus`, whose cases are its own (none, waiting, downloading, downloaded); it keeps no+ progress while it downloads, so the ring turns (Kit/SGRDownload.m).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 theplaylist's, so it shares nothing with Playlist/ but the Kit: the cover full bleed dissolving into thediff --git a/tweak/Sources/Redesigned/ContextMenu/ContextMenu.x b/tweak/Sources/Redesigned/ContextMenu/ContextMenu.xindex 513f0df0..c69334f0 100644--- a/tweak/Sources/Redesigned/ContextMenu/ContextMenu.x+++ b/tweak/Sources/Redesigned/ContextMenu/ContextMenu.x@@ -654,7 +654,26 @@ static void raiseHost(UIWindow *window) {SGLog(@"system menu: Spotify's rows asked for before the sheet has them");[session->_whenRead addObject:^{SGRMenuSession *read = weakSelf;- completion(read ? (read->_groups ? [read rowElements] : [read unavailable]) : @[]);+ NSArray<UIMenuElement *> *elements = read ? (read->_groups ? [read rowElements] : [read unavailable]) : @[];+ completion(elements);+ // UIKit can leave its loading row up although the rows were handed to it: the menu it shows is built+ // again after this one, and its deferred element is never asked (the songs liked by one artist, device+ // 2026-10-23). The visible menu is then given the rows in place of it, tried as the menu comes on screen.+ for (NSNumber *after in @[@0.15, @0.45, @0.9]) {+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(after.doubleValue * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ SGRMenuSession *later = weakSelf;+ if (!later || later.ended) return;+ [later.anchor.contextMenuInteraction updateVisibleMenuWithBlock:^UIMenu *(UIMenu *visible) {+ NSUInteger at = [visible.children indexOfObjectPassingTest:^BOOL(UIMenuElement *child, NSUInteger index, BOOL *stop) {+ return [child isKindOfClass:UIDeferredMenuElement.class];+ }];+ if (at == NSNotFound) return visible;+ NSMutableArray<UIMenuElement *> *children = [visible.children mutableCopy];+ [children replaceObjectsInRange:NSMakeRange(at, 1) withObjectsFromArray:elements];+ return [visible menuByReplacingChildren:children];+ }];+ });+ }}];}];}@@ -850,6 +869,10 @@ static NSString *storedKey(NSString *kind) {(unsigned long)(header.count + footer.count), (now - started) * 1000, now - from, self.touchedAt ? @"⋯ touch" : @"takeover");if (self.items) [self matchQuick];if (self.direct) [self storeRows];+ // A page's menu: its anchor's menu becomes the rows themselves. UIKit builds the menu it shows again from the+ // anchor's (the one asked for while the sheet came up is never on screen), so the menu comes up whole instead of+ // from its loading row, growing down as the rows come (device, 2026-10-23).+ if (!self.items && self.anchor && !self.ended) self.anchor.menu = [UIMenu menuWithChildren:[self rowElements]];NSArray<dispatch_block_t> *waiting = _whenRead;_whenRead = [NSMutableArray array];diff --git a/tweak/Sources/Redesigned/Kit/SGRDownload.m b/tweak/Sources/Redesigned/Kit/SGRDownload.mindex 9d2b75a8..72d85b67 100644--- a/tweak/Sources/Redesigned/Kit/SGRDownload.m+++ b/tweak/Sources/Redesigned/Kit/SGRDownload.m@@ -7,6 +7,8 @@#pragma mark - reading Spotify's buttonstatic NSString *const kIdentifierPrefix = @"DownloadButton.Granular.";+// The plain button the songs liked by one artist have, whose identifier says nothing of the state.+static NSString *const kPlainIdentifier = @"Components.UI.DownloadButton";static UIView *identifiedIn(UIView *source, NSString *prefix) {__block UIView *found = nil;@@ -49,23 +51,40 @@ static BOOL stateFromIdentifier(NSString *identifier, SGRDownloadState *state) {}BOOL SGRReadDownload(UIView *source, SGRDownloadState *state, CGFloat *progress) {- UIView *button = source ? identifiedIn(source, kIdentifierPrefix) : nil;+ // Either button in one walk, since every mirror button of a row asks (shuffle, Play, Add, ⋯). The plain one's+ // owner keeps its state in `currentStatus`, with cases of its own (none, waiting, downloading, downloaded;+ // device log on a Premium account, 2026-10-15). It keeps no progress while it downloads, so the ring turns, as+ // it does while waiting. A value outside the cases leaves the arrow.+ __block UIView *button = nil;+ __block BOOL plain = NO;+ if (source) SGForEachView(source, ^(UIView *v) {+ if (button) return;+ NSString *identifier = v.accessibilityIdentifier;+ if ([identifier hasPrefix:kIdentifierPrefix]) button = v;+ else if ([identifier hasPrefix:kPlainIdentifier]) {+ button = v;+ plain = YES;+ }+ });if (!button) return NO;SGRDownloadState said = SGRDownloadNone;- BOOL named = stateFromIdentifier(button.accessibilityIdentifier, &said);+ BOOL named = !plain && stateFromIdentifier(button.accessibilityIdentifier, &said);// What the button draws from. Its state is a Swift enum without payloads, one byte, its cases numbered// in the order they are declared; its progress an optional 8 byte number, the value then a byte that is// 1 when there is none. The identifier says the same state in words, and is what counts when the model// cannot be read.- id owner = ownerOf(button, @"GranularDownloadButton");- const uint8_t *current = propertyBytes(owner, "currentState", 1);- const uint8_t *stored = propertyBytes(owner, "progress", 9);- BOOL modelled = current && *current <= 5;+ id owner = ownerOf(button, plain ? @"DownloadButton" : @"GranularDownloadButton");+ const uint8_t *current = propertyBytes(owner, plain ? "currentStatus" : "currentState", 1);+ const uint8_t *stored = plain ? NULL : propertyBytes(owner, "progress", 9);+ BOOL modelled = current && *current <= (plain ? 3 : 5);static const SGRDownloadState fromModel[] = {SGRDownloadNone, SGRDownloadWaiting, SGRDownloadDownloading, SGRDownloadWaiting, SGRDownloadDownloaded, SGRDownloadError,};- SGRDownloadState modelState = modelled ? fromModel[*current] : SGRDownloadNone;+ static const SGRDownloadState fromPlainModel[] = {+ SGRDownloadNone, SGRDownloadWaiting, SGRDownloadDownloading, SGRDownloadDownloaded,+ };+ SGRDownloadState modelState = modelled ? (plain ? fromPlainModel : fromModel)[*current] : SGRDownloadNone;SGRDownloadState result = modelled ? modelState : said;if (!modelled && !named) return NO;diff --git a/tweak/Sources/Redesigned/Playlist/Playlist.h b/tweak/Sources/Redesigned/Playlist/Playlist.hindex 85c90d07..ac44454e 100644--- a/tweak/Sources/Redesigned/Playlist/Playlist.h+++ b/tweak/Sources/Redesigned/Playlist/Playlist.h@@ -2,7 +2,8 @@// laid out the way the Music app lays a playlist out. Liked Songs and a playlist of the user's own are the// same page (trees/clean/liked-songs/01.txt, own-playlist/01.txt: one FTPViewController, one// SPTFreeTierPlaylistEncoreHeaderViewController), so one redesign covers all three. Album and artist pages-// are built by another framework and are left alone.+// are built by another framework and are left alone. The page of the songs the user liked by one artist+// (CollectionArtist_ArtistImpl) is the same header kit with no cover, like Liked Songs, and is given the same files.//// PlaylistField.x the artwork field behind the whole page, the artwork it is read from, the flags// the screen forcesdiff --git a/tweak/Sources/Redesigned/Playlist/PlaylistField.x b/tweak/Sources/Redesigned/Playlist/PlaylistField.xindex 610b4e5e..28e4dc00 100644--- a/tweak/Sources/Redesigned/Playlist/PlaylistField.x+++ b/tweak/Sources/Redesigned/Playlist/PlaylistField.x@@ -60,18 +60,25 @@ static SGRArtworkField *fieldIn(UIView *page) {return field;}-%hook _TtC35ListUXPlatform_FreeTierPlaylistImpl17FTPViewController-- (void)viewDidLayoutSubviews {- %orig;- UIView *page = ((UIViewController *)self).viewIfLoaded;- if (!page || page.bounds.size.height < 200) return;+// The field goes under the page as its bottom-most view and the repaint hook keeps what Spotify paints over it+// clear. The same for the playlist page and for the page of the songs the user liked by one artist, which is+// Liked Songs' header kit with no cover: its field stays the neutral one.+static SGRArtworkField *putFieldUnder(UIView *page) {sgr_playlistRoot = page;SGRArtworkField *field = fieldIn(page);if (field.superview != page) [page insertSubview:field atIndex:0];else if (page.subviews.firstObject != field) [page sendSubviewToBack:field];if (!CGRectEqualToRect(field.frame, page.bounds)) field.frame = page.bounds;+ return field;+}++%hook _TtC35ListUXPlatform_FreeTierPlaylistImpl17FTPViewController+- (void)viewDidLayoutSubviews {+ %orig;+ UIView *page = ((UIViewController *)self).viewIfLoaded;+ if (!page || page.bounds.size.height < 200) return;// The page comes in whole once its cover has been read (Kit/SGRField.h).- [field holdPage:page];+ [putFieldUnder(page) holdPage:page];}// The page the repaint hook keeps clear is the one on screen; another playlist pushed over this one sets@@ -83,6 +90,22 @@ static SGRArtworkField *fieldIn(UIView *page) {}%end+// The songs liked by one artist (CollectionArtistView: the list, then the 207pt header over it, as here).+// No cover to wait for, so the page is not held.+%hook _TtC27CollectionArtist_ArtistImpl30CollectionArtistViewController+- (void)viewDidLayoutSubviews {+ %orig;+ UIView *page = ((UIViewController *)self).viewIfLoaded;+ if (page && page.bounds.size.height >= 200) putFieldUnder(page);+}++- (void)viewWillAppear:(BOOL)animated {+ %orig;+ UIView *page = ((UIViewController *)self).viewIfLoaded;+ if (page) sgr_playlistRoot = page;+}+%end+// The list paints itself the base surface from its own pass rather than through a layer that the repaint// hook would hear about, so it is cleared where it is laid out. So is the recommendations heading at the// bottom of some playlists (This Is ...): Spotify mounts it as a plain UICollectionViewCell straight into the@@ -99,6 +122,17 @@ static SGRArtworkField *fieldIn(UIView *page) {}%end+// That page's list is an SPTTableView painted the base surface from its own pass, like the one above. Every+// list of the app is one, so it is told by its identifier first.+%hook SPTTableView+- (void)layoutSubviews {+ %orig;+ UIView *list = (UIView *)self;+ if (![list.accessibilityIdentifier isEqualToString:@"CollectionArtistView.tableView"]) return;+ if (list.backgroundColor && SGIsBaseSurface(list.backgroundColor.CGColor)) list.backgroundColor = UIColor.clearColor;+}+%end+%ctor {// Registered whatever the switch says: the flag rows elsewhere lock to these while it is on.SGRedesignForceFlags(@"playlist", @{@@ -121,5 +155,7 @@ static SGRArtworkField *fieldIn(UIView *page) {SGRequireClasses(@[@"_TtC35ListUXPlatform_FreeTierPlaylistImpl17FTPViewController",@"_TtC35ListUXPlatform_FreeTierPlaylistImpl32FTPTouchCancellingCollectionView",+ @"_TtC27CollectionArtist_ArtistImpl30CollectionArtistViewController",+ @"SPTTableView",]);}diff --git a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.xindex cd698f9a..aab2438b 100644--- a/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x+++ b/tweak/Sources/Redesigned/Playlist/PlaylistHeader.x@@ -41,8 +41,8 @@ static const CGFloat kDissolve = 0.46, kTopScrim = 140, kTopScrimAlpha = 0.28;static const CGFloat kMinHero = 120, kMinCover = 80;static char kCoverKey, kMetaKey, kPlayKey, kLayoutKey, kToolbarKey, kScrimKey, kBarScrimKey;-static char kShuffleKey, kAddKey, kDownloadKey, kInfoKey, kBlockHeightKey, kBlockWatchedKey;-static char kHeroKey, kHeroHeightKey, kRestPlaneKey, kRowKey, kRowWatchedKey, kMoreKey, kCreatorKey, kPinnedMoreKey, kSortKey;+static char kShuffleKey, kAddKey, kDownloadKey, kPlainDownloadKey, kInfoKey, kBlockHeightKey, kBlockWatchedKey;+static char kHeroKey, kHeroHeightKey, kRestPlaneKey, kRowKey, kRowWatchedKey, kMoreKey, kCreatorKey, kPinnedMoreKey, kSortKey, kTitleKey;#pragma mark - finding things@@ -52,13 +52,16 @@ static char kHeroKey, kHeroHeightKey, kRestPlaneKey, kRowKey, kRowWatchedKey, kM@implementation SGRWeakView@end-// The page the header is on: FTPViewController's own view, which holds the field, the list and the header-// and does not scroll. Walked from the header rather than taken off sgr_playlistRoot, so a playlist under+// The page the header is on: FTPViewController's own view -- or, for the songs the user liked by one artist,+// CollectionArtistViewController's, the same header kit with no cover -- which holds the field, the list and the+// header and does not scroll. Walked from the header rather than taken off sgr_playlistRoot, so a playlist under// another one on the stack pins its own ⋯ and not the one on top.UIView *SGRPlaylistPageOf(UIView *view) {for (UIResponder *r = view; r; r = r.nextResponder) {if (![r isKindOfClass:UIViewController.class]) continue;- if ([NSStringFromClass(r.class) containsString:@"FTPViewController"]) return ((UIViewController *)r).viewIfLoaded;+ NSString *name = NSStringFromClass(r.class);+ // The page of the songs liked by one artist is the cover-less case of the same header kit.+ if ([name containsString:@"FTPViewController"] || [name hasSuffix:@"CollectionArtistViewController"]) return ((UIViewController *)r).viewIfLoaded;}return nil;}@@ -66,7 +69,8 @@ UIView *SGRPlaylistPageOf(UIView *view) {UIViewController *SGRPlaylistHeaderOf(UIView *view) {for (UIResponder *r = view; r; r = r.nextResponder) {if (![r isKindOfClass:UIViewController.class]) continue;- return [NSStringFromClass(r.class) containsString:@"FreeTierPlaylist"] ? (UIViewController *)r : nil;+ NSString *name = NSStringFromClass(r.class);+ return [name containsString:@"FreeTierPlaylist"] || [name hasSuffix:@"CollectionArtistHeaderViewController"] ? (UIViewController *)r : nil;}return nil;}@@ -323,12 +327,27 @@ static BOOL showsDownload(UIView *save, UIView *download) {return (SGRReadAddTo(save, &added) && added) || (SGRReadDownload(download, &state, NULL) && state != SGRDownloadNone);}+// The header of the songs the user liked by one artist: the playlist page's kit with no playlist behind it.+static BOOL isCollectionArtist(UIView *root) {+ return [NSStringFromClass(SGRPlaylistHeaderOf(root).class) hasSuffix:@"CollectionArtistHeaderViewController"];+}++// The name on the songs liked by one artist: the page's big label. Not the first text of the block, which is the+// word on Spotify's Follow button for as long as the name has not been filled in.+static NSString *artistTitle(UIView *block) {+ UIView *label = SGRFindByIdentifier(block, @"Encore.Label-internal", &kTitleKey);+ NSString *text = [label isKindOfClass:UILabel.class] ? ((UILabel *)label).text : nil;+ text = [text stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];+ return text.length ? text : nil;+}+// What the playlist's header shows: the name and the description from the page's model, the creator and the// length from Spotify's concealed labels, and on Play's right save for someone else's playlist (download once// it is saved, showsDownload), download for one's own and for Liked Songs, which Spotify reports as neither// owned nor unsaved (isOwnedBySelf NO, formatListType liked-songs).static void showPlaylist(SGRHeaderInfo *info, UIView *block, UIView *root, id model) {- NSString *title = modelString(model, @"playlistName") ?: firstText(block, nil);+ BOOL artistPage = isCollectionArtist(root);+ NSString *title = modelString(model, @"playlistName") ?: (artistPage ? artistTitle(block) : firstText(block, nil));[info showTitle:title creator:creatorIn(block) length:lengthIn(block)about:plainText(modelString(model, @"playlistDescription"))];@@ -337,7 +356,9 @@ static void showPlaylist(SGRHeaderInfo *info, UIView *block, UIView *root, id moUIView *shuffle = SGRFindByIdentifier(block, @"Components.UI.ShuffleButton", &kShuffleKey);UIView *play = SGRFindByIdentifier(root, @"header-play-button", &kPlayKey);UIView *save = own ? nil : SGRFindByIdentifier(block, @"Components.UI.AddToButton", &kAddKey);- UIView *download = SGRFindByIdentifier(block, @"DownloadButton.Granular*", &kDownloadKey);+ // The Granular button of the playlist pages, or the plain one the songs liked by one artist have.+ UIView *download = SGRFindByIdentifier(block, @"DownloadButton.Granular*", &kDownloadKey)+ ?: SGRFindByIdentifier(block, @"Components.UI.DownloadButton", &kPlainDownloadKey);if (save && showsDownload(save, download)) save = nil;if (save) download = nil;[info showShuffle:shuffle play:play trailing:save ?: downloaddiff --git a/tweak/Sources/Redesigned/Playlist/PlaylistRows.x b/tweak/Sources/Redesigned/Playlist/PlaylistRows.xindex 8d7e6ef8..1cb29cde 100644--- a/tweak/Sources/Redesigned/Playlist/PlaylistRows.x+++ b/tweak/Sources/Redesigned/Playlist/PlaylistRows.x@@ -28,7 +28,14 @@// Under the text rather than the whole row, as the Music app draws it; the trailing end clears the page margin.static const CGFloat kHairline = 0.5, kHairlineGap = 12;-static char kRowKey, kArtKey, kSubtitleKey, kLineKey, kToolbarKey;+static char kRowKey, kTrackRowKey, kArtKey, kArtHolderKey, kSubtitleKey, kLineKey, kToolbarKey;++@interface SGRRowArtHolder : NSObject+@property (nonatomic, weak) UIView *view;+@end++@implementation SGRRowArtHolder+@endstatic UIView *identified(UIView *root, NSString *identifier, const void *cacheKey) {return SGRFindByIdentifier(root, identifier, cacheKey);@@ -58,14 +65,35 @@ static void applyHairline(UIView *row, CGFloat leading) {[CATransaction commit];}+// Where the artwork has no Encore.ImageView of its own (Track.Row): the holder the picture is drawn in, a private+// class of the row kit that is told by its name. Kept on the row, as the lookups by identifier are.+static UIView *artHolderIn(UIView *row) {+ SGRRowArtHolder *box = objc_getAssociatedObject(row, &kArtHolderKey);+ UIView *cached = box.view;+ if (cached && [cached isDescendantOfView:row]) return cached;+ __block UIView *found = nil;+ SGForEachView(row, ^(UIView *v) {+ if (!found && [NSStringFromClass(v.class) hasSuffix:@"ImageViewHolder"]) found = v;+ });+ if (found) {+ if (!box) {+ box = [SGRRowArtHolder new];+ objc_setAssociatedObject(row, &kArtHolderKey, box, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ box.view = found;+ }+ return found;+}+static void applyRow(UIView *cell) {clearSurface(cell);- UIView *row = identified(cell, @"Encore.ListRow", &kRowKey);+ // A playlist's row is an Encore.ListRow; the songs liked by one artist have a Track.Row of the same kit.+ UIView *row = identified(cell, @"Encore.ListRow", &kRowKey) ?: identified(cell, @"Track.Row", &kTrackRowKey);if (!row) return;clearSurface(row);CGFloat leading = SGRSideMargin + 48 + kHairlineGap;- UIView *art = identified(row, @"Encore.ImageView", &kArtKey);+ UIView *art = identified(row, @"Encore.ImageView", &kArtKey) ?: artHolderIn(row);if (art) {if (art.layer.cornerRadius != SGRRadiusThumb) {art.layer.cornerRadius = SGRRadiusThumb;@@ -107,8 +135,20 @@ static void applyRow(UIView *cell) {}%end+// The rows of the songs liked by one artist are another cell (a UITableView's, Track.Row painted the base surface)+// with the same row kit in it, so they get the playlist's row: no paint, rounded artwork, the hairline.+%hook SPTEncoreSwipeableTableViewCell+- (void)layoutSubviews {+ %orig;+ UIView *cell = (UIView *)self;+ if (!sgr_playlistRoot || !SGIsInside(cell, sgr_playlistRoot)) return;+ SGRClearCellPaint(cell);+ applyRow(cell);+}+%end+%ctor {if (!SGRedesignedUI()) return;%init;- SGRequireClasses(@[@"_TtC35ListUXPlatform_FreeTierPlaylistImpl25ElementCollectionViewCell"]);+ SGRequireClasses(@[@"_TtC35ListUXPlatform_FreeTierPlaylistImpl25ElementCollectionViewCell", @"SPTEncoreSwipeableTableViewCell"]);}