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 Mod Settings row stays in the drawer and settings list

My-Name-Is-Jeff396bf8fef20b
diff --git a/harness/mod-settings/README.md b/harness/mod-settings/README.md
index 16a2dce8..3f5f9285 100644
--- a/harness/mod-settings/README.md
+++ b/harness/mod-settings/README.md
@@ -26,6 +26,11 @@ switch brings it in with its 38 pt heading and 28 pt note and scrolls 362 pt, ha
ticker brings the later row within a second without moving the page; the switch off takes the heading and note
away again.
+`rows` on the launch line makes Spotify's settings list controller and the side drawer's list class under their own
+names before the hooks are set, then lays a drawer list out and a settings list out under its controller, empties
+each of its subviews as Spotify can, and lays it out again. It logs how many Mod Settings rows each has: 1 and 1 for
+both. With main's ModSettings.x before the fix it read 0 and 0 for the drawer and 1 then 0 for the settings list.
+
`needs` pushes the Lock screen page's artwork section as iOS 18 to 25 get it (the real
`AnimatedArtworkSettings.m`'s `SGLockScreenArtworkNeedsRow`), and `tap=<section>.<row>` selects a row and logs the
alert it brings up: "Full-screen artwork", "Needs iOS 26", and an alert naming the iOS version.
@@ -41,5 +46,5 @@ Library for Albums & artists in place.
parser takes a plain XML plist as well as a signed one, so one written by hand will do (copy it in after
`build.sh`, before `simctl install`).
-What it does not cover: the pages the rows open, the row the mod adds to Spotify's settings list and side drawer,
-and iOS below 26, where the switch warns first.
+What it does not cover: the pages the rows open, the row the mod adds to Spotify's settings list and side drawer
+in Spotify's real lists (`rows` uses stand-ins of the same names), and iOS below 26, where the switch warns first.
diff --git a/harness/mod-settings/main.m b/harness/mod-settings/main.m
index e4f9964d..5a55e040 100644
--- a/harness/mod-settings/main.m
+++ b/harness/mod-settings/main.m
@@ -14,8 +14,10 @@
// section of twelve rows shown only while the switch is on, and a row that comes by itself), later (that row
// let come; the page's ticker brings it), top (scrolled to the start), layout (the scroll offset, and each
// section's rows and heading and note heights, to the log), needs (the Lock screen artwork section below iOS
-// 26), tap=<section>.<row> (that row selected, and the alert it brings up logged).
+// 26), tap=<section>.<row> (that row selected, and the alert it brings up logged), rows (the row the mod adds to
+// Spotify's settings list and drawer, after each list is emptied of its subviews, counted to the log).
#import <UIKit/UIKit.h>
+#import <objc/runtime.h>
#import "Core/SGCore.h"
#import "Settings/SGPage.h"
#import "Settings/SGModPage.h"
@@ -32,6 +34,17 @@ static void findViews(UIView *root, Class kind, NSMutableArray *found) {
for (UIView *sub in root.subviews) findViews(sub, kind, found);
}
+// With `rows` on the launch line, Spotify's settings list controller and the side drawer's list by their own
+// names, made before ModSettings.x's %ctor hooks them (constructor priorities hold within this binary).
+static const char *const kDrawerClass = "_TtC23SideDrawer_ListPageImplP33_1D8CA7A9CC41E8D184AF8B9AAE4E684E28SideDrawerListCollectionView";
+static const char *const kSettingsClass = "_TtC21Settings_PlatformImpl26SettingsListViewController";
+
+__attribute__((constructor(101))) static void harnessClasses(void) {
+ if (![NSProcessInfo.processInfo.arguments containsObject:@"rows"]) return;
+ objc_registerClassPair(objc_allocateClassPair(UICollectionView.class, kDrawerClass, 0));
+ objc_registerClassPair(objc_allocateClassPair(UIViewController.class, kSettingsClass, 0));
+}
+
// The `gated` page: a switch, ten rows of filler, then a headed and noted section whose twelve rows show only
// while the switch is on, and a row that comes by itself once `later` is played.
static BOOL sg_later;
@@ -124,6 +137,35 @@ static UIViewController *gatedPage(void) {
[table setContentOffset:CGPointMake(0, MAX(-table.adjustedContentInset.top, table.contentSize.height - table.bounds.size.height + table.adjustedContentInset.bottom)) animated:NO];
} else if ([verb isEqualToString:@"gated"]) {
[self.nav pushViewController:gatedPage() animated:NO];
+ } else if ([verb isEqualToString:@"rows"]) {
+ // The row ModSettings.x adds to Spotify's settings list and to the side drawer's list, each emptied of its
+ // subviews afterwards as Spotify can do, then laid out again.
+ NSUInteger (^count)(UIView *) = ^NSUInteger(UIView *list) {
+ NSUInteger n = 0;
+ for (UIView *sub in list.subviews) n += [NSStringFromClass(sub.class) isEqualToString:@"SGModSettingsRow"];
+ return n;
+ };
+ void (^empty)(UIView *) = ^(UIView *list) {
+ for (UIView *sub in [list.subviews copy]) [sub removeFromSuperview];
+ [list setNeedsLayout];
+ [list layoutIfNeeded];
+ };
+ UICollectionView *drawer = [[NSClassFromString(@(kDrawerClass)) alloc] initWithFrame:CGRectMake(0, 0, 390, 600)
+ collectionViewLayout:[UICollectionViewFlowLayout new]];
+ [self.window addSubview:drawer];
+ [drawer layoutIfNeeded];
+ NSUInteger drawerFirst = count(drawer);
+ empty(drawer);
+ UIViewController *settings = [NSClassFromString(@(kSettingsClass)) new];
+ UICollectionView *list = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 390, 600) collectionViewLayout:[UICollectionViewFlowLayout new]];
+ [settings.view addSubview:list];
+ [settings viewDidLayoutSubviews];
+ [list layoutIfNeeded];
+ NSUInteger settingsFirst = count(list);
+ empty(list);
+ NSLog(@"[harness] rows: drawer %lu on its first layout, %lu after it was emptied; settings %lu, %lu after it was emptied",
+ (unsigned long)drawerFirst, (unsigned long)count(drawer), (unsigned long)settingsFirst, (unsigned long)count(list));
+ [drawer removeFromSuperview];
} else if ([verb isEqualToString:@"needs"]) {
[self.nav pushViewController:[[SGModPage alloc] initWithTitle:@"Lock screen" intro:nil sections:@[
SGSection(@"Lock screen artwork", @[SGLockScreenArtworkNeedsRow()]),
diff --git a/tweak/Sources/App/ModSettings.x b/tweak/Sources/App/ModSettings.x
index accdafd2..d535ad38 100644
--- a/tweak/Sources/App/ModSettings.x
+++ b/tweak/Sources/App/ModSettings.x
@@ -260,31 +260,51 @@ static BOOL isSettingsRoot(UIViewController *list) {
%end
// The drawer's list (trees/test6.txt: SideDrawerListCollectionView under the profile header, Your
-// plan its first cell) is one of several collection views on the page, so it is found by name.
+// plan its first cell) is one of several collection views on the page, so it is found by name, and
+// its class is kept for the list's own layout below to know it by. Spotify 9.1.78's private class is
+// looked up at launch, so the list gets its row on its first layout, even before its controller's.
+static NSString *const kDrawerList = @"_TtC23SideDrawer_ListPageImplP33_1D8CA7A9CC41E8D184AF8B9AAE4E684E28SideDrawerListCollectionView";
+static Class sg_drawerList;
+
+// Spotify can take the list's subviews away and fill it again while keeping the list itself, so a
+// row that has lost its place is put back rather than a second one made.
+static void attachDrawerRow(UICollectionView *list) {
+ SGModSettingsRow *row = objc_getAssociatedObject(list, &kRowKey);
+ if (!row) {
+ row = [[SGModSettingsRow alloc] initWithFrame:CGRectZero];
+ row.drawer = YES;
+ objc_setAssociatedObject(list, &kRowKey, row, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ if (row.superview != list) [list addSubview:row];
+}
+
%hook _TtC23SideDrawer_ListPageImpl18ListViewController
- (void)viewDidLayoutSubviews {
%orig;
SGForEachView(((UIViewController *)self).view, ^(UIView *v) {
if (![v isKindOfClass:UICollectionView.class] || ![NSStringFromClass(v.class) containsString:@"SideDrawerListCollectionView"]) return;
- if (objc_getAssociatedObject(v, &kRowKey)) return;
- SGModSettingsRow *row = [[SGModSettingsRow alloc] initWithFrame:CGRectZero];
- row.drawer = YES;
- objc_setAssociatedObject(v, &kRowKey, row, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- [v addSubview:row];
+ sg_drawerList = v.class;
+ attachDrawerRow((UICollectionView *)v);
});
}
%end
-// The lists lay out after their controllers and again whenever their content changes.
+// The lists lay out after their controllers and again whenever their content changes. The drawer's
+// can fill after its controller laid out, so its row is made or put back there too. Either list's row
+// that Spotify took away with the list's subviews is put back before it is placed.
%hook UICollectionView
- (void)layoutSubviews {
%orig;
+ if (sg_drawerList && [self isKindOfClass:sg_drawerList]) attachDrawerRow(self);
SGModSettingsRow *row = objc_getAssociatedObject(self, &kRowKey);
- if (row) placeRow(self, row);
+ if (!row) return;
+ if (row.superview != self) [self addSubview:row];
+ placeRow(self, row);
}
%end
%ctor {
+ sg_drawerList = NSClassFromString(kDrawerList);
%init;
SGRequireClasses(@[@"_TtC21Settings_PlatformImpl26SettingsListViewController", @"_TtC23SideDrawer_ListPageImpl18ListViewController"]);
SGRegisterPages();