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: Hide controls automatically leaves only the lyrics

My-Name-Is-Jeffe145ea5e8ba1
diff --git a/docs/tweaks.md b/docs/tweaks.md
index f5381493..825ad030 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -510,7 +510,9 @@ Redesigned:
a paused song's hills have settled. The spectrum is checked on the Mac against harness/visualiser/,
the view in the simulator against harness/player/ (`visualiser`)
Lyrics/ the full screen lyrics page on glass with Apple Music style lyrics over it, always on (SGRKaraokeView,
- which the player shows in itself too, Player/PlayerLyrics.x): lines sung over each other lit together,
+ which the player shows in itself too, Player/PlayerLyrics.x, where with Hide the controls on
+ everything else -- the header row, the thumbnail, the title row and the controls -- fades a few
+ seconds after the last touch and the lines take the whole safe area until a tap): lines sung over each other lit together,
the stack moving on once the first is sung out; an instrumental break of 7 s or more held by three dots
that breathe and fill over its length on a Core Animation timeline laid against the song's clock; and
a line's pronunciation (under the words it spells) and translation, switched on from a glass button in
diff --git a/tweak/Sources/Redesigned/Player/PlayerLyrics.x b/tweak/Sources/Redesigned/Player/PlayerLyrics.x
index 953f1aa2..5f832610 100644
--- a/tweak/Sources/Redesigned/Player/PlayerLyrics.x
+++ b/tweak/Sources/Redesigned/Player/PlayerLyrics.x
@@ -59,7 +59,7 @@ static char kOverlayKey, kPlateKey, kTitleKey, kStackKey;
static BOOL sg_open;
static BOOL sg_moving; // the transition is in flight, so no layout pass may re-place it
static __weak UIView *sg_host; // SPTNowPlayingView
-static __weak UIViewController *sg_info, *sg_duration, *sg_floating;
+static __weak UIViewController *sg_info, *sg_duration, *sg_floating, *sg_header;
static __weak UIView *sg_titleElement; // the arranged element view holding the title and the artist
static __weak UIViewController *sg_player; // NowPlayingViewController, whose units the controls are
static BOOL sg_alone; // the lines have the player to themselves
@@ -118,11 +118,12 @@ static __weak UIGestureRecognizer *sg_wake; // on the player, on while alone: th
// What it hands them to instead is the title row. Translated to the top of the player it is drawn well
// outside the stack view it is arranged in, and UIKit stops looking at a view whose bounds the touch is
// not in, so the add button and the menu that rode up with it are past Spotify's own reach. Asked here
-// directly, the row answers for where it is drawn.
+// directly, the row answers for where it is drawn. Not while the lines are alone: the row is faded then,
+// and a tap where its add button was is the player's, which brings everything back.
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *hit = [super hitTest:point withEvent:event];
if (hit != self) return hit;
- UIView *row = SGRPlayerLyricsOpen() ? sg_info.viewIfLoaded : nil;
+ UIView *row = SGRPlayerLyricsOpen() && !sg_alone ? sg_info.viewIfLoaded : nil;
UIView *inRow = row ? [row hitTest:[row convertPoint:point fromView:self] withEvent:event] : nil;
return inRow == row ? nil : inRow;
}
@@ -309,33 +310,37 @@ static CGFloat thumbRadius(SGRLyricsLayout l, BOOL open) {
#pragma mark - the lines on their own
-// After kRest without a touch while the song plays, the controls under the lines fade and the lines grow
-// down into their room, the way the Music app leaves its lyrics alone. The header row, the thumbnail and
-// the title row stay, so the song playing is still named, and stay Spotify's and the thumbnail's to touch.
-// The lines scroll as they always do and leave the controls hidden; a tap brings them back and is not a
-// seek. A pause brings them back and keeps them; VoiceOver, a sheet over the player and the app in the
-// background keep them up. A scroll through the lines hides them at once. Sing's mic stays with the lines,
-// and a touch on it is the mic's: it does not bring the controls back.
+// After kRest without a touch while the song plays, everything but the lines fades -- the header row, the
+// thumbnail, the title row and the controls -- and the lines grow up and down into the whole safe area, the
+// way the Music app leaves its lyrics alone. The lines scroll as they always do and leave the rest hidden; a
+// tap anywhere brings it all back and is not a seek. A pause brings it back and keeps it; VoiceOver, a sheet
+// over the player and the app in the background keep it up. A scroll through the lines hides it at once.
+// Sing's mic stays with the lines, and a touch on it is the mic's: it does not bring the rest back.
//
-// The tap is a recognizer on the player that recognizes with any other, so the thumbnail's tap closes the
-// lyrics the same time it brings the controls back, and a button takes its own tap: UIKit gives a control
-// its tap over a tap recognizer above it. A drag or a second finger fails it. The lines' own tap, the one
-// that seeks, is off while they are alone, which holds whichever of the two would have finished first.
-
-// The controls under the lines: every view of Spotify's bottom stack but the title row and the chips (gone
-// while the lines are up), which is the progress bar, the buttons, the footer and a volume row where the
-// phone has one. Each fades by its alpha and the stack is left alone, since the title row is in it too.
-// Without the stack, the units of the first three. Only views on screen are taken, and only the ones
-// faded (sg_faded) come back, so nothing Spotify keeps hidden is shown.
+// The tap is a recognizer on the player that recognizes with any other, and a button takes its own tap:
+// UIKit gives a control its tap over a tap recognizer above it. A faded view takes no touch (UIKit's hit
+// test skips it), so a tap where the thumbnail or a button was only wakes. A drag or a second finger fails
+// it. The lines' own tap, the one that seeks, is off while they are alone, which holds whichever of the two
+// would have finished first.
+
+// What fades: every view of Spotify's bottom stack but the chips (gone while the lines are up), which is the
+// title row, the progress bar, the buttons, the footer and a volume row where the phone has one; the header
+// row's unit; and the thumbnail. Each fades by its alpha and the stack is left alone. Without the stack, the
+// units by name. Only views on screen are taken, and only the ones faded (sg_faded) come back, so nothing
+// Spotify keeps hidden is shown.
static NSHashTable<UIView *> *sg_faded;
-static NSArray<UIView *> *controlViews(void) {
- UIView *info = sg_info.viewIfLoaded, *floating = sg_floating.viewIfLoaded;
+static NSArray<UIView *> *fadingViews(void) {
+ UIView *floating = sg_floating.viewIfLoaded;
NSMutableArray<UIView *> *views = [NSMutableArray array];
+ SGRPlayerLyricsOverlay *overlay = objc_getAssociatedObject(sg_host, &kOverlayKey);
+ UIView *header = sg_header.viewIfLoaded, *thumb = overlay.thumb;
+ if (header && !header.hidden && header.alpha > 0.01) [views addObject:header];
+ if (thumb && !thumb.hidden && thumb.alpha > 0.01) [views addObject:thumb];
UIView *stack = SGRFindByIdentifier(sg_host, @"npv.bottomStackView", &kStackKey);
if (stack) {
for (UIView *view in stack.subviews) {
- if ([info isDescendantOfView:view] || [floating isDescendantOfView:view]) continue;
+ if ([floating isDescendantOfView:view]) continue;
if (!view.hidden && view.alpha > 0.01) [views addObject:view];
}
return views;
@@ -343,7 +348,7 @@ static NSArray<UIView *> *controlViews(void) {
static NSArray<NSString *> *names;
static dispatch_once_t once;
dispatch_once(&once, ^{
- names = @[@"DurationElementUnit", @"PlaybackControlsElementsUnit", @"FooterElementsUnit"];
+ names = @[@"InformationElementsUnit", @"DurationElementUnit", @"PlaybackControlsElementsUnit", @"FooterElementsUnit"];
});
// A unit's view answers to its controller as its next responder, wherever the unit sits in the tree.
SGForEachView(sg_host, ^(UIView *view) {
@@ -360,7 +365,7 @@ static NSArray<UIView *> *controlViews(void) {
static void fadeControls(BOOL faded) {
if (!sg_faded) sg_faded = [NSHashTable weakObjectsHashTable];
if (faded) {
- for (UIView *view in controlViews()) {
+ for (UIView *view in fadingViews()) {
view.alpha = 0;
[sg_faded addObject:view];
}
@@ -370,12 +375,12 @@ static void fadeControls(BOOL faded) {
}
}
-// Where the lines go on their own: from where they start under the title row down to the bottom of the
-// safe area, over the controls that faded.
+// Where the lines go on their own: the whole safe area, kLyricsBottom in at both ends, over everything that
+// faded. The safe area keeps them from under the status bar and the Dynamic Island.
static CGRect aloneStage(UIView *host, SGRLyricsLayout l) {
CGRect safe = UIEdgeInsetsInsetRect(host.bounds, host.safeAreaInsets);
- return CGRectMake(CGRectGetMinX(l.stage), CGRectGetMinY(l.stage), l.stage.size.width,
- CGRectGetMaxY(safe) - kLyricsBottom - CGRectGetMinY(l.stage));
+ CGFloat top = CGRectGetMinY(safe) + kLyricsBottom;
+ return CGRectMake(CGRectGetMinX(l.stage), top, l.stage.size.width, CGRectGetMaxY(safe) - kLyricsBottom - top);
}
// The lines' tap seeks, so it is off while they are alone. Back on a turn of the run loop later: the tap
@@ -742,6 +747,16 @@ static void replace(void) {
}
%end
+// The header row (the down arrow, Playing from, the ⋯; PlayerHeader.x has its tree), which fades with the
+// controls while the lines are alone.
+%hook _TtC20NowPlaying_ModesImpl18HeaderElementsUnit
+- (void)viewDidLayoutSubviews {
+ %orig;
+ sg_header = (UIViewController *)self;
+ replace();
+}
+%end
+
// The chips over the title (Switch to video and whatever else a track brings) sit in the middle of the
// room the lines take, so they go while the lines are up. The row keeps its height: the rest of the
// bottom stack stays where it was, which is the whole point of lifting only the title out of it.
@@ -854,5 +869,6 @@ static SGRPlayerLyricsWatcher *sg_watcher;
@"_TtC20NowPlaying_ModesImpl23InformationElementsUnit",
@"_TtC20NowPlaying_ModesImpl19DurationElementUnit",
@"_TtC20NowPlaying_ModesImpl20FloatingElementsUnit",
+ @"_TtC20NowPlaying_ModesImpl18HeaderElementsUnit",
]);
}