Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: pick the native or the redesigned player from tabs on the Player page, and drop the artist redesign
Vojtěch Škopek21df22cd6bbf
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex b505fed5..6aa7db37 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -11,6 +11,9 @@the row that opens it from Spotify's settings)tweak/Sources/Features/ one directory per feature, see belowtweak/Sources/Diagnostics/ screen dumps and the tree server of FLEX builds+ tweak/Sources/Redesign/ screens rebuilt in Liquid Glass instead of tweaked: Kit/ (the artwork field, glass inside+ Spotify's controls, glyphs, restyle helpers, player and link bridges, the switch per+ screen and the flags a screen forces) and Player/, the redesigned full screen playerscripts/ pipeline.sh (build + inject), install.sh (sign + install), record-trees.py,record-session.py, dump-log.sh, extract-flags.py, publish.sh (release: version bump,site release.json)@@ -96,7 +99,9 @@ one page, the mod's own rows first and Spotify's flags below them or on a sub pathey change. It opens on the Appearance card, the three switches that style the whole app: LiquidGlass UI, AMOLED and the accent colour (Spotify's green is offered from the colour row once a colouris set). Then a card of parts. Navbar: the glass tab bar and search field, then the tab editor.-Player: Gestures, Lyrics (Apple Music style, glass lyrics, the ordered list of lyrics sources, lyrics+Player: tabs at the top pick the player screen, Native player (Spotify's own, with the switches of+Player.x and Declutter.x) or Redesigned player (Redesign/Player, which those switches don't reach), each+tab showing only its own player's rows; the pages below belong to both. Then Gestures, Lyrics (Apple Music style, glass lyrics, the ordered list of lyrics sources, lyricsfor every track, naming the source, hiding the lyrics card and preview, the lyrics flags), Blocked artists (with the count on the row) and Now playing bar (its glass, its devicebutton and its flags) as pages; then the player screen (artwork background, glass header buttons,Disable Canvas and the sheet, header, slider and sticky header flags), the cards under the player anddiff --git a/tweak/Sources/Features/Appearance/Repaint.x b/tweak/Sources/Features/Appearance/Repaint.xindex 95d2f218..bbb8c205 100644--- a/tweak/Sources/Features/Appearance/Repaint.x+++ b/tweak/Sources/Features/Appearance/Repaint.x@@ -2,12 +2,10 @@// view is the now playing card from the album-colour paint.#import "Core/SGCore.h"#import "Appearance.h"-#import "Redesign/Kit/SGRRestyle.h"%hook CALayer- (void)setBackgroundColor:(CGColorRef)color {- if (color && (sg_nowPlayingRoot || sg_tabBarRoot || sg_lyricsCardRoot || sg_lyricsPageRoot || sg_homeRoot || sg_npvBackdropRoot- || SGRHasClearRoots())) {+ if (color && (sg_nowPlayingRoot || sg_tabBarRoot || sg_lyricsCardRoot || sg_lyricsPageRoot || sg_homeRoot || sg_npvBackdropRoot)) {UIView *view = (UIView *)self.delegate;if ([view isKindOfClass:UIView.class] && view.layer == self && !SGKeepsColor(view)) {if (SGIsInside(view, sg_nowPlayingRoot)) {@@ -29,9 +27,6 @@// Home keeps its cards and its placeholders; only the base surface the gradient// of Home/HomeGradient.x sits behind goes.color = NULL;- } else if (SGRHasClearRoots() && SGIsBaseSurface(color) && SGRInsideClearRoot(view)) {- // A redesigned page paints its own field behind Spotify's surfaces (Redesign/Kit/SGRRestyle.h).- color = NULL;}}}diff --git a/tweak/Sources/Features/Artist/Artist.x b/tweak/Sources/Features/Artist/Artist.xindex b24518bc..aa9af478 100644--- a/tweak/Sources/Features/Artist/Artist.x+++ b/tweak/Sources/Features/Artist/Artist.x@@ -9,13 +9,9 @@// Only the heading names the section, so the list remembers the heading above every cell it sizes// and a hidden section's cells all answer height 0, down to the next heading. The headings are// told apart by their English titles.-//-// While the artist page is redesigned (Redesign/Artist/) none of these hooks is installed, so the two-// never fight over the same views; with the redesign off they behave as they always did.#import <objc/runtime.h>#import <CoreImage/CoreImage.h>#import "Core/SGCore.h"-#import "Redesign/Kit/SGRedesign.h"#import "Artist.h"static BOOL onArtistPage(UIView *view) {@@ -181,8 +177,6 @@ static void applyPhotoFade(UIView *header) {[CATransaction commit];}-%group SGArtistLegacy-%hook _TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView- (void)layoutSubviews {%orig;@@ -334,11 +328,8 @@ static BOOL collapsed(UICollectionViewCell *cell, NSIndexPath *path) {}%end-%end-%ctor {- if (SGRedesignOn(@"artist")) return;- %init(SGArtistLegacy);+ %init;SGRequireClasses(@[@"_TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView",@"_TtC12Element_List18CollectionViewCell",diff --git a/tweak/Sources/Features/Artist/ArtistSettings.m b/tweak/Sources/Features/Artist/ArtistSettings.mindex 72570074..0991cede 100644--- a/tweak/Sources/Features/Artist/ArtistSettings.m+++ b/tweak/Sources/Features/Artist/ArtistSettings.m@@ -1,6 +1,5 @@#import "Core/SGCore.h"#import "Settings/SGModPage.h"-#import "Redesign/Kit/SGRedesign.h"#import "Artist.h"UIViewController *SGArtistSettingsPage(void) {@@ -38,8 +37,5 @@ UIViewController *SGArtistSettingsPage(void) {SGFlagRow(@"Top collaborators", @"ios-creator-impl.is_top_collaborators_enabled"),SGFlagRow(@"Artist facts", @"ios-creator-impl.is_artist_facts_enabled"), ]),];- // While the redesign has the page, these switches stand aside; the note says so and opens its page.- SGModSection *note = SGRedesignNoteSection(@"artist");- if (note) sections = [@[note] arrayByAddingObjectsFromArray:sections];return [[SGModPage alloc] initWithTitle:@"Artist" intro:nil sections:sections footer:nil];}diff --git a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.mindex 4b556110..4287308d 100644--- a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m+++ b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m@@ -8,6 +8,7 @@#import "Features/LockScreenLyrics/LockScreenLyrics.h"#import "Features/LyricsSources/LyricsSources.h"#import "Redesign/Kit/SGRedesign.h"+#import "Redesign/Player/Player.h"static UIViewController *nowPlayingBarPage(void) {return [[SGModPage alloc] initWithTitle:@"Now playing bar" intro:SGRestartNote sections:@[@@ -100,23 +101,17 @@ static UIViewController *lockScreenPage(void) {] footer:nil];}+// The player screen is one of two, picked with the tabs at the top of the page: Spotify's own player+// with the switches of Player.x and Declutter.x on it, or the redesigned one of Redesign/Player, which+// those switches don't reach. Each tab holds only its own player's rows; the pages above the player+// screen itself (gestures, lyrics, the bar, the queue) belong to both and follow the tabs.UIViewController *SGNowPlayingSettingsPage(void) {SGModRow *blocked = SGPageRow(@"Blocked artists", ^UIViewController *{ return SGArtistBlockSettingsPage(); });blocked.value = ^NSString *{return SGFlag(SGKeyArtistBlock, NO) ? @(SGBlockedArtists().count).stringValue : @"Off";};- NSArray<SGModSection *> *sections = @[- SGSection(nil, @[- SGWithSymbol(SGPageRow(@"Gestures", ^UIViewController *{ return SGGesturesSettingsPage(); }), @"hand.tap"),- SGWithSymbol(SGPageRow(@"Lyrics", ^UIViewController *{ return lyricsPage(); }), @"quote.bubble"),- SGWithSymbol(blocked, @"person.crop.circle.badge.xmark"),- ]),- SGSection(nil, @[- SGWithSymbol(SGPageRow(@"Now playing bar", ^UIViewController *{ return nowPlayingBarPage(); }), @"rectangle.bottomthird.inset.filled"),- SGWithSymbol(SGPageRow(@"Queue & devices", ^UIViewController *{ return queuePage(); }), @"text.line.first.and.arrowtriangle.forward"),- SGWithSymbol(SGPageRow(@"Lock screen widget", ^UIViewController *{ return lockScreenPage(); }), @"lock"),- ]),+ SGModTab *native = SGTab(@"Native player", @"Spotify's own player, with the switches below on it.", @[SGNotedSection(@"Player screen", @[SGOptionRow(@"Artwork background", @"The cover blurred and dimmed behind the player instead of the flat album colour", SGKeyPlayerBackdrop),SGOptionRow(@"Glass header buttons", nil, SGKeyPlayer),@@ -144,9 +139,29 @@ UIViewController *SGNowPlayingSettingsPage(void) {SGHideRow(@"Share", nil, SGHideShare),SGHideRow(@"Connect to a device", nil, SGHideConnect),]),- ];- // While the player is redesigned the player screen, card and button rows below don't apply.- SGModSection *note = SGRedesignNoteSection(@"player");- if (note) sections = [@[note] arrayByAddingObjectsFromArray:sections];- return [[SGModPage alloc] initWithTitle:@"Player" intro:@"Changes apply after you restart Spotify. Gestures and Blocked artists apply straight away." sections:sections footer:nil];+ ]);++ SGModTab *redesigned = SGTab(@"Redesigned player", @"The cover's own colour behind the whole player, glass behind the header buttons, bare playback controls, and nothing under the player but lyrics.", @[+ SGSection(@"Player screen", @[+ SGSwitchRow(@"Lyrics under the player", @"The lyrics card below the player; every other card is left out", SGKeyRedesignPlayerLyricsCard),+ ]),+ ]);++ return [[SGModPage alloc] initWithTitle:@"Player"+ intro:@"Changes apply after you restart Spotify. Gestures and Blocked artists apply straight away."+ tabsKey:SGKeyRedesignPlayer+ tabs:@[native, redesigned]+ fallback:0+ sections:@[+ SGSection(nil, @[+ SGWithSymbol(SGPageRow(@"Gestures", ^UIViewController *{ return SGGesturesSettingsPage(); }), @"hand.tap"),+ SGWithSymbol(SGPageRow(@"Lyrics", ^UIViewController *{ return lyricsPage(); }), @"quote.bubble"),+ SGWithSymbol(blocked, @"person.crop.circle.badge.xmark"),+ ]),+ SGSection(nil, @[+ SGWithSymbol(SGPageRow(@"Now playing bar", ^UIViewController *{ return nowPlayingBarPage(); }), @"rectangle.bottomthird.inset.filled"),+ SGWithSymbol(SGPageRow(@"Queue & devices", ^UIViewController *{ return queuePage(); }), @"text.line.first.and.arrowtriangle.forward"),+ SGWithSymbol(SGPageRow(@"Lock screen widget", ^UIViewController *{ return lockScreenPage(); }), @"lock"),+ ]),+ ] footer:nil];}diff --git a/tweak/Sources/Redesign/Artist/ArtistList.x b/tweak/Sources/Redesign/Artist/ArtistList.xdeleted file mode 100644index 8d0c9ab7..00000000--- a/tweak/Sources/Redesign/Artist/ArtistList.x+++ /dev/null@@ -1,485 +0,0 @@-// Artist page redesign, the Music list (RedesignArtist.h): Spotify's own list with only the music left on-// it, under the Kit's section headers, its rows restyled for the field.-//-// Trees (trees/clean/artist/01-13.txt): every row of the Music list is an Element_List CollectionViewCell-// holding a Creator_CreatorPageImpl LCR_Structure element, NoData or NeedsData by its content view's class.-// Spotify's own accessibility identifiers say what a cell is, in any language:-// Components.UI.SectionHeadingHome a section's heading-// Components.UI.LikedSongs.Row songs you liked (and its 0pt twin, songs available offline)-// Components.UI.RetrievalRowElementUI_Loaded a popular track, the sixth with the See more footer, or a-// popular release-// Components.UI.ListSectionFooter.Button See discography-// Components.UI.UpcomingReleaseRow the release countdown-// Components.UI.RetrievalRowLoadingElementUI the loading row standing in for one of those-// Components.UI.PinnedItem*, CreatorBiographyCard*, MusicVideoShelfHeader*, Music-Videos.*, HomeCard-// artist pick, about, music videos, and the carousels of-// featuring, artist playlists, fans also like and appears on-// and a NoData cell with no identifier and nothing in it is the spacer between two sections. What is not-// music answers height 0 from preferredLayoutAttributesFittingAttributes:, as Features/Artist/Artist.x-// proved, and a section no rule knows is left out.-//-// A heading comes right before the cell of its section (01.txt: Artist pick at 468.7, its card at 505.3) but-// is sized before that cell exists. So a heading stays when it is the list's first (Popular) or the cell-// under it is already known to be music, and otherwise waits collapsed; sizing the cell under it settles-// the heading, which is sized again when the answer changed. What a heading's section turned out to be is-// remembered by its title for the rest of the launch, so the next artist page in the same language has-// the answer before the cell under it is sized. The answer still comes from the cells, never from the words.-#import <objc/runtime.h>-#import "Core/SGCore.h"-#import "Redesign/Kit/SGRKit.h"-#import "RedesignArtist.h"--typedef NS_ENUM(NSInteger, SGArtistCell) {- SGArtistCellPending, // a NeedsData cell with nothing in it yet: Spotify's height until it fills- SGArtistCellHeading,- SGArtistCellMusic,- SGArtistCellLiked,- SGArtistCellLoading,- SGArtistCellSpacer,- SGArtistCellOther, // everything else, collapsed-};--static Class sg_listViewClass, sg_headingButtonClass, sg_gradientClass;-static BOOL sg_hideLiked;-static NSMutableDictionary<NSString *, NSNumber *> *sg_learntHeadings; // title: kept or not-static char kListKey, kFadedRowKey, kHiddenGradientKey;--// A cell's walk ends at its first telling identifier, a few views down; this bounds one that has none.-static const NSUInteger kWalkLimit = 160;-static NSString *const kFadeName = @"spotifyglass.artistFooterFade";--@interface SGArtistWeak : NSObject-@property (nonatomic, weak) UIView *view;-@end-@implementation SGArtistWeak-@end--static UIView *weakGet(id object, const void *key) {- return ((SGArtistWeak *)objc_getAssociatedObject(object, key)).view;-}--static void weakSet(id object, const void *key, UIView *view) {- SGArtistWeak *box = nil;- if (view) {- box = [SGArtistWeak new];- box.view = view;- }- objc_setAssociatedObject(object, key, box, OBJC_ASSOCIATION_RETAIN_NONATOMIC);-}--#pragma mark - what a cell is--static SGArtistCell kindOfIdentifier(NSString *identifier) {- static NSSet<NSString *> *music;- static NSArray<NSString *> *other;- static dispatch_once_t once;- dispatch_once(&once, ^{- // EmptyReleasesSectionElement is in the binary's strings only, for an artist with no releases.- music = [NSSet setWithArray:@[@"Components.UI.RetrievalRowElementUI_Loaded", @"Components.UI.ListSectionFooter.Button",- @"Components.UI.UpcomingReleaseRow", @"Components.UI.EmptyReleasesSectionElement"]];- other = @[@"Components.UI.PinnedItem", @"Components.UI.CreatorBiographyCard", @"Components.UI.MusicVideoShelfHeader",- @"Music-Videos.", @"Components.UI.HomeCard", @"Merch."];- });- if ([identifier isEqualToString:@"Components.UI.SectionHeadingHome"]) return SGArtistCellHeading;- if ([identifier isEqualToString:@"Components.UI.LikedSongs.Row"]) return SGArtistCellLiked;- if ([music containsObject:identifier]) return SGArtistCellMusic;- if ([identifier isEqualToString:@"Components.UI.RetrievalRowLoadingElementUI"]) return SGArtistCellLoading;- for (NSString *prefix in other) {- if ([identifier hasPrefix:prefix]) return SGArtistCellOther;- }- return SGArtistCellPending;-}--// Identifiers every kind of cell carries, which say nothing about the section.-static BOOL isGeneric(NSString *identifier) {- return [identifier hasPrefix:@"Encore."] || [identifier hasPrefix:@"EncoreConsumerMobile.View."] || [identifier hasSuffix:@"-internal"];-}--// Depth first, stopping at the first identifier with a rule; `unknown` gets the first other identifier of a-// cell no rule decided.-static SGArtistCell classify(UICollectionViewCell *cell, NSString **unknown) {- UIView *content = cell.contentView;- // The state is in the element content view's class (01.txt: ElementContentView<…9NeedsData>), which is- // the cell's only child and so its content view (a content configuration's view); its first child- // too, should UIKit keep a content view of its own around it.- BOOL needsData = [NSStringFromClass(content.class) containsString:@"9NeedsData"]- || [NSStringFromClass(content.subviews.firstObject.class) containsString:@"9NeedsData"];- NSMutableArray<UIView *> *stack = [NSMutableArray arrayWithObject:content];- NSUInteger visited = 0;- BOOL nested = NO;- NSString *first = nil;- while (stack.count && visited < kWalkLimit) {- UIView *view = stack.lastObject;- [stack removeLastObject];- // The Kit's own header, left in a heading cell Spotify reuses for another row.- if ([view isKindOfClass:SGRSectionHeader.class]) continue;- visited++;- NSString *identifier = view.accessibilityIdentifier;- if (identifier.length) {- SGArtistCell kind = kindOfIdentifier(identifier);- if (kind != SGArtistCellPending) return kind;- if (!first && !isGeneric(identifier)) first = identifier;- }- // A carousel's cards are a list of their own, and the carousel is not music.- if ([view isKindOfClass:UICollectionView.class]) {- nested = YES;- continue;- }- for (UIView *sub in view.subviews.reverseObjectEnumerator) [stack addObject:sub];- }- if (unknown) *unknown = first;- if (nested || first) return SGArtistCellOther;- if (needsData) return SGArtistCellPending;- // Element content view > element view > one bare UIView (01.txt: the 16pt cells), and one more level- // should the content view wrap the element content view.- return visited <= 4 ? SGArtistCellSpacer : SGArtistCellOther;-}--// Trees (01.txt): the title is the accessibility label of the heading's NoIntrinsicContentSizeButton.-static NSString *headingTitleIn(UIView *root) {- __block NSString *title = nil;- if (!root || !sg_headingButtonClass) return nil;- SGForEachView(root, ^(UIView *view) {- if (!title && [view isKindOfClass:sg_headingButtonClass] && view.accessibilityLabel.length) title = view.accessibilityLabel;- });- return title;-}--static BOOL settles(SGArtistCell kind) {- return kind != SGArtistCellPending && kind != SGArtistCellLoading;-}--// The Kit's header draws its title 24pt down in title 2 bold (capped at XXXL); the heading gets that and-// a little room under it, never less than 56.-static CGFloat headingHeight(void) {- UIFont *font = SGRFont(UIFontTextStyleTitle2, UIFontWeightBold, UIContentSizeCategoryExtraExtraExtraLarge);- return MAX(56, ceil(24 + font.lineHeight + SGRGrid / 2));-}--static void logUnknown(NSString *identifier, CGFloat height) {- static NSMutableSet<NSString *> *seen;- if (!seen) seen = [NSMutableSet set];- if (seen.count >= 12 || [seen containsObject:identifier]) return;- [seen addObject:identifier];- SGLog(@"artist: collapsed a cell no rule knows, first identifier %@, %.0f tall", identifier, height);-}--#pragma mark - the list--@interface SGArtistList : NSObject-@property (nonatomic, weak) UICollectionView *view;-- (CGFloat)heightOf:(UICollectionViewCell *)cell at:(NSIndexPath *)path fitting:(CGFloat)height;-- (void)willDisplay:(UICollectionViewCell *)cell at:(NSIndexPath *)path;-@end--@implementation SGArtistList {- NSMutableDictionary<NSIndexPath *, NSNumber *> *_kinds; // what each cell sized so far is- NSMutableDictionary<NSIndexPath *, NSNumber *> *_settled; // heading: kept or not, by the cell under it- NSMutableDictionary<NSIndexPath *, NSNumber *> *_answered; // heading: kept or not, as last sized- NSMutableDictionary<NSIndexPath *, NSString *> *_titles; // heading: its title- NSUInteger _corrections;-}--- (instancetype)init {- if (!(self = [super init])) return nil;- _kinds = [NSMutableDictionary dictionary];- _settled = [NSMutableDictionary dictionary];- _answered = [NSMutableDictionary dictionary];- _titles = [NSMutableDictionary dictionary];- return self;-}--- (CGFloat)heightOf:(UICollectionViewCell *)cell at:(NSIndexPath *)path fitting:(CGFloat)height {- NSString *unknown = nil;- SGArtistCell kind = classify(cell, &unknown);- [self record:kind at:path];- // See more reconfigures its cell in place (the footer goes, the row stays), which sizes the cell again- // but need not display it again.- [self fadeFooterOf:cell music:kind == SGArtistCellMusic retry:NO];- switch (kind) {- case SGArtistCellHeading: {- NSString *title = headingTitleIn(cell.contentView);- _titles[path] = title;- BOOL kept = [self headingKeptAt:path title:title];- _answered[path] = @(kept);- return kept ? headingHeight() : 0;- }- case SGArtistCellMusic:- [self settleHeadingAbove:path kept:YES];- return height;- case SGArtistCellLiked:- return sg_hideLiked ? 0 : height;- case SGArtistCellOther:- [self settleHeadingAbove:path kept:NO];- if (unknown) logUnknown(unknown, height);- return 0;- case SGArtistCellSpacer:- return 0;- case SGArtistCellPending:- case SGArtistCellLoading:- return height;- }- return height;-}--- (void)record:(SGArtistCell)kind at:(NSIndexPath *)path {- NSNumber *before = _kinds[path];- _kinds[path] = @(kind);- if (!before || before.integerValue == kind || !settles(before.integerValue) || !settles(kind)) return;- // Something else sits at this index now (See more put five tracks in): what was learnt about it and- // below it is stale.- for (NSMutableDictionary<NSIndexPath *, id> *map in @[_kinds, _settled, _titles]) {- NSMutableArray<NSIndexPath *> *stale = [NSMutableArray array];- for (NSIndexPath *key in map) {- if (key.section == path.section && (key.item > path.item || (map != (id)_kinds && key.item == path.item))) [stale addObject:key];- }- [map removeObjectsForKeys:stale];- }-}--- (BOOL)headingKeptAt:(NSIndexPath *)path title:(NSString *)title {- NSNumber *settled = _settled[path];- if (settled) return settled.boolValue;- NSNumber *below = _kinds[[NSIndexPath indexPathForItem:path.item + 1 inSection:path.section]];- if (below && below.integerValue == SGArtistCellMusic) return YES;- if (below && below.integerValue == SGArtistCellOther) return NO;- NSNumber *learnt = title ? sg_learntHeadings[title] : nil;- if (learnt) return learnt.boolValue;- for (NSIndexPath *key in _kinds) {- if (key.section == path.section && key.item < path.item && _kinds[key].integerValue == SGArtistCellHeading) return NO;- }- return YES;-}--- (void)settleHeadingAbove:(NSIndexPath *)path kept:(BOOL)kept {- if (path.item == 0) return;- NSIndexPath *above = [NSIndexPath indexPathForItem:path.item - 1 inSection:path.section];- NSNumber *kind = _kinds[above];- if (!kind || kind.integerValue != SGArtistCellHeading) return;- _settled[above] = @(kept);- NSString *title = _titles[above];- if (title) sg_learntHeadings[title] = @(kept);- NSNumber *answered = _answered[above];- if (!answered || answered.boolValue == kept) return;- [self resizeItemAt:above kept:kept];-}--// Self-sizing invalidation (iOS 16) sizes a shown cell again; a heading off screen is sized again when it-// scrolls in, and its layout item is invalidated meanwhile. After the current layout pass, not inside it.-- (void)resizeItemAt:(NSIndexPath *)path kept:(BOOL)kept {- __weak UICollectionView *weakView = self.view;- BOOL logged = _corrections++ < 3;- dispatch_async(dispatch_get_main_queue(), ^{- UICollectionView *view = weakView;- if (!view || path.section >= view.numberOfSections || path.item >= [view numberOfItemsInSection:path.section]) return;- UICollectionViewCell *cell = [view cellForItemAtIndexPath:path];- if (logged) SGLog(@"artist: heading %ld %@ by the cell under it, %@", (long)path.item, kept ? @"kept" : @"collapsed", cell ? @"on screen" : @"off screen");- if (cell && view.selfSizingInvalidation != UICollectionViewSelfSizingInvalidationDisabled) {- [cell invalidateIntrinsicContentSize];- return;- }- UICollectionViewLayout *layout = view.collectionViewLayout;- UICollectionViewLayoutInvalidationContext *context = [[layout.class invalidationContextClass] new];- [context invalidateItemsAtIndexPaths:@[path]];- [layout invalidateLayoutWithContext:context];- });-}--- (void)logSummarySoon {- __weak SGArtistList *weakSelf = self;- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{- SGArtistList *list = weakSelf;- if (!list) return;- NSUInteger counts[SGArtistCellOther + 1] = {0}, kept = 0;- for (NSNumber *kind in list->_kinds.allValues) {- if (kind.integerValue >= 0 && kind.integerValue <= SGArtistCellOther) counts[kind.integerValue]++;- }- for (NSNumber *answer in list->_answered.allValues) kept += answer.boolValue;- SGLog(@"artist: list after 2 s: heading %lu (kept %lu), music %lu, liked %lu, loading %lu, pending %lu, spacer %lu, collapsed %lu, corrections %lu",- (unsigned long)counts[SGArtistCellHeading], (unsigned long)kept, (unsigned long)counts[SGArtistCellMusic],- (unsigned long)counts[SGArtistCellLiked], (unsigned long)counts[SGArtistCellLoading], (unsigned long)counts[SGArtistCellPending],- (unsigned long)counts[SGArtistCellSpacer], (unsigned long)counts[SGArtistCellOther], (unsigned long)list->_corrections);- });-}--#pragma mark - restyle--- (void)willDisplay:(UICollectionViewCell *)cell at:(NSIndexPath *)path {- UICollectionView *view = self.view;- if (SGIsBaseSurface(view.layer.backgroundColor)) view.layer.backgroundColor = NULL;- SGArtistCell kind = classify(cell, NULL);- if (kind == SGArtistCellHeading) {- [self dressHeading:cell];- // A heading settled while it had no visible cell (sized ahead of the scroll, then the row under it)- // keeps its old size in the layout; the cell it finally shows in is sized again.- NSNumber *settled = path ? _settled[path] : nil, *answered = path ? _answered[path] : nil;- if (settled && answered && settled.boolValue != answered.boolValue) [self resizeItemAt:path kept:settled.boolValue];- } else {- for (UIView *sub in cell.contentView.subviews) {- if ([sub isKindOfClass:SGRSectionHeader.class]) sub.hidden = YES;- }- if (kind != SGArtistCellSpacer && kind != SGArtistCellOther) SGRStyleSpotifyCell(cell.contentView);- }- [self fadeFooterOf:cell music:kind == SGArtistCellMusic retry:YES];-}--static BOOL shownIn(UIView *view, UIView *root) {- if (CGRectGetWidth(view.bounds) <= 0) return NO;- for (UIView *v = view; v && v != root; v = v.superview) {- if (v.hidden) return NO;- }- return YES;-}--// Trees (01.txt): a section with somewhere to go shows Show all (id=Components.UI.NavigationButtonHome, an Encore tertiary-// button) in a passthrough view that is hidden otherwise (Popular).-- (void)dressHeading:(UICollectionViewCell *)cell {- static char headingKey, showAllKey;- UIView *spotify = SGRFindByIdentifier(cell.contentView, @"Components.UI.SectionHeadingHome", &headingKey);- NSString *title = headingTitleIn(spotify);- UIView *showAll = SGRFindByIdentifier(cell.contentView, @"Components.UI.NavigationButtonHome", &showAllKey);- UIControl *target = [showAll isKindOfClass:UIControl.class] && shownIn(showAll, cell) ? (UIControl *)showAll : nil;- if (spotify.alpha != 0) spotify.alpha = 0;- if (spotify && !spotify.accessibilityElementsHidden) spotify.accessibilityElementsHidden = YES;- SGRSectionHeader *header = [SGRSectionHeader headerInCell:cell title:title ?: @"" target:target];- header.hidden = NO;- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: section header \"%@\", show all %@", title, target ? NSStringFromClass(target.class) : @"none"); });-}--// The See more cell's gradient, found by level (01.txt, 08.txt: element content view > element view >-// clipping view > view > [the row element, GradientView, the footer element], four levels down); no-// other cell of the Music list carries one that high up, the biography card's is lower and collapsed.-static UIView *footerGradientIn(UIView *content) {- NSArray<UIView *> *level = content ? @[content] : @[];- for (NSUInteger depth = 0; depth <= 5 && level.count; depth++) {- NSMutableArray<UIView *> *next = [NSMutableArray array];- for (UIView *view in level) {- if ([view isKindOfClass:sg_gradientClass]) return view;- [next addObjectsFromArray:view.subviews];- }- level = next;- }- return nil;-}--// See more closes Popular with the sixth track fading out under the button (01.txt: the 88pt cell, the row-// element, a GradientView over all of it, then the footer element). The gradient is Spotify's base grey,-// a band on the field, so it goes and the row fades through a mask instead; both are put back when the-// cell comes back as anything else. A cell not laid out yet has a row of no size, so the mask is sized-// once more after the layout pass.-- (void)fadeFooterOf:(UICollectionViewCell *)cell music:(BOOL)music retry:(BOOL)retry {- UIView *row = nil, *gradient = music && sg_gradientClass ? footerGradientIn(cell.contentView) : nil;- NSArray<UIView *> *siblings = gradient.superview.subviews;- NSUInteger index = gradient ? [siblings indexOfObjectIdenticalTo:gradient] : NSNotFound;- if (index != NSNotFound && index > 0) row = siblings[index - 1];- if (!row) gradient = nil;- UIView *fadedRow = weakGet(cell, &kFadedRowKey), *hiddenGradient = weakGet(cell, &kHiddenGradientKey);- if (fadedRow && fadedRow != row && [fadedRow.layer.mask.name isEqualToString:kFadeName]) fadedRow.layer.mask = nil;- if (hiddenGradient && hiddenGradient != gradient && hiddenGradient.alpha == 0) hiddenGradient.alpha = 1;- if (!row || !gradient) {- if (fadedRow) weakSet(cell, &kFadedRowKey, nil);- if (hiddenGradient) weakSet(cell, &kHiddenGradientKey, nil);- return;- }- if (gradient.alpha != 0) gradient.alpha = 0;- if (hiddenGradient != gradient) weakSet(cell, &kHiddenGradientKey, gradient);- if (CGRectGetHeight(row.bounds) <= 0) {- if (!retry) return;- __weak SGArtistList *weakSelf = self;- __weak UICollectionViewCell *weakCell = cell;- dispatch_async(dispatch_get_main_queue(), ^{- UICollectionViewCell *later = weakCell;- if (later) [weakSelf fadeFooterOf:later music:classify(later, NULL) == SGArtistCellMusic retry:NO];- });- return;- }- CAGradientLayer *mask = [row.layer.mask.name isEqualToString:kFadeName] ? (CAGradientLayer *)row.layer.mask : nil;- [CATransaction begin];- [CATransaction setDisableActions:YES];- if (!mask) {- mask = [CAGradientLayer layer];- mask.name = kFadeName;- mask.colors = @[(id)UIColor.blackColor.CGColor, (id)UIColor.clearColor.CGColor];- mask.locations = @[@0.2, @1];- row.layer.mask = mask;- }- mask.frame = row.layer.bounds;- [CATransaction commit];- if (fadedRow != row) weakSet(cell, &kFadedRowKey, row);- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: See more row faded, Spotify's gradient hidden"); });-}--@end--// The list of a redesigned artist page's Music tab, kept on its collection view; NSNull for any other list.-static SGArtistList *listOf(UICollectionView *view) {- if (![view isKindOfClass:UICollectionView.class]) return nil;- id known = objc_getAssociatedObject(view, &kListKey);- if (known) return known == NSNull.null ? nil : known;- UIView *listView = view.superview;- // Not in its list view yet: asked again, not written off.- if (!listView) return nil;- // Only the first page of the tabs is Music (01.txt); a carousel inside a cell and the other tabs are left alone.- if (![listView isKindOfClass:sg_listViewClass]) {- objc_setAssociatedObject(view, &kListKey, NSNull.null, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- return nil;- }- BOOL pending = NO;- SGArtistPage *page = SGArtistPageOf(listView, &pending);- if (!page || listView.superview.subviews.firstObject != listView) {- if (!pending && view.window) objc_setAssociatedObject(view, &kListKey, NSNull.null, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- return nil;- }- SGArtistList *list = [SGArtistList new];- list.view = view;- objc_setAssociatedObject(view, &kListKey, list, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- if (SGIsBaseSurface(view.layer.backgroundColor)) view.layer.backgroundColor = NULL;- static dispatch_once_t once;- dispatch_once(&once, ^{- SGLog(@"artist: Music list found, %lu pages beside it", (unsigned long)listView.superview.subviews.count);- [list logSummarySoon];- });- return list;-}--%hook _TtC12Element_List18CollectionViewCell-- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)attributes {- UICollectionViewLayoutAttributes *result = %orig;- UICollectionViewCell *cell = (UICollectionViewCell *)self;- NSIndexPath *path = attributes.indexPath;- SGArtistList *list = path ? listOf((UICollectionView *)cell.superview) : nil;- if (!list) return result;- CGFloat height = [list heightOf:cell at:path fitting:result.size.height];- if (height == result.size.height) return result;- result.size = CGSizeMake(result.size.width, height);- if (height == 0) cell.clipsToBounds = YES;- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: first cell resized, %.0f tall", height); });- return result;-}-%end--%hook _TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView-- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {- %orig;- [listOf(collectionView) willDisplay:cell at:indexPath];-}-%end--%ctor {- if (!SGRedesignOn(@"artist")) return;- sg_listViewClass = NSClassFromString(@"_TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView");- sg_headingButtonClass = NSClassFromString(@"_TtCOOOE11Home_ECMKitO19LegacyUI_ECMCoreKit10Components18SectionHeadingHome2UI7Private28NoIntrinsicContentSizeButton");- sg_gradientClass = NSClassFromString(@"_TtC19LegacyUI_ECMCoreKit12GradientView");- sg_hideLiked = SGHidden(SGKeyRedesignArtistHideLikedSongs);- sg_learntHeadings = [NSMutableDictionary dictionary];- %init;- SGRequireClasses(@[- @"_TtC12Element_List18CollectionViewCell",- @"_TtC32CreativeWorkPlatform_TemplateKit28CreativeWorkTemplateListView",- @"_TtCOOOE11Home_ECMKitO19LegacyUI_ECMCoreKit10Components18SectionHeadingHome2UI7Private28NoIntrinsicContentSizeButton",- @"_TtC19LegacyUI_ECMCoreKit12GradientView",- ]);-}diff --git a/tweak/Sources/Redesign/Artist/ArtistPage.x b/tweak/Sources/Redesign/Artist/ArtistPage.xdeleted file mode 100644index f304f467..00000000--- a/tweak/Sources/Redesign/Artist/ArtistPage.x+++ /dev/null@@ -1,534 +0,0 @@-// Artist page redesign, the page (RedesignArtist.h): finds a redesigned artist page, lays the Kit's field-// behind it, puts the Kit's hero over Spotify's header and takes the tab strip away.-//-// Trees (trees/clean/artist/01.txt): LoadableTemplateViewController's view holds TemplateView-// (id=creator-page), and TemplateView the tab layout: an overlay scroll view that takes the pan-// (id=PCFFTabLayoutViewController.overlayScrollView) and over it the container scroll view-// (id=PCFFTabLayoutViewController.containerScrollView), whose stack holds the HeaderContainer (504 tall,-// 568 with a pre-save row under the buttons) and the tabs: the strip (id=Components.UI.TabsSectionHeading,-// 44 tall) over a paging scroll view of one list per tab. Scrolling down, the container stops at the-// header's height less 100 (02.txt: 468 of 568, 09.txt: 404 of 504) and Spotify keeps a 100pt band of-// its header pinned under the navigation bar while the list scrolls on.-//-// The page's URI comes from its hosting controller, MusicAppPageHostingViewController, a subclass of-// IdentifiedPageHostingViewController (objc-meta-Spotify.txt:1406777), whose spt_pageURI-// (objc-methods.txt:74510) SGRPageURI reads; an author's page is the same template with another URI.-//-// Spotify's header is ImageHeaderView: the photo (id=Components.Header.UI.ArtworkImage.ImageView holding an-// EncoreImageView, a UIImageView), the name (id=Encore.AdaptiveTitle around a CoreLabel), the listeners-// (id=Components.Header.UI.Metadata-internal), the explore deck of videos, and the buttons: Follow-// (id=Curation.FollowButtonElementKit.FollowButton, an Encore button), Shuffle (id=Components.UI.ShuffleButton,-// a UIButton whose 4pt green dot shows while shuffle is on) and Play (id=header-play-button, a PlayButtonView-// whose uiButtonTapped is its own action, objc-methods.txt:68122). It turns invisible and the hero lies over-// it in the HeaderContainer, so the hero scrolls with the page and Spotify's controls keep working under-// the glass buttons that fire them.-#import <objc/runtime.h>-#import "Core/SGCore.h"-#import "Settings/SGModPage.h"-#import "Redesign/Kit/SGRKit.h"-#import "RedesignArtist.h"--// The band of Spotify's header left pinned under the navigation bar (02.txt, 09.txt).-static const CGFloat kPinnedHeader = 100;--static Class sg_templateClass, sg_imageHeaderClass;-static char kPageKey, kArtworkContext;--@protocol SGArtistPlayButton-- (void)uiButtonTapped;-@end--static NSString *labelTextIn(UIView *root) {- __block NSString *text = nil;- if (!root) return nil;- SGForEachView(root, ^(UIView *view) {- if (!text && [view isKindOfClass:UILabel.class] && ((UILabel *)view).text.length) text = ((UILabel *)view).text;- });- return text;-}--static UIButton *buttonIn(UIView *root) {- __block UIButton *button = nil;- if (!root) return nil;- SGForEachView(root, ^(UIView *view) {- if (!button && [view isKindOfClass:UIButton.class]) button = (UIButton *)view;- });- return button;-}--// The shuffle button's dot (01.txt: a 4x4 UIView, hidden while shuffle is off).-static BOOL shuffleDotShown(UIView *shuffle) {- for (UIView *view in shuffle.subviews) {- CGFloat width = CGRectGetWidth(view.bounds);- if (width > 0 && width <= 6 && ![view isKindOfClass:UIImageView.class]) return !view.hidden && view.alpha > 0.01;- }- return NO;-}--// A tap on one of Spotify's controls: its registered action, else its own VoiceOver activation, which an-// Encore control that reads touches through a gesture recognizer still answers.-static BOOL fire(UIControl *control) {- if (!control) return NO;- return SGRFire(control) || [control accessibilityActivate];-}--@interface SGArtistPage () <SGRPlayerStateObserver>-- (instancetype)initWithURI:(NSString *)uri template:(UIView *)template;-- (void)templateDidLayout:(UIView *)template;-- (void)headerContainerDidLayout:(UIView *)container;-- (void)stockHeaderDidLayout:(UIView *)header;-- (BOOL)hideTabsIn:(UIView *)root;-@end--@implementation SGArtistPage {- SGRArtworkField *_field;- SGRHeroHeader *_hero;- SGRGlassButton *_shuffle, *_play, *_follow;- __weak UIScrollView *_container, *_overlay;- __weak UIImageView *_artworkView;- __weak UIView *_stockHeader, *_playControl;- __weak UIControl *_shuffleControl, *_followControl;- UIImage *_image;- CGFloat _containerY, _overlayY;- CFTimeInterval _lastMirror;- NSUInteger _missedReads;- BOOL _observing, _tabsHidden, _mirrorScheduled;-}--- (instancetype)initWithURI:(NSString *)uri template:(UIView *)template {- if (!(self = [super init])) return nil;- _uri = [uri copy];- _field = [[SGRArtworkField alloc] initWithFrame:template.bounds];- _field.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;- _field.userInteractionEnabled = NO;- [template insertSubview:_field atIndex:0];- // Spotify paints the page, its lists and its rows in its base grey (#121212); inside the template it- // is cleared now and whenever it is painted again, so the field shows through.- SGRRegisterClearRoot(template);- SGRAddPlayerStateObserver(self);- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: page %@, field and clear root in %@", uri, NSStringFromClass(template.class)); });- return self;-}--- (void)dealloc {- [self watchArtwork:nil];-}--#pragma mark - page--- (void)templateDidLayout:(UIView *)template {- if (template.subviews.firstObject != _field) [template insertSubview:_field atIndex:0];- if (!CGRectEqualToRect(_field.frame, template.bounds)) _field.frame = template.bounds;- if (!_observing) [self observeScrollIn:template];- if (!_tabsHidden) [self hideTabsIn:template];-}--- (void)observeScrollIn:(UIView *)template {- static char containerKey, overlayKey;- UIScrollView *container = (UIScrollView *)SGRFindByIdentifier(template, @"PCFFTabLayoutViewController.containerScrollView", &containerKey);- if (![container isKindOfClass:UIScrollView.class]) return;- UIScrollView *overlay = (UIScrollView *)SGRFindByIdentifier(template, @"PCFFTabLayoutViewController.overlayScrollView", &overlayKey);- _observing = YES;- _container = container;- SGRObserveOffset(container, self, ^(id owner, CGPoint offset) { [(SGArtistPage *)owner containerMoved:offset]; });- // The overlay takes the pan, so an overscroll may show there only; the container is where the header is.- if ([overlay isKindOfClass:UIScrollView.class]) {- _overlay = overlay;- SGRObserveOffset(overlay, self, ^(id owner, CGPoint offset) { [(SGArtistPage *)owner overlayMoved:offset]; });- }- static dispatch_once_t once;- dispatch_once(&once, ^{- SGLog(@"artist: scroll observed, container inset %.0f, overlay %@", container.adjustedContentInset.top, overlay ? @"found" : @"missing");- });-}--- (void)containerMoved:(CGPoint)offset {- _containerY = offset.y + _container.adjustedContentInset.top;- [self applyScroll];-}--- (void)overlayMoved:(CGPoint)offset {- _overlayY = offset.y + _overlay.adjustedContentInset.top;- if (_overlayY < 0 || _containerY <= 0) [self applyScroll];-}--// The hero's own scroll response: stretch on overscroll (from whichever scroll view shows it), drift, and-// the texts and buttons fading before the navigation bar. Only transforms and alphas change here.-- (void)applyScroll {- if (!_hero) return;- CGFloat y = _containerY;- if (y <= 0 && _overlayY < y) y = _overlayY;- CGFloat distance = MAX(0, CGRectGetHeight(_hero.bounds) - kPinnedHeader);- [_hero applyScrollOffset:y collapseDistance:distance];- if (y < -1) {- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: overscroll, container %.0f overlay %.0f", self->_containerY, self->_overlayY); });- } else if (distance > 0 && y >= distance) {- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: header pinned at %.0f, container %.0f overlay %.0f", distance, self->_containerY, self->_overlayY); });- }-}--// Trees (01.txt): the strip lives in a LegacyUI AutoLayoutStackView, so it goes invisible rather than-// hidden; the paging scroll view beside it moves up into its place and stops swiping, which leaves the-// Music list, the way Features/Artist/Artist.x hides it.-- (BOOL)hideTabsIn:(UIView *)root {- static char stripKey;- UIView *strip = SGRFindByIdentifier(root, @"Components.UI.TabsSectionHeading", &stripKey);- if (!strip.superview) return NO;- _tabsHidden = YES;- if (strip.alpha != 0) strip.alpha = 0;- if (strip.userInteractionEnabled) strip.userInteractionEnabled = NO;- if (!strip.accessibilityElementsHidden) strip.accessibilityElementsHidden = YES;- CGFloat lift = -CGRectGetHeight(strip.bounds);- NSUInteger pages = 0;- for (UIView *view in strip.superview.subviews) {- if (view == strip || ![view isKindOfClass:UIScrollView.class]) continue;- UIScrollView *paging = (UIScrollView *)view;- if (paging.scrollEnabled) paging.scrollEnabled = NO;- if (paging.transform.ty != lift) paging.transform = CGAffineTransformMakeTranslation(0, lift);- pages++;- }- if (lift == 0 || !pages) return YES;- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: tab strip hidden, %lu paging view moved up %.0f and not swiping", (unsigned long)pages, -lift); });- return YES;-}--#pragma mark - hero--- (SGRHeroHeader *)heroFor:(UIView *)container {- if (_hero) return _hero;- _hero = [[SGRHeroHeader alloc] initWithFrame:container.bounds];- [_hero bindToField:_field];- // English until Spotify's own words are read from its header (mirror:), a moment later.- _shuffle = [SGRGlassButton circleWithSymbol:@"shuffle" accessibilityLabel:@"Shuffle"];- _play = [SGRGlassButton capsuleWithSymbol:@"play.fill" title:@"Play" prominent:YES];- _follow = [SGRGlassButton capsuleWithSymbol:nil title:@"Follow" prominent:NO];- __weak SGArtistPage *weakSelf = self;- _shuffle.onTap = ^{ [weakSelf tapShuffle]; };- _play.onTap = ^{ [weakSelf tapPlay]; };- _follow.onTap = ^{ [weakSelf tapFollow]; };- SGRActionRow *row = [[SGRActionRow alloc] initWithFrame:_hero.actionSlot.bounds];- row.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;- row.buttons = @[_shuffle, _play, _follow];- [_hero.actionSlot addSubview:row];- [self updatePlay];- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: hero in the header container, %.0f tall", CGRectGetHeight(container.bounds)); });- return _hero;-}--- (void)headerContainerDidLayout:(UIView *)container {- SGRHeroHeader *hero = [self heroFor:container];- if (container.subviews.lastObject != hero) [container addSubview:hero];- if (!CGRectEqualToRect(hero.frame, container.bounds)) {- hero.frame = container.bounds;- [self applyScroll];- }- for (UIView *element in container.subviews) {- for (UIView *header in element.subviews) {- if ([header isKindOfClass:sg_imageHeaderClass]) [self stockHeaderDidLayout:header];- }- }-}--- (void)stockHeaderDidLayout:(UIView *)header {- if (header.alpha != 0 || header.userInteractionEnabled || !header.accessibilityElementsHidden) {- SGRSuppress(header);- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: Spotify's header hidden"); });- }- _stockHeader = header;- // Spotify shrinks its header into the pinned band while the page scrolls, laying it out every frame;- // what it shows does not change then, so it is read at full height only, and at most every 0.3 s with- // one more read after a burst of layouts.- UIView *container = header.superview.superview;- if (!_hero || CGRectGetHeight(header.bounds) < CGRectGetHeight(container.bounds) - 1 || _mirrorScheduled) return;- CFTimeInterval now = CACurrentMediaTime();- if (now - _lastMirror >= 0.3) {- _lastMirror = now;- [self mirror:header];- return;- }- [self mirrorLater:header];-}--- (void)mirrorLater:(UIView *)header {- if (_mirrorScheduled) return;- _mirrorScheduled = YES;- __weak SGArtistPage *weakSelf = self;- __weak UIView *weakHeader = header;- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{- SGArtistPage *page = weakSelf;- if (!page) return;- page->_mirrorScheduled = NO;- page->_lastMirror = CACurrentMediaTime();- UIView *later = weakHeader;- if (later) [page mirror:later];- });-}--// Spotify's controls, looked for inside its header only: the music videos shelf has a header-play-button-// and the biography card a follow button of their own (10.txt).-- (void)findControlsIn:(UIView *)header {- static char playKey, shuffleKey, followKey;- _playControl = SGRFindByIdentifier(header, @"header-play-button", &playKey);- UIView *shuffle = SGRFindByIdentifier(header, @"Components.UI.ShuffleButton", &shuffleKey);- _shuffleControl = [shuffle isKindOfClass:UIControl.class] ? (UIControl *)shuffle : nil;- UIView *follow = SGRFindByIdentifier(header, @"Curation.FollowButtonElementKit.FollowButton", &followKey);- _followControl = [follow isKindOfClass:UIControl.class] ? (UIControl *)follow : nil;-}--- (void)mirror:(UIView *)header {- static char titleKey, metaKey, artworkKey, exploreKey;- NSString *title = labelTextIn(SGRFindByIdentifier(header, @"Encore.AdaptiveTitle", &titleKey));- if (title.length) _hero.title = title;- UILabel *meta = (UILabel *)SGRFindByIdentifier(header, @"Components.Header.UI.Metadata-internal", &metaKey);- if ([meta isKindOfClass:UILabel.class]) _hero.meta = meta.text;-- UIImageView *artwork = nil;- for (UIView *view in SGRFindByIdentifier(header, @"Components.Header.UI.ArtworkImage.ImageView", &artworkKey).subviews) {- if ([view isKindOfClass:UIImageView.class]) {- artwork = (UIImageView *)view;- break;- }- }- if (artwork != _artworkView) [self watchArtwork:artwork];-- [self findControlsIn:header];- UIView *shuffle = _shuffleControl, *follow = _followControl;-- // The explore deck plays short videos in the header (01.txt: SPTVideoSurfaceImpl under- // Components.UI.WatchFeedEntityExplorerButton). It goes transparent, never hidden: hiding it, though it- // is no arranged view itself, changes the size of the button the header's Reprise OverflowStackView- // arranges, and that stack traps in updateConstraints (crash 2026-09-17 09:30, the same trap as- // Features/Artist/Artist.x on 2026-09-15). Spotify's whole header is transparent already.- UIView *deck = SGRFindByIdentifier(header, @"Components.UI.WatchFeedEntityExplorerButton", &exploreKey).subviews.firstObject;- if (deck.alpha != 0) deck.alpha = 0;-- [self mirrorControls];- // The buttons and the photo can arrive after the header's last layout at full height (Features/Artist/- // Artist.x watches the button row's stack for that), so a read that missed one is repeated, for a while.- if (!(title.length && artwork && _playControl && shuffle && follow) && _missedReads < 10) {- _missedReads++;- [self mirrorLater:header];- }- static dispatch_once_t once;- dispatch_once(&once, ^{- SGLog(@"artist: header read, title %@, meta %@, artwork %@, play %@, shuffle %@, follow %@, explore deck %@",- title.length ? @"yes" : @"no", meta.text.length ? @"yes" : @"no", artwork ? @"yes" : @"no",- NSStringFromClass(self->_playControl.class) ?: @"missing", NSStringFromClass(shuffle.class) ?: @"missing",- NSStringFromClass(follow.class) ?: @"missing", deck ? @"hidden" : @"missing");- });-}--// The photo arrives after the header is built, and setting it lays nothing out, so the image view is watched.-- (void)watchArtwork:(UIImageView *)view {- UIImageView *watched = _artworkView;- _artworkView = nil;- if (watched) {- @try {- [watched removeObserver:self forKeyPath:@"image" context:&kArtworkContext];- } @catch (NSException *exception) {- SGLog(@"artist: artwork observation was already gone (%@)", exception.reason);- }- }- if (!view) return;- _artworkView = view;- [view addObserver:self forKeyPath:@"image" options:NSKeyValueObservingOptionInitial context:&kArtworkContext];-}--- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {- if (context != &kArtworkContext) {- [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];- return;- }- UIImage *image = [object isKindOfClass:UIImageView.class] ? ((UIImageView *)object).image : nil;- if (!image || image == _image) return;- _image = image;- [_hero setImage:image animated:YES];- [_field setArtwork:image identity:nil animated:YES];- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: hero image %.0fx%.0f@%.0f", image.size.width, image.size.height, image.scale); });-}--#pragma mark - actions--- (void)mirrorControls {- // Spotify builds a control anew when its state changes (a follow), which lets go of the old one.- UIView *header = _stockHeader;- if (header && (!_playControl || !_shuffleControl || !_followControl)) [self findControlsIn:header];- UIControl *shuffle = _shuffleControl, *follow = _followControl;- _shuffle.enabled = shuffle != nil;- _follow.enabled = follow != nil;- _play.enabled = _playControl != nil;- if (shuffle) {- _shuffle.on = shuffleDotShown(shuffle);- if (shuffle.accessibilityLabel.length) _shuffle.accessibilityLabel = shuffle.accessibilityLabel;- }- NSString *followTitle = labelTextIn(follow) ?: follow.accessibilityLabel;- if (followTitle.length) [_follow setTitle:followTitle animated:YES];- [self updatePlay];-}--// Playing means this artist's context is the player's and it is not paused; the glyph follows the-// player, the title is Spotify's own for its play button.-- (void)updatePlay {- SPTPlayerState *state = SGRPlayerState();- BOOL playing = state.isPlaying && !state.isPaused && [SGRURIString(state.contextURI) isEqualToString:_uri];- [_play setSymbol:playing ? @"pause.fill" : @"play.fill" animated:YES];- NSString *title = buttonIn(_playControl).accessibilityLabel;- [_play setTitle:title.length ? title : playing ? @"Pause" : @"Play" animated:YES];-}--- (void)playerStateDidChange:(SPTPlayerState *)state {- if (!_hero) return;- [self mirrorControls];- [self refreshSoon];-}--// Spotify's controls change their look a moment after the tap, once the player or the follow state answers.-- (void)refreshSoon {- __weak SGArtistPage *weakSelf = self;- for (NSNumber *delay in @[@0.35, @1.2]) {- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay.doubleValue * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{- [weakSelf mirrorControls];- });- }-}--- (void)tapPlay {- UIView *control = _playControl;- BOOL direct = [control respondsToSelector:@selector(uiButtonTapped)];- BOOL fired = direct;- if (direct) [(id<SGArtistPlayButton>)control uiButtonTapped];- else fired = fire(buttonIn(control));- static dispatch_once_t once;- dispatch_once(&once, ^{- SPTPlayerState *state = SGRPlayerState();- SGLog(@"artist: play %@ (%@), player context %@ paused %d", fired ? @"fired" : @"fired nothing", direct ? @"uiButtonTapped" : @"its button",- SGRURIString(state.contextURI), state.isPaused);- });- [self refreshSoon];-}--- (void)tapShuffle {- UIControl *control = _shuffleControl;- BOOL before = control ? shuffleDotShown(control) : NO;- BOOL fired = fire(control);- static dispatch_once_t once;- dispatch_once(&once, ^{- __weak UIControl *weakControl = control;- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{- UIControl *later = weakControl;- SGLog(@"artist: shuffle %@, dot %d then %d", fired ? @"fired" : @"fired nothing", before, later ? shuffleDotShown(later) : -1);- });- });- [self refreshSoon];-}--- (void)tapFollow {- UIControl *control = _followControl;- NSString *before = labelTextIn(control);- BOOL fired = fire(control);- static dispatch_once_t once;- dispatch_once(&once, ^{- __weak UIControl *weakControl = control;- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{- UIControl *later = weakControl;- SGLog(@"artist: follow %@, label \"%@\" then \"%@\", selected %d", fired ? @"fired" : @"fired nothing", before, labelTextIn(later), later.isSelected);- });- });- [self refreshSoon];-}--@end--SGArtistPage *SGArtistPageOf(UIView *view, BOOL *pending) {- if (pending) *pending = NO;- UIView *template = view;- while (template && ![template isKindOfClass:sg_templateClass]) template = template.superview;- if (!template) {- if (pending) *pending = view.window == nil;- return nil;- }- id known = objc_getAssociatedObject(template, &kPageKey);- if (known) return known == NSNull.null ? nil : known;- NSString *uri = SGRURIString(SGRPageURI(template));- if (!uri) {- if (pending) *pending = YES;- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"artist: a creator page has no URI yet, asked again on its next layout"); });- return nil;- }- if (![uri hasPrefix:@"spotify:artist:"]) {- objc_setAssociatedObject(template, &kPageKey, NSNull.null, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- return nil;- }- SGArtistPage *page = [[SGArtistPage alloc] initWithURI:uri template:template];- objc_setAssociatedObject(template, &kPageKey, page, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- return page;-}--%hook _TtC32CreativeWorkPlatform_TemplateKit12TemplateView-- (void)layoutSubviews {- %orig;- [SGArtistPageOf((UIView *)self, NULL) templateDidLayout:(UIView *)self];-}-%end--%hook _TtC32CreativeWorkPlatform_TemplateKitP33_07D2BCE376DED6F379FF5AAB5402E56315HeaderContainer-- (void)layoutSubviews {- %orig;- [SGArtistPageOf((UIView *)self, NULL) headerContainerDidLayout:(UIView *)self];-}-%end--// Hidden from its first moment in the window, before its first layout could show Spotify's own header.-%hook _TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView-- (void)didMoveToWindow {- %orig;- UIView *header = (UIView *)self;- if (header.window) [SGArtistPageOf(header, NULL) stockHeaderDidLayout:header];-}--- (void)layoutSubviews {- %orig;- [SGArtistPageOf((UIView *)self, NULL) stockHeaderDidLayout:(UIView *)self];-}-%end--// The strip is laid out with the tabs' controller view, which holds it (01.txt: tabsViewAccessibilityID).-%hook _TtC28CreativeWorkPlatform_TabsKit16TabBarController-- (void)viewDidLayoutSubviews {- %orig;- UIView *view = ((UIViewController *)self).view;- SGArtistPage *page = SGArtistPageOf(view, NULL);- if (!page) return;- if (![page hideTabsIn:view] && view.superview) [page hideTabsIn:view.superview];-}-%end--%ctor {- // No remote-config flags are forced for this page. Forcing the creator flags (the Video tab, the video,- // collaborator and facts sections off, the context menu moved into the navigation bar) built a header- // the clean trees never showed, and the header's Reprise OverflowStackView trapped in updateConstraints- // on every artist page (crashes 2026-09-17 09:30, 09:44, 09:48, from the header's didMoveToWindow and- // layoutSubviews). The list's allowlist removes those sections as Spotify builds them.- SGRedesignRegisterRows(@"artist", ^NSArray<SGModRow *> *{- return @[SGHideRow(@"Hide songs you liked", @"The row of this artist's songs in your Liked Songs", SGKeyRedesignArtistHideLikedSongs)];- });- if (!SGRedesignOn(@"artist")) return;- sg_templateClass = NSClassFromString(@"_TtC32CreativeWorkPlatform_TemplateKit12TemplateView");- sg_imageHeaderClass = NSClassFromString(@"_TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView");- %init;- SGRequireClasses(@[- @"_TtC32CreativeWorkPlatform_TemplateKit12TemplateView",- @"_TtC32CreativeWorkPlatform_TemplateKitP33_07D2BCE376DED6F379FF5AAB5402E56315HeaderContainer",- @"_TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView",- @"_TtC28CreativeWorkPlatform_TabsKit16TabBarController",- @"_TtC28EncoreConsumerMobile_BaseKit14PlayButtonView",- ]);-}diff --git a/tweak/Sources/Redesign/Artist/RedesignArtist.h b/tweak/Sources/Redesign/Artist/RedesignArtist.hdeleted file mode 100644index 5acf2b3f..00000000--- a/tweak/Sources/Redesign/Artist/RedesignArtist.h+++ /dev/null@@ -1,25 +0,0 @@-// The artist page redesigned (Mod Settings > Redesign > Artist): Spotify's own page and its Music list-// stay, for the data, the rows and every row interaction, while the chrome is the Kit's: one field-// colour behind the whole page, the hero with the photo dissolving into it, the glass Shuffle, Play and-// Follow firing Spotify's own controls, and the Kit's section headers. Everything on the list that is-// not music collapses, told apart by accessibility identifiers, so it works in any language.-//-// ArtistPage.x the page: finding it by its URI, the field, the hero in Spotify's header, the tabs-// ArtistList.x the Music list: which cells stay, the section headers, the rows restyled-//-// Trees: trees/clean/artist/01-07.txt (Shawn Mendes, with an artist pick and a release countdown) and-// 08-13.txt (The Weeknd, with a liked songs row), recorded stock on 9.1.78.-#import <UIKit/UIKit.h>--// Off until switched on: the row of this artist's songs in Liked Songs collapses with the rest.-#define SGKeyRedesignArtistHideLikedSongs @"spotifyglass.redesign.artist.hideLikedSongs"--// The state of one redesigned artist page, kept on its TemplateView.-@interface SGArtistPage : NSObject-@property (nonatomic, readonly, copy) NSString *uri;-@end--// The redesigned artist page `view` is on, found up its superviews. nil on any other page (an author's-// page shares the template and the creator-page identifier, so the URI decides), and nil with-// `pending` set while the page's URI cannot be read yet, so the caller asks again later.-SGArtistPage *SGArtistPageOf(UIView *view, BOOL *pending);diff --git a/tweak/Sources/Redesign/Kit/SGRField.h b/tweak/Sources/Redesign/Kit/SGRField.hindex afc09e87..4b69a05b 100644--- a/tweak/Sources/Redesign/Kit/SGRField.h+++ b/tweak/Sources/Redesign/Kit/SGRField.h@@ -1,7 +1,6 @@// The artwork field: one continuous colour taken from the artwork's bottom edge (SGRPalette.h) behind// a whole redesigned page, with no card and no seam anywhere. The player's field also carries the-// artwork itself at the top, blurred and dimmed and dissolving into the colour (showsBackdrop); the-// artist page's hero draws its own photo (SGRHero.h), so its field is the colour alone.+// artwork itself at the top, blurred and dimmed and dissolving into the colour (showsBackdrop).//// Nothing is blurred live and nothing is masked: the view draws a solid colour layer, a black// gradient layer under AMOLED and at most one bitmap layer rendered off the main thread, so it costsdiff --git a/tweak/Sources/Redesign/Kit/SGRGlass.h b/tweak/Sources/Redesign/Kit/SGRGlass.hindex ed51e45d..6bc78b0f 100644--- a/tweak/Sources/Redesign/Kit/SGRGlass.h+++ b/tweak/Sources/Redesign/Kit/SGRGlass.h@@ -1,32 +1,12 @@-// Glass for the redesign's control layer, and only for it: never behind rows, cards or text. Adjacent-// glass shares one UIGlassContainerEffect, since glass cannot sample glass, and glass that takes a-// touch is interactive. Built on Core/SGGlass.m (the effect made through +effectWithStyle:).+// Glass for the redesign's control layer, and only for it: never behind rows, cards or text. Built on+// Core/SGGlass.m (the effect made through +effectWithStyle:). Under Reduce Transparency a shape is a+// solid SGRSolidGlassFill, on any OS; before iOS 26 without it, a dark thin material blur. Nothing+// touches a glass class on an OS without them.//-// Two stand-ins, chosen as a piece is laid out: under Reduce Transparency every shape and button is a-// solid SGRSolidGlassFill (a light fill for a prominent button), on any OS; before iOS 26 without it,-// a dark thin material blur with no container. Nothing touches a glass class on an OS without them.-//-// Ownership: a backing belongs to its host (associated with it under the caller's key); buttons and-// the action row belong to whoever adds them.+// Ownership: a shape belongs to the control it is made in (associated with it under the caller's key).// Threading: main thread only.#import <UIKit/UIKit.h>-typedef NS_ENUM(NSInteger, SGRGlassShape) {- SGRGlassCircle, // round, from the frame's shorter side- SGRGlassCapsule,-};--// Glass behind someone else's controls: one container spanning the host, behind everything the host-// draws (zPosition -1), holding a shape per frame, taking no touches, so Spotify's own buttons keep-// their actions, state and accessibility on top of it.-@interface SGRGlassBacking : UIView-// The host's backing under `key`, made on first use and put back at the bottom of the host whenever-// something moved it.-+ (instancetype)backingInHost:(UIView *)host key:(const void *)key;-// Frames in the host's coordinates; shapes are reused, and those past the count are hidden.-- (void)setShapes:(NSArray<NSValue *> *)framesInHost shape:(SGRGlassShape)shape;-@end-// A glass circle inside someone else's round control, `side` across, behind everything the control// draws (zPosition -1) and kept at its middle by the autoresizing mask. Being the control's own// subview it goes wherever the control goes: a frame worked out from outside goes stale when Spotify@@ -34,25 +14,3 @@ typedef NS_ENUM(NSInteger, SGRGlassShape) {// laid the unit out again, trees/continuous/1.txt 2026-09-17). Takes no touches; made once per control// under `key`, and made again when Reduce Transparency changes the kind of shape.UIView *SGRGlassInside(UIView *control, const void *key, CGFloat side);--// A glass button of the redesign's own: a circle with a symbol, or a capsule with a symbol and a-// title, prominent (light glass, dark content) for the one main action of a screen. UIKit's glass-// button configuration on iOS 26, with its own press response; a spring to 0.96 on the stand-ins.-@interface SGRGlassButton : UIButton-+ (instancetype)circleWithSymbol:(NSString *)symbol accessibilityLabel:(NSString *)label;-+ (instancetype)capsuleWithSymbol:(NSString *)symbol title:(NSString *)title prominent:(BOOL)prominent;-@property (nonatomic, copy) void (^onTap)(void);-// On tints the symbol with SGRAccent (shuffle on, following); it is also the accessibility value.-@property (nonatomic, getter=isOn) BOOL on;-// A symbol swap replaces the glyph with UIKit's symbol transition (none under Reduce Motion); a title-// swap crossfades. The same symbol or title again is a no-op.-- (void)setSymbol:(NSString *)symbol animated:(BOOL)animated;-- (void)setTitle:(NSString *)title animated:(BOOL)animated;-@end--// A centred row of glass buttons in one container, SGRActionSpacing apart and SGRActionHeight tall:-// circles SGRActionHeight wide, a prominent capsule at least 132, other capsules 96 to 140. Its-// own touches pass through; only the buttons take them.-@interface SGRActionRow : UIView-@property (nonatomic, copy) NSArray<UIButton *> *buttons;-@enddiff --git a/tweak/Sources/Redesign/Kit/SGRGlass.m b/tweak/Sources/Redesign/Kit/SGRGlass.mindex 59907295..edff4de8 100644--- a/tweak/Sources/Redesign/Kit/SGRGlass.m+++ b/tweak/Sources/Redesign/Kit/SGRGlass.m@@ -2,10 +2,6 @@#import "SGRGlass.h"#import "SGRTokens.h"-static const CGFloat kSymbolSize = 17, kPressScale = 0.96;-static const CGFloat kProminentMinWidth = 132, kCapsuleMinWidth = 96, kCapsuleMaxWidth = 140, kCapsulePadding = 20;-static const NSTimeInterval kTitleFade = 0.2;-typedef NS_ENUM(NSInteger, SGRGlassMode) {SGRGlassModeGlass,SGRGlassModeBlur,@@ -18,22 +14,6 @@ static SGRGlassMode glassMode(void) {return SGRGlassModeBlur;}-// The container glass shapes merge in, or a plain view where there is no glass to merge.-static UIView *newContainer(SGRGlassMode mode, CGFloat spacing) {- if (mode == SGRGlassModeGlass) {- if (@available(iOS 26.0, *)) {- UIGlassContainerEffect *effect = [UIGlassContainerEffect new];- effect.spacing = spacing;- return [[UIVisualEffectView alloc] initWithEffect:effect];- }- }- return [UIView new];-}--static UIView *contentOf(UIView *container) {- return [container isKindOfClass:UIVisualEffectView.class] ? ((UIVisualEffectView *)container).contentView : container;-}-static UIView *newShape(SGRGlassMode mode) {UIView *shape;switch (mode) {@@ -86,308 +66,3 @@ UIView *SGRGlassInside(UIView *control, const void *key, CGFloat side) {if (!CGPointEqualToPoint(shape.center, middle)) shape.center = middle;return shape;}--#pragma mark - backing--@implementation SGRGlassBacking {- UIView *_container;- NSMutableArray<UIView *> *_shapes;- SGRGlassMode _mode;-}--+ (instancetype)backingInHost:(UIView *)host key:(const void *)key {- if (!host || !key) return nil;- SGRGlassBacking *backing = objc_getAssociatedObject(host, key);- if (!backing) {- backing = [[self alloc] initWithFrame:host.bounds];- objc_setAssociatedObject(host, key, backing, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- }- if (backing.superview != host) [host insertSubview:backing atIndex:0];- if (!CGRectEqualToRect(backing.frame, host.bounds)) backing.frame = host.bounds;- return backing;-}--- (instancetype)initWithFrame:(CGRect)frame {- if (!(self = [super initWithFrame:frame])) return nil;- self.userInteractionEnabled = NO;- self.accessibilityElementsHidden = YES;- // Behind whatever the host puts in at index 0 after it, as the panes of Core/SGGlass.m are.- self.layer.zPosition = -1;- _shapes = [NSMutableArray array];- _mode = -1;- return self;-}--- (void)layoutSubviews {- [super layoutSubviews];- _container.frame = self.bounds;-}--// Reduce Transparency can change while the page is open; the shapes are made again for it.-- (void)rebuildIfNeeded {- SGRGlassMode mode = glassMode();- if (mode == _mode) return;- _mode = mode;- [_shapes makeObjectsPerformSelector:@selector(removeFromSuperview)];- [_shapes removeAllObjects];- [_container removeFromSuperview];- _container = newContainer(mode, SGRGlassSpacing);- _container.userInteractionEnabled = NO;- _container.frame = self.bounds;- [self addSubview:_container];-}--- (UIView *)newShape {- return newShape(_mode);-}--- (void)setShapes:(NSArray<NSValue *> *)framesInHost shape:(SGRGlassShape)kind {- [self rebuildIfNeeded];- NSUInteger count = 0;- for (NSValue *value in framesInHost) {- CGRect frame = [self convertRect:value.CGRectValue fromView:self.superview];- if (CGRectIsEmpty(frame) || CGRectIsNull(frame)) continue;- if (kind == SGRGlassCircle) {- CGFloat side = MIN(frame.size.width, frame.size.height);- frame = CGRectMake(CGRectGetMidX(frame) - side / 2, CGRectGetMidY(frame) - side / 2, side, side);- }- while (_shapes.count <= count) {- UIView *shape = [self newShape];- [contentOf(_container) addSubview:shape];- [_shapes addObject:shape];- }- UIView *shape = _shapes[count++];- shape.hidden = NO;- if (!CGRectEqualToRect(shape.frame, frame)) {- shape.frame = frame;- SGShapeGlass(shape, frame.size.height / 2, YES);- }- }- for (NSUInteger i = count; i < _shapes.count; i++) _shapes[i].hidden = YES;-}--@end--#pragma mark - buttons--@interface SGRGlassButton ()-- (CGFloat)rowWidth;-@end--@implementation SGRGlassButton {- NSString *_symbol;- NSString *_title;- BOOL _prominent;- BOOL _circle;- SGRGlassMode _mode;-}--+ (instancetype)circleWithSymbol:(NSString *)symbol accessibilityLabel:(NSString *)label {- SGRGlassButton *button = [[self alloc] initWithFrame:CGRectMake(0, 0, SGRActionHeight, SGRActionHeight)];- button->_circle = YES;- button->_symbol = [symbol copy];- button.accessibilityLabel = label;- [button configure];- return button;-}--+ (instancetype)capsuleWithSymbol:(NSString *)symbol title:(NSString *)title prominent:(BOOL)prominent {- SGRGlassButton *button = [[self alloc] initWithFrame:CGRectMake(0, 0, kCapsuleMinWidth, SGRActionHeight)];- button->_symbol = [symbol copy];- button->_title = [title copy];- button->_prominent = prominent;- [button configure];- return button;-}--- (instancetype)initWithFrame:(CGRect)frame {- if (!(self = [super initWithFrame:frame])) return nil;- _mode = -1;- [self addTarget:self action:@selector(tapped) forControlEvents:UIControlEventPrimaryActionTriggered];- [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(settingsChanged:) name:UIAccessibilityReduceTransparencyStatusDidChangeNotification object:nil];- [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(settingsChanged:) name:UIContentSizeCategoryDidChangeNotification object:nil];- return self;-}--- (void)dealloc {- [NSNotificationCenter.defaultCenter removeObserver:self];-}--- (void)tapped {- if (self.onTap) self.onTap();-}--- (void)settingsChanged:(NSNotification *)note {- [self configure];-}--// Above the Large content size the title would outgrow the 48pt button, so only the symbol is shown-// and the title stays the accessibility label.-static BOOL titleFits(void) {- UIContentSizeCategory current = UIApplication.sharedApplication.preferredContentSizeCategory;- return UIContentSizeCategoryCompareToCategory(current, UIContentSizeCategoryLarge) != NSOrderedDescending;-}--- (UIColor *)contentColor {- if (_on) return SGRAccent();- return _prominent ? UIColor.blackColor : SGRPrimary();-}--- (void)configure {- SGRGlassMode mode = glassMode();- UIButtonConfiguration *config = nil;- if (mode == SGRGlassModeGlass) {- if (@available(iOS 26.0, *)) {- config = _prominent ? [UIButtonConfiguration prominentGlassButtonConfiguration] : [UIButtonConfiguration glassButtonConfiguration];- if (_prominent) config.baseBackgroundColor = [UIColor colorWithWhite:0.96 alpha:1];- }- }- if (!config) {- config = [UIButtonConfiguration filledButtonConfiguration];- config.baseBackgroundColor = _prominent ? [UIColor colorWithWhite:0.96 alpha:1] : (mode == SGRGlassModeBlur ? [UIColor colorWithWhite:1 alpha:0.12] : SGRSolidGlassFill());- if (mode == SGRGlassModeBlur && !_prominent) {- config.background.customView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemThinMaterialDark]];- }- }- _mode = mode;- config.cornerStyle = UIButtonConfigurationCornerStyleCapsule;- config.baseForegroundColor = [self contentColor];- config.image = _symbol ? [UIImage systemImageNamed:_symbol] : nil;- config.preferredSymbolConfigurationForImage = [UIImageSymbolConfiguration configurationWithPointSize:kSymbolSize weight:UIImageSymbolWeightSemibold];- config.imagePadding = 6;- if (_circle) {- config.contentInsets = NSDirectionalEdgeInsetsZero;- } else {- config.contentInsets = NSDirectionalEdgeInsetsMake(0, kCapsulePadding, 0, kCapsulePadding);- BOOL showTitle = _title.length && (titleFits() || !_symbol);- UIFont *font = SGRFont(UIFontTextStyleBody, UIFontWeightSemibold, UIContentSizeCategoryLarge);- config.attributedTitle = showTitle ? [[NSAttributedString alloc] initWithString:_title attributes:@{NSFontAttributeName: font}] : nil;- self.accessibilityLabel = _title;- }- self.showsLargeContentViewer = YES;- self.largeContentTitle = _title ?: self.accessibilityLabel;- self.largeContentImage = config.image;- self.configuration = config;-}--- (void)setOn:(BOOL)on {- self.accessibilityValue = on ? @"On" : @"Off";- if (on == _on) return;- _on = on;- [self configure];-}--- (void)setSymbol:(NSString *)symbol animated:(BOOL)animated {- if (!symbol || [symbol isEqualToString:_symbol]) return;- _symbol = [symbol copy];- if (@available(iOS 17.0, *)) self.symbolAnimationEnabled = animated && !SGRReduceMotion() && self.window;- [self configure];-}--- (void)setTitle:(NSString *)title animated:(BOOL)animated {- if (!title || [title isEqualToString:_title]) return;- _title = [title copy];- if (!animated || !self.window) {- [self configure];- return;- }- [UIView transitionWithView:self duration:kTitleFade options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction animations:^{- [self configure];- } completion:nil];-}--// UIKit's glass buttons answer a press themselves; the stand-ins get the Kit's press spring.-- (void)setHighlighted:(BOOL)highlighted {- [super setHighlighted:highlighted];- if (_mode == SGRGlassModeGlass) return;- SGRAnimate(SGRMotionPress, ^{- self.transform = highlighted ? CGAffineTransformMakeScale(kPressScale, kPressScale) : CGAffineTransformIdentity;- }, nil);-}--// The width the action row gives the button.-- (CGFloat)rowWidth {- if (_circle) return SGRActionHeight;- CGFloat natural = ceil([self sizeThatFits:CGSizeMake(CGFLOAT_MAX, SGRActionHeight)].width);- if (_prominent) return MAX(kProminentMinWidth, natural);- return MIN(kCapsuleMaxWidth, MAX(kCapsuleMinWidth, natural));-}--@end--#pragma mark - action row--@implementation SGRActionRow {- UIView *_container;- SGRGlassMode _mode;-}--- (instancetype)initWithFrame:(CGRect)frame {- if (!(self = [super initWithFrame:frame])) return nil;- _mode = -1;- [self rebuildIfNeeded];- [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(transparencyChanged:) name:UIAccessibilityReduceTransparencyStatusDidChangeNotification object:nil];- return self;-}--- (void)dealloc {- [NSNotificationCenter.defaultCenter removeObserver:self];-}--- (void)transparencyChanged:(NSNotification *)note {- [self rebuildIfNeeded];- [self setNeedsLayout];-}--- (void)rebuildIfNeeded {- SGRGlassMode mode = glassMode();- if (mode == _mode) return;- _mode = mode;- [_container removeFromSuperview];- _container = newContainer(mode, SGRActionSpacing);- [self addSubview:_container];- for (UIButton *button in _buttons) [contentOf(_container) addSubview:button];-}--- (void)setButtons:(NSArray<UIButton *> *)buttons {- for (UIButton *button in _buttons) {- if (![buttons containsObject:button]) [button removeFromSuperview];- }- _buttons = [buttons copy];- for (UIButton *button in _buttons) [contentOf(_container) addSubview:button];- [self setNeedsLayout];-}--static CGFloat widthInRow(UIButton *button) {- if ([button isKindOfClass:SGRGlassButton.class]) return [(SGRGlassButton *)button rowWidth];- CGFloat natural = ceil([button sizeThatFits:CGSizeMake(CGFLOAT_MAX, SGRActionHeight)].width);- return MIN(kCapsuleMaxWidth, MAX(kCapsuleMinWidth, natural));-}--- (CGSize)sizeThatFits:(CGSize)size {- CGFloat total = 0;- for (UIButton *button in _buttons) total += widthInRow(button);- if (_buttons.count > 1) total += SGRActionSpacing * (_buttons.count - 1);- return CGSizeMake(total, SGRActionHeight);-}--- (void)layoutSubviews {- [super layoutSubviews];- CGSize row = [self sizeThatFits:self.bounds.size];- CGSize bounds = self.bounds.size;- _container.frame = CGRectMake(floor((bounds.width - row.width) / 2), floor((bounds.height - row.height) / 2), row.width, row.height);- CGFloat x = 0;- for (UIButton *button in _buttons) {- CGFloat width = widthInRow(button);- button.bounds = CGRectMake(0, 0, width, SGRActionHeight);- button.center = CGPointMake(x + width / 2, SGRActionHeight / 2);- x += width + SGRActionSpacing;- }-}--- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {- UIView *hit = [super hitTest:point withEvent:event];- return (hit == self || hit == _container || hit == contentOf(_container)) ? nil : hit;-}--@enddiff --git a/tweak/Sources/Redesign/Kit/SGRHero.h b/tweak/Sources/Redesign/Kit/SGRHero.hdeleted file mode 100644index 764b44f4..00000000--- a/tweak/Sources/Redesign/Kit/SGRHero.h+++ /dev/null@@ -1,36 +0,0 @@-// The hero header of a redesigned page (the artist page first): the picture across the full width-// under the status bar, its lower part going soft through a blurred copy and dissolving into the-// field colour, the title and a meta line over the dissolved part, and a slot for the action row-// (SGRGlass.h) under them. Laid out for whatever height it is given, measured from its bottom edge:-//-// title bottom at H - 98, large title bold, up to 2 lines, centred, scales down to 0.7-// meta H - 94, 18 tall, footnote in SGRSecondary, hidden while empty-// actionSlot H - 64, 48 tall, full width-// dissolve field colour from transparent at 0.45 H to opaque at H-//-// Scrolling moves only transforms and alphas (applyScrollOffset:), never frames or layout: the picture-// stretches from its bottom edge on overscroll, drifts at 0.3 of the scroll speed after that, and the-// texts and actions fade before they reach the top bar. Under Reduce Motion only the fade is left.-//-// Ownership: the screen owns the hero and puts it in its page. The hero keeps a weak reference to the-// field it is bound to and the images it was given.-// Threading: main thread only; the blurred copy is made off it.-#import <UIKit/UIKit.h>--@class SGRArtworkField;--@interface SGRHeroHeader : UIView-@property (nonatomic, copy) NSString *title;-@property (nonatomic, copy) NSString *meta;-// Where the action row goes; the hero lays out nothing inside it.-@property (nonatomic, readonly) UIView *actionSlot;--// The picture fades in over 0.25s and its blurred copy follows when it is ready; the same image-// again is a no-op, nil leaves the picture as it is.-- (void)setImage:(UIImage *)image animated:(BOOL)animated;-// The dissolve takes the field's colour now and crossfades with it from then on.-- (void)bindToField:(SGRArtworkField *)field;-// `offset` is the page's vertical scroll offset with 0 at rest (negative on overscroll), `distance`-// how far the page scrolls before the header is pinned under the top bar.-- (void)applyScrollOffset:(CGFloat)offset collapseDistance:(CGFloat)distance;-@enddiff --git a/tweak/Sources/Redesign/Kit/SGRHero.m b/tweak/Sources/Redesign/Kit/SGRHero.mdeleted file mode 100644index a4843de1..00000000--- a/tweak/Sources/Redesign/Kit/SGRHero.m+++ /dev/null@@ -1,275 +0,0 @@-#import "Core/SGCore.h"-#import "SGRHero.h"-#import "SGRField.h"-#import "SGRPalette.h"-#import "SGRTokens.h"--static const CGFloat kTitleBottom = 98, kMetaTop = 94, kMetaHeight = 18, kActionTop = 64;-static const CGFloat kScrimHeight = 140, kScrimAlpha = 0.3;-static const CGFloat kDissolveFrom = 0.45, kDissolveMid = 0.72, kDissolveMidAlpha = 0.55;-static const CGFloat kParallax = 0.3;-static const CGFloat kFadeStart = 300, kFadeLength = 120; // above the hero's bottom edge, in points of scroll-// The picture's clip reaches this far above the hero so an overscroll stretch can grow upwards; it-// clips the sides and the bottom only.-static const CGFloat kStretchRoom = 1000;-static const NSTimeInterval kImageFade = 0.25;--@interface SGRGradientView : UIView-@end--@implementation SGRGradientView-+ (Class)layerClass {- return CAGradientLayer.class;-}-@end--@implementation SGRHeroHeader {- UIView *_clip;- UIImageView *_photo;- UIImageView *_blurred;- SGRGradientView *_dissolve;- UILabel *_titleLabel;- UILabel *_metaLabel;- UIView *_actionSlot;- __weak SGRArtworkField *_field;- UIImage *_image;- NSUInteger _generation;- CGFloat _lastPictureOffset, _lastFade;-}--- (instancetype)initWithFrame:(CGRect)frame {- if (!(self = [super initWithFrame:frame])) return nil;- _lastPictureOffset = NAN;- _lastFade = NAN;-- _clip = [UIView new];- _clip.clipsToBounds = YES;- _clip.userInteractionEnabled = NO;- _clip.accessibilityElementsHidden = YES;- [self addSubview:_clip];-- _photo = [UIImageView new];- _photo.contentMode = UIViewContentModeScaleAspectFill;- CAGradientLayer *scrim = [CAGradientLayer layer];- scrim.colors = @[(id)[UIColor colorWithWhite:0 alpha:kScrimAlpha].CGColor, (id)[UIColor colorWithWhite:0 alpha:0].CGColor];- [_photo.layer addSublayer:scrim];- [_clip addSubview:_photo];-- _blurred = [UIImageView new];- _blurred.contentMode = UIViewContentModeScaleAspectFill;- _blurred.alpha = 0;- [_clip addSubview:_blurred];-- _dissolve = [SGRGradientView new];- [self paintDissolve:SGRNeutralField() animated:NO];- [_clip addSubview:_dissolve];-- _titleLabel = [UILabel new];- _titleLabel.textColor = SGRPrimary();- _titleLabel.textAlignment = NSTextAlignmentCenter;- _titleLabel.numberOfLines = 2;- _titleLabel.adjustsFontSizeToFitWidth = YES;- _titleLabel.minimumScaleFactor = 0.7;- _titleLabel.accessibilityTraits = UIAccessibilityTraitHeader;- [self addSubview:_titleLabel];-- _metaLabel = [UILabel new];- _metaLabel.textColor = SGRSecondary();- _metaLabel.textAlignment = NSTextAlignmentCenter;- _metaLabel.isAccessibilityElement = NO;- [self addSubview:_metaLabel];-- _actionSlot = [UIView new];- [self addSubview:_actionSlot];-- [self applyFonts];- [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(contentSizeChanged:) name:UIContentSizeCategoryDidChangeNotification object:nil];- return self;-}--- (void)dealloc {- [NSNotificationCenter.defaultCenter removeObserver:self];-}--- (UIView *)actionSlot {- return _actionSlot;-}--- (void)applyFonts {- // The header keeps Spotify's height, so at the largest sizes the title shrinks rather than grows.- _titleLabel.font = SGRFont(UIFontTextStyleLargeTitle, UIFontWeightBold, UIContentSizeCategoryAccessibilityMedium);- _metaLabel.font = SGRFont(UIFontTextStyleFootnote, UIFontWeightRegular, UIContentSizeCategoryExtraExtraExtraLarge);-}--- (void)contentSizeChanged:(NSNotification *)note {- [self applyFonts];- [self setNeedsLayout];-}--#pragma mark - content--- (NSString *)title {- return _titleLabel.text;-}--- (void)setTitle:(NSString *)title {- if ([title isEqualToString:_titleLabel.text] || (!title && !_titleLabel.text)) return;- _titleLabel.text = title;- [self updateAccessibility];- [self setNeedsLayout];-}--- (NSString *)meta {- return _metaLabel.text;-}--- (void)setMeta:(NSString *)meta {- if ([meta isEqualToString:_metaLabel.text] || (!meta && !_metaLabel.text)) return;- _metaLabel.text = meta;- _metaLabel.hidden = meta.length == 0;- [self updateAccessibility];-}--// The meta line is read with the title, as one element.-- (void)updateAccessibility {- NSString *title = _titleLabel.text ?: @"";- _titleLabel.accessibilityLabel = _metaLabel.text.length ? [NSString stringWithFormat:@"%@, %@", title, _metaLabel.text] : title;-}--- (void)setImage:(UIImage *)image animated:(BOOL)animated {- if (!image || image == _image) return;- _image = image;- animated = animated && self.window;- UIImageView *photo = _photo;- if (animated) {- [UIView transitionWithView:photo duration:kImageFade options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction animations:^{- photo.image = image;- } completion:nil];- } else {- photo.image = image;- }-- NSUInteger generation = ++_generation;- SGRPaletteRequest request = {CGSizeZero, YES, NO};- __weak SGRHeroHeader *weakSelf = self;- [SGRPalette paletteForImage:image request:request completion:^(SGRPalette *palette) {- SGRHeroHeader *hero = weakSelf;- if (!hero || !palette.dissolve || generation != hero->_generation) return;- [hero showBlurred:palette.dissolve];- }];-}--- (void)showBlurred:(UIImage *)image {- UIImageView *blurred = _blurred;- if (!self.window) {- blurred.image = image;- blurred.alpha = 1;- return;- }- if (blurred.alpha > 0) {- [UIView transitionWithView:blurred duration:SGRCrossfade options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction animations:^{- blurred.image = image;- } completion:nil];- return;- }- blurred.image = image;- SGRAnimate(SGRMotionFade, ^{ blurred.alpha = 1; }, nil);-}--- (void)bindToField:(SGRArtworkField *)field {- if (_field) [NSNotificationCenter.defaultCenter removeObserver:self name:SGRFieldColorDidChangeNotification object:_field];- _field = field;- if (!field) return;- [self paintDissolve:field.fieldColor animated:NO];- [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(fieldColorChanged:) name:SGRFieldColorDidChangeNotification object:field];-}--- (void)fieldColorChanged:(NSNotification *)note {- UIColor *color = note.userInfo[@"color"];- if (color) [self paintDissolve:color animated:self.window != nil];-}--// Started in the same transaction as the field's own colour animation, so the two stay one colour.-- (void)paintDissolve:(UIColor *)color animated:(BOOL)animated {- CAGradientLayer *layer = (CAGradientLayer *)_dissolve.layer;- NSArray *from = ((CAGradientLayer *)layer.presentationLayer ?: layer).colors;- NSArray *to = @[(id)[color colorWithAlphaComponent:0].CGColor, (id)[color colorWithAlphaComponent:kDissolveMidAlpha].CGColor, (id)color.CGColor];- [CATransaction begin];- [CATransaction setDisableActions:YES];- layer.colors = to;- layer.locations = @[@0, @((kDissolveMid - kDissolveFrom) / (1 - kDissolveFrom)), @1];- [CATransaction commit];- if (!animated || !from) return;- CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"colors"];- fade.fromValue = from;- fade.toValue = layer.colors;- fade.duration = SGRCrossfade;- fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];- [layer addAnimation:fade forKey:@"colors"];-}--#pragma mark - layout and scroll--// Only the action row takes touches; anywhere else the touch belongs to the page under the hero.-- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {- UIView *hit = [super hitTest:point withEvent:event];- return hit == self ? nil : hit;-}--- (void)layoutSubviews {- [super layoutSubviews];- CGFloat width = self.bounds.size.width, height = self.bounds.size.height;- CGRect picture = CGRectMake(0, kStretchRoom, width, height);- [UIView performWithoutAnimation:^{- CGAffineTransform photoTransform = _photo.transform, blurredTransform = _blurred.transform;- _photo.transform = CGAffineTransformIdentity;- _blurred.transform = CGAffineTransformIdentity;- _clip.frame = CGRectMake(0, -kStretchRoom, width, height + kStretchRoom);- _photo.frame = picture;- _blurred.frame = picture;- _photo.transform = photoTransform;- _blurred.transform = blurredTransform;- _dissolve.frame = CGRectMake(0, kStretchRoom + height * kDissolveFrom, width, height * (1 - kDissolveFrom));- [CATransaction begin];- [CATransaction setDisableActions:YES];- _photo.layer.sublayers.firstObject.frame = CGRectMake(0, 0, width, kScrimHeight);- [CATransaction commit];-- CGFloat textWidth = MAX(0, width - 2 * SGRSideMargin);- CGFloat twoLines = ceil(_titleLabel.font.lineHeight * 2);- CGFloat titleHeight = MIN(twoLines, ceil([_titleLabel sizeThatFits:CGSizeMake(textWidth, CGFLOAT_MAX)].height));- _titleLabel.frame = CGRectMake(SGRSideMargin, height - kTitleBottom - titleHeight, textWidth, titleHeight);- _metaLabel.frame = CGRectMake(SGRSideMargin, height - kMetaTop, textWidth, MAX(kMetaHeight, ceil(_metaLabel.font.lineHeight)));- _actionSlot.frame = CGRectMake(0, height - kActionTop, width, SGRActionHeight);- }];-}--- (void)applyScrollOffset:(CGFloat)offset collapseDistance:(CGFloat)distance {- CGFloat height = self.bounds.size.height;- if (height <= 0) return;- CGFloat pictureOffset = SGRReduceMotion() ? 0 : MIN(offset, MAX(0, distance));- if (pictureOffset != _lastPictureOffset) {- _lastPictureOffset = pictureOffset;- CGAffineTransform transform = CGAffineTransformIdentity;- if (pictureOffset < 0) {- // Scaled about the centre, then moved so the bottom edge stays where it is.- CGFloat scale = (height - pictureOffset) / height;- transform = CGAffineTransformMake(scale, 0, 0, scale, 0, height / 2 * (1 - scale));- } else if (pictureOffset > 0) {- transform = CGAffineTransformMakeTranslation(0, kParallax * pictureOffset);- }- _photo.transform = transform;- _blurred.transform = transform;- }- CGFloat fade = MIN(1, MAX(0, (offset - (height - kFadeStart)) / kFadeLength));- if (fade != _lastFade) {- _lastFade = fade;- CGFloat alpha = 1 - fade;- _titleLabel.alpha = alpha;- _metaLabel.alpha = alpha;- _actionSlot.alpha = alpha;- _actionSlot.userInteractionEnabled = alpha > 0.1;- }-}--@enddiff --git a/tweak/Sources/Redesign/Kit/SGRKit.h b/tweak/Sources/Redesign/Kit/SGRKit.hindex 06585bab..c927cd5a 100644--- a/tweak/Sources/Redesign/Kit/SGRKit.h+++ b/tweak/Sources/Redesign/Kit/SGRKit.h@@ -1,14 +1,13 @@// The Redesign Kit: what every redesigned screen (Redesign/<Screen>/) builds on, so the screens share// one look and nothing is hand-rolled per screen. A screen imports this and Core/SGCore.h.//-// SGRedesign.h the switch per screen, the flags a screen forces, the Redesign page+// SGRedesign.h the switch per screen and the flags a screen forces// SGRTokens.h colours, type, spacing, radii, motion, the accessibility settings// SGRPalette.h the artwork's edge colour, the field colour and the pre-blurred bitmaps// SGRField.h the artwork field behind a page, and content cards on it-// SGRHero.h the full-width hero header with title, meta and the action slot-// SGRGlass.h glass behind Spotify's controls, glass buttons, the action row+// SGRGlass.h glass inside Spotify's round controls// SGRGlyph.h bare glyph overlays and glyph buttons-// SGRRestyle.h keeping Spotify's views restyled: suppress, digits, lookups, cells, repaint roots+// SGRRestyle.h keeping Spotify's views restyled: suppress, digits, lookups, shadows, firing controls// SGRBridges.h player state, now playing artwork, links, the player's open and close//// A screen's hooks install only while its switch is on: every .x of a screen ends with@@ -19,7 +18,6 @@#import "SGRTokens.h"#import "SGRPalette.h"#import "SGRField.h"-#import "SGRHero.h"#import "SGRGlass.h"#import "SGRGlyph.h"#import "SGRRestyle.h"diff --git a/tweak/Sources/Redesign/Kit/SGRPalette.h b/tweak/Sources/Redesign/Kit/SGRPalette.hindex 56192698..2a7d5f33 100644--- a/tweak/Sources/Redesign/Kit/SGRPalette.h+++ b/tweak/Sources/Redesign/Kit/SGRPalette.h@@ -1,6 +1,6 @@// What a redesigned page takes from its artwork, worked out off the main thread in one pass: the// colour along the artwork's bottom edge, the field colour made from it, and the blurred bitmaps the-// field (SGRField.h) and the hero (SGRHero.h) draw instead of a live blur.+// field (SGRField.h) draws instead of a live blur.//// The field colour is the edge colour with its saturation held to 0.55 and its relative luminance to// 0.07 (0.04 with Increase Contrast). On anything that dark white text is past 8:1 and SGRSecondarydiff --git a/tweak/Sources/Redesign/Kit/SGRRestyle.h b/tweak/Sources/Redesign/Kit/SGRRestyle.hindex 87780924..e861b412 100644--- a/tweak/Sources/Redesign/Kit/SGRRestyle.h+++ b/tweak/Sources/Redesign/Kit/SGRRestyle.h@@ -6,8 +6,7 @@//// Ownership: what a helper creates belongs to the view it was made for (associated objects), and a// helper keeps only weak references to Spotify's views.-// Threading: main thread only, except SGRInsideClearRoot, which Appearance/Repaint.x calls from-// wherever a layer is painted.+// Threading: main thread only.#import <UIKit/UIKit.h>#pragma mark - views@@ -36,48 +35,9 @@ UIView *SGRFindByIdentifier(UIView *root, NSString *identifier, const void *cach@endSGRShadowPlate *SGRShadowPlateIn(UIView *host, const void *key);-// A Spotify list cell's content restyled for the field: base backgrounds (#121212, or the black AMOLED-// makes of it) cleared, white text to SGRPrimary and #B3B3B3 text to SGRSecondary (the now playing-// tint and other colours are left), Encore list row dividers at alpha 0, and image views of 40pt and-// more rounded (SGRRadiusThumb up to 64pt, SGRRadiusCover above). Idempotent; one walk of the subtree.-void SGRStyleSpotifyCell(UIView *content);--// A section header of the redesign's own over a Spotify heading cell: the title in title 2 bold, 24pt-// from the top and SGRSideMargin from the sides, and a chevron when there is somewhere to go, which-// fires `target` (Spotify's own "show all") with SGRFire. One per cell, updated on every call; the-// caller makes Spotify's heading invisible under it.-@interface SGRSectionHeader : UIView-+ (instancetype)headerInCell:(UICollectionViewCell *)cell title:(NSString *)title target:(UIControl *)target;-@end-#pragma mark - Spotify's controls and pages// Fires a control's action the way a tap would: the actions registered for primary action triggered,// else those for touch up inside. NO when the control has neither (an Encore control that reads its// touches through a gesture recognizer); what was found is logged once per class.BOOL SGRFire(UIControl *control);--// The scroll view's contentOffset through KVO, on the main thread, until `owner` or the scroll view goes-// away or the observation is invalidated. The block is handed the owner so it need not capture it-// (the owner keeps the observation, so a captured owner would never be freed).-@interface SGROffsetObservation : NSObject-- (void)invalidate;-@end-SGROffsetObservation *SGRObserveOffset(UIScrollView *scrollView, id owner, void (^changed)(id owner, CGPoint offset));--// The URI of the page `view` is in (spotify:artist:…), from the first controller up its responder-// chain that answers spt_pageURI (IdentifiedPageHostingViewController and the other page wrappers);-// kept on the view once found.-NSURL *SGRPageURI(UIView *view);--#pragma mark - repaint--// A redesigned page that paints its own field registers the view that holds Spotify's surfaces:-// Appearance/Repaint.x then clears every base surface colour (SGIsBaseSurface) set on a view inside it,-// now and whenever Spotify repaints. Registering sweeps what is already painted once. The mark lives-// on the view, so it goes with it.-void SGRRegisterClearRoot(UIView *root);-// For Repaint.x: whether any root has been registered this launch, and whether `view` is inside one-// (stopping at a visual effect view, as SGIsInside does).-BOOL SGRHasClearRoots(void);-BOOL SGRInsideClearRoot(UIView *view);diff --git a/tweak/Sources/Redesign/Kit/SGRRestyle.m b/tweak/Sources/Redesign/Kit/SGRRestyle.mindex b2e3fd6c..7c291cb0 100644--- a/tweak/Sources/Redesign/Kit/SGRRestyle.m+++ b/tweak/Sources/Redesign/Kit/SGRRestyle.m@@ -4,7 +4,7 @@#import "SGRRestyle.h"#import "SGRTokens.h"-static char kPlateKey, kHeaderKey, kObservationsKey, kPageURIKey, kClearRootKey;+static char kPlateKey;@interface SGRWeakBox : NSObject@property (nonatomic, weak) id value;@@ -216,123 +216,6 @@ SGRShadowPlate *SGRShadowPlateIn(UIView *host, const void *key) {return plate;}-static BOOL isOpaqueRGB(UIColor *color, CGFloat red, CGFloat green, CGFloat blue) {- CGFloat r = 0, g = 0, b = 0, a = 0;- if (![color getRed:&r green:&g blue:&b alpha:&a]) return NO;- return a > 0.99 && fabs(r - red) < 0.01 && fabs(g - green) < 0.01 && fabs(b - blue) < 0.01;-}--void SGRStyleSpotifyCell(UIView *content) {- if (!content) return;- static Class divider;- static dispatch_once_t once;- dispatch_once(&once, ^{ divider = NSClassFromString(@"_TtCCE16Encore_LayoutKitO16EncoreFoundation6Encore7ListRow7Divider"); });- UIColor *secondary = SGRSecondary();- const CGFloat grey = 0xB3 / 255.0;- SGForEachView(content, ^(UIView *view) {- if (SGIsBaseSurface(view.layer.backgroundColor)) view.layer.backgroundColor = NULL;- if ([view isKindOfClass:UILabel.class]) {- UILabel *label = (UILabel *)view;- if (isOpaqueRGB(label.textColor, grey, grey, grey)) label.textColor = secondary;- } else if (divider && [view isKindOfClass:divider]) {- if (view.alpha != 0) view.alpha = 0;- } else if ([view isKindOfClass:UIImageView.class]) {- CGSize size = view.bounds.size;- if (size.width < 40 || fabs(size.width - size.height) > 1) return;- CGFloat radius = size.width <= 64 ? SGRRadiusThumb : SGRRadiusCover;- if (view.layer.cornerRadius == radius) return;- view.layer.cornerRadius = radius;- view.layer.cornerCurve = kCACornerCurveContinuous;- view.clipsToBounds = YES;- }- });-}--@implementation SGRSectionHeader {- UILabel *_label;- UIImageView *_chevron;- __weak UIControl *_target;-}--+ (instancetype)headerInCell:(UICollectionViewCell *)cell title:(NSString *)title target:(UIControl *)target {- UIView *content = cell.contentView;- if (!content) return nil;- SGRSectionHeader *header = objc_getAssociatedObject(cell, &kHeaderKey);- if (!header) {- header = [[SGRSectionHeader alloc] initWithFrame:content.bounds];- objc_setAssociatedObject(cell, &kHeaderKey, header, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- }- if (content.subviews.lastObject != header) [content addSubview:header];- header.frame = content.bounds;- [header setTitle:title target:target];- return header;-}--- (instancetype)initWithFrame:(CGRect)frame {- if (!(self = [super initWithFrame:frame])) return nil;- self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;- _label = [UILabel new];- _label.textColor = SGRPrimary();- [self addSubview:_label];- _chevron = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:@"chevron.right"]];- _chevron.preferredSymbolConfiguration = [UIImageSymbolConfiguration configurationWithPointSize:15 weight:UIImageSymbolWeightSemibold];- _chevron.tintColor = SGRSecondary();- [_chevron sizeToFit];- [self addSubview:_chevron];- self.isAccessibilityElement = YES;- [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped)]];- [self applyFont];- [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(contentSizeChanged:) name:UIContentSizeCategoryDidChangeNotification object:nil];- return self;-}--- (void)dealloc {- [NSNotificationCenter.defaultCenter removeObserver:self];-}--- (void)applyFont {- _label.font = SGRFont(UIFontTextStyleTitle2, UIFontWeightBold, UIContentSizeCategoryExtraExtraExtraLarge);-}--- (void)contentSizeChanged:(NSNotification *)note {- [self applyFont];- [self setNeedsLayout];-}--- (void)setTitle:(NSString *)title target:(UIControl *)target {- _target = target;- // Without a target the touches go to Spotify's cell as they would without the header.- self.userInteractionEnabled = target != nil;- _chevron.hidden = target == nil;- self.accessibilityLabel = title;- self.accessibilityTraits = target ? UIAccessibilityTraitHeader | UIAccessibilityTraitButton : UIAccessibilityTraitHeader;- if (![title isEqualToString:_label.text]) {- _label.text = title;- [self setNeedsLayout];- }-}--- (void)layoutSubviews {- [super layoutSubviews];- CGFloat width = self.bounds.size.width, lineHeight = ceil(_label.font.lineHeight);- CGFloat room = MAX(0, width - 2 * SGRSideMargin - (_chevron.hidden ? 0 : _chevron.bounds.size.width + 6));- CGFloat textWidth = MIN(room, ceil([_label sizeThatFits:CGSizeMake(CGFLOAT_MAX, lineHeight)].width));- _label.frame = CGRectMake(SGRSideMargin, 24, textWidth, lineHeight);- _chevron.center = CGPointMake(SGRSideMargin + textWidth + 6 + _chevron.bounds.size.width / 2, CGRectGetMidY(_label.frame));-}--- (void)tapped {- UIControl *target = _target;- if (target) SGRFire(target);-}--- (BOOL)accessibilityActivate {- UIControl *target = _target;- return target && SGRFire(target);-}--@end-#pragma mark - Spotify's controls and pagesBOOL SGRFire(UIControl *control) {@@ -354,102 +237,3 @@ BOOL SGRFire(UIControl *control) {[control sendActionsForControlEvents:fire];return YES;}--@interface SGROffsetObservation ()-@property (nonatomic, weak) UIScrollView *scrollView;-@property (nonatomic, weak) id owner;-@property (nonatomic, copy) void (^changed)(id owner, CGPoint offset);-@end--@implementation SGROffsetObservation--- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {- id owner = self.owner;- UIScrollView *scrollView = self.scrollView;- if (!owner || !scrollView) {- [self invalidate];- return;- }- if (self.changed) self.changed(owner, scrollView.contentOffset);-}--// A scroll view that went first took its observers with it (KVO lets go at the end of dealloc for a-// property it notifies about itself, iOS 11 on), so only a live one is asked to remove this.-- (void)invalidate {- UIScrollView *scrollView = self.scrollView;- self.scrollView = nil;- self.changed = nil;- if (!scrollView) return;- @try {- [scrollView removeObserver:self forKeyPath:@"contentOffset" context:&kObservationsKey];- } @catch (NSException *exception) {- SGLog(@"redesign kit: offset observation was already gone (%@)", exception.reason);- }-}--- (void)dealloc {- [self invalidate];-}--@end--SGROffsetObservation *SGRObserveOffset(UIScrollView *scrollView, id owner, void (^changed)(id owner, CGPoint offset)) {- if (!scrollView || !owner || !changed) return nil;- SGROffsetObservation *observation = [SGROffsetObservation new];- observation.scrollView = scrollView;- observation.owner = owner;- observation.changed = changed;- NSMutableArray *kept = objc_getAssociatedObject(owner, &kObservationsKey);- if (!kept) {- kept = [NSMutableArray array];- objc_setAssociatedObject(owner, &kObservationsKey, kept, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- }- [kept addObject:observation];- [scrollView addObserver:observation forKeyPath:@"contentOffset" options:0 context:&kObservationsKey];- return observation;-}--@protocol SGRPageController-- (id)spt_pageURI;-@end--NSURL *SGRPageURI(UIView *view) {- if (!view) return nil;- NSURL *cached = objc_getAssociatedObject(view, &kPageURIKey);- if (cached) return cached;- for (UIResponder *responder = view; responder; responder = responder.nextResponder) {- if (![responder isKindOfClass:UIViewController.class] || ![responder respondsToSelector:@selector(spt_pageURI)]) continue;- id uri = [(id<SGRPageController>)responder spt_pageURI];- NSURL *url = [uri isKindOfClass:NSURL.class] ? uri : [uri isKindOfClass:NSString.class] ? [NSURL URLWithString:uri] : nil;- if (!url) continue;- objc_setAssociatedObject(view, &kPageURIKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- return url;- }- return nil;-}--#pragma mark - repaint--static BOOL sg_clearRoots = NO;--void SGRRegisterClearRoot(UIView *root) {- if (!root || objc_getAssociatedObject(root, &kClearRootKey)) return;- objc_setAssociatedObject(root, &kClearRootKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- sg_clearRoots = YES;- SGForEachView(root, ^(UIView *view) {- if (!SGKeepsColor(view) && SGIsBaseSurface(view.layer.backgroundColor) && SGRInsideClearRoot(view)) view.layer.backgroundColor = NULL;- });-}--BOOL SGRHasClearRoots(void) {- return sg_clearRoots;-}--BOOL SGRInsideClearRoot(UIView *view) {- if (!sg_clearRoots) return NO;- for (UIView *v = view; v; v = v.superview) {- if ([v isKindOfClass:UIVisualEffectView.class]) return NO;- if (objc_getAssociatedObject(v, &kClearRootKey)) return YES;- }- return NO;-}diff --git a/tweak/Sources/Redesign/Kit/SGRedesign.h b/tweak/Sources/Redesign/Kit/SGRedesign.hindex 48b977b5..00bb9bb9 100644--- a/tweak/Sources/Redesign/Kit/SGRedesign.h+++ b/tweak/Sources/Redesign/Kit/SGRedesign.h@@ -7,19 +7,18 @@//// Threading: SGRedesignOn, SGRedesignAnyOn and SGRedesignForcedFlag are safe from any thread (the// configuration provider asks from several). Registration happens in a %ctor, before Spotify reads a-// flag. Everything that builds settings rows is main thread only.+// flag.#import <UIKit/UIKit.h>// spotifyglass.redesign.<screen>; the screens with a redesign are listed in SGRedesign.m.#define SGKeyRedesignPrefix @"spotifyglass.redesign."#define SGKeyRedesignPlayer @"spotifyglass.redesign.player"-#define SGKeyRedesignArtist @"spotifyglass.redesign.artist"-// Whether the screen ("player", "artist") was redesigned when Spotify started. A screen without a+// Whether the screen ("player") was redesigned when Spotify started. A screen without a// redesign yet reads off whatever is stored for it.BOOL SGRedesignOn(NSString *screen);BOOL SGRedesignAnyOn(void);-// The screens with a redesign, in the order the Redesign page lists them.+// The screens with a redesign.NSArray<NSString *> *SGRedesignScreens(void);// The flags a screen's redesign forces, flag key to @YES/@NO/number/string, registered from the@@ -31,19 +30,3 @@ id SGRedesignForcedFlag(NSString *key);// For the flag rows of Settings/SGModPage.m: the value a screen whose switch is on now forces, or// nil. It follows the stored switch rather than the launch, as the Liquid Glass UI lock does.id SGRedesignOwnedFlag(NSString *key);--@class SGModRow, SGModSection;-// Extra rows a screen shows under its switch on the Redesign page, asked for each time the page-// opens. Register from the screen's %ctor whether or not the screen is on.-void SGRedesignRegisterRows(NSString *screen, NSArray<SGModRow *> *(^rows)(void));--// The card under Appearance on the root page of Mod Settings: one row opening the Redesign page,-// reading out how many screens are redesigned ("1 of 2").-SGModSection *SGRedesignSection(void);-UIViewController *SGRedesignSettingsPage(void);-// The first section of a legacy page (Player, Artist) while that screen's switch is on: it says the-// switches of that page for the screen don't apply and opens the Redesign page. nil while the switch-// is off, so a page adds it only when there is one:-// SGModSection *note = SGRedesignNoteSection(@"artist");-// if (note) sections = [@[note] arrayByAddingObjectsFromArray:sections];-SGModSection *SGRedesignNoteSection(NSString *screen);diff --git a/tweak/Sources/Redesign/Kit/SGRedesign.m b/tweak/Sources/Redesign/Kit/SGRedesign.mindex 9214bb5a..798ec02d 100644--- a/tweak/Sources/Redesign/Kit/SGRedesign.m+++ b/tweak/Sources/Redesign/Kit/SGRedesign.m@@ -1,12 +1,12 @@-// The switches of the redesigned screens and the flags they force. The rows of the Redesign page are-// in SGRedesignSettings.m.+// The switches of the redesigned screens and the flags they force. A screen's switch is the tab its+// part's settings page picks it with (the Player page's Native player and Redesigned player).#import <os/lock.h>#import "Core/SGCore.h"#import "SGRedesign.h"-// A screen added later needs its name here and its title in SGRedesignSettings.m.+// A screen added later needs its name here and a way to pick it on its part's settings page.NSArray<NSString *> *SGRedesignScreens(void) {- return @[@"player", @"artist"];+ return @[@"player"];}static NSString *keyFor(NSString *screen) {diff --git a/tweak/Sources/Redesign/Kit/SGRedesignSettings.m b/tweak/Sources/Redesign/Kit/SGRedesignSettings.mdeleted file mode 100644index 95fe17ff..00000000--- a/tweak/Sources/Redesign/Kit/SGRedesignSettings.m+++ /dev/null@@ -1,77 +0,0 @@-// The Redesign page: a switch per redesigned screen and whatever rows a screen registers under it,-// the row on the root page of Mod Settings that opens it, and the note the legacy pages lead with-// while their screen is redesigned. Main thread only.-#import "Core/SGCore.h"-#import "Settings/SGModPage.h"-#import "SGRedesign.h"--typedef struct {- __unsafe_unretained NSString *screen;- __unsafe_unretained NSString *title;- __unsafe_unretained NSString *subtitle;- __unsafe_unretained NSString *symbol;-} SGRScreenRow;--// Spelled out in full rather than built from the screen's name: the page reads like the rest of Mod-// Settings, and a screen without a line here has no switch to show yet.-static const SGRScreenRow kRows[] = {- {@"player", @"Player", @"The cover's own colour behind the whole player, glass behind the header buttons, and only the lyrics card below it", @"play.circle"},- {@"artist", @"Artist", @"The photo across the full width fading into its colour, glass Play, Shuffle and Follow, and only the music below", @"music.mic"},-};--static const SGRScreenRow *rowFor(NSString *screen) {- for (size_t i = 0; i < sizeof(kRows) / sizeof(kRows[0]); i++) {- if ([kRows[i].screen isEqualToString:screen]) return &kRows[i];- }- return NULL;-}--static NSMutableDictionary<NSString *, NSArray<SGModRow *> *(^)(void)> *sg_extraRows;--void SGRedesignRegisterRows(NSString *screen, NSArray<SGModRow *> *(^rows)(void)) {- if (!screen || !rows) return;- if (!sg_extraRows) sg_extraRows = [NSMutableDictionary dictionary];- sg_extraRows[screen] = [rows copy];-}--static NSUInteger countOn(void) {- NSUInteger on = 0;- for (NSString *screen in SGRedesignScreens()) {- if (SGFlag([SGKeyRedesignPrefix stringByAppendingString:screen], NO)) on++;- }- return on;-}--UIViewController *SGRedesignSettingsPage(void) {- NSMutableArray<SGModRow *> *switches = [NSMutableArray array];- NSMutableArray<SGModSection *> *extras = [NSMutableArray array];- for (NSString *screen in SGRedesignScreens()) {- const SGRScreenRow *row = rowFor(screen);- if (!row) continue;- [switches addObject:SGWithSymbol(SGOptionRow(row->title, row->subtitle, [SGKeyRedesignPrefix stringByAppendingString:screen]), row->symbol)];- NSArray<SGModRow *> *(^rows)(void) = sg_extraRows[screen];- NSArray<SGModRow *> *more = rows ? rows() : nil;- if (more.count) [extras addObject:SGSection(row->title, more)];- }- NSArray<SGModSection *> *sections = [@[- SGNotedSection(@"Screens", switches, @"A redesigned screen replaces Spotify's own layout, so the switches for it on its part's page stop applying until it is off again."),- ] arrayByAddingObjectsFromArray:extras];- return [[SGModPage alloc] initWithTitle:@"Redesign" intro:SGRestartNote sections:sections footer:nil];-}--SGModSection *SGRedesignSection(void) {- SGModRow *row = SGWithSymbol(SGPageRow(@"Redesign", ^UIViewController *{ return SGRedesignSettingsPage(); }), @"sparkles");- row.value = ^NSString *{- NSUInteger on = countOn();- return on ? [NSString stringWithFormat:@"%lu of %lu", (unsigned long)on, (unsigned long)SGRedesignScreens().count] : @"Off";- };- return SGSection(nil, @[row]);-}--SGModSection *SGRedesignNoteSection(NSString *screen) {- const SGRScreenRow *screenRow = rowFor(screen);- if (!screenRow || !SGFlag([SGKeyRedesignPrefix stringByAppendingString:screen], NO)) return nil;- SGModRow *row = SGPageRow([NSString stringWithFormat:@"%@ redesign is on", screenRow->title], ^UIViewController *{ return SGRedesignSettingsPage(); });- row.subtitle = @"Its own layout replaces Spotify's, so the switches below that change this screen don't apply";- return SGSection(nil, @[SGWithSymbol(row, @"sparkles")]);-}diff --git a/tweak/Sources/Redesign/Player/Player.h b/tweak/Sources/Redesign/Player/Player.hindex 1c605efd..10d0fd89 100644--- a/tweak/Sources/Redesign/Player/Player.h+++ b/tweak/Sources/Redesign/Player/Player.h@@ -1,12 +1,12 @@// The player redesign (screen key "player"): Spotify's full screen player kept, with its controller,// units, controls and card list, and restyled from the Kit. Every control stays Spotify's own, so its// action, state and accessibility do too; the redesign adds the artwork field behind it, glass behind-// the header buttons and the add button, bare glyphs for previous, play and next, a lyrics glyph in the+// the header buttons, bare glyphs for previous, play and next, a lyrics glyph in the// footer, and collapses every card under the player except lyrics.//// PlayerField.x the switch's flags and rows, the field in the background plane, the cover it reads// PlayerArtwork.x the cover's corners, shadow and paused shrink, the lyric preview under it hidden-// PlayerHeader.x glass behind the close and more buttons, and behind add+// PlayerHeader.x glass behind the close and more buttons// PlayerControls.x previous, play and next as bare glyphs, monospaced times// PlayerFooter.x share gone, lyrics, Connect and queue as one row of three glyphs// PlayerCards.x the lyrics card kept on a content surface, every other card collapseddiff --git a/tweak/Sources/Redesign/Player/PlayerCards.x b/tweak/Sources/Redesign/Player/PlayerCards.xindex d6343f22..0b4ab0f5 100644--- a/tweak/Sources/Redesign/Player/PlayerCards.x+++ b/tweak/Sources/Redesign/Player/PlayerCards.x@@ -127,7 +127,7 @@ static UIView *cellAround(UIView *view) {if (cell.bounds.size.height >= kLivingHeight) {objc_setAssociatedObject(cell, &kRevalidatedKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);SGRArtworkField *field = SGRPlayerField();- // Made only with the player's own field to follow; the artist page has a field of its own.+ // Made only once the player has a field of its own for the surface to follow.if (field && surfaceWanted()) SGRCardSurface(cell, field);return;}diff --git a/tweak/Sources/Redesign/Player/PlayerField.x b/tweak/Sources/Redesign/Player/PlayerField.xindex 05f1bd57..4e306ca6 100644--- a/tweak/Sources/Redesign/Player/PlayerField.x+++ b/tweak/Sources/Redesign/Player/PlayerField.x@@ -170,10 +170,6 @@ static SGRPlayerCoverWatcher *sg_coverWatcher;flags[[@"ios-feature-nowplaying." stringByAppendingString:egg]] = @NO;}SGRedesignForceFlags(@"player", flags);- SGRedesignRegisterRows(@"player", ^NSArray<SGModRow *> *{- return @[SGSwitchRow(@"Lyrics under the player", @"The lyrics card below the player; every other card is left out", SGKeyRedesignPlayerLyricsCard)];- });-if (!SGRedesignOn(@"player")) return;%init;sg_coverWatcher = [SGRPlayerCoverWatcher new];diff --git a/tweak/Sources/Settings/SGModPage.h b/tweak/Sources/Settings/SGModPage.hindex cc07f7ee..0932931b 100644--- a/tweak/Sources/Settings/SGModPage.h+++ b/tweak/Sources/Settings/SGModPage.h@@ -29,8 +29,23 @@@property (nonatomic, copy) NSString *footer;@end+// One tab of a page with tabs: its name on the control, a line under the control saying what picking+// it means, and the sections that show while it is picked.+@interface SGModTab : NSObject+@property (nonatomic, copy) NSString *title;+@property (nonatomic, copy) NSString *note;+@property (nonatomic, copy) NSArray<SGModSection *> *sections;+@end++SGModTab *SGTab(NSString *title, NSString *note, NSArray<SGModSection *> *sections);+@interface SGModPage : SGPage- (instancetype)initWithTitle:(NSString *)title intro:(NSString *)intro sections:(NSArray<SGModSection *> *)sections footer:(NSString *)footer;+// A page whose tabs pick one of several ways of doing the same thing, the Player page's native and+// redesigned player: a segmented control leads the page, the picked tab's sections follow it, then+// `sections`, which every tab shows. The pick is stored under `key` as the tab's index, `fallback`+// until there is one, and picking another swaps the sections in place.+- (instancetype)initWithTitle:(NSString *)title intro:(NSString *)intro tabsKey:(NSString *)key tabs:(NSArray<SGModTab *> *)tabs fallback:(NSInteger)fallback sections:(NSArray<SGModSection *> *)sections footer:(NSString *)footer;@end// The intro of every page whose switches the hooks read at launch.diff --git a/tweak/Sources/Settings/SGModPage.m b/tweak/Sources/Settings/SGModPage.mindex a038af05..7b39f9f7 100644--- a/tweak/Sources/Settings/SGModPage.m+++ b/tweak/Sources/Settings/SGModPage.m@@ -199,6 +199,25 @@ SGModRow *SGWithSymbol(SGModRow *row, NSString *symbol) {return row;}+@implementation SGModTab+@end++SGModTab *SGTab(NSString *title, NSString *note, NSArray<SGModSection *> *sections) {+ SGModTab *tab = [SGModTab new];+ tab.title = title;+ tab.note = note;+ tab.sections = sections;+ return tab;+}++// The row the tabs are drawn in: no key, no page, no action, so nothing else in the page mistakes it+// for a row of its own kind.+@interface SGTabsRow : SGModRow+@end++@implementation SGTabsRow+@end+// What a page row carrying a value shows on the right: the value, then the chevron, the same// distance apart as Spotify's own rows keep them.static UIView *valueAndChevron(NSString *text) {@@ -242,6 +261,10 @@ static BOOL lockedRowOn(SGModRow *row) {@implementation SGModPage {NSArray<SGModSection *> *_sections;+ NSArray<SGModSection *> *_shared;+ NSArray<SGModTab *> *_tabs;+ NSString *_tabsKey;+ NSInteger _tabsFallback;UIView *_intro;UIView *_footer;NSTimer *_ticker;@@ -254,12 +277,83 @@ static BOOL lockedRowOn(SGModRow *row) {_sections = sections;_intro = intro ? SGNote(intro) : nil;_footer = footer ? SGNote(footer) : nil;- // A page row reads its value out when the page appears rather than on the ticker, so only the- // rows whose numbers climb on their own keep one running.- for (SGModSection *s in sections) for (SGModRow *row in s.rows) _live |= row.value && !row.page;+ [self noteLiveRows];+ return self;+}++- (instancetype)initWithTitle:(NSString *)title intro:(NSString *)intro tabsKey:(NSString *)key tabs:(NSArray<SGModTab *> *)tabs fallback:(NSInteger)fallback sections:(NSArray<SGModSection *> *)sections footer:(NSString *)footer {+ if (!(self = [self initWithTitle:title intro:intro sections:sections footer:footer])) return nil;+ _shared = sections;+ _tabs = tabs;+ _tabsKey = key;+ _tabsFallback = fallback;+ [self layOutTabs];return self;}+// A page row reads its value out when the page appears rather than on the ticker, so only the rows+// whose numbers climb on their own keep one running.+- (void)noteLiveRows {+ _live = NO;+ for (SGModSection *s in _sections) for (SGModRow *row in s.rows) _live |= row.value && !row.page;+}++- (NSInteger)pickedTab {+ NSInteger index = SGInt(_tabsKey, _tabsFallback);+ return index >= 0 && index < (NSInteger)_tabs.count ? index : 0;+}++// The control's own section, footed by what the picked tab means, then the tab's sections, then the+// ones every tab shares.+- (void)layOutTabs {+ SGModTab *tab = _tabs[(NSUInteger)[self pickedTab]];+ SGModSection *control = SGNotedSection(nil, @[[SGTabsRow new]], tab.note);+ _sections = [[@[control] arrayByAddingObjectsFromArray:tab.sections ?: @[]] arrayByAddingObjectsFromArray:_shared ?: @[]];+ [self noteLiveRows];+}++- (void)tabPicked:(UISegmentedControl *)control {+ if (control.selectedSegmentIndex == [self pickedTab]) return;+ SGSetInt(_tabsKey, control.selectedSegmentIndex);+ [self layOutTabs];+ [UIView transitionWithView:self.tableView duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction animations:^{+ [self.tableView reloadData];+ } completion:nil];+}++// The control on the page itself rather than on a card, full width, the picked tab's name in white on+// the selection and the other names in the grey of a subtitle.+- (UITableViewCell *)tabsCellIn:(UITableView *)table {+ UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"tabs"];+ UISegmentedControl *control = (UISegmentedControl *)[cell.contentView viewWithTag:1];+ if (!cell) {+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"tabs"];+ cell.backgroundConfiguration = [UIBackgroundConfiguration clearConfiguration];+ cell.selectionStyle = UITableViewCellSelectionStyleNone;+ control = [UISegmentedControl new];+ control.tag = 1;+ control.translatesAutoresizingMaskIntoConstraints = NO;+ UIFont *font = [UIFont systemFontOfSize:14 weight:UIFontWeightSemibold];+ [control setTitleTextAttributes:@{NSFontAttributeName: font, NSForegroundColorAttributeName: SGGrey()} forState:UIControlStateNormal];+ [control setTitleTextAttributes:@{NSFontAttributeName: font, NSForegroundColorAttributeName: UIColor.whiteColor} forState:UIControlStateSelected];+ [control addTarget:self action:@selector(tabPicked:) forControlEvents:UIControlEventValueChanged];+ [cell.contentView addSubview:control];+ [NSLayoutConstraint activateConstraints:@[+ [control.leadingAnchor constraintEqualToAnchor:cell.contentView.leadingAnchor],+ [control.trailingAnchor constraintEqualToAnchor:cell.contentView.trailingAnchor],+ [control.topAnchor constraintEqualToAnchor:cell.contentView.topAnchor],+ [control.bottomAnchor constraintEqualToAnchor:cell.contentView.bottomAnchor],+ [control.heightAnchor constraintEqualToConstant:40],+ ]];+ }+ if (control.numberOfSegments != _tabs.count) {+ [control removeAllSegments];+ for (NSUInteger i = 0; i < _tabs.count; i++) [control insertSegmentWithTitle:_tabs[i].title atIndex:i animated:NO];+ }+ control.selectedSegmentIndex = [self pickedTab];+ return cell;+}+- (void)viewDidLoad {[super viewDidLoad];self.tableView.tableHeaderView = _intro;@@ -339,8 +433,9 @@ static BOOL lockedRowOn(SGModRow *row) {}- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {- UITableViewCell *cell = SGDequeueCell(table, @"row");SGModRow *row = [self rowAt:path];+ if ([row isKindOfClass:SGTabsRow.class]) return [self tabsCellIn:table];+ UITableViewCell *cell = SGDequeueCell(table, @"row");SGFillCell(cell, row.title, row.subtitle, row.color, row.symbol);UIListContentConfiguration *content = (UIListContentConfiguration *)cell.contentConfiguration;if (row.color) content.secondaryTextProperties.color = row.color;diff --git a/tweak/Sources/Settings/SGModSettings.x b/tweak/Sources/Settings/SGModSettings.xindex 5c848f07..9e08eea7 100644--- a/tweak/Sources/Settings/SGModSettings.x+++ b/tweak/Sources/Settings/SGModSettings.x@@ -1,5 +1,5 @@// Settings: a Mod Settings row at the end of Spotify's settings list opens the mod's own page: the-// Appearance card that styles the whole app, the Redesign row under it (Redesign/Kit), then a page per part of Spotify, each holding that+// Appearance card that styles the whole app, then a page per part of Spotify, each holding that// part's glass, hide switches and flags (Navbar, Player, Home & Library), Premium, ads & privacy// and Labs, All flags, a searchable list of every flag with an override per flag, and Mod, the// build, its updates and links. The same row leads the side drawer's list (trees/test6.txt), above@@ -22,7 +22,6 @@#import "Features/AdBlock/AdBlock.h"#import "Features/Flags/Flags.h"#import "Features/About/About.h"-#import "Redesign/Kit/SGRedesign.h"static const CGFloat kRowHeight = 56;static char kRowKey, kInsetKey;@@ -43,7 +42,6 @@ static UIViewController *modSettingsPage(void) {mod.value = ^NSString *{ return @(SG_VERSION); };[sections addObjectsFromArray:@[SGAppearanceSection(),- SGRedesignSection(),SGSection(nil, @[pageRow(@"Navbar", @"dock.rectangle", ^UIViewController *{ return SGNavbarSettingsPage(); }),pageRow(@"Player", @"play.circle", ^UIViewController *{ return SGNowPlayingSettingsPage(); }),