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

fix: the album page's black band under the title as it scrolled, and its field taking Spotify's colour where Spotify has one

Vojtěch Škopek8dc7a7f0ef98
diff --git a/harness/album/main.m b/harness/album/main.m
index 0e436c68..e1ccc3c8 100644
--- a/harness/album/main.m
+++ b/harness/album/main.m
@@ -16,8 +16,11 @@
@interface _TtC28EncoreConsumerMobile_BaseKit20HeaderNavigationBar : UIView @end
@implementation _TtC28EncoreConsumerMobile_BaseKit20HeaderNavigationBar @end
+// Spotify's draws a CAGradientLayer; whether it is the view's own layer is what the device log settles.
@interface _TtC19LegacyUI_ECMCoreKit12GradientView : UIView @end
-@implementation _TtC19LegacyUI_ECMCoreKit12GradientView @end
+@implementation _TtC19LegacyUI_ECMCoreKit12GradientView
++ (Class)layerClass { return CAGradientLayer.class; }
+@end
@interface _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView : UIView @end
@implementation _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView @end
@@ -73,6 +76,9 @@ static UIImage *artwork(void) {
for (int i = 0; i < 4; i++) {
[[UIBezierPath bezierPathWithRect:CGRectMake(24 + i * 62, 60 + (i % 2) * 90, 48, 150)] fill];
}
+ // A scanned sleeve: the scanner's pale border along the bottom, which is all the Kit's palette reads.
+ [[UIColor colorWithWhite:0.82 alpha:1] setFill];
+ UIRectFill(CGRectMake(0, 282, 300, 18));
}];
}
@@ -159,11 +165,15 @@ static UIView *actionButton(UIView *row, CGRect frame, NSString *identifier, NSS
// Spotify's colour wash behind the header, the height of the header at rest.
UIView *wash = box(page, _TtCO19LegacyUI_ECMCoreKit5Views10HeaderView.class, CGRectMake(0, 0, W, 486.67), nil);
UIView *gradient = box(wash, _TtC19LegacyUI_ECMCoreKit12GradientView.class, wash.bounds, nil);
- gradient.backgroundColor = [UIColor colorWithRed:0.13 green:0.24 blue:0.44 alpha:1];
+ // The colour Spotify read off the whole cover, down to its base surface.
+ ((CAGradientLayer *)gradient.layer).colors = @[(id)[UIColor colorWithRed:0.29 green:0.22 blue:0.62 alpha:1].CGColor,
+ (id)[UIColor colorWithRed:0.07 green:0.07 blue:0.07 alpha:1].CGColor];
// the tab, the scroll and the stack the header and the list sit in
UIView *tab = box(page, UIView.class, CGRectMake(0, 0, W, H), @"CreativeWorkPlatform.Tab");
UIScrollView *scroll = (UIScrollView *)box(tab, UIScrollView.class, CGRectMake(0, 0, W, H), @"PCFFTabLayoutViewController.containerScrollView");
+ // Spotify's starts its content at the very top of the page, under the status bar.
+ scroll.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
UIStackView *stack = (UIStackView *)box(scroll, UIStackView.class, CGRectMake(0, 0, W, 2200), nil);
UIView *headerElement = box(stack, UIView.class, CGRectMake(0, 0, W, 486.67), @"CreativeWorkPlatform.Header");
@@ -300,8 +310,14 @@ static UIView *actionButton(UIView *row, CGRect frame, NSString *identifier, NSS
// the sticky navigation bar, its gradient hidden until the page scrolls
UIView *navBar = box(page, _TtC28EncoreConsumerMobile_BaseKit20HeaderNavigationBar.class, CGRectMake(0, 0, W, 118), @"CreativeWorkPlatform.HeaderNavigationBar");
UIView *navGradient = box(navBar, _TtC19LegacyUI_ECMCoreKit12GradientView.class, navBar.bounds, nil);
- navGradient.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
+ ((CAGradientLayer *)navGradient.layer).colors = @[(id)[UIColor colorWithWhite:0.02 alpha:1].CGColor,
+ (id)[UIColor colorWithWhite:0.02 alpha:1].CGColor];
navGradient.hidden = YES;
+ // Scrolled, Spotify shows it by -setHidden:, which is what took a conceal() back.
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ navGradient.hidden = NO;
+ NSLog(@"[harness] Spotify showed the navigation bar's gradient; mask %@", navGradient.layer.mask ? @"on" : @"off");
+ });
// the two controls Spotify floats over the page, outside the scroll
UIView *shuffleElement = box(page, UIView.class, CGRectMake(282, 62, 48, 48), nil);
diff --git a/tweak/Sources/Redesigned/Album/Album.h b/tweak/Sources/Redesigned/Album/Album.h
index 80bb0fbd..9e30b776 100644
--- a/tweak/Sources/Redesigned/Album/Album.h
+++ b/tweak/Sources/Redesigned/Album/Album.h
@@ -33,3 +33,6 @@ UIView *SGRAlbumPageOf(UIView *view);
UIColor *SGRAlbumFieldColor(UIView *view);
// The cover of the page `view` is on, for its field to take its colour from. The same image again is a no-op.
void SGRAlbumSetArtwork(UIView *view, UIImage *image);
+// The colour Spotify picked for the album, read off the wash it paints behind the header: the field takes it
+// over the one read from the cover's bottom edge. The same colour again is a no-op.
+void SGRAlbumSetSpotifyColor(UIView *view, UIColor *color);
diff --git a/tweak/Sources/Redesigned/Album/AlbumField.x b/tweak/Sources/Redesigned/Album/AlbumField.x
index 93765c9c..f3031e85 100644
--- a/tweak/Sources/Redesigned/Album/AlbumField.x
+++ b/tweak/Sources/Redesigned/Album/AlbumField.x
@@ -14,8 +14,11 @@
// repaint hook while sgr_albumRoot is this page, and by the list's own pass below, which paints itself
// rather than through a layer the repaint hook would hear about.
//
-// The colour is read from the cover the header shows (AlbumHeader.x hands it over), and until that has
-// loaded the field is the neutral one, as it is for an album with no cover at all.
+// The colour is Spotify's own for the album, read off the wash it paints behind the header, which
+// AlbumHeader.x hands over as it conceals it. Spotify reads the whole cover; the Kit's palette reads its
+// bottom edge, and a scanned cover's bottom edge is the scanner's pale border, which turned the field grey
+// where Spotify had it blue (device, 2026-09-18). The colour read from the cover is what shows until
+// Spotify's arrives, or for good if it never does, and before either the field is the neutral one.
//
// The page is the album's by its identifier, which is how Native/Album/Album.x has told it apart since it
// shipped: the artist page is TemplateKit's TemplateView instead, and podcasts are their own framework.
@@ -58,6 +61,10 @@ void SGRAlbumSetArtwork(UIView *view, UIImage *image) {
if (image) [fieldOn(view) setArtwork:image identity:nil animated:YES];
}
+void SGRAlbumSetSpotifyColor(UIView *view, UIColor *color) {
+ if (color) [fieldOn(view) setPreferredColor:color];
+}
+
static SGRArtworkField *fieldIn(UIView *page) {
SGRArtworkField *field = objc_getAssociatedObject(page, &kFieldKey);
if (field) return field;
diff --git a/tweak/Sources/Redesigned/Album/AlbumHeader.x b/tweak/Sources/Redesigned/Album/AlbumHeader.x
index f8346970..cc1b1643 100644
--- a/tweak/Sources/Redesigned/Album/AlbumHeader.x
+++ b/tweak/Sources/Redesigned/Album/AlbumHeader.x
@@ -375,15 +375,59 @@ static void applyActions(UIView *row, UIView *header, UIView *page) {
#pragma mark - the header's pass
-// Spotify's colour wash behind the header goes, so the page's field shows through. The sticky navigation
-// bar above it keeps its own gradient: that one is hidden at rest and fades in under the title as the page
-// scrolls, which is what makes the title legible over the list.
+// Drawn by nothing, whatever Spotify does to it: an empty mask. Spotify switches the navigation bar's
+// gradient on and off with -setHidden:, which writes the layer's own hidden and so undoes conceal(); and
+// it fades both gradients by alpha. Neither touches a mask.
+static void maskOut(UIView *view) {
+ if (!view || view.layer.mask) return;
+ view.layer.mask = [CALayer layer];
+ view.accessibilityElementsHidden = YES;
+}
+
+// The colour Spotify painted the wash in: the first opaque colour of the gradient layer it draws with,
+// whether that is the view's own layer or one under it. nil when it draws some other way, or has
+// no colour yet.
+static UIColor *washColorOf(UIView *gradient) {
+ NSMutableArray<CALayer *> *layers = [NSMutableArray arrayWithObject:gradient.layer];
+ [layers addObjectsFromArray:gradient.layer.sublayers ?: @[]];
+ for (CALayer *layer in layers) {
+ if (![layer isKindOfClass:CAGradientLayer.class]) continue;
+ for (id value in ((CAGradientLayer *)layer).colors) {
+ CGColorRef cg = (__bridge CGColorRef)value;
+ if (CFGetTypeID(cg) != CGColorGetTypeID() || CGColorGetAlpha(cg) < 0.5) continue;
+ // The page's base surface is what a wash is before Spotify has a colour for it, not a colour.
+ if (SGIsBaseSurface(cg)) return nil;
+ return [UIColor colorWithCGColor:cg];
+ }
+ }
+ return nil;
+}
+
+// Spotify's colour wash behind the header goes, so the page's field shows through, and the colour it was
+// painted in goes to the field: Spotify reads the whole cover for it, where the Kit reads the bottom edge.
+//
+// The navigation bar's gradient goes too. Hidden at rest, it is shown as the page scrolls under the
+// title, and over the field it was a flat dark band across the top (device, 2026-09-18). What keeps the
+// title legible over the list is the soft top edge every redesigned page has (SGREdgeEffect.x), as it is
+// on Home, Search and Library.
static void applyWash(UIView *page) {
for (UIView *sub in page.subviews) {
NSString *name = NSStringFromClass(sub.class);
- if (![name containsString:@"HeaderView"] || [name containsString:@"NavigationBar"]) continue;
+ if (![name containsString:@"HeaderView"] && ![name containsString:@"HeaderNavigationBar"]) continue;
+ BOOL wash = ![name containsString:@"NavigationBar"];
for (UIView *v in sub.subviews) {
- if ([NSStringFromClass(v.class) containsString:@"GradientView"]) conceal(v);
+ if (![NSStringFromClass(v.class) containsString:@"GradientView"]) continue;
+ if (wash) {
+ UIColor *color = washColorOf(v);
+ static BOOL logged;
+ if (!logged) {
+ logged = YES;
+ SGLog(@"redesign album: Spotify's wash %@ on %@, colour %@", NSStringFromClass(v.class),
+ NSStringFromClass(v.layer.class), color ?: @"not found");
+ }
+ SGRAlbumSetSpotifyColor(page, color);
+ }
+ maskOut(v);
}
}
}
diff --git a/tweak/Sources/Redesigned/Kit/SGRField.h b/tweak/Sources/Redesigned/Kit/SGRField.h
index a73a3585..3f863249 100644
--- a/tweak/Sources/Redesigned/Kit/SGRField.h
+++ b/tweak/Sources/Redesigned/Kit/SGRField.h
@@ -29,6 +29,10 @@ extern NSNotificationName const SGRFieldColorDidChangeNotification;
// A colour Spotify already has for the page (the player's background colour), made fit to be a field
// and shown until the first artwork has been read; ignored after that.
- (void)setProvisionalColor:(UIColor *)color;
+// A colour the page already picked for itself (Spotify's own for an album), made fit to be a field; it wins
+// over the one read from the artwork's bottom edge, which on a scanned cover is the scanner's grey border
+// rather than the picture. nil keeps what is set.
+- (void)setPreferredColor:(UIColor *)color;
// Reads the artwork off the main thread and crossfades the result in (without animation when
// `animated` is NO or the field is not in a window). The same image, or the same non-nil identity,
// as the last call is a no-op, and a result that lands after a newer call is dropped. nil keeps
diff --git a/tweak/Sources/Redesigned/Kit/SGRField.m b/tweak/Sources/Redesigned/Kit/SGRField.m
index 2c30c7bd..ad9fbedc 100644
--- a/tweak/Sources/Redesigned/Kit/SGRField.m
+++ b/tweak/Sources/Redesigned/Kit/SGRField.m
@@ -33,6 +33,7 @@ static NSDictionary *noActions(void) {
CAGradientLayer *_black;
CALayer *_backdrop;
UIColor *_color;
+ UIColor *_preferred; // the page's own colour, made fit; wins over the artwork's
UIImage *_image;
NSString *_identity;
NSUInteger _generation;
@@ -125,6 +126,14 @@ static NSDictionary *noActions(void) {
[self applyColor:SGRFieldColorFor(color) animated:self.window != nil];
}
+- (void)setPreferredColor:(UIColor *)color {
+ if (!color) return;
+ UIColor *fit = SGRFieldColorFor(color);
+ if (_preferred && CGColorEqualToColor(fit.CGColor, _preferred.CGColor)) return;
+ _preferred = fit;
+ [self applyColor:fit animated:self.window != nil];
+}
+
- (void)setArtwork:(UIImage *)image identity:(NSString *)identity animated:(BOOL)animated {
if (!image || image == _image || (identity && [identity isEqualToString:_identity])) return;
_image = image;
@@ -155,7 +164,7 @@ static NSDictionary *noActions(void) {
_backdrop.hidden = NO;
[CATransaction commit];
}
- [self applyColor:palette.fieldColor animated:animated];
+ [self applyColor:_preferred ?: palette.fieldColor animated:animated];
}
@end