Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

feat: the redesigned Home title can stay at the top as Home scrolls (#121)

My-Name-Is-Jefff531742f09a0
diff --git a/docs/tweaks.md b/docs/tweaks.md
index a57c4073..399e3bda 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -502,11 +502,11 @@ Native:
Redesigned:
Kit/ what the redesign builds on (SGRKit.h lists it), the flags it forces (SGRedesign.h, SGRGlassDesign.x for
- Spotify's own glass design), its repaint hook (SGRRepaint.x), soft top edge, AMOLED black (always on,
- SGRAmoled.x) and its own accent color (SGRAccent.x, stored apart from the native look's). The
- playlist, album and artist pages take their field's color from the cover's main color (checked on
- the Mac by harness/palette/), and come in whole: a black veil over the page until the cover has
- been read, at most SGRFieldHoldLimit (1 s), then faded away (SGRField.h)
+ Spotify's own glass design), its repaint hook (SGRRepaint.x), soft top edge (hard where a page asks for
+ it, SGRHardTopEdge), AMOLED black (always on, SGRAmoled.x) and its own accent color (SGRAccent.x, stored
+ apart from the native look's). The playlist, album and artist pages take their field's color from the
+ cover's main color (checked on the Mac by harness/palette/), and come in whole: a black veil over the
+ page until the cover has been read, at most SGRFieldHoldLimit (1 s), then faded away (SGRField.h)
Navbar/ the glass tab bar (TabBar.x) over its own composition (Navbar.x, NavbarLayout.m) and editor, the glass search field.
Spotify is made to leave the glass bar its height where its own bar is shorter (a phone with a home button,
Offline or Private Session under the bar), so the now playing bar and the pages move up with it. Under both
@@ -608,7 +608,9 @@ Redesigned:
Home/ Home decluttered to music on black (an allow list of its sections: shortcuts, the DJ without its heading and
transcript, the shelves of cards, each with a switch on the Home page of Mod Settings; the previews and the
song suggestions only when switched on), a large title where the filter pills were, the title rising and
- fading with the feed as it scrolls, as the Music app's does, the shelves' headings at the Music app's size,
+ fading with the feed as it scrolls, as the Music app's does (or, with Title stays on scroll, staying put
+ over the feed's hard top edge, shaped to the row, and no scroll observer), the shelves' headings at the
+ Music app's size,
continuous corners on the covers, and, under the Home look switch (the Home page's first row; off, none of
its hooks install and Home is as before it): at the trailing edge a glass pill of the filter (a menu that
drives Spotify's own chips, with the device picker and the top shelf's Show all) and the avatar, Top picks
diff --git a/tweak/Sources/Redesigned/Home/Home.h b/tweak/Sources/Redesigned/Home/Home.h
index 21abb26d..d6168918 100644
--- a/tweak/Sources/Redesigned/Home/Home.h
+++ b/tweak/Sources/Redesigned/Home/Home.h
@@ -36,6 +36,9 @@ BOOL SGRHomeLook(void);
// 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"
+// The title row stays where it is as the feed scrolls under it, over the feed's hard top edge shaped to the row
+// (HomeHeader.x), rather than rising and fading away. Off until switched on; read at launch.
+#define SGRKeyHomeKeepTitle @"spotifyglass.redesign.home.keepTitle"
// 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"
diff --git a/tweak/Sources/Redesigned/Home/HomeHeader.x b/tweak/Sources/Redesigned/Home/HomeHeader.x
index 401ac428..d9df936c 100644
--- a/tweak/Sources/Redesigned/Home/HomeHeader.x
+++ b/tweak/Sources/Redesigned/Home/HomeHeader.x
@@ -1,7 +1,8 @@
// Home redesign: the header the way the Music app has it. The filter pills (All, Music, Podcasts) go and
// a large title takes their place at the leading edge; the avatar that opens the side drawer moves to the
// trailing edge; the scrim Spotify lays behind the header goes too, the soft scroll edge (Kit/SGREdgeEffect.x)
-// being what keeps the page scrolling under it soft; the title itself scrolls away (followScroll).
+// being what keeps the page scrolling under it soft; the title itself scrolls away (followScroll), or stays
+// with the feed's hard edge under it (keepTitle).
//
// Tree (trees/clean/home/10.txt:3018-3051): FunkisViewController's view holds a 402x112 UIView around
// Reprise_LiquidGlassKit LiquidGlass.GradientView (the scrim) and, at {0, 62}, an
@@ -226,7 +227,7 @@ static CGRect untransformed(UIView *view) {
return CGRectMake(view.center.x - size.width / 2, view.center.y - size.height / 2, size.width, size.height);
}
-// The avatar's place, by its center and bounds too: it carries the scroll's transform (followScroll).
+// The avatar's place, by its center and bounds too: it carries the scroll's transform (followScroll), unless kept.
static CGRect facePlace(UIStackView *stack, UIView *face) {
CGRect place = untransformed(stack);
return CGRectOffset(untransformed(face), place.origin.x - stack.bounds.origin.x, place.origin.y - stack.bounds.origin.y);
@@ -324,7 +325,7 @@ static BOOL findHeader(UIView *view) {
// The title row scrolls away with the page, as the Music app's large title and avatar do: the title, the glass pill
// and Spotify's avatar rise with what is under them and fade over the title's height, so the page never passes
-// under them.
+// under them. Kept in place instead (keepTitle), the page passes under them over a hard edge.
static __weak UIView *sg_face;
static void rise(UIView *part, CGAffineTransform transform, CGFloat alpha) {
if (!CGAffineTransformEqualToTransform(part.transform, transform)) part.transform = transform;
@@ -375,11 +376,41 @@ static void followScroll(UIScrollView *scroll) {
// The feed: the page's outermost scroll view taller than the pills, found once. Not the tallest: a shelf can grow taller
// than the page, and a shelf's offset never moves the title. Followed by an observer that lives as long as it does.
-static char kFollowerKey;
+static char kFollowerKey, kEdgeKey;
static __weak UIScrollView *sg_feed;
static __weak UIView *sg_pageView;
+// Kept in place (SGRKeyHomeKeepTitle), the row stays and no observer is added: the header instead shapes the feed's
+// top edge effect, hard rather than the redesign's soft one (too faint under a large title, as Apple's guidelines
+// say of text outside glass), which then darkens the page under the title and the pill as under a navigation bar.
+static BOOL keepTitle(void) {
+ static int state = -1;
+ // Below iOS 26 there is no edge effect to put under it, and the scrim is gone: the title scrolls away there.
+ if (state < 0) state = SGRedesignAvailable() && SGHidden(SGRKeyHomeKeepTitle) ? 1 : 0;
+ return state == 1;
+}
+
+static void shapeEdge(UIScrollView *feed) {
+ SGRHardTopEdge(feed);
+ if (@available(iOS 26.0, *)) {
+ UIView *header = sg_header;
+ if (!header) return;
+ UIScrollEdgeElementContainerInteraction *edge = objc_getAssociatedObject(header, &kEdgeKey);
+ if (!edge) {
+ edge = [UIScrollEdgeElementContainerInteraction new];
+ edge.edge = UIRectEdgeTop;
+ [header addInteraction:edge];
+ objc_setAssociatedObject(header, &kEdgeKey, edge, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ if (edge.scrollView != feed) edge.scrollView = feed;
+ }
+}
+
static void followFeed(UIScrollView *feed) {
sg_feed = feed;
+ if (keepTitle()) {
+ shapeEdge(feed);
+ return;
+ }
if (!objc_getAssociatedObject(feed, &kFollowerKey)) {
SGRHomeTitleFollower *follower = [SGRHomeTitleFollower new];
follower.scroll = feed;
diff --git a/tweak/Sources/Redesigned/Home/HomeSettings.m b/tweak/Sources/Redesigned/Home/HomeSettings.m
index 7a7a18a6..a2cbac3d 100644
--- a/tweak/Sources/Redesigned/Home/HomeSettings.m
+++ b/tweak/Sources/Redesigned/Home/HomeSettings.m
@@ -33,6 +33,7 @@ UIViewController *SGRHomeSettingsPage(void) {
SGSection(@"On Home", @[
SGShownRow(@"Shortcuts", nil, SGRKeyHomeHideShortcuts),
SGShownRow(@"DJ", nil, SGRKeyHomeHideDJ),
+ SGOptionRow(@"Title stays on scroll", @"The title, the avatar and the pill stay at the top as Home scrolls under them", SGRKeyHomeKeepTitle),
SGOptionRow(@"Song suggestions", @"Spotify's carousel of songs to try, when Home offers one", SGRKeyHomeSongSuggestions),
SGOptionRow(@"Video and playlist previews", @"The cards that play as Home scrolls", SGRKeyHomePreviews),
]),
diff --git a/tweak/Sources/Redesigned/Kit/SGREdgeEffect.x b/tweak/Sources/Redesigned/Kit/SGREdgeEffect.x
index 12587195..938585b2 100644
--- a/tweak/Sources/Redesigned/Kit/SGREdgeEffect.x
+++ b/tweak/Sources/Redesigned/Kit/SGREdgeEffect.x
@@ -5,30 +5,39 @@
// on arrival, in case UIKit resolves the style again after the page appears.
#import <objc/runtime.h>
#import "Core/SGCore.h"
+#import "SGRRestyle.h"
-static void soften(UIScrollView *scrollView) {
+// The style last set here, so a layout pass the setter itself causes does not set it again; and whether a page asked
+// for the hard style rather than the soft one (SGRHardTopEdge).
+static char setKey, hardKey;
+
+static void styleTopEdge(UIScrollView *scrollView) {
if (@available(iOS 26.0, *)) {
- // The style last set here, so a layout pass the setter itself causes does not set it again.
- static char setKey;
UIScrollEdgeEffect *top = scrollView.topEdgeEffect;
if (top.style == objc_getAssociatedObject(scrollView, &setKey)) return;
- UIScrollEdgeEffectStyle *soft = UIScrollEdgeEffectStyle.softStyle;
- top.style = soft;
+ top.style = objc_getAssociatedObject(scrollView, &hardKey) ? UIScrollEdgeEffectStyle.hardStyle : UIScrollEdgeEffectStyle.softStyle;
objc_setAssociatedObject(scrollView, &setKey, top.style, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
static dispatch_once_t once;
dispatch_once(&once, ^{ SGLog(@"soft top edge: first scroll view %@", NSStringFromClass(scrollView.class)); });
}
}
+void SGRHardTopEdge(UIScrollView *scrollView) {
+ if (objc_getAssociatedObject(scrollView, &hardKey)) return;
+ objc_setAssociatedObject(scrollView, &hardKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ objc_setAssociatedObject(scrollView, &setKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ styleTopEdge(scrollView);
+}
+
%hook UIScrollView
- (void)didMoveToWindow {
%orig;
- if (self.window) soften(self);
+ if (self.window) styleTopEdge(self);
}
- (void)layoutSubviews {
%orig;
- if (self.window) soften(self);
+ if (self.window) styleTopEdge(self);
}
%end
diff --git a/tweak/Sources/Redesigned/Kit/SGRKit.h b/tweak/Sources/Redesigned/Kit/SGRKit.h
index 51c3bdeb..5e47b494 100644
--- a/tweak/Sources/Redesigned/Kit/SGRKit.h
+++ b/tweak/Sources/Redesigned/Kit/SGRKit.h
@@ -12,7 +12,7 @@
// SGRDownload.h Spotify's download state, read, and the glyph drawn for it
// SGRHeaderInfo.h a page header's title, creator, length, row and description, the Music app's
// SGRRestyle.h keeping Spotify's views restyled: suppress, digits, lookups, shadows, firing
-// controls, taking a list cell's paint off the field
+// controls, taking a list cell's paint off the field, a hard top edge (SGREdgeEffect.x)
// SGRBridges.h player state, now playing artwork, the player's open and close
// SGRRepaint.h the areas the redesign keeps transparent when Spotify repaints them
// SGRAccent.h the redesign's accent color; its AMOLED black is SGRAmoled.x, always on
diff --git a/tweak/Sources/Redesigned/Kit/SGRRestyle.h b/tweak/Sources/Redesigned/Kit/SGRRestyle.h
index a650e272..c11cccb8 100644
--- a/tweak/Sources/Redesigned/Kit/SGRRestyle.h
+++ b/tweak/Sources/Redesigned/Kit/SGRRestyle.h
@@ -84,3 +84,8 @@ void SGRActivate(UIView *source);
// 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);
+
+// Gives a scroll view the hard top edge effect, a dark band, and keeps the soft one SGREdgeEffect.x sets on every
+// other scroll view off it: for text that stays over a page scrolling under it (Home's kept title, HomeHeader.x).
+// iOS 26 on; nothing before.
+void SGRHardTopEdge(UIScrollView *scrollView);