Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
fix: the redesigned Home's large shelf keeps its footer, and its hooks stay off other screens
My-Name-Is-Jeffeb79dca3c314
diff --git a/tweak/Sources/Redesigned/Home/HomeCards.x b/tweak/Sources/Redesigned/Home/HomeCards.xindex 21cd8ee2..fc8159cf 100644--- a/tweak/Sources/Redesigned/Home/HomeCards.x+++ b/tweak/Sources/Redesigned/Home/HomeCards.x@@ -47,11 +47,19 @@ static void calmDJ(UIView *card) {}}+// The button's content (Encore's card, the cover's holder, a tile's row with its playing indicator) is laid out after+// the button's own pass otherwise; brought up to date now, the styling reads final frames.+static void settle(UIView *button) {+ if (!SGRHomeLook()) return;+ for (UIView *sub in button.subviews) [sub layoutIfNeeded];+}+static void style(UIView *button) {NSString *identifier = button.accessibilityIdentifier;// Spotify reuses a button across kinds (a tile's became a shelf card on the phone, 2026-10-11): what the other// kind put on it comes off first.if ([identifier isEqualToString:@"Shortcut.Card.Home"]) {+ settle(button);SGRHomeStyleLargeCard(button);CGFloat radius = SGRHomeLook() ? SGRHomeTileRadius : SGRRadiusCover;roundCorners(button, radius);@@ -60,6 +68,7 @@ static void style(UIView *button) {return;}if ([identifier isEqualToString:@"Components.UI.HomeCard"]) {+ settle(button);SGRHomeUnstyleTile(button);if (!SGRHomeStyleLargeCard(button)) roundCover(button);return;@@ -78,11 +87,6 @@ static void style(UIView *button) {- (void)layoutSubviews {%orig;CFTimeInterval began = SGRHomeProbeBegin();- // The button's content (Encore's card, the cover's holder, a tile's row with its playing indicator) is laid out- // after the button's own pass otherwise; brought up to date now, the styling reads final frames.- if (SGRHomeLook()) {- for (UIView *sub in ((UIView *)self).subviews) [sub layoutIfNeeded];- }style((UIView *)self);SGRHomeProbeEnd(SGRHomeProbeCards, began);}@@ -103,6 +107,8 @@ static void retextedUnder(UIView *label) {if (ours) SGRHomeProbeEnd(SGRHomeProbeLabelsMatched, began);}+// The walk is 20 to 30 ns a call (measured 2026-10-12 against an isDescendantOfView: check on Home's list, which is+// no cheaper and would miss a label that joins the window before its card does), so no cheaper gate is kept.static void relayoutButtonAround(UIView *label) {static Class backing;if (!backing) backing = NSClassFromString(@"_TtC19LegacyUI_ECMCoreKit31InteractableLayoutBackingButton");@@ -135,7 +141,15 @@ static void relayoutButtonAround(UIView *label) {%hook SPTEncoreLabel- (void)didMoveToWindow {%orig;- if (((UIView *)self).window) relayoutButtonAround((UIView *)self);+ UIView *label = (UIView *)self;+ if (!label.window) return;+ CFTimeInterval began = SGRHomeProbeBegin();+ // Spotify's card and tile text (id Encore.Label, Shortcut.Card.Home.Content.title); the rest of its labels pass.+ NSString *identifier = label.accessibilityIdentifier;+ BOOL ours = [identifier isEqualToString:@"Encore.Label"] || [identifier hasSuffix:@".Content.title"];+ if (ours) relayoutButtonAround(label);+ SGRHomeProbeEnd(SGRHomeProbeLabels, began);+ if (ours) SGRHomeProbeEnd(SGRHomeProbeLabelsMatched, began);}%enddiff --git a/tweak/Sources/Redesigned/Home/HomeHeader.x b/tweak/Sources/Redesigned/Home/HomeHeader.xindex 92cd8cad..dae34e08 100644--- a/tweak/Sources/Redesigned/Home/HomeHeader.x+++ b/tweak/Sources/Redesigned/Home/HomeHeader.x@@ -363,7 +363,13 @@ static void layoutHeader(UIViewController *page);static const NSUInteger kHeaderWaits = 30;static const NSTimeInterval kHeaderWait = 0.1;static void layoutHeaderOnceSized(UIViewController *page, UIView *header) {- if (!CGRectIsEmpty(header.bounds)) return;+ // findHeader answers YES on the stack alone, so the header can be gone while the stack is not.+ if (!header) return;+ if (!CGRectIsEmpty(header.bounds)) {+ // Sized: a later spell without a size gets its waits again.+ if (objc_getAssociatedObject(header, &kWatchKey)) objc_setAssociatedObject(header, &kWatchKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ return;+ }NSUInteger waits = [objc_getAssociatedObject(header, &kWatchKey) unsignedIntegerValue];if (waits >= kHeaderWaits) return;objc_setAssociatedObject(header, &kWatchKey, @(waits + 1), OBJC_ASSOCIATION_RETAIN_NONATOMIC);diff --git a/tweak/Sources/Redesigned/Home/HomePerf.x b/tweak/Sources/Redesigned/Home/HomePerf.xindex 3e7ebdba..3c7450e8 100644--- a/tweak/Sources/Redesigned/Home/HomePerf.x+++ b/tweak/Sources/Redesigned/Home/HomePerf.x@@ -40,7 +40,7 @@ static BOOL probing(void) {// frames the display link saw late, logged only for a second in which any of them happened. A Home that is// still and quiet logs nothing, which is the proof that nothing fires at rest (`make log | grep "home perf/s"`).// Off unless asked for: its display link holds the screen at up to 120 Hz while Spotify is open-// (scripts/phone.py pref --key spotifyglass.debug.homeRestMeter --value 1, then relaunch).+// (scripts/phone.py pref --key spotifyglass.redesign.debug.homeRestMeter --value 1, then relaunch).static NSUInteger sg_restFrames, sg_restHitches, sg_listLayouts;static CFTimeInterval sg_restLast;@interface SGRHomeRestMeter : NSObject@@ -60,7 +60,7 @@ static void startRestMeter(void) {static NSUInteger calls[SGRHomeProbeCount];static CFTimeInterval time[SGRHomeProbeCount];static SGRHomeRestMeter *meter;- if (timer || !SGFlag(@"spotifyglass.debug.homeRestMeter", NO)) return;+ if (timer || !SGFlag(@"spotifyglass.redesign.debug.homeRestMeter", NO)) return;meter = [SGRHomeRestMeter new];CADisplayLink *link = [CADisplayLink displayLinkWithTarget:meter selector:@selector(tick:)];if (@available(iOS 15.0, *)) link.preferredFrameRateRange = CAFrameRateRangeMake(80, 120, 120);diff --git a/tweak/Sources/Redesigned/Home/HomeTopPicks.x b/tweak/Sources/Redesigned/Home/HomeTopPicks.xindex d299a92d..3db8132f 100644--- a/tweak/Sources/Redesigned/Home/HomeTopPicks.x+++ b/tweak/Sources/Redesigned/Home/HomeTopPicks.x@@ -131,6 +131,9 @@ static __weak UICollectionViewLayout *sg_blocksLayout;static BOOL sg_blocksKnown, sg_blocksSwap;static CGRect sg_blocksGrid, sg_blocksShelf;static CGFloat sg_blocksBefore;+// The sections the cached frames belong to: move() reads these, not the globals, which the measuring can change+// between two queries of one pass.+static NSInteger sg_blocksGridSection, sg_blocksShelfSection;static BOOL blocks(UICollectionViewLayout *layout, CGRect *grid, CGRect *shelf, CGFloat *before) {if (!objc_getAssociatedObject(layout, &kListKey)) return NO;@@ -144,6 +147,8 @@ static BOOL blocks(UICollectionViewLayout *layout, CGRect *grid, CGRect *shelf,sg_blocksKnown = YES;sg_blocksSwap = NO;NSInteger shelfSection = sg_topIndex == NSIntegerMax ? NSNotFound : sg_topIndex / 10000, shelfItem = sg_topIndex % 10000;+ sg_blocksGridSection = sg_gridSection;+ sg_blocksShelfSection = shelfSection;if (sg_gridSection == NSNotFound || shelfSection == NSNotFound || sg_gridSection >= shelfSection) return NO;UICollectionView *list = layout.collectionView;NSInteger sections = list.numberOfSections;@@ -179,9 +184,9 @@ static BOOL blocks(UICollectionViewLayout *layout, CGRect *grid, CGRect *shelf,// top); the grid and everything between it and the shelf move down by the shelf's block, the gap above the shelf// (its section inset) kept between the two.static void move(UICollectionViewLayoutAttributes *attributes, CGRect grid, CGRect shelf, CGFloat before) {- NSInteger section = attributes.indexPath.section, shelfSection = sg_topIndex / 10000;+ NSInteger section = attributes.indexPath.section, gridSection = sg_blocksGridSection, shelfSection = sg_blocksShelfSection;CGRect frame = attributes.frame;- if (section >= sg_gridSection && section < shelfSection) frame.origin.y += CGRectGetMaxY(shelf) - before + kBandAbove;+ if (section >= gridSection && section < shelfSection) frame.origin.y += CGRectGetMaxY(shelf) - before + kBandAbove;else if (section == shelfSection) frame.origin.y += CGRectGetMinY(grid) - CGRectGetMinY(shelf) + kBandAbove;else return;attributes.frame = frame;@@ -266,6 +271,7 @@ static void move(UICollectionViewLayoutAttributes *attributes, CGRect grid, CGRe// and every shelf on screen is measured again, so the next one takes the place now rather than on the next scroll.static void topLost(UICollectionView *list) {sg_topIndex = NSIntegerMax;+ sg_blocksKnown = NO;sg_largeShelf = nil;SGRHomeSetPageTint(nil);static Class shelf;@@ -294,9 +300,11 @@ static void topLost(UICollectionView *list) {if (index == sg_topIndex) topLost((UICollectionView *)list);// The shortcuts grid is the one bare list Home has (HomeSections.x); a section of anything else in its place// (no shortcuts) leaves the order alone.- BOOL grid = [root isKindOfClass:UICollectionView.class] && !root.accessibilityIdentifier.length && result.size.height > 0;+ BOOL grid = [root isKindOfClass:UICollectionView.class] && !(shelf && [root isKindOfClass:shelf]) && !root.accessibilityIdentifier.length+ && result.size.height > 0;if (grid) sg_gridSection = attributes.indexPath.section;else if (attributes.indexPath.section == sg_gridSection) sg_gridSection = NSNotFound;+ sg_blocksKnown = NO;return result;}UICollectionViewLayout *layout = ((UICollectionView *)root).collectionViewLayout;@@ -339,8 +347,8 @@ static void topLost(UICollectionView *list) {// Never shorter than what the shelf lays out: Spotify's height can be taken before its tallest card sized// itself (a title on 4 lines), and the shelf then scrolls inside its cell. The shelf's height comes from its// cards, not from the cell, so taking it does not feed back.- if (natural && large && grow) result.size = CGSizeMake(result.size.width, MAX(natural.doubleValue + grow.doubleValue,- ceil(layout.collectionViewContentSize.height)) - offset);+ if (natural && large && grow) result.size = CGSizeMake(result.size.width, MAX(natural.doubleValue + grow.doubleValue - offset,+ ceil(layout.collectionViewContentSize.height)));else if (natural && was) result.size = CGSizeMake(result.size.width, natural.doubleValue);return result;}@@ -546,18 +554,19 @@ static BOOL styleLargeCard(UIView *card) {parts.cover.userInteractionEnabled = NO;parts.cover.accessibilityElementsHidden = YES;objc_setAssociatedObject(card, &kPartsKey, parts, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- __weak UIView *weakCard = card;- // The block is replaced on every pass, so a cover taken into another card tells the card it is in now.- SGRObserveImage(cover, ^(UIImageView *view) {- UIView *strongCard = weakCard;- if (!strongCard || ![view isDescendantOfView:strongCard]) return;- SGRLargeCardParts *now = objc_getAssociatedObject(strongCard, &kPartsKey);- if (now.cover.image != view.image) now.cover.image = view.image;- tintCard(strongCard, view);- });static dispatch_once_t once;dispatch_once(&once, ^{ SGLog(@"redesign home: top picks card %@ styled", NSStringFromCGRect(card.bounds)); });}+ // On every pass: the block is replaced, so a cover taken into another card tells the card it is in now, and a+ // card given a new image view is followed from this pass on.+ __weak UIView *weakCard = card;+ SGRObserveImage(cover, ^(UIImageView *view) {+ UIView *strongCard = weakCard;+ if (!strongCard || ![view isDescendantOfView:strongCard]) return;+ SGRLargeCardParts *now = objc_getAssociatedObject(strongCard, &kPartsKey);+ if (now.cover.image != view.image) now.cover.image = view.image;+ tintCard(strongCard, view);+ });CALayer *layer = card.layer;if (layer.cornerRadius != SGRRadiusCard) layer.cornerRadius = SGRRadiusCard;if (layer.cornerCurve != kCACornerCurveContinuous) layer.cornerCurve = kCACornerCurveContinuous;