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: one Redesigned UI switch in place of Liquid Glass UI, glowing, with what it changes behind its info button

Vojtěch Škopek2f8a8b81b54b
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 27944a2d..f21b5f6e 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -96,17 +96,20 @@ Mod Settings, opened by holding Home on the tab bar or from the first row of the
last row of Spotify's Settings, sorts every
setting by the part of Spotify it changes, so a part's glass, its hide switches and its flags sit on
one page, the mod's own rows first and Spotify's flags below them or on a sub page named after what
-they change. It opens on the Appearance card, the three switches that style the whole app: Liquid
-Glass UI, AMOLED and the accent colour (Spotify's green is offered from the colour row once a colour
-is set). Then a card of parts. Navbar: the glass tab bar and search field, then the tab editor.
+they change. It opens on the Appearance card, the three switches that style the whole app: Redesigned
+UI, AMOLED and the accent colour (Spotify's green is offered from the colour row once a colour
+is set). Redesigned UI is the one switch between two looks: off, Spotify's own screens with the mod's
+switches on them; on, the redesigned screens of Redesign/ in their place (for now the full screen
+player), Spotify's newer glass design and every glass switch of the mod's. It glows (Settings/SGGlowSwitch)
+and its ⓘ says what it changes. While it is on, the switches for Spotify's own version of a redesigned
+screen are put away on that screen's page, the legacy hooks of that screen stand aside, and the flags
+the redesign is built on are forced over any override. Then a card of parts. Navbar: the glass tab bar and search field, then the tab editor.
Player: Gestures, Lyrics (Apple Music style, glass lyrics, the ordered list of lyrics sources, lyrics
for every track, naming the source, the lyrics flags), Blocked artists (with the count on the row), Now
playing bar (its glass, its device button and its flags), and Queue & devices and Lock screen widget as
-flag pages; these work with either player. Under them, tabs pick the player screen: Native player,
-Spotify's own with the switches of Player.x and Declutter.x (artwork background, glass header buttons,
-Disable Canvas and the sheet, header, slider and sticky header flags, the cards under the player and the
-lyrics preview and player buttons to hide), or Redesigned player (Redesign/Player, which those switches
-don't reach, with the lyrics card as its one row). Each tab shows only its own player's rows. Home & Library:
+flag pages, which work with either player; then Spotify's own player screen (artwork background, glass
+header buttons, Disable Canvas and the sheet, header, slider and sticky header flags, the cards under the
+player and the lyrics preview and player buttons to hide), put away while Redesigned UI is on. Home & Library:
the Gradient page (the wash behind the top of Home in one of eight colours, at three strengths and
four heights) and the Home flags, the parts of Home to hide including the DJ button and badge, the
playlist header, buttons and pills to hide, and the Library flags. Then Premium, ads & privacy
@@ -119,7 +122,7 @@ Auto / Off / On control per flag (a text field for the number and text ones), an
check, the build and Spotify's version, the site and the repo, the welcome tour again and Reset all
settings. A flag switch on a page forces that one flag and off leaves Spotify's own value, so the All
flags page is where a flag goes back to Auto. Spotify ships its newer design behind several flags at
-once, so Liquid Glass UI owns them (the glass navigation bar, the new player slider, the sheet style
+once, so Redesigned UI owns them (the glass navigation bar, the new player slider, the sheet style
player, the queue and Connect sheets, the redesigned player header, the sleep timer's options sheet):
while it is on it forces each of them, and their rows elsewhere show what it forces and take no
touch, so the group has one switch. `SGGlassOwnsFlag` in Features/Flags/Flags.x holds the list. A
diff --git a/tweak/Sources/Features/Appearance/Appearance.h b/tweak/Sources/Features/Appearance/Appearance.h
index 95e51735..3a84be5e 100644
--- a/tweak/Sources/Features/Appearance/Appearance.h
+++ b/tweak/Sources/Features/Appearance/Appearance.h
@@ -12,10 +12,12 @@ UIColor *SGAccentColor(void); // nil while Spotify's own green is kept
NSString *SGAccentLabel(void); // "#RRGGBB", or the name of Spotify's own
void SGPickAccent(void); // the system colour picker over the top of the app, stored on the way out
-// Liquid Glass UI, the one switch of Appearance that sets others: Spotify's own glass and, with
-// it, the tab bar, the search field, the now playing bar, the artwork background and the lyrics card. Each
-// stays a switch of its own afterwards, on the page of the part it styles.
-void SGSetLiquidGlassUI(BOOL on);
+// Redesigned UI, the one switch of Appearance that sets others: the redesigned screens
+// (Redesign/Kit/SGRedesign.h), Spotify's own glass and, with it, the tab bar, the search field, the now
+// playing bar, the artwork background and the lyrics card. Each glass switch stays a switch of its own
+// afterwards, on the page of the part it styles. SGRedesignedUIInfo is what its ⓘ reads out.
+void SGSetRedesignedUI(BOOL on);
+extern NSString *const SGRedesignedUIInfo;
@class SGModSection;
SGModSection *SGAppearanceSection(void); // the Appearance card at the top of Mod Settings
diff --git a/tweak/Sources/Features/Appearance/AppearanceSettings.m b/tweak/Sources/Features/Appearance/AppearanceSettings.m
index 2204dfa1..ad8874d8 100644
--- a/tweak/Sources/Features/Appearance/AppearanceSettings.m
+++ b/tweak/Sources/Features/Appearance/AppearanceSettings.m
@@ -5,9 +5,12 @@
#import "Features/Navbar/Navbar.h"
#import "Features/Flags/Flags.h"
#import "Features/NowPlaying/NowPlaying.h"
+#import "Redesign/Kit/SGRedesign.h"
-void SGSetLiquidGlassUI(BOOL on) {
- for (NSString *key in @[SGKeySpotifyGlass, SGKeyTabBar, SGKeySearchField, SGKeyNowPlayingBar, SGKeyPlayer, SGKeyPlayerBackdrop, SGKeyLyricsCard]) {
+NSString *const SGRedesignedUIInfo = @"Replaces Spotify's own screens with the mod's redesign, built in Liquid Glass: for now the full screen player with the lyrics under it, and every screen redesigned later joins it here. It also turns on Spotify's own glass bars, slider and sheets, and the mod's glass tab bar, search field and now playing bar.\n\nWhile it is on, the switches that change Spotify's own version of a redesigned screen are put away on that screen's page, since the screen is no longer Spotify's. Off, Spotify looks the way it does with the switches you set.\n\nChanges apply after you restart Spotify.";
+
+void SGSetRedesignedUI(BOOL on) {
+ for (NSString *key in @[SGKeyRedesign, SGKeySpotifyGlass, SGKeyTabBar, SGKeySearchField, SGKeyNowPlayingBar, SGKeyPlayer, SGKeyPlayerBackdrop, SGKeyLyricsCard]) {
SGSetEnabled(key, on);
}
}
@@ -31,11 +34,13 @@ static void chooseAccent(void) {
}
SGModSection *SGAppearanceSection(void) {
- SGModRow *glass = SGOptionRow(@"Liquid Glass UI", @"Spotify's own glass bars, slider and sheets, and every glass switch of the mod's with it", SGKeySpotifyGlass);
- glass.changed = ^(BOOL on) { SGSetLiquidGlassUI(on); };
+ SGModRow *redesign = SGOptionRow(@"Redesigned UI", @"The mod's own screens in Liquid Glass, and every glass switch with them", SGKeyRedesign);
+ redesign.glows = YES;
+ redesign.info = SGRedesignedUIInfo;
+ redesign.changed = ^(BOOL on) { SGSetRedesignedUI(on); };
return SGNotedSection(@"Appearance", @[
- SGWithSymbol(glass, @"drop"),
+ SGWithSymbol(redesign, @"sparkles"),
SGWithSymbol(SGOptionRow(@"AMOLED background", nil, SGKeyAmoled), @"moon"),
SGWithSymbol(SGStatActionRow(@"Accent colour", nil, ^NSString *{ return SGAccentLabel(); }, ^{ chooseAccent(); }), @"paintpalette"),
- ], @"Liquid Glass UI turns every glass switch of the mod's on or off with it. Changes apply after you restart Spotify.");
+ ], @"Redesigned UI turns every glass switch of the mod's on or off with it. Changes apply after you restart Spotify.");
}
diff --git a/tweak/Sources/Features/Flags/FlagPages.m b/tweak/Sources/Features/Flags/FlagPages.m
index c81ad699..532fe778 100644
--- a/tweak/Sources/Features/Flags/FlagPages.m
+++ b/tweak/Sources/Features/Flags/FlagPages.m
@@ -37,7 +37,7 @@ UIViewController *SGLabsPage(void) {
SGFlagRow(@"Fade out", @"ios-feature-sleeptimer.enable_fade_out"),
SGFlagRow(@"One minute option", @"ios-feature-sleeptimer.enable_one_minute_option"),
SGFlagRow(@"Options sheet", @"ios-feature-sleeptimer.use_options_sheet"),
- ], @"The options sheet is locked on while Liquid Glass UI is on."),
+ ], @"The options sheet is locked on while Redesigned UI is on."),
SGSection(@"Player", @[
SGFlagRow(@"Snake on the cover art", @"ios-feature-cover-art-snake.enabled"),
]),
diff --git a/tweak/Sources/Features/Flags/Flags.x b/tweak/Sources/Features/Flags/Flags.x
index 8fc0b5c3..53a40036 100644
--- a/tweak/Sources/Features/Flags/Flags.x
+++ b/tweak/Sources/Features/Flags/Flags.x
@@ -1,7 +1,8 @@
// Spotify reads every remote-config flag once at startup through the configuration provider,
-// keyed "component.property". An override from the Flags page wins; a redesigned screen then forces
-// the flags its redesign is built on (Redesign/Kit/SGRedesign.h), and the Spotify's own Liquid
-// Glass switch the flags of Spotify's own newer design, which it ships switched off.
+// keyed "component.property". While Redesigned UI is on, the flags its screens are built on come first
+// (Redesign/Kit/SGRedesign.h), so an override left from Spotify's own screens cannot pull a redesigned
+// one apart; then an override from the Flags page, then the flags of Spotify's own newer design, which
+// it ships switched off and Redesigned UI turns on.
#import "Core/SGCore.h"
#import "Flags.h"
#import "Features/AdBlock/AdBlock.h"
@@ -27,8 +28,8 @@ BOOL SGGlassOwnsFlag(NSString *key) {
}
static id forced(NSString *key) {
- id value = SGFlagOverride(key);
- if (!value) value = SGRedesignForcedFlag(key);
+ id value = SGRedesignForcedFlag(key);
+ if (!value) value = SGFlagOverride(key);
if (!value && SGFlag(SGKeySpotifyGlass, NO) && SGGlassOwnsFlag(key)) value = @YES;
if (!value && SGAdBlockForcesFlagOff(key)) value = @NO;
if (!value) value = SGLyricsForcedFlag(key);
diff --git a/tweak/Sources/Features/NowPlaying/NowPlaying.h b/tweak/Sources/Features/NowPlaying/NowPlaying.h
index 554daa97..4f669a17 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). The bar, the backdrop and the lyrics card are off
-// until asked for, together through Liquid Glass UI in Appearance; the header buttons are on.
+// until asked for, together through Redesigned UI in Appearance; the header buttons are on.
#import <UIKit/UIKit.h>
#define SGKeyNowPlayingBar @"spotifyglass.nowPlayingBar"
diff --git a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m
index 3da3b30f..7fd6d79f 100644
--- a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m
+++ b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m
@@ -8,7 +8,6 @@
#import "Features/LockScreenLyrics/LockScreenLyrics.h"
#import "Features/LyricsSources/LyricsSources.h"
#import "Redesign/Kit/SGRedesign.h"
-#import "Redesign/Player/Player.h"
static UIViewController *nowPlayingBarPage(void) {
return [[SGModPage alloc] initWithTitle:@"Now playing bar" intro:SGRestartNote sections:@[
@@ -73,7 +72,7 @@ static UIViewController *queuePage(void) {
bare(SGFlagRow(@"Queue as a bottom sheet", @"ios-feature-nowplaying.bottom_sheet_queue_enabled")),
bare(SGFlagRow(@"Connect as a bottom sheet", @"ios-feature-nowplaying-elements.enable_connect_bottom_sheet")),
bare(SGFlagRow(@"Connect sheet from the video switcher", @"ios-playbackcontrol-audiovideoswitcher-impl.enable_connect_bottom_sheet")),
- ], @"Locked on while Liquid Glass UI is on."),
+ ], @"Locked on while Redesigned UI is on."),
SGSection(@"Queue", @[
bare(SGFlagRow(@"Queue flip transition", @"ios-feature-nowplaying.queue_flip_transition_enabled")),
bare(SGFlagRow(@"Play next in the context menu", @"ios-feature-queue.is_play_next_context_menu_enabled")),
@@ -97,18 +96,16 @@ static UIViewController *lockScreenPage(void) {
] footer:nil];
}
-// The player screen is one of two, picked with the tabs: Spotify's own player with the switches of
-// Player.x and Declutter.x on it, or the redesigned one of Redesign/Player, which those switches don't
-// reach. Everything above the tabs (gestures, lyrics, blocked artists, the bar, the queue, the lock
-// screen) works the same with either player, so it sits above them and the tabs never hide it.
-UIViewController *SGNowPlayingSettingsPage(void) {
- SGModRow *blocked = SGPageRow(@"Blocked artists", ^UIViewController *{ return SGArtistBlockSettingsPage(); });
- blocked.value = ^NSString *{
- return SGFlag(SGKeyArtistBlock, NO) ? @(SGBlockedArtists().count).stringValue : @"Off";
- };
-
- SGModTab *native = SGTab(@"Native player", @"Spotify's own player, with the switches below on it.", @[
- SGNotedSection(@"Look", @[
+// The pages at the top work with either player. Under them, Spotify's own player screen and its
+// switches (Player.x and Declutter.x), which are put away while Redesigned UI is on: the player is the
+// redesign's then (Redesign/Player), and none of them would change it. The stored switch decides, so a
+// page opened after flipping it and before the restart already shows what the restart will bring.
+static NSArray<SGModSection *> *playerScreenSections(void) {
+ if (SGFlag(SGKeyRedesign, NO)) {
+ return @[SGNotedSection(@"Player screen", @[], @"Redesigned UI is on, so the player is the redesign's own and the switches for Spotify's player are put away. Turn it off in Appearance to change Spotify's player again.")];
+ }
+ return @[
+ SGNotedSection(@"Player screen", @[
SGOptionRow(@"Artwork background", @"The cover blurred and dimmed behind the player instead of the flat album colour", SGKeyPlayerBackdrop),
SGOptionRow(@"Glass header buttons", nil, SGKeyPlayer),
bare(SGKillRow(@"Disable Canvas", @"ios-feature-canvas.canvas_enabled")),
@@ -116,7 +113,7 @@ UIViewController *SGNowPlayingSettingsPage(void) {
bare(SGFlagRow(@"Redesigned header", @"ios-feature-nowplaying.new_redesign_header_with_context_menu_enabled")),
bare(SGFlagRow(@"New progress slider", @"ios-feature-encoreexperiments.new_npv_slider_enabled")),
bare(SGFlagRow(@"Expand the sticky header on tap", @"ios-feature-nowplaying.expand_sticky_header_on_tap")),
- ], @"Liquid Glass UI turns the first two on or off with it, and locks the sheet, header and slider on."),
+ ], @"Redesigned UI turns the first two on or off with it."),
SGSection(@"Hide cards below the player", @[
SGHideRow(@"Lyrics", nil, SGHideLyricsCard),
SGHideRow(@"About the artist", nil, SGHideAboutArtist),
@@ -137,17 +134,16 @@ UIViewController *SGNowPlayingSettingsPage(void) {
SGHideRow(@"Share", nil, SGHideShare),
SGHideRow(@"Connect to a device", nil, SGHideConnect),
]),
- ]);
+ ];
+}
- SGModTab *redesigned = SGTab(@"Redesigned player", @"The cover's own colour behind the whole player, glass behind the header buttons, bare playback controls, and nothing under the player but lyrics.", @[
- SGSection(@"Below the player", @[
- SGSwitchRow(@"Lyrics", @"The lyrics card below the player; every other card is left out", SGKeyRedesignPlayerLyricsCard),
- ]),
- ]);
+UIViewController *SGNowPlayingSettingsPage(void) {
+ SGModRow *blocked = SGPageRow(@"Blocked artists", ^UIViewController *{ return SGArtistBlockSettingsPage(); });
+ blocked.value = ^NSString *{
+ return SGFlag(SGKeyArtistBlock, NO) ? @(SGBlockedArtists().count).stringValue : @"Off";
+ };
- return [[SGModPage alloc] initWithTitle:@"Player"
- intro:@"Changes apply after you restart Spotify. Gestures and Blocked artists apply straight away."
- sections:@[
+ NSArray<SGModSection *> *sections = @[
SGSection(nil, @[
SGWithSymbol(SGPageRow(@"Gestures", ^UIViewController *{ return SGGesturesSettingsPage(); }), @"hand.tap"),
SGWithSymbol(SGPageRow(@"Lyrics", ^UIViewController *{ return lyricsPage(); }), @"quote.bubble"),
@@ -158,10 +154,9 @@ UIViewController *SGNowPlayingSettingsPage(void) {
SGWithSymbol(SGPageRow(@"Queue & devices", ^UIViewController *{ return queuePage(); }), @"text.line.first.and.arrowtriangle.forward"),
SGWithSymbol(SGPageRow(@"Lock screen widget", ^UIViewController *{ return lockScreenPage(); }), @"lock"),
]),
- ]
- tabsTitle:@"Player screen"
- tabsKey:SGKeyRedesignPlayer
- tabs:@[native, redesigned]
- fallback:0
+ ];
+ return [[SGModPage alloc] initWithTitle:@"Player"
+ intro:@"Changes apply after you restart Spotify. Gestures and Blocked artists apply straight away."
+ sections:[sections arrayByAddingObjectsFromArray:playerScreenSections()]
footer:nil];
}
diff --git a/tweak/Sources/Features/Onboarding/Tour.m b/tweak/Sources/Features/Onboarding/Tour.m
index 6c368c57..b5eb3781 100644
--- a/tweak/Sources/Features/Onboarding/Tour.m
+++ b/tweak/Sources/Features/Onboarding/Tour.m
@@ -9,6 +9,7 @@
#import "Features/Declutter/Declutter.h"
#import "Features/Navbar/Navbar.h"
#import "Features/Privacy/Privacy.h"
+#import "Redesign/Kit/SGRedesign.h"
static const CGFloat kMargin = 24;
static const CGFloat kCardRadius = 22;
@@ -336,8 +337,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 tab bar, search field, now playing bar, artwork background and lyrics", SGKeySpotifyGlass, NO);
- glass.changed = ^(BOOL on) { SGSetLiquidGlassUI(on); };
+ SGTourRow *glass = switchRow(@"sparkles", @"Redesigned UI", @"The mod's own player in Liquid Glass, with Spotify's glass bars and sheets, the tab bar, search field and now playing bar", SGKeyRedesign, NO);
+ glass.changed = ^(BOOL on) { SGSetRedesignedUI(on); };
SGTourRow *premium = switchRow(@"crown.fill", @"Spoof Premium", @"Free accounts only", SGKeyFakePremium, NO);
premium.warning = SGFakePremiumWarning;
NSMutableArray *pages = [NSMutableArray array];
diff --git a/tweak/Sources/Redesign/Kit/SGRField.h b/tweak/Sources/Redesign/Kit/SGRField.h
index 4b69a05b..363b4282 100644
--- a/tweak/Sources/Redesign/Kit/SGRField.h
+++ b/tweak/Sources/Redesign/Kit/SGRField.h
@@ -38,8 +38,3 @@ extern NSNotificationName const SGRFieldColorDidChangeNotification;
// what the field shows.
- (void)setArtwork:(UIImage *)image identity:(NSString *)identity animated:(BOOL)animated;
@end
-
-// A content surface (a card, not glass) filling `host` behind its content, rounded SGRRadiusCard, in
-// SGRElevated of the field's colour and following it. `field` nil follows whichever field posts.
-// Created once per host and returned again after; main thread.
-UIView *SGRCardSurface(UIView *host, SGRArtworkField *field);
diff --git a/tweak/Sources/Redesign/Kit/SGRField.m b/tweak/Sources/Redesign/Kit/SGRField.m
index 7727fc14..348a3228 100644
--- a/tweak/Sources/Redesign/Kit/SGRField.m
+++ b/tweak/Sources/Redesign/Kit/SGRField.m
@@ -9,9 +9,6 @@ NSNotificationName const SGRFieldColorDidChangeNotification = @"spotifyglass.red
static const CGFloat kAmoledFrom = 0.55;
static const CGFloat kFallbackHeight = 874; // a window-less field sizes for an iPhone 17 Pro
-// The colour the last field took, for a card surface that follows whichever field posts.
-static UIColor *sg_lastFieldColor;
-
static CGFloat windowHeight(UIView *view) {
CGFloat height = view.window.bounds.size.height;
return height > 0 ? height : kFallbackHeight;
@@ -110,7 +107,6 @@ static NSDictionary *noActions(void) {
CALayer *shown = _solid.presentationLayer ?: _solid;
id from = (__bridge id)shown.backgroundColor;
_color = color;
- sg_lastFieldColor = color;
[CATransaction begin];
[CATransaction setDisableActions:YES];
_solid.backgroundColor = color.CGColor;
@@ -166,80 +162,3 @@ static NSDictionary *noActions(void) {
}
@end
-
-#pragma mark - card surface
-
-static char kSurfaceKey;
-
-@interface SGRCardSurfaceView : UIView
-@property (nonatomic, weak) SGRArtworkField *field;
-@end
-
-@implementation SGRCardSurfaceView {
- CALayer *_paint;
-}
-
-- (instancetype)initWithFrame:(CGRect)frame {
- if (!(self = [super initWithFrame:frame])) return nil;
- self.userInteractionEnabled = NO;
- self.accessibilityElementsHidden = YES;
- self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- self.layer.zPosition = -1;
- _paint = [CALayer layer];
- _paint.actions = noActions();
- _paint.cornerRadius = SGRRadiusCard;
- _paint.cornerCurve = kCACornerCurveContinuous;
- [self.layer addSublayer:_paint];
- [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(fieldColorChanged:) name:SGRFieldColorDidChangeNotification object:nil];
- return self;
-}
-
-- (void)dealloc {
- [NSNotificationCenter.defaultCenter removeObserver:self];
-}
-
-- (void)layoutSubviews {
- [super layoutSubviews];
- [CATransaction begin];
- [CATransaction setDisableActions:YES];
- _paint.frame = self.bounds;
- [CATransaction commit];
-}
-
-- (void)paintWith:(UIColor *)field animated:(BOOL)animated {
- CGColorRef color = SGRElevated(field ?: SGRNeutralField()).CGColor;
- if (!animated) {
- [CATransaction begin];
- [CATransaction setDisableActions:YES];
- _paint.backgroundColor = color;
- [CATransaction commit];
- return;
- }
- [CATransaction begin];
- [CATransaction setAnimationDuration:SGRCrossfade];
- _paint.actions = nil;
- _paint.backgroundColor = color;
- _paint.actions = noActions();
- [CATransaction commit];
-}
-
-- (void)fieldColorChanged:(NSNotification *)note {
- SGRArtworkField *field = self.field;
- if (field && note.object != field) return;
- [self paintWith:note.userInfo[@"color"] animated:self.window != nil];
-}
-
-@end
-
-UIView *SGRCardSurface(UIView *host, SGRArtworkField *field) {
- if (!host) return nil;
- SGRCardSurfaceView *surface = objc_getAssociatedObject(host, &kSurfaceKey);
- if (!surface) {
- surface = [[SGRCardSurfaceView alloc] initWithFrame:host.bounds];
- surface.field = field;
- [surface paintWith:field ? field.fieldColor : sg_lastFieldColor animated:NO];
- objc_setAssociatedObject(host, &kSurfaceKey, surface, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- }
- if (surface.superview != host) [host insertSubview:surface atIndex:0];
- return surface;
-}
diff --git a/tweak/Sources/Redesign/Kit/SGRKit.h b/tweak/Sources/Redesign/Kit/SGRKit.h
index c927cd5a..8c5bf1fb 100644
--- a/tweak/Sources/Redesign/Kit/SGRKit.h
+++ b/tweak/Sources/Redesign/Kit/SGRKit.h
@@ -1,18 +1,18 @@
// The Redesign Kit: what every redesigned screen (Redesign/<Screen>/) builds on, so the screens share
// one look and nothing is hand-rolled per screen. A screen imports this and Core/SGCore.h.
//
-// SGRedesign.h the switch per screen and the flags a screen forces
+// SGRedesign.h Redesigned UI, the one switch, and the flags the redesigned screens force
// SGRTokens.h colours, type, spacing, radii, motion, the accessibility settings
// SGRPalette.h the artwork's edge colour, the field colour and the pre-blurred bitmaps
-// SGRField.h the artwork field behind a page, and content cards on it
+// SGRField.h the artwork field behind a page
// SGRGlass.h glass inside Spotify's round controls
// SGRGlyph.h bare glyph overlays and glyph buttons
// SGRRestyle.h keeping Spotify's views restyled: suppress, digits, lookups, shadows, firing controls
// SGRBridges.h player state, now playing artwork, links, the player's open and close
//
-// A screen's hooks install only while its switch is on: every .x of a screen ends with
+// A screen's hooks install only while Redesigned UI is on: every .x of a screen ends with
// %ctor { if (!SGRedesignOn(@"<screen>")) return; %init; SGRequireClasses(@[...]); }
-// and the legacy hooks of that screen stand aside with the same test, so with every switch off the mod
+// and the legacy hooks of that screen stand aside with the same test, so with the switch off the mod
// behaves exactly as it did before the Kit.
#import "SGRedesign.h"
#import "SGRTokens.h"
diff --git a/tweak/Sources/Redesign/Kit/SGRTokens.h b/tweak/Sources/Redesign/Kit/SGRTokens.h
index abf3c4a8..b47c859b 100644
--- a/tweak/Sources/Redesign/Kit/SGRTokens.h
+++ b/tweak/Sources/Redesign/Kit/SGRTokens.h
@@ -14,7 +14,7 @@
extern const CGFloat SGRSideMargin; // 16, the page's side margin
extern const CGFloat SGRGrid; // 8, every gap is a multiple of it
extern const CGFloat SGRRadiusArtwork; // 12, the player's cover
-extern const CGFloat SGRRadiusCard; // 16, a content card (the lyrics card under the player)
+extern const CGFloat SGRRadiusCard; // 16, a content card
extern const CGFloat SGRRadiusCover; // 8, a release cover in a list
extern const CGFloat SGRRadiusThumb; // 6, a row's thumbnail up to 64pt
extern const CGFloat SGRGlassCircleSize; // 44, a round glass behind a top bar button
diff --git a/tweak/Sources/Redesign/Kit/SGRedesign.h b/tweak/Sources/Redesign/Kit/SGRedesign.h
index 00bb9bb9..9fa40f8b 100644
--- a/tweak/Sources/Redesign/Kit/SGRedesign.h
+++ b/tweak/Sources/Redesign/Kit/SGRedesign.h
@@ -1,32 +1,30 @@
-// Redesign: per screen, either Spotify's own layout with the legacy tweaks on it, or the screen
-// redesigned from the Kit (Redesign/<Screen>/). One switch per screen, off until asked for and read
-// once per launch like every other switch, so a screen never changes hands while it is on screen.
-// While a screen's switch is on, the legacy hooks of that screen stand aside (each gates itself with
-// SGRedesignOn) and the redesign may force some of Spotify's remote-config flags, which the flag
-// rows elsewhere then show locked, the way Liquid Glass UI locks the flags it owns.
+// Redesign: Redesigned UI, one switch in Appearance, puts every redesigned screen (Redesign/<Screen>/)
+// in place of Spotify's own and turns on Spotify's glass and the mod's glass switches (Appearance/AppearanceSettings.m).
+// Off until asked for and read once per launch like every other switch, so a screen never changes
+// hands while it is on screen. While it is on, the legacy hooks of the redesigned screens stand aside
+// (each gates itself with SGRedesignOn), their switches are put away on their pages, and the
+// redesign forces the remote-config flags it is built on, over any override, with their rows locked.
//
// Threading: SGRedesignOn, SGRedesignAnyOn and SGRedesignForcedFlag are safe from any thread (the
// configuration provider asks from several). Registration happens in a %ctor, before Spotify reads a
// flag.
#import <UIKit/UIKit.h>
-// spotifyglass.redesign.<screen>; the screens with a redesign are listed in SGRedesign.m.
-#define SGKeyRedesignPrefix @"spotifyglass.redesign."
-#define SGKeyRedesignPlayer @"spotifyglass.redesign.player"
+#define SGKeyRedesign @"spotifyglass.redesign"
-// Whether the screen ("player") was redesigned when Spotify started. A screen without a
-// redesign yet reads off whatever is stored for it.
+// Whether the screen ("player") is one Redesigned UI replaces and the switch was on when Spotify started.
BOOL SGRedesignOn(NSString *screen);
BOOL SGRedesignAnyOn(void);
-// The screens with a redesign.
+// The screens Redesigned UI replaces.
NSArray<NSString *> *SGRedesignScreens(void);
// The flags a screen's redesign forces, flag key to @YES/@NO/number/string, registered from the
// screen's %ctor whether or not the screen is on: the settings rows need the list to lock theirs.
-// Only the screens on at launch force anything; an override from the All flags page still wins.
+// Only while Redesigned UI was on at launch does anything get forced, and then over an override from
+// the All flags page too: the redesign is built on these values.
void SGRedesignForceFlags(NSString *screen, NSDictionary<NSString *, id> *flags);
-// For Features/Flags/Flags.x, right after SGFlagOverride: the value a screen on at launch forces, or nil.
+// For Features/Flags/Flags.x, before SGFlagOverride: the value a screen on at launch forces, or nil.
id SGRedesignForcedFlag(NSString *key);
-// For the flag rows of Settings/SGModPage.m: the value a screen whose switch is on now forces, or
-// nil. It follows the stored switch rather than the launch, as the Liquid Glass UI lock does.
+// For the flag rows of Settings/SGModPage.m: the value a redesigned screen forces while the stored
+// switch is on, or nil. It follows the stored switch rather than the launch, as the glass lock does.
id SGRedesignOwnedFlag(NSString *key);
diff --git a/tweak/Sources/Redesign/Kit/SGRedesign.m b/tweak/Sources/Redesign/Kit/SGRedesign.m
index 798ec02d..328c382b 100644
--- a/tweak/Sources/Redesign/Kit/SGRedesign.m
+++ b/tweak/Sources/Redesign/Kit/SGRedesign.m
@@ -1,42 +1,35 @@
-// The switches of the redesigned screens and the flags they force. A screen's switch is the tab its
-// part's settings page picks it with (the Player page's Native player and Redesigned player).
+// The one switch of the redesign, Redesigned UI in Appearance, and the flags the redesigned screens
+// force. The switch turns every redesigned screen on together: two looks, Spotify's with the mod's
+// switches on it or the redesign, rather than a mix of both whose switches would cross.
#import <os/lock.h>
#import "Core/SGCore.h"
#import "SGRedesign.h"
-// A screen added later needs its name here and a way to pick it on its part's settings page.
+// The screens Redesigned UI turns on; a screen added later needs only its name here.
NSArray<NSString *> *SGRedesignScreens(void) {
return @[@"player"];
}
-static NSString *keyFor(NSString *screen) {
- return [SGKeyRedesignPrefix stringByAppendingString:screen];
-}
-
-#pragma mark - switches
+#pragma mark - switch
// Read once, the first time anything asks, so a switch flipped in Mod Settings waits for the restart
// like every other; the hooks, the flags and the pages all see the same answer for the whole launch.
-static NSSet<NSString *> *onAtLaunch(void) {
- static NSSet<NSString *> *on;
+static BOOL onAtLaunch(void) {
+ static BOOL on;
static dispatch_once_t once;
dispatch_once(&once, ^{
- NSMutableSet *found = [NSMutableSet set];
- for (NSString *screen in SGRedesignScreens()) {
- if (SGFlag(keyFor(screen), NO)) [found addObject:screen];
- }
- on = [found copy];
- if (on.count) SGLog(@"redesign: on for %@", [on.allObjects componentsJoinedByString:@", "]);
+ on = SGFlag(SGKeyRedesign, NO);
+ if (on) SGLog(@"redesign: on for %@", [SGRedesignScreens() componentsJoinedByString:@", "]);
});
return on;
}
BOOL SGRedesignOn(NSString *screen) {
- return screen && [onAtLaunch() containsObject:screen];
+ return screen && onAtLaunch() && [SGRedesignScreens() containsObject:screen];
}
BOOL SGRedesignAnyOn(void) {
- return onAtLaunch().count > 0;
+ return onAtLaunch();
}
#pragma mark - forced flags
@@ -64,7 +57,7 @@ void SGRedesignForceFlags(NSString *screen, NSDictionary<NSString *, id> *flags)
SGLog(@"redesign %@: forcing %lu flags", screen, (unsigned long)flags.count);
[flags enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) {
id override = SGFlagOverride(key);
- if (override) SGLog(@"redesign %@: flag %@ forced %@, the All flags override %@ wins", screen, key, value, override);
+ if (override) SGLog(@"redesign %@: flag %@ forced %@ over the All flags override %@", screen, key, value, override);
}];
}
@@ -77,13 +70,13 @@ id SGRedesignForcedFlag(NSString *key) {
}
id SGRedesignOwnedFlag(NSString *key) {
- if (!key) return nil;
+ if (!key || !SGFlag(SGKeyRedesign, NO)) return nil;
os_unfair_lock_lock(&sg_flagsLock);
NSDictionary<NSString *, NSDictionary<NSString *, id> *> *byScreen = sg_flagsByScreen;
os_unfair_lock_unlock(&sg_flagsLock);
for (NSString *screen in SGRedesignScreens()) {
id value = byScreen[screen][key];
- if (value && SGFlag(keyFor(screen), NO)) return value;
+ if (value) return value;
}
return nil;
}
diff --git a/tweak/Sources/Redesign/Player/Player.h b/tweak/Sources/Redesign/Player/Player.h
index 10d0fd89..e2ffce1c 100644
--- a/tweak/Sources/Redesign/Player/Player.h
+++ b/tweak/Sources/Redesign/Player/Player.h
@@ -17,10 +17,6 @@
@class SGRArtworkField;
-// Whether the lyrics card stays under the player; on until switched off. Off collapses it with the
-// rest, and the lyrics glyph still opens the full screen page.
-#define SGKeyRedesignPlayerLyricsCard @"spotifyglass.redesign.player.lyricsCard"
-
// The field behind the player, nil until the player has laid out once (PlayerField.x).
SGRArtworkField *SGRPlayerField(void);
diff --git a/tweak/Sources/Redesign/Player/PlayerCards.x b/tweak/Sources/Redesign/Player/PlayerCards.x
index 0b4ab0f5..e4de1caf 100644
--- a/tweak/Sources/Redesign/Player/PlayerCards.x
+++ b/tweak/Sources/Redesign/Player/PlayerCards.x
@@ -1,6 +1,7 @@
-// Player redesign: of the cards under the player only lyrics is kept, on a content surface in the field's
-// colour when Apple Music style lyrics draw it; every other card (about the artist, videos, SongDNA, events, explore, credits, merch, anything
-// Spotify adds later) reports no height, so the list closes up around it.
+// Player redesign: of the cards under the player only lyrics is kept, and it has no card of its own when
+// Apple Music style lyrics draw it: the lines sit straight on the field, with no edge where the card was;
+// every other card (about the artist, videos, SongDNA, events, explore, credits, merch, anything Spotify
+// adds later) reports no height, so the list closes up around it.
//
// An allow list rather than Declutter's block list: the server decides which cards a track gets, and a
// new kind should not turn up under a redesigned player. The collapse is the one Declutter/Declutter.x
@@ -23,18 +24,10 @@ static const CGFloat kLivingHeight = 40;
static char kShareKey, kRevalidatedKey;
static __weak UIView *sg_lyricsCard;
-// Read once, like the switch: every card is sized through here.
-static BOOL lyricsAllowed(void) {
- static BOOL allowed;
- static dispatch_once_t once;
- dispatch_once(&once, ^{ allowed = SGEnabled(SGKeyRedesignPlayerLyricsCard); });
- return allowed;
-}
-
// Spotify draws the lines still to come in black, for its card in the album colour (lyrics/01.txt:1054),
-// so they read on the field's dark surface only with Apple Music style lyrics drawn over them; without
-// those the card keeps Spotify's own colour.
-static BOOL surfaceWanted(void) {
+// so they read on the dark field only with Apple Music style lyrics drawn over them; without those the
+// card keeps Spotify's own colour.
+static BOOL clearWanted(void) {
static BOOL wanted;
static dispatch_once_t once;
dispatch_once(&once, ^{ wanted = SGFlag(SGKeyKaraokeLyrics, NO); });
@@ -94,7 +87,7 @@ static UIView *cellAround(UIView *view) {
UIView *content = cell.subviews.firstObject;
if (!content || !isPlayerCard(content)) return result;
UIView *root = content.subviews.firstObject.subviews.firstObject;
- if ([root isKindOfClass:cardViewClass()] && lyricsAllowed()) return result;
+ if ([root isKindOfClass:cardViewClass()]) return result;
result.size = CGSizeMake(result.size.width, 0);
cell.clipsToBounds = YES;
@@ -123,12 +116,16 @@ static UIView *cellAround(UIView *view) {
UIView *share = SGRFindByIdentifier(card, @"lyrics-share-button", &kShareKey);
SGRPlayerVanish(share);
- if (!lyricsAllowed()) return;
if (cell.bounds.size.height >= kLivingHeight) {
objc_setAssociatedObject(cell, &kRevalidatedKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- SGRArtworkField *field = SGRPlayerField();
- // Made only once the player has a field of its own for the surface to follow.
- if (field && surfaceWanted()) SGRCardSurface(cell, field);
+ // Spotify paints the cell the album colour again at every track change, which is no layout pass
+ // of the card's; as the root of the lyrics card, Appearance/Repaint.x keeps it clear in between.
+ if (clearWanted()) {
+ sg_lyricsCardRoot = cell;
+ SGStripBackgrounds(cell);
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{ SGLog(@"redesign player: lyrics card cleared onto the field"); });
+ }
return;
}
// Sized before its card was in it, so it was collapsed as an unknown card: the list is asked once to
diff --git a/tweak/Sources/Settings/SGGlowSwitch.h b/tweak/Sources/Settings/SGGlowSwitch.h
new file mode 100644
index 00000000..0ab42093
--- /dev/null
+++ b/tweak/Sources/Settings/SGGlowSwitch.h
@@ -0,0 +1,14 @@
+// A switch that glows: a capsule whose rim turns into a slowly circling rainbow with a soft glow of the
+// same colours around it when on, and a plain dark rim when off, with a white knob sliding on a spring.
+// For the one switch of a page that changes the whole app (Redesigned UI in Appearance); every other
+// switch stays a UISwitch.
+//
+// It answers isOn and sends UIControlEventValueChanged the way a UISwitch does, so a page treats both
+// alike. The rim stops circling under Reduce Motion, and the glow is left out under Reduce Transparency.
+// Threading: main thread only.
+#import <UIKit/UIKit.h>
+
+@interface SGGlowSwitch : UIControl
+@property (nonatomic, getter=isOn) BOOL on;
+- (void)setOn:(BOOL)on animated:(BOOL)animated;
+@end
diff --git a/tweak/Sources/Settings/SGGlowSwitch.m b/tweak/Sources/Settings/SGGlowSwitch.m
new file mode 100644
index 00000000..b9479655
--- /dev/null
+++ b/tweak/Sources/Settings/SGGlowSwitch.m
@@ -0,0 +1,254 @@
+#import "SGGlowSwitch.h"
+
+static const CGFloat kWidth = 56, kHeight = 32, kKnobInset = 3, kKnobStretch = 5;
+static const CGFloat kRimWidth = 2, kGlowWidth = 5, kGlowRadius = 6, kGlowBleed = 14;
+static const CFTimeInterval kTurn = 4; // seconds for the rainbow to go round once
+static NSString *const kTurnKey = @"turn";
+
+@interface CAFilter : NSObject
++ (instancetype)filterWithType:(NSString *)type;
+@end
+
+// Around the capsule the way a conic gradient runs, starting and ending on the same pink so the turn
+// has no seam.
+static NSArray *rainbow(void) {
+ static NSArray *colors;
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{
+ NSMutableArray *list = [NSMutableArray array];
+ for (NSNumber *rgb in @[@0xFF375F, @0xFF9F0A, @0xFFD60A, @0x30D158, @0x64D2FF, @0x0A84FF, @0xBF5AF2, @0xFF375F]) {
+ uint32_t v = rgb.unsignedIntValue;
+ [list addObject:(id)[UIColor colorWithRed:((v >> 16) & 0xFF) / 255.0 green:((v >> 8) & 0xFF) / 255.0 blue:(v & 0xFF) / 255.0 alpha:1].CGColor];
+ }
+ colors = list;
+ });
+ return colors;
+}
+
+static CAGradientLayer *newRainbow(void) {
+ CAGradientLayer *gradient = [CAGradientLayer layer];
+ gradient.type = kCAGradientLayerConic;
+ gradient.colors = rainbow();
+ gradient.startPoint = CGPointMake(0.5, 0.5);
+ gradient.endPoint = CGPointMake(0.5, 0);
+ return gradient;
+}
+
+static CAShapeLayer *newStroke(CGFloat width) {
+ CAShapeLayer *stroke = [CAShapeLayer layer];
+ stroke.fillColor = UIColor.clearColor.CGColor;
+ stroke.strokeColor = UIColor.blackColor.CGColor;
+ stroke.lineWidth = width;
+ return stroke;
+}
+
+@implementation SGGlowSwitch {
+ CAShapeLayer *_track;
+ CALayer *_rim, *_glow, *_glowShape;
+ CAShapeLayer *_rimMask, *_glowMask;
+ CAGradientLayer *_rimColors, *_glowColors;
+ UIView *_knob;
+ UIImpactFeedbackGenerator *_haptic;
+ BOOL _pressed;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ if (!(self = [super initWithFrame:CGRectMake(frame.origin.x, frame.origin.y, kWidth, kHeight)])) return nil;
+ self.isAccessibilityElement = YES;
+ self.accessibilityTraits = UIAccessibilityTraitButton;
+ if (@available(iOS 17.0, *)) self.accessibilityTraits = UIAccessibilityTraitToggleButton;
+
+ _track = [CAShapeLayer layer];
+ _track.lineWidth = 1;
+ [self.layer addSublayer:_track];
+
+ // The glow: the rainbow cut to a wide stroke, blurred as a whole, in a layer larger than the switch
+ // so the blur has room to spread.
+ _glow = [CALayer layer];
+ _glowShape = [CALayer layer];
+ _glowMask = newStroke(kGlowWidth);
+ _glowShape.mask = _glowMask;
+ _glowColors = newRainbow();
+ [_glowShape addSublayer:_glowColors];
+ [_glow addSublayer:_glowShape];
+ CAFilter *blur = [NSClassFromString(@"CAFilter") respondsToSelector:@selector(filterWithType:)] ? [NSClassFromString(@"CAFilter") filterWithType:@"gaussianBlur"] : nil;
+ if (blur) {
+ [blur setValue:@(kGlowRadius) forKey:@"inputRadius"];
+ _glow.filters = @[blur];
+ }
+ [self.layer addSublayer:_glow];
+
+ _rim = [CALayer layer];
+ _rimMask = newStroke(kRimWidth);
+ _rim.mask = _rimMask;
+ _rimColors = newRainbow();
+ [_rim addSublayer:_rimColors];
+ [self.layer addSublayer:_rim];
+
+ _knob = [UIView new];
+ _knob.userInteractionEnabled = NO;
+ _knob.backgroundColor = UIColor.whiteColor;
+ _knob.layer.shadowColor = UIColor.blackColor.CGColor;
+ _knob.layer.shadowOpacity = 0.3;
+ _knob.layer.shadowRadius = 3;
+ _knob.layer.shadowOffset = CGSizeMake(0, 1);
+ [self addSubview:_knob];
+
+ _haptic = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight];
+ [self paint];
+ return self;
+}
+
+- (CGSize)intrinsicContentSize {
+ return CGSizeMake(kWidth, kHeight);
+}
+
+- (CGSize)sizeThatFits:(CGSize)size {
+ return CGSizeMake(kWidth, kHeight);
+}
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ CGRect bounds = self.bounds;
+ UIBezierPath *capsule = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(bounds, kRimWidth / 2, kRimWidth / 2) cornerRadius:bounds.size.height / 2];
+ // A square the capsule's diagonal across, so the colours cover the rim at every angle of the turn.
+ CGFloat side = ceil(hypot(bounds.size.width, bounds.size.height)) + 2;
+ CGRect square = CGRectMake(CGRectGetMidX(bounds) - side / 2, CGRectGetMidY(bounds) - side / 2, side, side);
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ _track.frame = bounds;
+ _track.path = capsule.CGPath;
+ _rim.frame = bounds;
+ _rimMask.frame = bounds;
+ _rimMask.path = capsule.CGPath;
+ _rimColors.frame = square;
+
+ _glow.frame = CGRectInset(bounds, -kGlowBleed, -kGlowBleed);
+ _glowShape.frame = _glow.bounds;
+ _glowMask.frame = _glow.bounds;
+ UIBezierPath *glowPath = [capsule copy];
+ [glowPath applyTransform:CGAffineTransformMakeTranslation(kGlowBleed, kGlowBleed)];
+ _glowMask.path = glowPath.CGPath;
+ _glowColors.frame = CGRectOffset(square, kGlowBleed, kGlowBleed);
+ [CATransaction commit];
+
+ [self placeKnob];
+}
+
+- (void)placeKnob {
+ CGFloat side = self.bounds.size.height - kKnobInset * 2;
+ CGFloat width = side + (_pressed ? kKnobStretch : 0);
+ CGFloat x = self.on ? self.bounds.size.width - kKnobInset - width : kKnobInset;
+ _knob.frame = CGRectMake(x, kKnobInset, width, side);
+ _knob.layer.cornerRadius = side / 2;
+}
+
+// Colours for the state: a dark inset track and a faint rim when off, the rainbow rim and its glow on a
+// darker track when on.
+- (void)paint {
+ BOOL on = self.on;
+ BOOL glow = on && !UIAccessibilityIsReduceTransparencyEnabled();
+ _track.fillColor = [UIColor colorWithWhite:on ? 0.08 : 0.2 alpha:1].CGColor;
+ _track.strokeColor = [UIColor colorWithWhite:1 alpha:on ? 0 : 0.14].CGColor;
+ _rim.opacity = on ? 1 : 0;
+ _glow.opacity = glow ? 0.85 : 0;
+ _knob.alpha = self.enabled ? 1 : 0.5;
+ self.alpha = self.enabled ? 1 : 0.4;
+ self.accessibilityValue = on ? @"On" : @"Off";
+ [self updateTurn];
+}
+
+- (void)updateTurn {
+ BOOL turning = self.on && self.window && !UIAccessibilityIsReduceMotionEnabled();
+ for (CAGradientLayer *colors in @[_rimColors, _glowColors]) {
+ if (!turning) {
+ [colors removeAnimationForKey:kTurnKey];
+ continue;
+ }
+ if ([colors animationForKey:kTurnKey]) continue;
+ CABasicAnimation *turn = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
+ turn.fromValue = @0;
+ turn.toValue = @(M_PI * 2);
+ turn.duration = kTurn;
+ turn.repeatCount = HUGE_VALF;
+ turn.removedOnCompletion = NO;
+ [colors addAnimation:turn forKey:kTurnKey];
+ }
+}
+
+// The app going to the background drops layer animations; the rim starts again on the way back.
+- (void)didMoveToWindow {
+ [super didMoveToWindow];
+ [NSNotificationCenter.defaultCenter removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
+ if (self.window) [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateTurn) name:UIApplicationWillEnterForegroundNotification object:nil];
+ [self updateTurn];
+}
+
+- (void)dealloc {
+ [NSNotificationCenter.defaultCenter removeObserver:self];
+}
+
+- (void)setOn:(BOOL)on {
+ [self setOn:on animated:NO];
+}
+
+- (void)setOn:(BOOL)on animated:(BOOL)animated {
+ _on = on;
+ if (!animated || UIAccessibilityIsReduceMotionEnabled()) {
+ [CATransaction begin];
+ [CATransaction setDisableActions:!animated];
+ [self paint];
+ [CATransaction commit];
+ [self placeKnob];
+ return;
+ }
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:0.3];
+ [self paint];
+ [CATransaction commit];
+ [UIView animateWithDuration:0.4 delay:0 usingSpringWithDamping:0.72 initialSpringVelocity:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
+ [self placeKnob];
+ } completion:nil];
+}
+
+- (void)setEnabled:(BOOL)enabled {
+ [super setEnabled:enabled];
+ [self paint];
+}
+
+- (void)setPressed:(BOOL)pressed {
+ if (pressed == _pressed) return;
+ _pressed = pressed;
+ [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut animations:^{
+ [self placeKnob];
+ } completion:nil];
+}
+
+- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
+ [_haptic prepare];
+ [self setPressed:YES];
+ return YES;
+}
+
+- (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
+ [self setPressed:NO];
+ if (touch && CGRectContainsPoint(CGRectInset(self.bounds, -16, -16), [touch locationInView:self])) [self flip];
+}
+
+- (void)cancelTrackingWithEvent:(UIEvent *)event {
+ [self setPressed:NO];
+}
+
+- (BOOL)accessibilityActivate {
+ [self flip];
+ return YES;
+}
+
+- (void)flip {
+ [self setOn:!self.on animated:YES];
+ [_haptic impactOccurred];
+ [self sendActionsForControlEvents:UIControlEventValueChanged];
+}
+
+@end
diff --git a/tweak/Sources/Settings/SGModPage.h b/tweak/Sources/Settings/SGModPage.h
index 29a43b24..1e600336 100644
--- a/tweak/Sources/Settings/SGModPage.h
+++ b/tweak/Sources/Settings/SGModPage.h
@@ -21,6 +21,10 @@
@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;
+// A switch row that changes the whole app draws SGGlowSwitch instead of a UISwitch.
+@property (nonatomic) BOOL glows;
+// An ⓘ button beside the row's switch, whose tap reads this out under the row's title.
+@property (nonatomic, copy) NSString *info;
@end
@interface SGModSection : NSObject
@@ -29,24 +33,8 @@
@property (nonatomic, copy) NSString *footer;
@end
-// One tab of a page with tabs: its name on the control, a line under the control saying what picking
-// it means, and the sections that show while it is picked.
-@interface SGModTab : NSObject
-@property (nonatomic, copy) NSString *title;
-@property (nonatomic, copy) NSString *note;
-@property (nonatomic, copy) NSArray<SGModSection *> *sections;
-@end
-
-SGModTab *SGTab(NSString *title, NSString *note, NSArray<SGModSection *> *sections);
-
@interface SGModPage : SGPage
- (instancetype)initWithTitle:(NSString *)title intro:(NSString *)intro sections:(NSArray<SGModSection *> *)sections footer:(NSString *)footer;
-// A page whose tabs pick one of several ways of doing the same thing, the Player page's native and
-// redesigned player: `sections`, which have nothing to do with the pick, come first, then the segmented
-// control under the heading `tabsTitle`, then the picked tab's sections, so that everything under the
-// control belongs to it. The pick is stored under `key` as the tab's index, `fallback` until there is
-// one, and picking another swaps the sections in place.
-- (instancetype)initWithTitle:(NSString *)title intro:(NSString *)intro sections:(NSArray<SGModSection *> *)sections tabsTitle:(NSString *)tabsTitle tabsKey:(NSString *)key tabs:(NSArray<SGModTab *> *)tabs fallback:(NSInteger)fallback footer:(NSString *)footer;
@end
// The intro of every page whose switches the hooks read at launch.
diff --git a/tweak/Sources/Settings/SGModPage.m b/tweak/Sources/Settings/SGModPage.m
index 67e3d25e..13d9db7d 100644
--- a/tweak/Sources/Settings/SGModPage.m
+++ b/tweak/Sources/Settings/SGModPage.m
@@ -1,5 +1,6 @@
#import "SGModPage.h"
#import "SGPageStyle.h"
+#import "SGGlowSwitch.h"
#import "Core/SGCore.h"
#import "Features/Flags/Flags.h"
#import "Features/About/About.h"
@@ -199,25 +200,6 @@ SGModRow *SGWithSymbol(SGModRow *row, NSString *symbol) {
return row;
}
-@implementation SGModTab
-@end
-
-SGModTab *SGTab(NSString *title, NSString *note, NSArray<SGModSection *> *sections) {
- SGModTab *tab = [SGModTab new];
- tab.title = title;
- tab.note = note;
- tab.sections = sections;
- return tab;
-}
-
-// The row the tabs are drawn in: no key, no page, no action, so nothing else in the page mistakes it
-// for a row of its own kind.
-@interface SGTabsRow : SGModRow
-@end
-
-@implementation SGTabsRow
-@end
-
// What a page row carrying a value shows on the right: the value, then the chevron, the same
// distance apart as Spotify's own rows keep them.
static UIView *valueAndChevron(NSString *text) {
@@ -243,8 +225,8 @@ static BOOL flagRowOn(SGModRow *row) {
return value && [value boolValue] != row.forceOff;
}
-// A flag the Liquid Glass UI switch or a redesigned screen 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.
+// A flag Redesigned UI owns, for Spotify's newer design or for a redesigned screen: its row shows what
+// the switch forces and takes no touch, so the flag has one place to change.
static BOOL flagRowLocked(SGModRow *row) {
if (!row.flag) return NO;
return (SGGlassOwnsFlag(row.key) && SGFlag(SGKeySpotifyGlass, NO)) || (row.forceOff && SGAdBlockForcesFlagOff(row.key))
@@ -252,7 +234,7 @@ static BOOL flagRowLocked(SGModRow *row) {
}
// What a locked row shows: the value its owner forces, read the row's way, so a Disable Canvas row
-// reads on while a redesign forces Canvas off. Liquid Glass UI and the ad blocking only ever force a
+// reads on while the redesign forces Canvas off. The glass flags and the ad blocking only ever force a
// flag the way its row would.
static BOOL lockedRowOn(SGModRow *row) {
id owned = SGRedesignOwnedFlag(row.key);
@@ -261,11 +243,6 @@ static BOOL lockedRowOn(SGModRow *row) {
@implementation SGModPage {
NSArray<SGModSection *> *_sections;
- NSArray<SGModSection *> *_shared;
- NSArray<SGModTab *> *_tabs;
- NSString *_tabsKey;
- NSString *_tabsTitle;
- NSInteger _tabsFallback;
UIView *_intro;
UIView *_footer;
NSTimer *_ticker;
@@ -278,84 +255,12 @@ static BOOL lockedRowOn(SGModRow *row) {
_sections = sections;
_intro = intro ? SGNote(intro) : nil;
_footer = footer ? SGNote(footer) : nil;
- [self noteLiveRows];
- return self;
-}
-
-- (instancetype)initWithTitle:(NSString *)title intro:(NSString *)intro sections:(NSArray<SGModSection *> *)sections tabsTitle:(NSString *)tabsTitle tabsKey:(NSString *)key tabs:(NSArray<SGModTab *> *)tabs fallback:(NSInteger)fallback footer:(NSString *)footer {
- if (!(self = [self initWithTitle:title intro:intro sections:sections footer:footer])) return nil;
- _shared = sections;
- _tabs = tabs;
- _tabsKey = key;
- _tabsTitle = [tabsTitle copy];
- _tabsFallback = fallback;
- [self layOutTabs];
+ // A page row reads its value out when the page appears rather than on the ticker, so only the
+ // rows whose numbers climb on their own keep one running.
+ for (SGModSection *s in sections) for (SGModRow *row in s.rows) _live |= row.value && !row.page;
return self;
}
-// A page row reads its value out when the page appears rather than on the ticker, so only the rows
-// whose numbers climb on their own keep one running.
-- (void)noteLiveRows {
- _live = NO;
- for (SGModSection *s in _sections) for (SGModRow *row in s.rows) _live |= row.value && !row.page;
-}
-
-- (NSInteger)pickedTab {
- NSInteger index = SGInt(_tabsKey, _tabsFallback);
- return index >= 0 && index < (NSInteger)_tabs.count ? index : 0;
-}
-
-// The sections the pick has nothing to do with, then the control's own section, headed and footed by
-// what the picked tab means, then the tab's sections.
-- (void)layOutTabs {
- SGModTab *tab = _tabs[(NSUInteger)[self pickedTab]];
- SGModSection *control = SGNotedSection(_tabsTitle, @[[SGTabsRow new]], tab.note);
- _sections = [[(_shared ?: @[]) arrayByAddingObject:control] arrayByAddingObjectsFromArray:tab.sections ?: @[]];
- [self noteLiveRows];
-}
-
-- (void)tabPicked:(UISegmentedControl *)control {
- if (control.selectedSegmentIndex == [self pickedTab]) return;
- SGSetInt(_tabsKey, control.selectedSegmentIndex);
- [self layOutTabs];
- [UIView transitionWithView:self.tableView duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction animations:^{
- [self.tableView reloadData];
- } completion:nil];
-}
-
-// The control on the page itself rather than on a card, full width, the picked tab's name in white on
-// the selection and the other names in the grey of a subtitle.
-- (UITableViewCell *)tabsCellIn:(UITableView *)table {
- UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"tabs"];
- UISegmentedControl *control = (UISegmentedControl *)[cell.contentView viewWithTag:1];
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"tabs"];
- cell.backgroundConfiguration = [UIBackgroundConfiguration clearConfiguration];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- control = [UISegmentedControl new];
- control.tag = 1;
- control.translatesAutoresizingMaskIntoConstraints = NO;
- UIFont *font = [UIFont systemFontOfSize:14 weight:UIFontWeightSemibold];
- [control setTitleTextAttributes:@{NSFontAttributeName: font, NSForegroundColorAttributeName: SGGrey()} forState:UIControlStateNormal];
- [control setTitleTextAttributes:@{NSFontAttributeName: font, NSForegroundColorAttributeName: UIColor.whiteColor} forState:UIControlStateSelected];
- [control addTarget:self action:@selector(tabPicked:) forControlEvents:UIControlEventValueChanged];
- [cell.contentView addSubview:control];
- [NSLayoutConstraint activateConstraints:@[
- [control.leadingAnchor constraintEqualToAnchor:cell.contentView.leadingAnchor],
- [control.trailingAnchor constraintEqualToAnchor:cell.contentView.trailingAnchor],
- [control.topAnchor constraintEqualToAnchor:cell.contentView.topAnchor],
- [control.bottomAnchor constraintEqualToAnchor:cell.contentView.bottomAnchor],
- [control.heightAnchor constraintEqualToConstant:40],
- ]];
- }
- if (control.numberOfSegments != _tabs.count) {
- [control removeAllSegments];
- for (NSUInteger i = 0; i < _tabs.count; i++) [control insertSegmentWithTitle:_tabs[i].title atIndex:i animated:NO];
- }
- control.selectedSegmentIndex = [self pickedTab];
- return cell;
-}
-
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.tableHeaderView = _intro;
@@ -436,7 +341,6 @@ static BOOL lockedRowOn(SGModRow *row) {
- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {
SGModRow *row = [self rowAt:path];
- if ([row isKindOfClass:SGTabsRow.class]) return [self tabsCellIn:table];
UITableViewCell *cell = SGDequeueCell(table, @"row");
SGFillCell(cell, row.title, row.subtitle, row.color, row.symbol);
UIListContentConfiguration *content = (UIListContentConfiguration *)cell.contentConfiguration;
@@ -447,16 +351,28 @@ static BOOL lockedRowOn(SGModRow *row) {
cell.separatorInset = UIEdgeInsetsMake(0, row.symbol ? (tile ? 58 : 48) : 16, 0, 0);
if (row.key) {
- UISwitch *toggle = [UISwitch new];
- toggle.onTintColor = SGGreen();
BOOL locked = flagRowLocked(row);
- toggle.on = row.flag ? (locked && !SGFlagOverride(row.key) ? lockedRowOn(row) : flagRowOn(row)) : SGFlag(row.key, row.defaultOn);
+ // The redesign's own flags win over an override; the others' lock gives way to one.
+ BOOL showsLock = locked && (SGRedesignOwnedFlag(row.key) || !SGFlagOverride(row.key));
+ BOOL on = row.flag ? (showsLock ? lockedRowOn(row) : flagRowOn(row)) : SGFlag(row.key, row.defaultOn);
+ UIControl *toggle;
+ if (row.glows) {
+ SGGlowSwitch *glow = [SGGlowSwitch new];
+ glow.on = on;
+ glow.accessibilityLabel = row.title;
+ toggle = glow;
+ } else {
+ UISwitch *plain = [UISwitch new];
+ plain.onTintColor = SGGreen();
+ plain.on = on;
+ toggle = plain;
+ }
toggle.enabled = !locked;
// A disabled switch would swallow the tap; letting it through is what gets the row asked.
toggle.userInteractionEnabled = !locked;
toggle.tag = path.section * 1000 + path.row;
[toggle addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventValueChanged];
- cell.accessoryView = toggle;
+ cell.accessoryView = row.info ? [self infoButtonBeside:toggle tag:toggle.tag] : toggle;
cell.selectionStyle = locked ? UITableViewCellSelectionStyleDefault : UITableViewCellSelectionStyleNone;
} else if (row.page) {
cell.accessoryView = row.value ? valueAndChevron(row.value()) : SGSymbolView(@"chevron.right", 13, UIImageSymbolWeightSemibold, 16);
@@ -489,15 +405,45 @@ static BOOL lockedRowOn(SGModRow *row) {
[self readValues];
}
-- (void)toggled:(UISwitch *)toggle {
+// The ⓘ to the left of the switch, the grey of a subtitle, 30pt across so it is easy to hit next to it.
+- (UIView *)infoButtonBeside:(UIControl *)toggle tag:(NSInteger)tag {
+ UIButton *info = [UIButton buttonWithType:UIButtonTypeSystem];
+ UIImageSymbolConfiguration *symbol = [UIImageSymbolConfiguration configurationWithPointSize:17 weight:UIImageSymbolWeightRegular];
+ [info setImage:[UIImage systemImageNamed:@"info.circle" withConfiguration:symbol] forState:UIControlStateNormal];
+ info.tintColor = SGGrey();
+ info.tag = tag;
+ info.accessibilityLabel = @"About this switch";
+ [info addTarget:self action:@selector(infoTapped:) forControlEvents:UIControlEventTouchUpInside];
+ [toggle sizeToFit];
+ CGFloat side = 30, gap = 8, height = MAX(side, toggle.bounds.size.height);
+ UIView *box = [[UIView alloc] initWithFrame:CGRectMake(0, 0, side + gap + toggle.bounds.size.width, height)];
+ info.frame = CGRectMake(0, (height - side) / 2, side, side);
+ toggle.frame = CGRectMake(side + gap, (height - toggle.bounds.size.height) / 2, toggle.bounds.size.width, toggle.bounds.size.height);
+ [box addSubview:info];
+ [box addSubview:toggle];
+ return box;
+}
+
+- (void)infoTapped:(UIButton *)button {
+ SGModRow *row = [self rowAt:[NSIndexPath indexPathForRow:button.tag % 1000 inSection:button.tag / 1000]];
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:row.title message:row.info preferredStyle:UIAlertControllerStyleAlert];
+ [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]];
+ [self presentViewController:alert animated:YES completion:nil];
+}
+
+// A UISwitch or an SGGlowSwitch, both answering isOn.
+- (void)toggled:(UIControl *)toggle {
+ BOOL on = [(UISwitch *)toggle isOn];
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.flag) SGSetFlagOverride(row.key, on ? @(!row.forceOff) : nil);
+ else SGSetEnabled(row.key, on);
if (row.changed) {
- row.changed(toggle.on);
- [self.tableView reloadData];
+ row.changed(on);
+ // A glowing switch is let finish its slide before the reload puts a new one in its place.
+ NSTimeInterval wait = [toggle isKindOfClass:SGGlowSwitch.class] ? 0.45 : 0;
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(wait * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.tableView reloadData]; });
}
- if (toggle.on && row.warning) [self warn:row];
+ if (on && row.warning) [self warn:row];
}
// A locked row will not move, and nothing on it says why.