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: the player's header buttons wear glass circles that press under a finger

My-Name-Is-Jeffd5c30674768e
diff --git a/harness/player/README.md b/harness/player/README.md
index 3ecac667..27acd9b5 100644
--- a/harness/player/README.md
+++ b/harness/player/README.md
@@ -14,7 +14,8 @@ too. `SRC=<another checkout>/tweak/Sources OUT=<dir> ./build.sh` builds it again
sources, for example an older commit, to see a bug before its fix.
`build.sh` runs `logos.pl -c generator=internal` over `PlayerLyrics.x`, `PlayerArtwork.x`,
-`PlayerControls.x`, `PlayerFooter.x`, `PlayerScroll.x`, `PlayerField.x` and the Kit's `SGRBridges.x`, and links them with
+`PlayerControls.x`, `PlayerFooter.x`, `PlayerScroll.x`, `PlayerField.x`, `PlayerHeader.x` (the glass circles of
+the down arrow and the ⋯, in a mocked `HeaderElementsUnit`, and their press) and the Kit's `SGRBridges.x`, and links them with
the real `Core/`, `Redesigned/Kit/`, `SGRKaraokeView`, `Settings/`, the Player page and the Visualiser (`PlayerVisualiser.m`, `SGRSpectrum.m`). `stubs.m` stands in for the hooks the harness
does not compile (the Kit's accent and repaint, the rest of the player, the lyrics store, the haptics,
Sing's mic) and plays a mock player: `SGRHarnessSetTrack` reports a track, with the image ids Spotify's
@@ -93,6 +94,13 @@ come late, out of order, or not at all.
30, settle and stop with the reader off on a pause, come back on play, and go and come back through the ⋯
menu's switch to Fluid and back. The log ends with `visualiser checks: n of 7 right -- PASS` or `FAIL`.
+- `header` is the glass circles' press (`PlayerHeader.x`): a finger (`../tabbar/touch.m`) held half a second on
+ the down arrow and then on the ⋯, each a `UIControl` under Spotify's identifier. It checks each has a 44pt glass
+ circle first among its subviews, that a touch at its middle lands on the button, that the circle is pressed
+ in (scale 0.92) while the finger is down and whole again once it lifts. The log ends with
+ `header checks: n of 9 right -- PASS` or `FAIL`. The ⋯'s press on the phone comes through the mod's button
+ over it, which this harness does not build; `harness/system-menu`'s `arrow` run covers that button's events.
+
- `seek` is the tap around the progress bar (`PlayerControls.x`): a mock slider with Spotify's identifier and
the two times beside it. It checks that a tap counts below the bar and up to 12 pt past its ends, not on the
thumb or the times, that the ends of the thumb's travel are the song's start and end, that a tap is played
diff --git a/harness/player/build.sh b/harness/player/build.sh
index a6cd06ad..ac4aafca 100755
--- a/harness/player/build.sh
+++ b/harness/player/build.sh
@@ -6,7 +6,7 @@ OUT=${OUT:-$(dirname "$0")/build}
rm -rf "$OUT"; mkdir -p "$OUT/gen" "$OUT/PlayerHarness.app"
for f in Redesigned/Player/PlayerLyrics.x Redesigned/Player/PlayerArtwork.x Redesigned/Player/PlayerFooter.x \
- Redesigned/Player/PlayerScroll.x Redesigned/Player/PlayerField.x Redesigned/Player/PlayerMotion.x Redesigned/Player/PlayerLandscape.x Redesigned/Player/PlayerControls.x Redesigned/Kit/SGRBridges.x; do
+ Redesigned/Player/PlayerScroll.x Redesigned/Player/PlayerField.x Redesigned/Player/PlayerMotion.x Redesigned/Player/PlayerLandscape.x Redesigned/Player/PlayerControls.x Redesigned/Player/PlayerHeader.x Redesigned/Kit/SGRBridges.x; do
name=$(basename "$f" .x)
"$THEOS/bin/logos.pl" -c generator=internal "$SRC/$f" > "$OUT/gen/$name.m"
done
@@ -15,7 +15,7 @@ SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)
xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-arc -g -O0 \
-I"$SRC" -I"$SRC/Redesigned/Player" -I"$SRC/Redesigned/Kit" -I"$OUT/gen" -isysroot "$SDK" \
-Wno-deprecated-declarations \
- "$(dirname "$0")/main.m" "$(dirname "$0")/../scene.m" "$(dirname "$0")/stubs.m" \
+ "$(dirname "$0")/main.m" "$(dirname "$0")/../scene.m" "$(dirname "$0")/stubs.m" "$(dirname "$0")/../tabbar/touch.m" \
"$OUT"/gen/*.m \
"$SRC"/Core/SGLog.m "$SRC"/Core/SGPrefs.m "$SRC"/Core/SGViewTree.m "$SRC"/Core/SGGlass.m \
"$SRC"/Core/SGBackdrop.m "$SRC"/Core/SGFlagForce.m "$SRC"/Core/SGUIMode.m \
@@ -26,7 +26,7 @@ xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-ar
"$SRC"/Redesigned/Player/PlayerSettings.m "$SRC"/Redesigned/Player/PlayerVisualiser.m "$SRC"/Redesigned/Player/SGRSpectrum.m "$SRC"/Redesigned/NowPlayingBar/NowPlayingBarSettings.m \
"$SRC"/Settings/SGPage.m "$SRC"/Settings/SGPageStyle.m "$SRC"/Settings/SGModPage.m "$SRC"/Settings/SGGlowSwitch.m \
"$SRC"/Redesigned/Lyrics/SGRKaraokeView.m "$SRC"/Redesigned/Lyrics/LyricsLook.m "$SRC"/Redesigned/Lyrics/SGRSingButton.m "$SRC"/Redesigned/Lyrics/MeaningSheet.m "$SRC"/Redesigned/Lyrics/LyricsText.m "$SRC"/Shared/Lyrics/KaraokeTiming.m "$SRC"/Shared/Lyrics/Romanise.m "$SRC"/Shared/AdBlock/Protobuf.m \
- -framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols -framework AVFoundation -framework CoreMedia -framework CoreVideo -framework Accelerate \
+ -framework UIKit -framework IOKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols -framework AVFoundation -framework CoreMedia -framework CoreVideo -framework Accelerate \
-o "$OUT/PlayerHarness.app/PlayerHarness"
cat > "$OUT/PlayerHarness.app/Info.plist" <<'PLIST'
diff --git a/harness/player/main.m b/harness/player/main.m
index 8986bda8..cee79d58 100644
--- a/harness/player/main.m
+++ b/harness/player/main.m
@@ -46,6 +46,8 @@
void SGRHarnessPlayFrom(NSInteger ms);
void SGRHarnessSetTrack(NSString *uri, NSString *imageURI, BOOL paused);
+// ../tabbar/touch.m: a finger's touches, through UIKit's own recognizers.
+extern void SGHarnessHold(UIWindow *window, CGPoint point, NSTimeInterval seconds);
static NSString *scenario(void) {
const char *value = getenv("HARNESS_SCENARIO");
@@ -187,6 +189,9 @@ static NSString *colorName(UIImage *image) {
@interface _TtC20NowPlaying_ModesImpl28PlaybackControlsElementsUnit : UIViewController @end
@implementation _TtC20NowPlaying_ModesImpl28PlaybackControlsElementsUnit @end
+@interface _TtC20NowPlaying_ModesImpl18HeaderElementsUnit : UIViewController @end
+@implementation _TtC20NowPlaying_ModesImpl18HeaderElementsUnit @end
+
@interface _TtC20NowPlaying_ModesImpl18FooterElementsUnit : UIViewController @end
@implementation _TtC20NowPlaying_ModesImpl18FooterElementsUnit @end
@@ -375,6 +380,7 @@ static void loadLyrics(void) {
@implementation SGRHarnessDelegate {
NSArray<UIViewController *> *_units;
+ NSUInteger _headerDowns;
UIImageView *_cover, *_barCover;
UIViewController *_bar;
UICollectionView *_covers;
@@ -538,9 +544,11 @@ static void loadLyrics(void) {
footer.view = footerView;
UIViewController *playback = [_TtC20NowPlaying_ModesImpl28PlaybackControlsElementsUnit new];
playback.view = controls;
+ UIViewController *headerUnit = [_TtC20NowPlaying_ModesImpl18HeaderElementsUnit new];
+ headerUnit.view = header;
UIViewController *player = [_TtC19NowPlaying_ViewImpl24NowPlayingViewController new];
player.view = host;
- _units = @[info, duration, floating, playback, footer, scrollUnit, background, player];
+ _units = @[headerUnit, info, duration, floating, playback, footer, scrollUnit, background, player];
_covers = covers;
_plane = plane;
_host = host;
@@ -548,7 +556,7 @@ static void loadLyrics(void) {
// The player has not been opened yet: its background plane is laid out only when it is.
if ([scenario() isEqualToString:@"motion"]) {
[plane removeFromSuperview];
- _units = @[info, duration, floating, playback, footer, scrollUnit, player];
+ _units = @[headerUnit, info, duration, floating, playback, footer, scrollUnit, player];
}
[self start];
[self layOut];
@@ -581,6 +589,7 @@ static void loadLyrics(void) {
else if ([scenario() isEqualToString:@"preview"]) [self runPreviewChecks];
else if ([scenario() isEqualToString:@"seek"]) [self runSeekChecks];
else if ([scenario() isEqualToString:@"visualiser"]) [self runVisualiserChecks];
+ else if ([scenario() isEqualToString:@"header"]) [self runHeaderChecks];
// Opened, closed and opened again, so a screenshot can be taken of each state and of the move itself.
else for (NSNumber *at in @[@2, @6, @10]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(at.doubleValue * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@@ -1558,6 +1567,52 @@ static BOOL linesSeek(SGRKaraokeView *lyrics) {
}
// One track, then another album's at 8 s, its picture on the screens 0.4 s later.
+// The header's glass circles press in under a finger (PlayerHeader.x): held on the down arrow and then on the
+// ⋯, each circle is smaller while the finger is down and whole again once it lifts.
+- (void)headerDown:(UIControl *)control {
+ _headerDowns++;
+}
+
+- (void)runHeaderChecks {
+ __block NSUInteger right = 0, checks = 0;
+ void (^check)(NSString *, BOOL, NSString *) = ^(NSString *step, BOOL ok, NSString *detail) {
+ checks++;
+ if (ok) right++;
+ NSLog(@"[harness] header %@: %@ -- %@", step, detail, ok ? @"ok" : @"WRONG");
+ };
+ UIView *header = _units.firstObject.view;
+ NSMutableArray<UIView *> *buttons = [NSMutableArray array];
+ for (UIView *view in header.subviews) if ([view isKindOfClass:MockEncoreButton.class]) [buttons addObject:view];
+ check(@"buttons", buttons.count == 2, [NSString stringWithFormat:@"%lu Encore buttons in the header", (unsigned long)buttons.count]);
+ __block NSUInteger i = 0;
+ __block void (^next)(void);
+ next = ^{
+ if (i == buttons.count) {
+ NSLog(@"[harness] header checks: %lu of %lu right -- %@", (unsigned long)right, (unsigned long)checks, right == checks ? @"PASS" : @"FAIL");
+ next = nil;
+ return;
+ }
+ UIView *button = buttons[i++];
+ NSString *name = button.accessibilityIdentifier;
+ UIView *circle = button.subviews.firstObject;
+ check(name, [circle isKindOfClass:UIVisualEffectView.class] && circle.bounds.size.width == 44, [NSString stringWithFormat:@"a 44pt glass circle first in it (%@)", NSStringFromClass(circle.class)]);
+ CGPoint middle = [button convertPoint:CGPointMake(CGRectGetMidX(button.bounds), CGRectGetMidY(button.bounds)) toView:nil];
+ check(name, [self.window hitTest:middle withEvent:nil] == button, @"a touch at its middle lands on the button");
+ [(UIControl *)button addTarget:self action:@selector(headerDown:) forControlEvents:UIControlEventTouchDown];
+ SGHarnessHold(self.window, middle, 0.5);
+ after(0.4, ^{
+ CGFloat scale = circle.transform.a;
+ check(name, scale < 0.95, [NSString stringWithFormat:@"its circle pressed in while the finger is down (scale %.2f, touch down events %lu, tracking %d)", scale, (unsigned long)self->_headerDowns, ((UIControl *)button).tracking]);
+ });
+ after(1.2, ^{
+ CGFloat scale = [[circle.layer.presentationLayer valueForKeyPath:@"transform.scale.x"] doubleValue];
+ check(name, fabs(scale - 1) < 0.01 && CGAffineTransformIsIdentity(circle.transform), [NSString stringWithFormat:@"and whole again once it lifts (scale %.2f)", scale]);
+ next();
+ });
+ };
+ after(2, next);
+}
+
- (void)runLook {
UIImage *second = secondArtwork();
// Issue #54: the footer row moved down past the bottom stack's bounds must still take its touches,
diff --git a/harness/player/stubs.m b/harness/player/stubs.m
index 94f7d7e8..5358313d 100644
--- a/harness/player/stubs.m
+++ b/harness/player/stubs.m
@@ -227,3 +227,8 @@ BOOL SGMotionAppleMusicOn(void) { return YES; }
// TabBar.x: the Mini player section's Apple Music style switch lays the tab bar out again; there is none here.
void SGRSetTabBarMinimized(BOOL minimized, BOOL animated) {}
void SGRRefreshTabBar(void) {}
+
+// The ⋯'s system menu (PlayerMenu.m, ContextMenu.x), which this harness does not build; PlayerHeader.x hands it
+// the ⋯, and with no button of the mod's over it the ⋯'s own touches press its circle.
+void SGRPlayerMenuWatch(UIView *button) {}
+UIControl *SGRSystemMenuFront(UIView *button) { return nil; }
diff --git a/tweak/Sources/Redesigned/Player/PlayerHeader.x b/tweak/Sources/Redesigned/Player/PlayerHeader.x
index 9d8c6e5b..20af9492 100644
--- a/tweak/Sources/Redesigned/Player/PlayerHeader.x
+++ b/tweak/Sources/Redesigned/Player/PlayerHeader.x
@@ -15,32 +15,84 @@
//
// Tree (trees/clean/player/01.txt): HeaderElementsUnit's view is a 402x48 row holding
// id=now-playing-minimize-button 48x48 (:103) and id=Context menu 48x48 (:122), the playlist name
-// between them.
+// between them. The down arrow and the ⋯ are a pair, as the Music app's are: the same circle, size and glass.
+// 9.1.78 also carries mobile-nowplaying-close-button (strings in the binary), so the down arrow is looked for
+// under either name; which view each circle went into is logged once, so a phone where the arrow has none
+// says why.
+//
+// The circle presses in itself (scale, the Kit's press spring), from the control that takes the touches: the
+// arrow's own, and for the ⋯ the mod's button over it (ContextMenu.x). Spotify draws a button's pressed look
+// under its subviews, where the circle covers it (phone, 2026-10-06: the arrow closed the player but showed
+// no ripple), and the ⋯'s touches no longer reach Spotify's button at all.
#import "Core/SGCore.h"
#import "Redesigned/Kit/SGRKit.h"
+#import "Redesigned/ContextMenu/ContextMenu.h"
#import "Player.h"
-static char kGlassKey, kCloseKey, kMoreKey;
+static char kGlassKey, kCloseKey, kMoreKey, kPressKey;
+static const CGFloat kPressScale = 0.92;
+
+@interface SGRHeaderPress : NSObject
+@end
+@implementation SGRHeaderPress
+// The circle of the control pressed, or of the button under it (the ⋯'s front).
+static UIView *circleOf(UIControl *control) {
+ return objc_getAssociatedObject(control, &kGlassKey) ?: objc_getAssociatedObject(control.superview, &kGlassKey);
+}
+- (void)down:(UIControl *)control {
+ UIView *circle = circleOf(control);
+ SGRAnimate(SGRMotionPress, ^{ circle.transform = CGAffineTransformMakeScale(kPressScale, kPressScale); }, nil);
+}
+- (void)up:(UIControl *)control {
+ UIView *circle = circleOf(control);
+ SGRAnimate(SGRMotionPress, ^{ circle.transform = CGAffineTransformIdentity; }, nil);
+}
+@end
-static void glassInside(UIViewController *unit, NSArray<NSString *> *identifiers, const void **findKeys) {
+// `throughMenu`: the mod's ⋯, whose touch UIKit cancels as the menu comes up on it; the press holds until the
+// menu ends, which the button reports as a touch up outside (ContextMenu.x), so its cancel is not listened to.
+static void pressFrom(UIControl *control, BOOL throughMenu) {
+ if (![control isKindOfClass:UIControl.class] || objc_getAssociatedObject(control, &kPressKey)) return;
+ objc_setAssociatedObject(control, &kPressKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ static SGRHeaderPress *press;
+ if (!press) press = [SGRHeaderPress new];
+ [control addTarget:press action:@selector(down:) forControlEvents:UIControlEventTouchDown | UIControlEventTouchDragEnter];
+ UIControlEvents up = UIControlEventTouchUpInside | UIControlEventTouchUpOutside | UIControlEventTouchDragExit;
+ [control addTarget:press action:@selector(up:) forControlEvents:throughMenu ? up : up | UIControlEventTouchCancel];
+}
+
+// `identifiers` holds, for each button, the identifiers it may carry, the first found winning.
+static void glassInside(UIViewController *unit, NSArray<NSArray<NSString *> *> *identifiers, const void **findKeys) {
UIView *host = unit.viewIfLoaded;
if (!host) return;
NSUInteger found = 0;
for (NSUInteger i = 0; i < identifiers.count; i++) {
- UIView *button = SGRFindByIdentifier(host, identifiers[i], findKeys[i]);
+ UIView *button = nil;
+ for (NSString *identifier in identifiers[i]) {
+ if ((button = SGRFindByIdentifier(host, identifier, findKeys[i]))) break;
+ }
+ NSString *name = identifiers[i].firstObject;
+ static NSMutableSet<NSString *> *said;
+ if (!said) said = [NSMutableSet set];
if (!button) {
- static NSMutableSet<NSString *> *missing;
- if (!missing) missing = [NSMutableSet set];
- if (![missing containsObject:identifiers[i]]) {
- [missing addObject:identifiers[i]];
- SGLog(@"redesign player: %@ not found in %@, left as Spotify's", identifiers[i], NSStringFromClass(host.class));
+ if (![said containsObject:name]) {
+ [said addObject:name];
+ SGLog(@"redesign player: %@ not found in %@, left as Spotify's", [identifiers[i] componentsJoinedByString:@" or "], NSStringFromClass(host.class));
}
continue;
}
- SGRGlassInside(button, &kGlassKey, SGRGlassCircleSize);
- if ([identifiers[i] isEqualToString:@"Context menu"]) {
+ UIView *circle = SGRGlassInside(button, &kGlassKey, SGRGlassCircleSize);
+ if (![said containsObject:name] && button.bounds.size.width > 0) {
+ [said addObject:name];
+ SGLog(@"redesign player: a %.0fpt glass circle in %@ (id %@, %.0fx%.0f, %@)", circle.bounds.size.width, NSStringFromClass(button.class),
+ button.accessibilityIdentifier, button.bounds.size.width, button.bounds.size.height,
+ button.hidden || button.alpha < 0.01 ? @"hidden" : @"shown");
+ }
+ if ([name isEqualToString:@"Context menu"]) {
SGRPlayerMenuWatch(button);
}
+ UIControl *front = SGRSystemMenuFront(button);
+ pressFrom(front ?: (UIControl *)button, front != nil);
found++;
}
@@ -57,7 +109,7 @@ static void glassInside(UIViewController *unit, NSArray<NSString *> *identifiers
- (void)viewDidLayoutSubviews {
%orig;
static const void *keys[] = {&kCloseKey, &kMoreKey};
- glassInside((UIViewController *)self, @[@"now-playing-minimize-button", @"Context menu"], keys);
+ glassInside((UIViewController *)self, @[@[@"now-playing-minimize-button", @"mobile-nowplaying-close-button"], @[@"Context menu"]], keys);
}
%end