Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: add proper state management into settings
Vojtěch Škopek5a7113c5c853
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex 5cea9e24..613fb658 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -45,6 +45,10 @@ app:Onboarding/ the welcome tour over Home on the first launch (Onboarding.x, the pages in Tour.m), offered again from AboutAbout/ the update check and the About section of the root page+Every key a feature stores starts with `spotifyglass.`, whatever it holds: Reset all settings in+About removes by that prefix and has no list to keep up to date. It leaves `SGKeyStock` behind,+which makes every unset switch read off, so a reset is stock Spotify whatever switches exist.+A hook reads its switch when it runs (`SGEnabled`, `SGHidden`, `SGFlag` from Core/SGPrefs.h), so achange shows after Spotify restarts; Navbar is the exception and applies as soon as the bar laysout again, as are the Home gradient's colour, strength and height, but not the switch that turns it on. The root page in `Settings/SGModSettings.x` lists every feature's page by hand.diff --git a/tweak/Sources/Core/SGPrefs.h b/tweak/Sources/Core/SGPrefs.hindex 37688086..3aeaf7c7 100644--- a/tweak/Sources/Core/SGPrefs.h+++ b/tweak/Sources/Core/SGPrefs.h@@ -1,7 +1,13 @@// The mod's own settings, in Spotify's NSUserDefaults. Every key is declared by the feature that-// owns it, in that feature's header; the accessors here are what the hooks and the pages share.+// owns it, in that feature's header, and starts with "spotifyglass.": Reset all settings in About+// sweeps by that prefix and knows no key by name. The accessors here are what the hooks and the+// pages share.#import <Foundation/Foundation.h>+// Set by the reset, after the sweep: an unset switch then reads off rather than the way the build+// came, so a reset is stock Spotify, for every switch there is and every one added later.+#define SGKeyStock @"spotifyglass.stock"+BOOL SGFlag(NSString *key, BOOL fallback);BOOL SGEnabled(NSString *key); // an unset switch is onBOOL SGHidden(NSString *key); // an unset switch is off@@ -17,3 +23,6 @@ void SGSetInt(NSString *key, NSInteger value);extern NSString *const SGFlagOverridePrefix;id SGFlagOverride(NSString *key);void SGSetFlagOverride(NSString *key, id value);++// Quits Spotify so the hooks read the switches afresh on the next launch; the writes reach cfprefsd first.+void SGRestartSpotify(void);diff --git a/tweak/Sources/Core/SGPrefs.m b/tweak/Sources/Core/SGPrefs.mindex bcd6051b..985012d0 100644--- a/tweak/Sources/Core/SGPrefs.m+++ b/tweak/Sources/Core/SGPrefs.m@@ -1,8 +1,10 @@#import "SGPrefs.h"BOOL SGFlag(NSString *key, BOOL fallback) {- id value = [NSUserDefaults.standardUserDefaults objectForKey:key];- return value ? [value boolValue] : fallback;+ NSUserDefaults *store = NSUserDefaults.standardUserDefaults;+ id value = [store objectForKey:key];+ if (value) return [value boolValue];+ return fallback && ![store boolForKey:SGKeyStock];}BOOL SGEnabled(NSString *key) {@@ -37,3 +39,8 @@ void SGSetFlagOverride(NSString *key, id value) {if (value) [NSUserDefaults.standardUserDefaults setObject:value forKey:key];else [NSUserDefaults.standardUserDefaults removeObjectForKey:key];}++void SGRestartSpotify(void) {+ [NSUserDefaults.standardUserDefaults synchronize];+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ exit(0); });+}diff --git a/tweak/Sources/Features/About/AboutSettings.m b/tweak/Sources/Features/About/AboutSettings.mindex 2de0785e..d4a79cde 100644--- a/tweak/Sources/Features/About/AboutSettings.m+++ b/tweak/Sources/Features/About/AboutSettings.m@@ -1,10 +1,37 @@+#import "Core/SGCore.h"#import "Settings/SGPageStyle.h"#import "About.h"#import "Features/Onboarding/Onboarding.h"+// Every key of the mod's is under one prefix, so a reset is a sweep of the defaults with the stock+// marker of SGPrefs.h left behind; the hooks read them at launch, so it ends in a restart.+static void resetAll(void) {+ NSUserDefaults *store = NSUserDefaults.standardUserDefaults;+ NSUInteger removed = 0;+ for (NSString *key in [store persistentDomainForName:NSBundle.mainBundle.bundleIdentifier].allKeys) {+ if (![key hasPrefix:@"spotifyglass."]) continue;+ [store removeObjectForKey:key];+ removed++;+ }+ [store setBool:YES forKey:SGKeyStock];+ SGLog(@"reset: removed %lu keys", (unsigned long)removed);+ SGRestartSpotify();+}++static void confirmReset(void) {+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Reset all settings?"+ message:@"Every switch goes off, flag overrides and the tab bar layout are cleared, and Spotify restarts as it came, with the mod doing nothing until asked. Spotify's own settings are untouched."+ preferredStyle:UIAlertControllerStyleAlert];+ [alert addAction:[UIAlertAction actionWithTitle:@"Reset and restart" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { resetAll(); }]];+ [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];+ [SGTopController() presentViewController:alert animated:YES completion:nil];+}+// Which build this is, whether the site has a newer one, and where to reach the mod: without these// rows a build that is already installed has no way of telling its user that anything moved on.SGModSection *SGAboutSection(void) {+ SGModRow *reset = SGActionRow(@"Reset all settings", @"Every switch off, Spotify as it came, then a restart", ^{ confirmReset(); });+ reset.color = SGRed();NSString *spotify = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: @"unknown";return SGSection(@"About", @[SGStatRow(@"Version", ^NSString *{ return @(SG_VERSION); }),@@ -15,5 +42,6 @@ SGModSection *SGAboutSection(void) {SGLinkRow(@"Website", @"Downloads, and the source to add to AltStore or SideStore", SGSiteURL),SGLinkRow(@"GitHub", @"Source, releases and issues", SGRepoURL),SGActionRow(@"Welcome tour", @"The pages from the first launch, again", ^{ SGShowOnboarding(); }),+ reset,]);}diff --git a/tweak/Sources/Features/Appearance/Amoled.x b/tweak/Sources/Features/Appearance/Amoled.xindex 05378d9c..0f4d9bb4 100644--- a/tweak/Sources/Features/Appearance/Amoled.x+++ b/tweak/Sources/Features/Appearance/Amoled.x@@ -51,8 +51,19 @@ static CGColorRef copyBlack(CGColorRef color) {}%end+// Spotify's settings list paints nothing of its own and shows whatever sits under it, which is not+// the base grey the hooks above turn black. The list is the top surface, so it takes the black.+%hook _TtC21Settings_PlatformImpl26SettingsListViewController+- (void)viewDidLayoutSubviews {+ %orig;+ for (UIView *sub in ((UIViewController *)self).view.subviews) {+ if ([sub isKindOfClass:UICollectionView.class]) sub.backgroundColor = UIColor.blackColor;+ }+}+%end+%ctor {- if (SGEnabled(SGKeyAmoled)) {+ if (SGFlag(SGKeyAmoled, NO)) {%init;}}diff --git a/tweak/Sources/Features/Appearance/Appearance.h b/tweak/Sources/Features/Appearance/Appearance.hindex f46aa499..1adf919d 100644--- a/tweak/Sources/Features/Appearance/Appearance.h+++ b/tweak/Sources/Features/Appearance/Appearance.h@@ -1,8 +1,14 @@// Appearance: the AMOLED background (Amoled.x), the glass search field (SearchField.x) and// Repaint.x, which keeps what the other features stripped transparent when Spotify repaints it.+// Both switches are off until asked for, as are the tab bar's and Spotify's own glass.#import <UIKit/UIKit.h>#define SGKeyAmoled @"spotifyglass.amoled"#define SGKeySearchField @"spotifyglass.searchField"+// Liquid Glass UI, the one switch of UI Tweaks that sets others: Spotify's own glass and, with+// it, the search field, the now playing bar, the artwork background and the lyrics card. Each+// stays a switch of its own afterwards.+void SGSetLiquidGlassUI(BOOL on);+UIViewController *SGAppearanceSettingsPage(void);diff --git a/tweak/Sources/Features/Appearance/AppearanceSettings.m b/tweak/Sources/Features/Appearance/AppearanceSettings.mindex 3f713f03..cb1173e5 100644--- a/tweak/Sources/Features/Appearance/AppearanceSettings.m+++ b/tweak/Sources/Features/Appearance/AppearanceSettings.m@@ -1,18 +1,30 @@+#import "Core/SGCore.h"#import "Settings/SGModPage.h"#import "Appearance.h"#import "Features/Navbar/Navbar.h"#import "Features/Flags/Flags.h"+#import "Features/NowPlaying/NowPlaying.h"++void SGSetLiquidGlassUI(BOOL on) {+ for (NSString *key in @[SGKeySpotifyGlass, SGKeySearchField, SGKeyNowPlayingBar, SGKeyPlayerBackdrop, SGKeyLyricsCard]) {+ SGSetEnabled(key, on);+ }+}UIViewController *SGAppearanceSettingsPage(void) {+ SGModRow *tabBar = SGUnstableRow(@"Tab bar", @"[WIP] Unstable", SGKeyTabBar,+ @"The glass capsule does not render the way iOS draws its own, and there is no selection indicator behind the active tab. Switching this on will look wrong.\n\nIf you want to take it further, pull requests are very welcome.");+ tabBar.defaultOn = NO;+ SGModRow *glass = SGOptionRow(@"Liquid Glass UI", @"Spotify's own glass navigation bar, slider and sheets, and with it the search field, now playing bar, artwork background and lyrics", SGKeySpotifyGlass);+ glass.changed = ^(BOOL on) { SGSetLiquidGlassUI(on); };return [[SGModPage alloc] initWithTitle:@"UI Tweaks" intro:SGRestartNote sections:@[SGSection(@"Liquid Glass", @[- SGUnstableRow(@"Tab bar", @"[WIP] Unstable", SGKeyTabBar,- @"The glass capsule does not render the way iOS draws its own, and there is no selection indicator behind the active tab. Switching this on will look wrong.\n\nIf you want to take it further, pull requests are very welcome."),- SGSwitchRow(@"Search field", @"Glass capsule instead of the white field", SGKeySearchField),- SGSwitchRow(@"Spotify's own Liquid Glass", @"The glass navigation bar, the new player slider and the new sheets, all shipped switched off", SGKeySpotifyGlass),+ tabBar,+ SGOptionRow(@"Search field", @"Glass capsule instead of the white field", SGKeySearchField),+ glass,]),SGSection(@"Theme", @[- SGSwitchRow(@"AMOLED background", @"Pure black instead of Spotify's dark grey", SGKeyAmoled),+ SGOptionRow(@"AMOLED background", @"Pure black instead of Spotify's dark grey", SGKeyAmoled),]),] footer:nil];}diff --git a/tweak/Sources/Features/Appearance/SearchField.x b/tweak/Sources/Features/Appearance/SearchField.xindex edabf551..29a4a5b9 100644--- a/tweak/Sources/Features/Appearance/SearchField.x+++ b/tweak/Sources/Features/Appearance/SearchField.x@@ -95,7 +95,7 @@ static void traceFieldArriving(UIView *button) {}static void styleSearchField(UIView *button) {- if (!SGEnabled(SGKeySearchField)) return;+ if (!SGFlag(SGKeySearchField, NO)) return;CGSize size = button.bounds.size;if (size.width < 200 || size.height < 40 || size.height > 60) return;BOOL styled = [objc_getAssociatedObject(button, &kStyledKey) boolValue];diff --git a/tweak/Sources/Features/Flags/Flags.x b/tweak/Sources/Features/Flags/Flags.xindex fc7f82ce..f781cb04 100644--- a/tweak/Sources/Features/Flags/Flags.x+++ b/tweak/Sources/Features/Flags/Flags.x@@ -25,7 +25,7 @@ BOOL SGGlassOwnsFlag(NSString *key) {static id forced(NSString *key) {id value = SGFlagOverride(key);- if (!value && SGEnabled(SGKeySpotifyGlass) && SGGlassOwnsFlag(key)) value = @YES;+ if (!value && SGFlag(SGKeySpotifyGlass, NO) && SGGlassOwnsFlag(key)) value = @YES;if (!value && SGAdBlockForcesFlagOff(key)) value = @NO;return value;}@@ -78,7 +78,7 @@ static id enumFor(NSString *key, id orig) {%hook SPTHubViewController- (BOOL)prefersLiquidGlassNavigationBar {- return SGEnabled(SGKeySpotifyGlass) ? YES : %orig;+ return SGFlag(SGKeySpotifyGlass, NO) ? YES : %orig;}%enddiff --git a/tweak/Sources/Features/Navbar/Navbar.x b/tweak/Sources/Features/Navbar/Navbar.xindex a47cb633..d0405bfe 100644--- a/tweak/Sources/Features/Navbar/Navbar.x+++ b/tweak/Sources/Features/Navbar/Navbar.x@@ -108,7 +108,7 @@ static UIView *iconView(NSString *name) {- (void)layoutSubviews {[super layoutSubviews];CGFloat width = self.bounds.size.width;- _title.hidden = SGEnabled(SGKeyTabBar);+ _title.hidden = SGFlag(SGKeyTabBar, NO);_title.font = sg_tabFont ?: [UIFont systemFontOfSize:10];_title.frame = CGRectMake(0, CGRectGetMinY(sg_labelBox), width, CGRectGetHeight(sg_labelBox));_icon.frame = CGRectMake((width - CGRectGetWidth(sg_iconBox)) / 2, CGRectGetMinY(sg_iconBox),diff --git a/tweak/Sources/Features/Navbar/TabBar.x b/tweak/Sources/Features/Navbar/TabBar.xindex 2174ae91..2da7f4fd 100644--- a/tweak/Sources/Features/Navbar/TabBar.x+++ b/tweak/Sources/Features/Navbar/TabBar.x@@ -25,7 +25,7 @@ static NSArray<UIView *> *tabItems(UIView *tabBar) {}static void styleTabBar(UIView *tabBar) {- if (!SGEnabled(SGKeyTabBar)) return;+ if (!SGFlag(SGKeyTabBar, NO)) return;sg_tabBarRoot = tabBar;SGStripBackgrounds(tabBar);tabBar.superview.layer.backgroundColor = NULL;@@ -68,7 +68,7 @@ static UIView *tabBarOf(UIView *item) {// Items lay out their own icon and label, after the bar; hide the label, centre the icon, then// restyle the bar, whose own pass ran before the items had frames.static void styleTabItem(UIView *item) {- if (!SGEnabled(SGKeyTabBar)) return;+ if (!SGFlag(SGKeyTabBar, NO)) return;CGFloat midY = CGRectGetMidY(item.bounds);SGForEachView(item, ^(UIView *v) {if ([v isKindOfClass:UILabel.class]) {diff --git a/tweak/Sources/Features/NowPlaying/Lyrics.x b/tweak/Sources/Features/NowPlaying/Lyrics.xindex b7c2b1da..4def5d32 100644--- a/tweak/Sources/Features/NowPlaying/Lyrics.x+++ b/tweak/Sources/Features/NowPlaying/Lyrics.x@@ -34,7 +34,7 @@ static UIView *cellAround(UIView *view) {%hook _TtC22Lyrics_CardElementImpl8CardView- (void)layoutSubviews {%orig;- if (!SGEnabled(SGKeyLyricsCard)) return;+ if (!SGFlag(SGKeyLyricsCard, NO)) return;UIView *cell = cellAround((UIView *)self);// A card Declutter/Declutter.x collapsed reports no height; leave it alone.if (!cell || cell.bounds.size.height < 40) return;@@ -68,12 +68,12 @@ static UIView *clearAncestors(UIView *view) {- (void)setBackgroundColor:(UIColor *)color {static dispatch_once_t once;dispatch_once(&once, ^{ SGLog(@"lyrics page paints itself %@ through UIView", color); });- %orig(SGEnabled(SGKeyLyricsCard) ? nil : color);+ %orig(SGFlag(SGKeyLyricsCard, NO) ? nil : color);}- (void)layoutSubviews {%orig;- if (!SGEnabled(SGKeyLyricsCard)) return;+ if (!SGFlag(SGKeyLyricsCard, NO)) return;UIView *page = (UIView *)self;if (page.bounds.size.height < 200) return;diff --git a/tweak/Sources/Features/NowPlaying/NowPlaying.h b/tweak/Sources/Features/NowPlaying/NowPlaying.hindex 5709d597..305c49f8 100644--- a/tweak/Sources/Features/NowPlaying/NowPlaying.h+++ b/tweak/Sources/Features/NowPlaying/NowPlaying.h@@ -1,6 +1,6 @@// Now Playing: the glass bar (NowPlayingBar.x), the full screen player (Player.x) and the lyrics-// card with the page it expands into (Lyrics.x). An unset switch is on; the backdrop is off until-// it is asked for.+// card with the page it expands into (Lyrics.x). The bar, the backdrop and the lyrics card are off+// until asked for, together through Liquid Glass UI in UI Tweaks; the header buttons are on.#import <UIKit/UIKit.h>#define SGKeyNowPlayingBar @"spotifyglass.nowPlayingBar"diff --git a/tweak/Sources/Features/NowPlaying/NowPlayingBar.x b/tweak/Sources/Features/NowPlaying/NowPlayingBar.xindex ae2c9bd3..ace6b113 100644--- a/tweak/Sources/Features/NowPlaying/NowPlayingBar.x+++ b/tweak/Sources/Features/NowPlaying/NowPlayingBar.x@@ -86,7 +86,7 @@ static void restyleCardContent(UIView *card) {}static void styleNowPlayingBar(UIViewController *container) {- if (!SGEnabled(SGKeyNowPlayingBar)) return;+ if (!SGFlag(SGKeyNowPlayingBar, NO)) return;UIViewController *barVC = container.childViewControllers.firstObject;UIView *bar = barVC.viewIfLoaded ?: container.view;sg_nowPlayingRoot = bar;@@ -128,7 +128,7 @@ static void styleNowPlayingBar(UIViewController *container) {// `stock` gives the bar back to Spotify for the length of an animation, and takes it again after.static void barStock(BOOL stock, NSTimeInterval fade) {UIView *host = sg_barGlassHost;- if (!host || !SGEnabled(SGKeyNowPlayingBar) || sg_nowPlayingStock == stock) return;+ if (!host || !SGFlag(SGKeyNowPlayingBar, NO) || sg_nowPlayingStock == stock) return;sg_nowPlayingStock = stock;if (stock) {diff --git a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.mindex e1539a8b..263a6fcf 100644--- a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m+++ b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m@@ -19,10 +19,10 @@ static UIViewController *lyricsPage(void) {UIViewController *SGNowPlayingSettingsPage(void) {return [[SGModPage alloc] initWithTitle:@"Now Playing" intro:SGRestartNote sections:@[SGSection(@"Liquid Glass", @[- SGSwitchRow(@"Now playing bar", @"Glass card with round artwork", SGKeyNowPlayingBar),+ SGOptionRow(@"Now playing bar", @"Glass card with round artwork", SGKeyNowPlayingBar),SGOptionRow(@"Artwork background", @"The cover blurred and dimmed behind the player instead of the flat album colour", SGKeyPlayerBackdrop),SGSwitchRow(@"Header buttons", @"Glass circles behind close and more, over the artwork", SGKeyPlayer),- SGSwitchRow(@"Lyrics", @"Glass card, and the page it expands into", SGKeyLyricsCard),+ SGOptionRow(@"Lyrics", @"Glass card, and the page it expands into", SGKeyLyricsCard),]),SGSection(@"Spotify's flags", @[SGFlagRow(@"Sheet style player", @"ios-feature-nowplaying.sheet_style_npv"),diff --git a/tweak/Sources/Features/NowPlaying/Player.x b/tweak/Sources/Features/NowPlaying/Player.xindex d9611035..8a2c42c1 100644--- a/tweak/Sources/Features/NowPlaying/Player.x+++ b/tweak/Sources/Features/NowPlaying/Player.x@@ -153,7 +153,7 @@ static UIView *backdropIn(UIView *plane) {fade.colors = @[(id)[UIColor colorWithWhite:0 alpha:0.40].CGColor,(id)[UIColor colorWithWhite:0 alpha:0.60].CGColor,- (id)[UIColor colorWithWhite:0 alpha:SGEnabled(SGKeyAmoled) ? 1 : 0.94].CGColor,+ (id)[UIColor colorWithWhite:0 alpha:SGFlag(SGKeyAmoled, NO) ? 1 : 0.94].CGColor,];fade.locations = @[@0, @0.5, @1];[backdrop addSubview:scrim];diff --git a/tweak/Sources/Features/Onboarding/Tour.m b/tweak/Sources/Features/Onboarding/Tour.mindex 2a30f737..9e67ebc2 100644--- a/tweak/Sources/Features/Onboarding/Tour.m+++ b/tweak/Sources/Features/Onboarding/Tour.m@@ -35,6 +35,7 @@ typedef NS_ENUM(NSInteger, SGTourRowKind) { SGTourRowPlain, SGTourRowSwitch, SGT@interface SGTourRow : NSObject@property (nonatomic, copy) NSString *symbol, *title, *subtitle, *key, *warning;+@property (nonatomic, copy) void (^changed)(BOOL on);@property (nonatomic) SGTourRowKind kind;@property (nonatomic) BOOL defaultOn;@property (nonatomic, copy) void (^action)(void);@@ -139,6 +140,7 @@ static SGTourRow *actionRow(NSString *symbol, NSString *title, NSString *subtitl- (void)toggled {SGSetEnabled(_row.key, _toggle.on);+ if (_row.changed) _row.changed(_toggle.on);if (!_toggle.on || !_row.warning) return;UIAlertController *alert = [UIAlertController alertControllerWithTitle:_row.titlemessage:_row.warning@@ -291,6 +293,8 @@ static SGTourRow *actionRow(NSString *symbol, NSString *title, NSString *subtitl- (NSArray<SGTourPage *> *)buildPages {__weak typeof(self) weakSelf = self;+ SGTourRow *glass = switchRow(@"drop.fill", @"Liquid Glass UI", @"Spotify's own glass bars and sheets, the search field, now playing bar, artwork background and lyrics", SGKeySpotifyGlass, NO);+ glass.changed = ^(BOOL on) { SGSetLiquidGlassUI(on); };SGTourRow *premium = switchRow(@"crown.fill", @"Pretend to be Premium", @"Free accounts only", SGKeyFakePremium, NO);premium.warning = SGFakePremiumWarning;NSMutableArray *pages = [NSMutableArray array];@@ -301,9 +305,9 @@ static SGTourRow *actionRow(NSString *symbol, NSString *title, NSString *subtitlplainRow(@"dock.rectangle", @"A tab bar you compose", @"Reorder, hide, add any Spotify link"),plainRow(@"flag.fill", @"Every flag Spotify ships", @"Searchable, with the features it never released"),]]];- [pages addObject:[self pageWithSymbol:@"circle.lefthalf.filled" heading:@"Your look." body:@"Matters of taste. Pick now, change any time in Mod Settings." rows:@[- switchRow(@"moon.fill", @"AMOLED background", @"Pure black instead of Spotify's dark grey", SGKeyAmoled, YES),- switchRow(@"drop.fill", @"Spotify's own Liquid Glass", @"The glass navigation bar, slider and sheets Spotify shipped switched off", SGKeySpotifyGlass, YES),+ [pages addObject:[self pageWithSymbol:@"circle.lefthalf.filled" heading:@"Your look." body:@"Everything starts off. Switch on what you like now, change any time in Mod Settings." rows:@[+ glass,+ switchRow(@"moon.fill", @"AMOLED background", @"Pure black instead of Spotify's dark grey", SGKeyAmoled, NO),switchRow(@"paintpalette.fill", @"Home gradient", @"A wash of colour behind the top of Home", SGKeyHomeGradient, NO),]]];[pages addObject:[self pageWithSymbol:@"eye.slash.fill" heading:@"Ads and nags." body:@"From EeveeSpotify. All three are off until switched on, and none is needed on a Premium account." rows:@[@@ -432,10 +436,9 @@ static UIButton *glassButton(NSString *title, BOOL prominent) {// tap on the icon comes up the chosen way.- (void)finish {SGSetEnabled(SGKeyOnboardingSeen, YES);- BOOL restart = self.changed;- [NSUserDefaults.standardUserDefaults synchronize];- if (restart) {- exit(0);+ if (self.changed) {+ SGRestartSpotify();+ return;}[self dismissViewControllerAnimated:YES completion:^{ SGShowSigningFixIfPending(); }];}diff --git a/tweak/Sources/Settings/SGModPage.h b/tweak/Sources/Settings/SGModPage.hindex 89002357..992b45bd 100644--- a/tweak/Sources/Settings/SGModPage.h+++ b/tweak/Sources/Settings/SGModPage.h@@ -18,6 +18,7 @@@property (nonatomic, copy) NSString *(^value)(void);@property (nonatomic, copy) void (^action)(void);@property (nonatomic, copy) NSString *warning;+@property (nonatomic, copy) void (^changed)(BOOL on); // after the switch is stored; the page reloads@property (nonatomic, strong) UIColor *color; // title, subtitle and symbol, for a warning row@property (nonatomic, copy) NSString *symbol;@enddiff --git a/tweak/Sources/Settings/SGModPage.m b/tweak/Sources/Settings/SGModPage.mindex 3ae6b56d..f1de5795 100644--- a/tweak/Sources/Settings/SGModPage.m+++ b/tweak/Sources/Settings/SGModPage.m@@ -219,11 +219,11 @@ static BOOL flagRowOn(SGModRow *row) {return value && [value boolValue] != row.forceOff;}-// A flag the Spotify's own Liquid Glass switch owns: its row shows what that switch forces and+// A flag the Liquid Glass UI switch owns: its row shows what that switch forces and// takes no touch, so the flag has one place to change. An override from All flags still wins.static BOOL flagRowLocked(SGModRow *row) {if (!row.flag) return NO;- return (SGGlassOwnsFlag(row.key) && SGEnabled(SGKeySpotifyGlass)) || (row.forceOff && SGAdBlockForcesFlagOff(row.key));+ return (SGGlassOwnsFlag(row.key) && SGFlag(SGKeySpotifyGlass, NO)) || (row.forceOff && SGAdBlockForcesFlagOff(row.key));}@implementation SGModPage {@@ -369,6 +369,10 @@ static BOOL flagRowLocked(SGModRow *row) {SGModRow *row = [self rowAt:[NSIndexPath indexPathForRow:toggle.tag % 1000 inSection:toggle.tag / 1000]];if (row.flag) SGSetFlagOverride(row.key, toggle.on ? @(!row.forceOff) : nil);else SGSetEnabled(row.key, toggle.on);+ if (row.changed) {+ row.changed(toggle.on);+ [self.tableView reloadData];+ }if (toggle.on && row.warning) [self warn:row];}diff --git a/tweak/Sources/Settings/SGPageStyle.m b/tweak/Sources/Settings/SGPageStyle.mindex 749e7754..dd4fe3e2 100644--- a/tweak/Sources/Settings/SGPageStyle.m+++ b/tweak/Sources/Settings/SGPageStyle.m@@ -1,5 +1,6 @@#import "SGPageStyle.h"#import "Core/SGCore.h"+#import "Features/Appearance/Appearance.h"static UIFont *sg_titleFont, *sg_subtitleFont;@@ -68,7 +69,7 @@ void SGInsetForBars(UITableView *table) {UIColor *SGGreen(void) { return [UIColor colorWithRed:0x1E / 255.0 green:0xD7 / 255.0 blue:0x60 / 255.0 alpha:1]; }UIColor *SGRed(void) { return [UIColor colorWithRed:0xF1 / 255.0 green:0x5E / 255.0 blue:0x6B / 255.0 alpha:1]; }-UIColor *SGPageBackground(void) { return [UIColor colorWithWhite:0x12 / 255.0 alpha:1]; }+UIColor *SGPageBackground(void) { return SGFlag(SGKeyAmoled, NO) ? UIColor.blackColor : [UIColor colorWithWhite:0x12 / 255.0 alpha:1]; }const CGFloat SGSectionHeaderHeight = 38;