Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
// Playlist redesign: the track rows on the field, the way the Music app has them -- no surface of their own,
// artwork with rounded corners, and a hairline from the text's edge between one row and the next.
//
// Tree (trees/clean/playlist/02.txt:164-247): a cell id=Playlist.ItemCell holds an Encore.ListRow painted the
// base surface, and in it Encore.ImageView 48x48 (the artwork), Track.Row.Content.Title,
// Track.Row.Content.Subtitle and, at the trailing edge, Components.UI.ContextMenuButton. The row's own paint
// is cleared here rather than left to the Kit's repaint hook, which only hears about a color when Spotify
// sets it and not when a reused cell already carries one.
//
// Spotify's type and its spacing are left alone: the row is 64pt for a title of 18pt, and a larger font of
// the Kit's would be cut off by the box the element framework measured for it.
//
// The pills over the first row (own-playlist/01.txt:33) are a cell of the list: Add, Mix, Notes, Video,
// Edit, Sort and Name & details. The row is closed up -- ListUXPlatform_LayoutKit.ListLayout gives every
// item its height, so the cell can only close up where the layout asks it how tall it wants to be -- and
// Sort and Mix are put on the ⋯ sheet instead (PlaylistMenu.x), where the rest of the row already is. The
// cell is handed over as it lays out, so the sheet has Spotify's own buttons to fire.
//
// Not every cell of the list is a track row. Under the tracks Spotify puts the extender -- Recommended
// songs, its rows and Refresh (ListUXPlatformConsumers_PlaylistExtenderImpl) -- and its heading and its
// Refresh cell paint the base surface over the field, where the black made bands of them (device,
// trees/continuous/2.txt 2026-09-20). So the paint comes off every cell of the page, the Kit's way, and
// only the row below is a row.
#import "Core/SGCore.h"
#import "Redesigned/Kit/SGRKit.h"
#import "Playlist.h"
// Under the text rather than the whole row, as the Music app draws it; the trailing end clears the page margin.
static const CGFloat kHairline = 0.5, kHairlineGap = 12;
static char kRowKey, kTrackRowKey, kArtKey, kArtHolderKey, kSubtitleKey, kLineKey, kToolbarKey;
@interface SGRRowArtHolder : NSObject
@property (nonatomic, weak) UIView *view;
@end
@implementation SGRRowArtHolder
@end
static UIView *identified(UIView *root, NSString *identifier, const void *cacheKey) {
return SGRFindByIdentifier(root, identifier, cacheKey);
}
static void clearSurface(UIView *view) {
UIColor *color = view.backgroundColor;
if (color && SGIsBaseSurface(color.CGColor)) view.backgroundColor = UIColor.clearColor;
}
static void applyHairline(UIView *row, CGFloat leading) {
CALayer *line = objc_getAssociatedObject(row, &kLineKey);
if (!line) {
line = [CALayer layer];
line.backgroundColor = [UIColor colorWithWhite:1 alpha:0.12].CGColor;
line.zPosition = 1;
objc_setAssociatedObject(row, &kLineKey, line, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
if (line.superlayer != row.layer) [row.layer addSublayer:line];
CGRect bounds = row.bounds;
CGRect frame = CGRectMake(leading, bounds.size.height - kHairline,
MAX(0, bounds.size.width - leading - SGRSideMargin), kHairline);
if (CGRectEqualToRect(line.frame, frame)) return;
[CATransaction begin];
[CATransaction setDisableActions:YES];
line.frame = frame;
[CATransaction commit];
}
// 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;
}
// A playlist's row is an Encore.ListRow; the songs liked by one artist have a Track.Row of the same kit.
static UIView *rowIn(UIView *cell) {
return identified(cell, @"Encore.ListRow", &kRowKey) ?: identified(cell, @"Track.Row", &kTrackRowKey);
}
// YES when the cell holds a track row.
static BOOL applyRow(UIView *cell) {
clearSurface(cell);
UIView *row = rowIn(cell);
if (!row) return NO;
clearSurface(row);
CGFloat leading = SGRSideMargin + 48 + kHairlineGap;
UIView *art = identified(row, @"Encore.ImageView", &kArtKey) ?: artHolderIn(row);
if (art) {
if (art.layer.cornerRadius != SGRRadiusThumb) {
art.layer.cornerRadius = SGRRadiusThumb;
art.layer.cornerCurve = kCACornerCurveContinuous;
art.clipsToBounds = YES;
}
CGRect frame = [row convertRect:art.bounds fromView:art];
if (frame.size.width > 0) leading = CGRectGetMaxX(frame) + kHairlineGap;
}
UIView *subtitle = identified(row, @"Track.Row.Content.Subtitle", &kSubtitleKey);
SGForEachView(subtitle, ^(UIView *v) {
if (![v isKindOfClass:UILabel.class]) return;
UILabel *label = (UILabel *)v;
if (![label.textColor isEqual:SGRSecondary()]) label.textColor = SGRSecondary();
});
applyHairline(row, leading);
return YES;
}
%hook _TtC35ListUXPlatform_FreeTierPlaylistImpl25ElementCollectionViewCell
- (void)layoutSubviews {
%orig;
UIView *cell = (UIView *)self;
if (!SGRPlaylistHeaderOf(cell)) return;
SGRClearCellPaint(cell);
// A track row is not the curation row, so only the other cells are searched for its toolbar.
if (!applyRow(cell)) SGRPlaylistTakeCuration(cell);
}
- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)attributes {
UICollectionViewLayoutAttributes *result = %orig;
if (!SGRFindByIdentifier((UIView *)self, SGRPlaylistCurationIdentifier, &kToolbarKey)) return result;
result.size = CGSizeMake(result.size.width, 0);
((UIView *)self).clipsToBounds = YES;
static dispatch_once_t once;
dispatch_once(&once, ^{ SGLog(@"redesign playlist: curation pills asked for a height, answered 0"); });
return result;
}
%end
// 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", @"SPTEncoreSwipeableTableViewCell"]);
}