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: declutter the artist page and fade its photo into a blur

Vojtěch Škopekd1692876dcd2
diff --git a/tweak/Makefile b/tweak/Makefile
index e4524d32..9e46cac1 100644
--- a/tweak/Makefile
+++ b/tweak/Makefile
@@ -12,7 +12,7 @@ SG_VERSION := $(shell sed -n 's/^Version: //p' control)
# is generated from the IPA by scripts/extract-flags.py.
spotifyglass_FILES := $(shell find Sources -name '*.m' -o -name '*.x' -o -name '*.swift' | sort)
spotifyglass_CFLAGS := -fobjc-arc -ISources -DSG_VERSION=\"$(SG_VERSION)\"
-spotifyglass_FRAMEWORKS := UIKit QuartzCore UniformTypeIdentifiers MediaPlayer
+spotifyglass_FRAMEWORKS := UIKit QuartzCore UniformTypeIdentifiers MediaPlayer CoreImage
# Runtime swizzling instead of Substrate so the dylib has no extra dependency inside the IPA.
spotifyglass_LOGOS_DEFAULT_GENERATOR := internal
diff --git a/tweak/Sources/Features/Artist/Artist.h b/tweak/Sources/Features/Artist/Artist.h
new file mode 100644
index 00000000..66f37838
--- /dev/null
+++ b/tweak/Sources/Features/Artist/Artist.h
@@ -0,0 +1,27 @@
+// Artist: parts of the artist page hidden one switch each (Artist.x). An unset switch is off.
+#import <UIKit/UIKit.h>
+
+#define SGKeyArtistPhotoFade @"spotifyglass.artistPhotoFade"
+
+#define SGHideArtistExplore @"spotifyglass.hide.artistExplore"
+#define SGHideArtistFollow @"spotifyglass.hide.artistFollow"
+#define SGHideArtistMore @"spotifyglass.hide.artistMore"
+#define SGHideArtistShuffle @"spotifyglass.hide.artistShuffle"
+#define SGHideArtistVerified @"spotifyglass.hide.artistVerified"
+#define SGHideArtistListeners @"spotifyglass.hide.artistListeners"
+
+#define SGHideArtistTabBar @"spotifyglass.hide.artistTabBar"
+
+#define SGHideArtistLikedSongs @"spotifyglass.hide.artistLikedSongs"
+#define SGHideArtistPopular @"spotifyglass.hide.artistPopular"
+#define SGHideArtistPick @"spotifyglass.hide.artistPick"
+#define SGHideArtistReleases @"spotifyglass.hide.artistReleases"
+#define SGHideArtistFeaturing @"spotifyglass.hide.artistFeaturing"
+#define SGHideArtistVideos @"spotifyglass.hide.artistVideos"
+#define SGHideArtistAbout @"spotifyglass.hide.artistAbout"
+#define SGHideArtistPlaylists @"spotifyglass.hide.artistPlaylists"
+#define SGHideArtistFansAlsoLike @"spotifyglass.hide.artistFansAlsoLike"
+#define SGHideArtistAppearsOn @"spotifyglass.hide.artistAppearsOn"
+#define SGHideArtistDiscoveredOn @"spotifyglass.hide.artistDiscoveredOn"
+
+UIViewController *SGArtistSettingsPage(void); // opened from the Home & Library page
diff --git a/tweak/Sources/Features/Artist/Artist.x b/tweak/Sources/Features/Artist/Artist.x
new file mode 100644
index 00000000..aa9af478
--- /dev/null
+++ b/tweak/Sources/Features/Artist/Artist.x
@@ -0,0 +1,338 @@
+// Artist: hides parts of the artist page, one switch each in Mod Settings > Home & Library > Artist.
+//
+// Trees (trees/continuous/*.txt): the page is a CreativeWorkPlatform TemplateView with the
+// identifier creator-page. Its header is an ImageHeaderView whose badge, listeners and buttons carry
+// accessibility identifiers. Below the Music/Video tabs every row is an Element_List cell: a titled
+// section is one cell for its heading (SectionHeadingHome), then its tracks, carousel or card, then
+// a 16pt spacer, each a cell of its own.
+//
+// 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.
+#import <objc/runtime.h>
+#import <CoreImage/CoreImage.h>
+#import "Core/SGCore.h"
+#import "Artist.h"
+
+static BOOL onArtistPage(UIView *view) {
+ for (UIView *v = view.superview; v; v = v.superview) {
+ if ([v.accessibilityIdentifier isEqualToString:@"creator-page"]) return YES;
+ }
+ return NO;
+}
+
+static UIView *identNamed(UIView *root, NSString *ident) {
+ __block UIView *found = nil;
+ SGForEachView(root, ^(UIView *v) {
+ if (!found && [v.accessibilityIdentifier hasPrefix:ident]) found = v;
+ });
+ return found;
+}
+
+#pragma mark - header
+
+static void hide(UIView *view, NSString *key) {
+ if (view && SGHidden(key)) view.hidden = YES;
+}
+
+// The identifier sits on the button; the action is the view the button row arranges around it.
+static UIView *actionHolding(UIView *button, UIView *header) {
+ for (UIView *v = button; v.superview && v.superview != header; v = v.superview) {
+ if (v.superview.superview == header) return v;
+ if ([NSStringFromClass(v.superview.class) containsString:@"OverflowStackView"]) return v;
+ }
+ return nil;
+}
+
+static void applyHeader(UIView *header) {
+ hide(identNamed(header, @"ImageHeaderView.VerifiedBadge"), SGHideArtistVerified);
+ // Its AutoLayoutStackView traps like OverflowStackView below once the label goes hidden.
+ if (SGHidden(SGHideArtistListeners)) identNamed(header, @"Components.Header.UI.Metadata").alpha = 0;
+
+ static const struct { __unsafe_unretained NSString *ident, *key; } buttons[] = {
+ {@"Components.UI.WatchFeedEntityExplorerButton", SGHideArtistExplore},
+ {@"Curation.FollowButtonElementKit.FollowButton", SGHideArtistFollow},
+ {@"Components.UI.ContextMenuButton", SGHideArtistMore},
+ {@"Components.UI.ShuffleButton", SGHideArtistShuffle},
+ };
+ for (size_t i = 0; i < sizeof(buttons) / sizeof(buttons[0]); i++) {
+ if (!SGHidden(buttons[i].key)) continue;
+ UIView *action = actionHolding(identNamed(header, buttons[i].ident), header);
+ if (!action) continue;
+ // OverflowStackView traps in updateConstraints once its views go hidden (crash 2026-09-15),
+ // so those only turn invisible and keep their place.
+ if ([NSStringFromClass(action.superview.class) containsString:@"OverflowStackView"]) {
+ action.alpha = 0;
+ action.userInteractionEnabled = NO;
+ } else {
+ action.hidden = YES;
+ }
+ }
+}
+
+static CGFloat bottomOf(UIView *v) {
+ return v.center.y + CGRectGetHeight(v.bounds) / 2;
+}
+
+static UIView *childOfHeader(UIView *view, UIView *header) {
+ for (UIView *v = view; v; v = v.superview) {
+ if (v.superview == header) return v;
+ }
+ return nil;
+}
+
+// The header keeps Spotify's height, so the room the hidden badge and listeners leave is given to
+// the photo: the title block slides down to sit where the lowest of them sat. Transforms, because
+// the header's stack views crash on anything that changes their layout.
+static void closeUpTitle(UIView *header) {
+ UIView *title = childOfHeader(identNamed(header, @"Encore.AdaptiveTitle"), header);
+ UIView *badge = identNamed(header, @"ImageHeaderView.VerifiedBadge");
+ UIView *listeners = identNamed(header, @"Components.Header.UI.Metadata");
+ UIView *metadata = childOfHeader(listeners, header);
+ if (!title || !badge || !metadata || badge.superview != header) return;
+
+ // Walks up from the listeners' line: each shown line lands on the bottom edge the line under it
+ // left free, keeping its own gap to the line above.
+ CGFloat edge = listeners.alpha > 0 ? bottomOf(badge) : bottomOf(metadata);
+ CGFloat move = 0;
+ if (!badge.hidden) {
+ move = edge - bottomOf(badge);
+ badge.transform = CGAffineTransformMakeTranslation(0, move);
+ edge = bottomOf(title) + move;
+ }
+ title.transform = CGAffineTransformMakeTranslation(0, MAX(0, edge - bottomOf(title)));
+}
+
+#pragma mark - photo fade
+
+// The photo sits in a clipping view shorter than the header, and Spotify's gradient over it is cut by
+// the same clip, so the picture ends in a straight line well above the buttons. With the switch on,
+// the photo's lower part dissolves into a blurred copy of itself that reaches the header's bottom
+// and fades out there.
+static UIImage *blurred(UIImage *image) {
+ static CIContext *context;
+ if (!context) context = [CIContext contextWithOptions:nil];
+ CIImage *input = [CIImage imageWithCGImage:image.CGImage];
+ if (!input) return nil;
+ CIImage *output = [[input imageByClampingToExtent] imageByApplyingGaussianBlurWithSigma:MAX(input.extent.size.width / 18, 6)];
+ CGImageRef cg = [context createCGImage:[output imageByCroppingToRect:input.extent] fromRect:input.extent];
+ UIImage *result = [UIImage imageWithCGImage:cg];
+ CGImageRelease(cg);
+ return result;
+}
+
+static CAGradientLayer *fadeMask(CALayer *host, NSArray<NSNumber *> *locations) {
+ CAGradientLayer *mask = [host.mask isKindOfClass:CAGradientLayer.class] ? (CAGradientLayer *)host.mask : nil;
+ if (!mask) {
+ mask = [CAGradientLayer layer];
+ mask.colors = @[(id)UIColor.blackColor.CGColor, (id)UIColor.blackColor.CGColor, (id)UIColor.clearColor.CGColor];
+ host.mask = mask;
+ }
+ mask.locations = locations;
+ mask.frame = host.bounds;
+ return mask;
+}
+
+static void applyPhotoFade(UIView *header) {
+ if (!SGFlag(SGKeyArtistPhotoFade, NO)) return;
+ UIView *artwork = identNamed(header, @"Components.Header.UI.ArtworkImage");
+ UIView *clip = childOfHeader(artwork, header);
+ if (!artwork || !clip || clip == artwork) return;
+ __block UIImageView *source = nil;
+ SGForEachView(artwork, ^(UIView *v) {
+ if (!source && [v isKindOfClass:UIImageView.class] && ((UIImageView *)v).image) source = (UIImageView *)v;
+ });
+
+ static char backdropKey, sourceKey;
+ UIImageView *backdrop = objc_getAssociatedObject(header, &backdropKey);
+ if (!backdrop) {
+ backdrop = [[UIImageView alloc] init];
+ backdrop.contentMode = UIViewContentModeScaleAspectFill;
+ backdrop.clipsToBounds = YES;
+ backdrop.userInteractionEnabled = NO;
+ UIView *shade = [[UIView alloc] init];
+ shade.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
+ shade.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ [backdrop addSubview:shade];
+ objc_setAssociatedObject(header, &backdropKey, backdrop, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ if (header.subviews.firstObject != backdrop) [header insertSubview:backdrop atIndex:0];
+ if (source.image && objc_getAssociatedObject(header, &sourceKey) != source.image) {
+ UIImage *soft = blurred(source.image);
+ if (soft) {
+ objc_setAssociatedObject(header, &sourceKey, source.image, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ backdrop.image = soft;
+ }
+ }
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ CGRect photo = [artwork convertRect:artwork.bounds toView:header];
+ CGFloat side = MAX(CGRectGetWidth(photo), CGRectGetHeight(header.bounds));
+ backdrop.frame = CGRectMake(CGRectGetMidX(photo) - side / 2, 0, side, CGRectGetHeight(header.bounds));
+ backdrop.subviews.firstObject.frame = backdrop.bounds;
+ backdrop.alpha = MIN(1, MAX(0, artwork.alpha));
+ fadeMask(backdrop.layer, @[@0, @0.7, @1]);
+ fadeMask(clip.layer, @[@0, @0.55, @1]);
+ [CATransaction commit];
+}
+
+%hook _TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView
+- (void)layoutSubviews {
+ %orig;
+ applyHeader((UIView *)self);
+ closeUpTitle((UIView *)self);
+ applyPhotoFade((UIView *)self);
+}
+%end
+
+// The buttons arrive after the header has laid out, and a row that keeps its size never lays the
+// header out again.
+%hook UIStackView
+- (void)layoutSubviews {
+ %orig;
+ UIView *header = self.superview;
+ if (![NSStringFromClass(header.class) containsString:@"ImageHeaderKit"]) return;
+ applyHeader(header);
+ closeUpTitle(header);
+}
+%end
+
+#pragma mark - tab bar
+
+// Trees (trees/continuous/1.txt): the strip (Components.UI.TabsSectionHeading) sits above a paging
+// scroll view holding one list per tab. The strip lives in a LegacyUI AutoLayoutStackView, so it
+// goes invisible rather than hidden; the pages move up into its place and stop swiping, which
+// leaves the Music list.
+static void hideTabBar(UIView *strip) {
+ strip.alpha = 0;
+ strip.userInteractionEnabled = NO;
+ for (UIView *v in strip.superview.subviews) {
+ if (![v isKindOfClass:UIScrollView.class]) continue;
+ ((UIScrollView *)v).scrollEnabled = NO;
+ v.transform = CGAffineTransformMakeTranslation(0, -CGRectGetHeight(strip.bounds));
+ }
+}
+
+%hook _TtCOOOE16PodcastUI_ECMKitO19LegacyUI_ECMCoreKit10Components18TabsSectionHeading2UI7Private9TabButton
+- (void)layoutSubviews {
+ %orig;
+ if (!SGHidden(SGHideArtistTabBar)) return;
+ for (UIView *v = ((UIView *)self).superview; v; v = v.superview) {
+ if (![v.accessibilityIdentifier isEqualToString:@"Components.UI.TabsSectionHeading"]) continue;
+ if (onArtistPage(v)) hideTabBar(v);
+ return;
+ }
+}
+%end
+
+#pragma mark - sections
+
+static const struct { __unsafe_unretained NSString *title, *key; BOOL prefix; } sections[] = {
+ {@"Popular", SGHideArtistPopular, NO},
+ {@"Artist pick", SGHideArtistPick, NO},
+ {@"Popular releases", SGHideArtistReleases, NO},
+ {@"Featuring ", SGHideArtistFeaturing, YES},
+ {@"Music videos", SGHideArtistVideos, NO},
+ {@"Watch more from ", SGHideArtistVideos, YES},
+ {@"About", SGHideArtistAbout, NO},
+ {@"Artist playlists", SGHideArtistPlaylists, NO},
+ {@"Fans also like", SGHideArtistFansAlsoLike, NO},
+ {@"Appears on", SGHideArtistAppearsOn, NO},
+ {@"Discovered on", SGHideArtistDiscoveredOn, NO},
+};
+
+static BOOL sectionHidden(NSString *title) {
+ for (size_t i = 0; i < sizeof(sections) / sizeof(sections[0]); i++) {
+ NSString *wanted = sections[i].title;
+ BOOL match = sections[i].prefix
+ ? [title.lowercaseString hasPrefix:wanted.lowercaseString]
+ : [title caseInsensitiveCompare:wanted] == NSOrderedSame;
+ if (match) return SGHidden(sections[i].key);
+ }
+ return NO;
+}
+
+static BOOL anySectionSwitch(void) {
+ for (size_t i = 0; i < sizeof(sections) / sizeof(sections[0]); i++) {
+ if (SGHidden(sections[i].key)) return YES;
+ }
+ return NO;
+}
+
+// The heading's title, or @"" for a cell that is not a heading.
+static NSString *headingIn(UIView *cell) {
+ __block NSString *title = nil;
+ SGForEachView(cell, ^(UIView *v) {
+ if (!title && v.accessibilityLabel.length && [NSStringFromClass(v.class) containsString:@"SectionHeadingHome"]) {
+ title = v.accessibilityLabel;
+ }
+ });
+ return title ?: @"";
+}
+
+// Per list: index path -> heading title, @"" for every other cell sized so far.
+static NSMutableDictionary<NSIndexPath *, NSString *> *headingsOf(UICollectionView *list) {
+ static char key;
+ NSMutableDictionary *headings = objc_getAssociatedObject(list, &key);
+ if (!headings) {
+ headings = [NSMutableDictionary dictionary];
+ objc_setAssociatedObject(list, &key, headings, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ return headings;
+}
+
+// The title of the section the cell falls under; nil above the first heading, or where a cell
+// between it and its heading has not been sized yet.
+static NSString *sectionOf(NSIndexPath *path, NSDictionary<NSIndexPath *, NSString *> *headings) {
+ for (NSInteger item = path.item; item >= 0; item--) {
+ NSString *title = headings[[NSIndexPath indexPathForItem:item inSection:path.section]];
+ if (!title) return nil;
+ if (title.length) return title;
+ }
+ return nil;
+}
+
+static UICollectionView *listOf(UIView *cell) {
+ for (UIView *v = cell.superview; v; v = v.superview) {
+ if ([v isKindOfClass:UICollectionView.class]) return (UICollectionView *)v;
+ }
+ return nil;
+}
+
+static BOOL collapsed(UICollectionViewCell *cell, NSIndexPath *path) {
+ for (UIView *v = cell.superview; v; v = v.superview) {
+ if ([v isKindOfClass:cell.class]) return NO; // a card inside a carousel: its row decides
+ }
+ if (!onArtistPage(cell)) return NO;
+ if (SGHidden(SGHideArtistLikedSongs) && identNamed(cell, @"Components.UI.LikedSongs.Row")) return YES;
+ if (!anySectionSwitch() || !path) return NO;
+
+ UICollectionView *list = listOf(cell);
+ if (!list) return NO;
+ NSMutableDictionary *headings = headingsOf(list);
+ headings[path] = headingIn(cell);
+ NSString *section = sectionOf(path, headings);
+ return section && sectionHidden(section);
+}
+
+%hook _TtC12Element_List18CollectionViewCell
+- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)attributes {
+ UICollectionViewLayoutAttributes *result = %orig;
+ if (!collapsed((UICollectionViewCell *)self, attributes.indexPath)) return result;
+ result.size = CGSizeMake(result.size.width, 0);
+ ((UIView *)self).clipsToBounds = YES;
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{ SGLog(@"artist page: collapsed the first row"); });
+ return result;
+}
+%end
+
+%ctor {
+ %init;
+ SGRequireClasses(@[
+ @"_TtC35CreativeWorkPlatform_ImageHeaderKit15ImageHeaderView",
+ @"_TtC12Element_List18CollectionViewCell",
+ @"_TtCOOOE16PodcastUI_ECMKitO19LegacyUI_ECMCoreKit10Components18TabsSectionHeading2UI7Private9TabButton",
+ ]);
+}
diff --git a/tweak/Sources/Features/Artist/ArtistSettings.m b/tweak/Sources/Features/Artist/ArtistSettings.m
new file mode 100644
index 00000000..0991cede
--- /dev/null
+++ b/tweak/Sources/Features/Artist/ArtistSettings.m
@@ -0,0 +1,41 @@
+#import "Core/SGCore.h"
+#import "Settings/SGModPage.h"
+#import "Artist.h"
+
+UIViewController *SGArtistSettingsPage(void) {
+ NSArray<SGModSection *> *sections = @[
+ SGSection(@"Photo", @[
+ SGOptionRow(@"Fade into a blur", @"The photo melts into a blurred copy of itself instead of ending in a straight line", SGKeyArtistPhotoFade),
+ ]),
+ SGSection(@"Hide in the header", @[
+ SGHideRow(@"Explore (video deck)", nil, SGHideArtistExplore),
+ SGHideRow(@"Follow", nil, SGHideArtistFollow),
+ SGHideRow(@"More options", nil, SGHideArtistMore),
+ SGHideRow(@"Shuffle", nil, SGHideArtistShuffle),
+ SGHideRow(@"Verified badge", nil, SGHideArtistVerified),
+ SGHideRow(@"Monthly listeners", nil, SGHideArtistListeners),
+ ]),
+ SGNotedSection(@"Tabs", @[
+ SGHideRow(@"Hide the tab bar", nil, SGHideArtistTabBar),
+ ], @"Music, Video, Merch, Events and any other tab. The page stays on Music and no longer swipes to the others."),
+ SGNotedSection(@"Hide on the page", @[
+ SGHideRow(@"Songs you liked", nil, SGHideArtistLikedSongs),
+ SGHideRow(@"Popular", nil, SGHideArtistPopular),
+ SGHideRow(@"Artist pick", nil, SGHideArtistPick),
+ SGHideRow(@"Popular releases", nil, SGHideArtistReleases),
+ SGHideRow(@"Featuring", nil, SGHideArtistFeaturing),
+ SGHideRow(@"Music videos", nil, SGHideArtistVideos),
+ SGHideRow(@"About", nil, SGHideArtistAbout),
+ SGHideRow(@"Artist playlists", nil, SGHideArtistPlaylists),
+ SGHideRow(@"Fans also like", nil, SGHideArtistFansAlsoLike),
+ SGHideRow(@"Appears on", nil, SGHideArtistAppearsOn),
+ SGHideRow(@"Discovered on", nil, SGHideArtistDiscoveredOn),
+ ], @"Sections are found by their English titles, so these do nothing while Spotify is in another language."),
+ SGSection(@"Spotify's own", @[
+ SGFlagRow(@"Share button in the header", @"ios-creator-impl.share_in_action_row_enabled_artist"),
+ SGFlagRow(@"More options in the navigation bar", @"ios-creator-impl.context_menu_in_navigation_bar_enabled_artist"),
+ SGFlagRow(@"Top collaborators", @"ios-creator-impl.is_top_collaborators_enabled"),
+ SGFlagRow(@"Artist facts", @"ios-creator-impl.is_artist_facts_enabled"), ]),
+ ];
+ return [[SGModPage alloc] initWithTitle:@"Artist" intro:nil sections:sections footer:nil];
+}
diff --git a/tweak/Sources/Features/Home/HomeSettings.m b/tweak/Sources/Features/Home/HomeSettings.m
index 7da14573..67487da7 100644
--- a/tweak/Sources/Features/Home/HomeSettings.m
+++ b/tweak/Sources/Features/Home/HomeSettings.m
@@ -3,6 +3,7 @@
#import "Home.h"
#import "Features/Declutter/Declutter.h"
#import "Features/Playlist/Playlist.h"
+#import "Features/Artist/Artist.h"
static SGModRow *choiceRow(NSString *title, NSString *subtitle, SGHomeChoice choice) {
return SGChoiceRow(title, subtitle, SGHomeChoiceKey(choice), SGHomeChoiceNames(choice),
@@ -59,7 +60,7 @@ UIViewController *SGHomeSettingsPage(void) {
SGWithSymbol(SGPageRow(@"Playlists", ^UIViewController *{ return SGPlaylistSettingsPage(); }), @"music.note.list"),
SGWithSymbol(SGPageRow(@"Library", ^UIViewController *{ return libraryPage(); }), @"books.vertical"),
SGWithSymbol(SGPageRow(@"Album", ^UIViewController *{ return emptyPage(@"Album"); }), @"square.stack"),
- SGWithSymbol(SGPageRow(@"Artist", ^UIViewController *{ return emptyPage(@"Artist"); }), @"music.mic"),
+ SGWithSymbol(SGPageRow(@"Artist", ^UIViewController *{ return SGArtistSettingsPage(); }), @"music.mic"),
]),
SGSection(@"Home", @[
SGWithSymbol(gradient, @"rectangle.tophalf.inset.filled"),