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: turn the redesigned player's play glyph at the tap, and keep the Player page's shared rows above the player tabs

Vojtěch Škopek53ebda6959ef
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 6aa7db37..27944a2d 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -99,13 +99,14 @@ one page, the mod's own rows first and Spotify's flags below them or on a sub pa
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.
-Player: tabs at the top pick the player screen, Native player (Spotify's own, with the switches of
-Player.x and Declutter.x) or Redesigned player (Redesign/Player, which those switches don't reach), each
-tab showing only its own player's rows; the pages below belong to both. Then Gestures, Lyrics (Apple Music style, glass lyrics, the ordered list of lyrics sources, lyrics
-for every track, naming the source, hiding the lyrics card and preview, the lyrics flags), Blocked artists (with the count on the row) and Now playing bar (its glass, its device
-button and its flags) as pages; then the 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 player buttons to hide, and Queue & devices and Lock screen widget as flag pages. Home & Library:
+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:
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
diff --git a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m
index 4287308d..3da3b30f 100644
--- a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m
+++ b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m
@@ -49,10 +49,6 @@ static UIViewController *lyricsPage(void) {
SGOptionRow(@"Lyrics for every track", @"Offers the lyrics card on tracks Spotify has no lyrics for; needs a source above", SGKeyLyricsAllTracks),
SGOptionRow(@"Name the source", @"Reads out which source the lines on the full screen page came from", SGKeyLyricsCredit),
], @"With no source on, Spotify's own lyrics are left alone."),
- SGSection(@"Hide in the player", @[
- SGHideRow(@"Lyrics card", @"The lyrics card below the player", SGHideLyricsCard),
- SGHideRow(@"Lyrics preview", @"The lyric lines shown under the artwork", SGHideLyricsInline),
- ]),
SGSection(@"Spotify's flags", @[
SGFlagRow(@"Translations in the player", @"ios-feature-lyrics.enable_lyrics_multilanguage_npv"),
SGFlagRow(@"Translations full screen", @"ios-feature-lyrics.enable_lyrics_multilanguage_fullscreen"),
@@ -101,10 +97,10 @@ static UIViewController *lockScreenPage(void) {
] footer:nil];
}
-// The player screen is one of two, picked with the tabs at the top of the page: 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. Each tab holds only its own player's rows; the pages above the player
-// screen itself (gestures, lyrics, the bar, the queue) belong to both and follow the tabs.
+// 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 *{
@@ -112,7 +108,7 @@ UIViewController *SGNowPlayingSettingsPage(void) {
};
SGModTab *native = SGTab(@"Native player", @"Spotify's own player, with the switches below on it.", @[
- SGNotedSection(@"Player screen", @[
+ SGNotedSection(@"Look", @[
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")),
@@ -121,7 +117,8 @@ UIViewController *SGNowPlayingSettingsPage(void) {
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."),
- SGNotedSection(@"Hide cards below the player", @[
+ SGSection(@"Hide cards below the player", @[
+ SGHideRow(@"Lyrics", nil, SGHideLyricsCard),
SGHideRow(@"About the artist", nil, SGHideAboutArtist),
SGHideRow(@"Related videos", nil, SGHideRelatedVideos),
SGHideRow(@"SongDNA", nil, SGHideSongDNA),
@@ -130,8 +127,9 @@ UIViewController *SGNowPlayingSettingsPage(void) {
SGHideRow(@"Credits", nil, SGHideCredits),
SGHideRow(@"Merch", nil, SGHideMerch),
SGHideRow(@"Recommendations", nil, SGHideRecommendations),
- ], @"The lyrics card is hidden from the Lyrics page."),
- SGSection(@"Hide player buttons", @[
+ ]),
+ SGSection(@"Hide on the player", @[
+ SGHideRow(@"Lyrics preview", @"The lyric lines shown under the artwork", SGHideLyricsInline),
SGHideRow(@"Shuffle", nil, SGHideShuffle),
SGHideRow(@"Repeat", nil, SGHideRepeat),
SGHideRow(@"Add to playlist", nil, SGHideAddTo),
@@ -142,16 +140,13 @@ UIViewController *SGNowPlayingSettingsPage(void) {
]);
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(@"Player screen", @[
- SGSwitchRow(@"Lyrics under the player", @"The lyrics card below the player; every other card is left out", SGKeyRedesignPlayerLyricsCard),
+ SGSection(@"Below the player", @[
+ SGSwitchRow(@"Lyrics", @"The lyrics card below the player; every other card is left out", SGKeyRedesignPlayerLyricsCard),
]),
]);
return [[SGModPage alloc] initWithTitle:@"Player"
intro:@"Changes apply after you restart Spotify. Gestures and Blocked artists apply straight away."
- tabsKey:SGKeyRedesignPlayer
- tabs:@[native, redesigned]
- fallback:0
sections:@[
SGSection(nil, @[
SGWithSymbol(SGPageRow(@"Gestures", ^UIViewController *{ return SGGesturesSettingsPage(); }), @"hand.tap"),
@@ -163,5 +158,10 @@ 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"),
]),
- ] footer:nil];
+ ]
+ tabsTitle:@"Player screen"
+ tabsKey:SGKeyRedesignPlayer
+ tabs:@[native, redesigned]
+ fallback:0
+ footer:nil];
}
diff --git a/tweak/Sources/Redesign/Kit/SGRGlyph.m b/tweak/Sources/Redesign/Kit/SGRGlyph.m
index fd4423fb..f81e1627 100644
--- a/tweak/Sources/Redesign/Kit/SGRGlyph.m
+++ b/tweak/Sources/Redesign/Kit/SGRGlyph.m
@@ -32,7 +32,8 @@ static const CGFloat kMinTouch = 44, kPressAlpha = 0.5, kPressScale = 0.9, kDisa
UIImage *image = [UIImage systemImageNamed:symbol];
if (@available(iOS 17.0, *)) {
if (animated && image && self.window && !SGRReduceMotion()) {
- [self setSymbolImage:image withContentTransition:[NSSymbolReplaceContentTransition transition]];
+ // Twice UIKit's pace: a control's glyph answers a tap, and the default replace lingers.
+ [self setSymbolImage:image withContentTransition:[NSSymbolReplaceContentTransition transition] options:[NSSymbolEffectOptions optionsWithSpeed:2]];
return;
}
}
diff --git a/tweak/Sources/Redesign/Player/PlayerControls.x b/tweak/Sources/Redesign/Player/PlayerControls.x
index 6ec13530..30ea9cfc 100644
--- a/tweak/Sources/Redesign/Player/PlayerControls.x
+++ b/tweak/Sources/Redesign/Player/PlayerControls.x
@@ -24,8 +24,15 @@ static const CGFloat kSkipGlyphSize = 32, kPlayGlyphSize = 44;
// A spinner that is still up this long after a state change is buffering, not a track starting.
static const NSTimeInterval kSpinnerCheck = 0.6;
+// After a tap the glyph shows what the tap asked for, and a state still saying the opposite is taken for
+// one sent before the player caught up, for this long; after it the player's word is final.
+static const NSTimeInterval kTapTrust = 1.2;
+
static char kPreviousKey, kNextKey, kPlayKey, kGlyphKey, kTakeKey, kRemainingKey;
+static __weak UIView *sg_playView;
static __weak UIButton *sg_playButton;
+static CFTimeInterval sg_tappedUntil;
+static BOOL sg_tappedPaused;
static __weak SGRGlyphView *sg_playGlyph;
static __weak UIView *sg_controlsHost;
@@ -94,12 +101,33 @@ static BOOL spinnerShowing(UIButton *button) {
return NO;
}
+static NSString *symbolFor(BOOL paused) {
+ return paused ? @"play.fill" : @"pause.fill";
+}
+
static void refreshPlayGlyph(BOOL animated) {
SGRGlyphView *glyph = sg_playGlyph;
SPTPlayerState *state = SGRPlayerState();
if (!glyph || !state) return;
- [glyph setSymbol:state.isPaused ? @"play.fill" : @"pause.fill" animated:animated];
glyph.alpha = spinnerShowing(sg_playButton) ? 0 : 1;
+ CFTimeInterval now = CACurrentMediaTime();
+ if (now < sg_tappedUntil) {
+ if (state.isPaused != sg_tappedPaused) return;
+ sg_tappedUntil = 0;
+ }
+ [glyph setSymbol:symbolFor(state.isPaused) animated:animated];
+}
+
+// The player's state reaches the glyph a beat after the tap (the request goes through the player core
+// and comes back as a state), which read as a slow button; Spotify's own disc turns at the touch. So the
+// glyph turns at the touch too, to the opposite of what it shows, and the state settles it after.
+static void playTapped(void) {
+ SGRGlyphView *glyph = sg_playGlyph;
+ if (!glyph || glyph.alpha == 0) return;
+ sg_tappedPaused = ![glyph.symbol isEqualToString:@"play.fill"];
+ sg_tappedUntil = CACurrentMediaTime() + kTapTrust;
+ [glyph setSymbol:symbolFor(sg_tappedPaused) animated:YES];
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kTapTrust * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ refreshPlayGlyph(YES); });
}
static void playGlyph(UIView *host) {
@@ -133,8 +161,9 @@ static void playGlyph(UIView *host) {
}
// Inside the button, over the disc it replaces, so it follows the button's own press.
- SGRGlyphView *glyph = glyphFor(play, state.isPaused ? @"play.fill" : @"pause.fill", kPlayGlyphSize);
+ SGRGlyphView *glyph = glyphFor(play, symbolFor(state.isPaused), kPlayGlyphSize);
keepOnTop(glyph, button);
+ sg_playView = play;
sg_playButton = button;
sg_playGlyph = glyph;
refreshPlayGlyph(NO);
@@ -186,6 +215,19 @@ static UILabel *monospaced(UIView *host, NSString *identifier, const void *findK
return label;
}
+// The action the play button's own UIButton sends (objc-methods.txt: -[PlayButtonView uiButtonTapped]).
+// Only the player's button turns the glyph: the sticky header and every page with a play button of
+// its own use the same class.
+%hook _TtC28EncoreConsumerMobile_BaseKit14PlayButtonView
+- (void)uiButtonTapped {
+ %orig;
+ if ((UIView *)self != sg_playView) return;
+ playTapped();
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{ SGLog(@"redesign player: play glyph turned at the tap"); });
+}
+%end
+
%hook _TtC20NowPlaying_ModesImpl19DurationElementUnit
- (void)viewDidLayoutSubviews {
%orig;
diff --git a/tweak/Sources/Settings/SGModPage.h b/tweak/Sources/Settings/SGModPage.h
index 0932931b..29a43b24 100644
--- a/tweak/Sources/Settings/SGModPage.h
+++ b/tweak/Sources/Settings/SGModPage.h
@@ -42,10 +42,11 @@ SGModTab *SGTab(NSString *title, NSString *note, NSArray<SGModSection *> *sectio
@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: a segmented control leads the page, the picked tab's sections follow it, then
-// `sections`, which every tab shows. 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 tabsKey:(NSString *)key tabs:(NSArray<SGModTab *> *)tabs fallback:(NSInteger)fallback sections:(NSArray<SGModSection *> *)sections footer:(NSString *)footer;
+// 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 7b39f9f7..67e3d25e 100644
--- a/tweak/Sources/Settings/SGModPage.m
+++ b/tweak/Sources/Settings/SGModPage.m
@@ -264,6 +264,7 @@ static BOOL lockedRowOn(SGModRow *row) {
NSArray<SGModSection *> *_shared;
NSArray<SGModTab *> *_tabs;
NSString *_tabsKey;
+ NSString *_tabsTitle;
NSInteger _tabsFallback;
UIView *_intro;
UIView *_footer;
@@ -281,11 +282,12 @@ static BOOL lockedRowOn(SGModRow *row) {
return self;
}
-- (instancetype)initWithTitle:(NSString *)title intro:(NSString *)intro tabsKey:(NSString *)key tabs:(NSArray<SGModTab *> *)tabs fallback:(NSInteger)fallback sections:(NSArray<SGModSection *> *)sections footer:(NSString *)footer {
+- (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];
return self;
@@ -303,12 +305,12 @@ static BOOL lockedRowOn(SGModRow *row) {
return index >= 0 && index < (NSInteger)_tabs.count ? index : 0;
}
-// The control's own section, footed by what the picked tab means, then the tab's sections, then the
-// ones every tab shares.
+// 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(nil, @[[SGTabsRow new]], tab.note);
- _sections = [[@[control] arrayByAddingObjectsFromArray:tab.sections ?: @[]] arrayByAddingObjectsFromArray:_shared ?: @[]];
+ SGModSection *control = SGNotedSection(_tabsTitle, @[[SGTabsRow new]], tab.note);
+ _sections = [[(_shared ?: @[]) arrayByAddingObject:control] arrayByAddingObjectsFromArray:tab.sections ?: @[]];
[self noteLiveRows];
}