Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: a switch shows the Top picks heading on the redesigned Home (#129)
My-Name-Is-Jeff94d655e4396e
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex 1225cb50..95e5c185 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -608,10 +608,11 @@ Redesigned:continuous corners on the covers, and, under the Home look switch (the Home page's first row; off, none ofits hooks install and Home is as before it): at the trailing edge a glass pill of the filter (a menu thatdrives Spotify's own chips, with the device picker and the top shelf's Show all) and the avatar, Top picks- (the first shelf, or the one Cards from names, found in Spotify's feed model before its cells are built, moved above the shortcuts and drawn as large cards in their- covers' colors with no heading, the page tinted by the first card) and each shortcut tile as a glass pill- in its cover's color with its name in bold on up to two lines; in FLEX builds a meter of each scroll's- frames and the hooks' time (Home.h lists its files)+ (the first shelf, or the one Cards from names, found in Spotify's feed model before its cells are+ built, moved above the shortcuts and drawn as large cards in their covers' colors with no heading+ unless Show Top picks heading is on, the page tinted by the first card) and each shortcut tile as+ a glass pill in its cover's color with its name in bold on up to two lines; in FLEX builds a meter+ of each scroll's frames and the hooks' time (Home.h lists its files)Search/ the Browse page decluttered to its category cards (an allow list of the list's cells: the watch feedcarousels and promos collapse, and the cards move up by the spacing they leave), the header the way Homehas it without the camera, and each card as Liquid Glass tinted by its own color, read off the Box'sdiff --git a/tweak/Sources/Redesigned/Home/Home.h b/tweak/Sources/Redesigned/Home/Home.hindex 384c6131..21abb26d 100644--- a/tweak/Sources/Redesigned/Home/Home.h+++ b/tweak/Sources/Redesigned/Home/Home.h@@ -33,6 +33,9 @@ BOOL SGRHomeLook(void);#define SGRKeyHomeTopPicksFrom @"spotifyglass.redesign.home.topPicksFrom"// The footer of a large card in its cover's color. On until switched off; off, the footer is the plain surface.#define SGRKeyHomeTopPicksColour @"spotifyglass.redesign.home.topPicksColour"+// Top picks keeps Spotify's heading over its cards (drawn at the size of the other shelves' headings, HomeHeadings.x)+// when set; unset, the heading and the band it takes go. Read at launch.+#define SGRKeyHomeTopPicksHeading @"spotifyglass.redesign.home.topPicksHeading"// Parts of Home hidden when set (HomeSections.x): the shortcuts grid and the DJ.#define SGRKeyHomeHideShortcuts @"spotifyglass.redesign.home.hide.shortcuts"#define SGRKeyHomeHideDJ @"spotifyglass.redesign.home.hide.dj"@@ -86,10 +89,12 @@ void SGRHomeTintForCover(UIImage *image, void (^completion)(UIColor *color));// cover's color under the cover. NO, and the card left as Spotify's, for one at Spotify's own size.BOOL SGRHomeStyleLargeCard(UIView *card);-// Whether `view` is in the shelf Top picks draws large (HomeTopPicks.x), whose heading goes (HomeHeadings.x).+// Whether `view` is in the shelf Top picks draws large (HomeTopPicks.x), whose heading goes unless Show Top picks+// heading is on (HomeHeadings.x).BOOL SGRHomeInTopPicks(UIView *view);// Spotify's "Show all" of the shelf Top picks draws, while the shelf is on screen and offers one, and the shelf's-// title with it: the header's menu offers it (HomeHeader.x), the heading it sits in being gone.+// title with it: the header's menu offers it (HomeHeader.x), the heading it sits in being gone. nil while Show Top+// picks heading keeps the heading.UIControl *SGRHomeTopPicksShowAll(NSString **title);// The page's color from the first large card's cover (HomeHeader.x draws it behind the title, fading to black);// nil for none.diff --git a/tweak/Sources/Redesigned/Home/HomeHeader.x b/tweak/Sources/Redesigned/Home/HomeHeader.xindex 8c396731..401ac428 100644--- a/tweak/Sources/Redesigned/Home/HomeHeader.x+++ b/tweak/Sources/Redesigned/Home/HomeHeader.x@@ -28,7 +28,7 @@ static const NSUInteger kTitleTries = 8;static char kTitleKey, kTabKey, kPillGlassKey, kGlassKey, kButtonsKey, kConnectKey, kTintKey, kWatchKey;// The title row's pill: a glass capsule around the filter button and the avatar, 44pt tall, as the reference has// it; the menu drives Spotify's own filter chips, hidden in the stack, and offers the device picker when Spotify-// has one (a now playing bar) and the large shelf's Show all, its heading being gone (HomeTopPicks.x).+// has one (a now playing bar) and the large shelf's Show all while its heading is gone (HomeTopPicks.x).static const CGFloat kPillHeight = 44, kPillButton = 44, kPillPad = 6;// The page's color behind the title (SGRHomeSetPageTint), fading to black over this height.static const CGFloat kTintHeight = 480;diff --git a/tweak/Sources/Redesigned/Home/HomeHeadings.x b/tweak/Sources/Redesigned/Home/HomeHeadings.xindex e2b94067..9cb70c68 100644--- a/tweak/Sources/Redesigned/Home/HomeHeadings.x+++ b/tweak/Sources/Redesigned/Home/HomeHeadings.x@@ -63,7 +63,7 @@ static void restyle(UIView *button) {if (!heading) return;// The heading names the shelf (HomeShelves.m). The page's list may have sized the shelf before the heading// was in; one switched off, or the one Top picks is to draw, is then measured again now that it is known. The- // large shelf's heading goes with the band above its cards (HomeTopPicks.x).+ // large shelf's heading goes with the band above its cards, unless Show Top picks heading is on (HomeTopPicks.x).UIView *shelf = heading.superview;while (shelf && ![shelf isKindOfClass:UICollectionView.class]) shelf = shelf.superview;NSString *identity = SGRHomeShelfIdentity(shelf);diff --git a/tweak/Sources/Redesigned/Home/HomeSettings.m b/tweak/Sources/Redesigned/Home/HomeSettings.mindex 64839383..7a7a18a6 100644--- a/tweak/Sources/Redesigned/Home/HomeSettings.m+++ b/tweak/Sources/Redesigned/Home/HomeSettings.m@@ -20,13 +20,15 @@ UIViewController *SGRHomeSettingsPage(void) {from.waitsOn = SGRKeyHomeTopPicks;SGModRow *colour = SGSwitchRow(@"Color behind Top picks", nil, SGRKeyHomeTopPicksColour);colour.waitsOn = SGRKeyHomeTopPicks;+ SGModRow *heading = SGOptionRow(@"Show Top picks heading", @"The shelf's own heading over its cards", SGRKeyHomeTopPicksHeading);+ heading.waitsOn = SGRKeyHomeTopPicks;NSMutableArray<SGModRow *> *rows = [NSMutableArray array];for (NSString *identity in shelves) [rows addObject:SGShownRow(identity, nil, SGRHomeShelfHideKey(identity))];if (!rows.count) [rows addObject:SGStatRow(@"None seen yet", ^NSString *{ return @""; })];return [[SGModPage alloc] initWithTitle:@"Home" intro:SGRestartNote sections:@[- SGNotedSection(nil, @[look, topPicks, from, colour],+ SGNotedSection(nil, @[look, topPicks, from, colour, heading],@"A shelf Home does not show today leaves Top picks off until it is back."),SGSection(@"On Home", @[SGShownRow(@"Shortcuts", nil, SGRKeyHomeHideShortcuts),diff --git a/tweak/Sources/Redesigned/Home/HomeTopPicks.x b/tweak/Sources/Redesigned/Home/HomeTopPicks.xindex dd789c9c..77d78da7 100644--- a/tweak/Sources/Redesigned/Home/HomeTopPicks.x+++ b/tweak/Sources/Redesigned/Home/HomeTopPicks.x@@ -48,6 +48,8 @@ static _Thread_local CGFloat sg_containerWidth;// large one is than it. 0 until a card is made.static _Thread_local CGFloat sg_cardWidth, sg_cardGrow;static NSInteger sg_topIndex = NSIntegerMax;+// SGRKeyHomeTopPicksHeading, read at launch.+static BOOL sg_showHeading;// The layout a wrapped provider belongs to, set once the layout is made.@interface SGRLayoutBox : NSObject@@ -60,12 +62,12 @@ static CGFloat targetWidth(void) {return round(sg_containerWidth * kCardShare);}-// The large shelf's heading goes, and the band it took with it. Its section's header is a boundary item (kind-// UICollectionElementKindSectionHeader, 39pt tall over the cards on 9.1.90, extending the section); it is made-// again not extending the section, so it takes no room and lies over the cards' top instead, where it stays in the-// shelf's visible rect, and so alive with the Show all the header's menu offers, transparent and without touches-// (the shelf's layout pass). The section's top inset goes the same way. What they took together is the band the-// shelf's cell loses (kOffsetKey, read as the cell is measured).+// The large shelf's heading goes, and the band it took with it, unless Show Top picks heading keeps both. Its+// section's header is a boundary item (kind UICollectionElementKindSectionHeader, 39pt tall over the cards on+// 9.1.90, extending the section); it is made again not extending the section, so it takes no room and lies over the+// cards' top instead, where it stays in the shelf's visible rect, and so alive with the Show all the header's menu+// offers, transparent and without touches (the shelf's layout pass). The section's top inset goes the same way. What+// they took together is the band the shelf's cell loses (kOffsetKey, read as the cell is measured).static void headingAside(NSCollectionLayoutSection *made, UICollectionViewLayout *layout) {NSMutableArray<NSCollectionLayoutBoundarySupplementaryItem *> *items = [NSMutableArray array];CGFloat band = made.contentInsets.top;@@ -99,7 +101,7 @@ static UICollectionViewCompositionalLayoutSectionProvider wrapped(UICollectionVisg_containerWidth = environment.container.effectiveContentSize.width;sg_cardWidth = sg_cardGrow = 0;NSCollectionLayoutSection *made = provider(section, environment);- if (sg_enlarging && made) headingAside(made, layout);+ if (sg_enlarging && made && !sg_showHeading) headingAside(made, layout);if (layout && sg_cardGrow > 0) objc_setAssociatedObject(layout, &kGrowKey, @(sg_cardGrow), OBJC_ASSOCIATION_RETAIN_NONATOMIC);sg_enlarging = was;sg_cardWidth = wasWidth;@@ -500,7 +502,11 @@ static void dropLarge(UICollectionView *shelf) {}return elements;}+%end+// Installed only while the heading is hidden.+%group SGRTopPicksHeadingAside+%hook _TtC16Home_CarouselKit29TouchCancellingCollectionView// The large shelf's heading lies over its cards' top (headingAside), transparent and without touches; a shelf no// longer large gets it back. Set here, on the shelf's own pass, since the heading's button lays out before the// shelf is marked and not after.@@ -523,10 +529,12 @@ static void dropLarge(UICollectionView *shelf) {SGRHomeProbeEnd(SGRHomeProbeShelfLayout, began);}%end+%endUIControl *SGRHomeTopPicksShowAll(NSString **title) {UICollectionView *shelf = sg_largeShelf;- if (!shelf.window) return nil;+ // A heading kept on screen offers its own.+ if (sg_showHeading || !shelf.window) return nil;UIView *showAll = SGRFindByIdentifier(shelf, @"Components.UI.NavigationButtonHome", &kShowAllKey);__block UIControl *control = [showAll isKindOfClass:UIControl.class] ? (UIControl *)showAll : nil;if (!control) SGForEachView(showAll, ^(UIView *v) {@@ -760,5 +768,7 @@ SGModRow *SGRHomeTopPicksRow(void) {%ctor {if (!SGRedesignedUI() || !SGRHomeLook() || !SGEnabled(SGRKeyHomeTopPicks)) return;+ sg_showHeading = SGHidden(SGRKeyHomeTopPicksHeading);%init;+ if (!sg_showHeading) %init(SGRTopPicksHeadingAside);}