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 tab bar and now playing card minimize together and return at a tap
My-Name-Is-Jeff521fa9ed72db
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex 5ca39a49..8f8457d2 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -280,8 +280,12 @@ Redesigned:Navbar/ the glass tab bar (TabBar.x) over its own composition (Navbar.x, NavbarLayout.m) and editor, the glass search field.Spotify is made to leave the glass bar its height where its own bar is shorter (a phone with a home button,Offline or Private Session under the bar), so the now playing bar and the pages move up with it. Under both- bars the pages fade to half black (SGRBarFade, the stock bar's own subview). Laid out on the Mac against- harness/tabbar/+ bars the pages fade to half black (SGRBarFade, the stock bar's own subview). A page scrolled down+ minimizes the bar to two circles, the first or current tab and the last, with the now playing card+ between them, and a scroll back up, its top, another tab or the player brings it back+ (TabBarMinimize.x, MinimizeStep.h; the Navbar page's Minimize on scroll). Spotify's container is no+ UITabBarController, so UIKit's tabBarMinimizeBehavior and bottomAccessory cannot do it. Laid out on+ the Mac against harness/tabbar/ (`mini`), the scroll's steps checked by harness/tabbar/minimize-check.cNowPlayingBar/ the glass now playing bar (NowPlayingBar.x), with Spotify's device button on it hidden on request(BarConnect.x, its own key and its own Now playing page, apart from the native look's). In a Jam theglass stays on the track and Spotify's Jam strip gets a pane of its own above it (harness/tabbar/, jam)diff --git a/extension/LiveActivity/LiveActivityWidget.swift b/extension/LiveActivity/LiveActivityWidget.swiftindex 41161f0e..27572644 100644--- a/extension/LiveActivity/LiveActivityWidget.swift+++ b/extension/LiveActivity/LiveActivityWidget.swift@@ -107,7 +107,6 @@ private func lyricsActivity<A: ActivityAttributes, Card: View>(.foregroundStyle(.white).activityBackgroundTint(tint(context.state)).activitySystemActionForegroundColor(.white)- .widgetURL(URL(string: "spotify:"))} dynamicIsland: { context inDynamicIsland {// The row beside the camera: a note, and the sleep timer or whether it plays.@@ -151,7 +150,6 @@ private func lyricsActivity<A: ActivityAttributes, Card: View>(} minimal: {Badge(state: context.state)}- .widgetURL(URL(string: "spotify:"))}}diff --git a/harness/player/build.sh b/harness/player/build.shindex 90afe3f8..285b6736 100755--- a/harness/player/build.sh+++ b/harness/player/build.sh@@ -20,7 +20,7 @@ xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-ar"$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 \"$SRC"/Redesigned/Kit/SGRTokens.m "$SRC"/Redesigned/Kit/SGRPalette.m "$SRC"/Redesigned/Kit/SGRField.m "$SRC"/Redesigned/Kit/SGRFlow.m "$SRC"/Redesigned/Kit/SGRFluid.m "$SRC"/Shared/AnimatedArtwork/SGMotionCatalog.m "$SRC"/Shared/AnimatedArtwork/SGMotionStore.m \- "$SRC"/Redesigned/Kit/SGRGlass.m "$SRC"/Redesigned/Kit/SGRGlyph.m "$SRC"/Redesigned/Kit/SGRRestyle.m \+ "$SRC"/Redesigned/Kit/SGRGlass.m "$SRC"/Redesigned/Kit/SGRMarquee.m "$SRC"/Redesigned/Kit/SGRGlyph.m "$SRC"/Redesigned/Kit/SGRRestyle.m \"$SRC"/Redesigned/Kit/SGRedesign.m \"$SRC"/Redesigned/Lyrics/SGRKaraokeView.m "$SRC"/Redesigned/Lyrics/SGRSingButton.m "$SRC"/Redesigned/Lyrics/MeaningSheet.m "$SRC"/Redesigned/Lyrics/LyricsText.m "$SRC"/Shared/Lyrics/KaraokeTiming.m "$SRC"/Shared/AdBlock/Protobuf.m \-framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols -framework AVFoundation -framework CoreMedia \diff --git a/harness/tabbar/README.md b/harness/tabbar/README.mdindex 50789e55..1dbb9047 100644--- a/harness/tabbar/README.md+++ b/harness/tabbar/README.md@@ -43,6 +43,17 @@ and logs which bar selects what after each: `xcrun simctl launch <udid> com.vojtxcrun simctl spawn <udid> log show --last 1m --style compact --predicate 'eventMessage CONTAINS "[harness]" OR eventMessage CONTAINS "tab bar:"'+`mini` minimizes the bar at 1 s through `SGRSetTabBarMinimized`, logs at 2.5 s and expands it again at 3.5 s,+logging at 5 s. Minimized, the platters should be two 62 pt circles 21 pt in from each side, the card+between them 8 pt from each, centred on them, and a touch at the card's middle should land in the now+playing bar (through the hook on the page's `TouchPassthroughView`); expanded again, all as `none` has+it. Every report also gives the frame of the fade under the bars. The mock card's labels have fixed+frames, so how Spotify's own content takes the narrower card is not shown here.++`minimize-check.c` runs the scroll's steps (`MinimizeStep.h`) on the Mac:++ cc -I../../tweak/Sources/Redesigned/Navbar minimize-check.c -o build/minimize-check && build/minimize-check+`jam` plays a Jam: a strip under the class name of Spotify's (a SwiftUI hosting view of`Jam_AttachmentsImpl.JamHatElement`, 44 pt) over the card, both in a view painted the album colour too,the bar 44 pt taller, and the strip gone again at 3.5 s. The log then lists the bar's glass panes. Thediff --git a/harness/tabbar/build.sh b/harness/tabbar/build.shindex 811fb4db..7f70a610 100755--- a/harness/tabbar/build.sh+++ b/harness/tabbar/build.sh@@ -5,7 +5,7 @@ SRC=${SRC:-$(cd "$(dirname "$0")/../../tweak/Sources" && pwd)}OUT=$(dirname "$0")/buildrm -rf "$OUT"; mkdir -p "$OUT/gen" "$OUT/TabBarHarness.app"-for f in Redesigned/Navbar/TabBar.x Redesigned/NowPlayingBar/NowPlayingBar.x; do+for f in Redesigned/Navbar/TabBar.x Redesigned/Navbar/TabBarMinimize.x Redesigned/NowPlayingBar/NowPlayingBar.x; doname=$(basename "$f" .x)"$THEOS/bin/logos.pl" -c generator=internal "$SRC/$f" > "$OUT/gen/$name.m"donediff --git a/harness/tabbar/main.m b/harness/tabbar/main.mindex 571dc2f6..177ea48e 100644--- a/harness/tabbar/main.m+++ b/harness/tabbar/main.m@@ -373,6 +373,7 @@ static UIView *item(Class cls, NSString *title, NSString *symbol, BOOL active) {#pragma mark - what the harness measuresextern CGRect SGRNowPlayingCardFrameIn(UIView *host, CGFloat *radius);+extern void SGRSetTabBarMinimized(BOOL minimized, BOOL animated);static UIView *platterIn(UIView *root) {// UIKit._UITabBarItemPlatterView on iOS 27; BarTransition.x looks for the same suffix.@@ -458,6 +459,14 @@ static void report(SGHarnessChrome *chrome, NSString *moment) {}for (UIView *v in found) [platters appendFormat:@" %@ %@", NSStringFromClass(v.class), NSStringFromCGRect([v convertRect:v.bounds toView:window])];NSLog(@"%@", platters);+ // What a finger at the card's middle lands on, and the fade under the bars.+ if (!CGRectIsNull(card)) {+ UIView *hit = [window hitTest:CGPointMake(CGRectGetMidX(card), CGRectGetMidY(card)) withEvent:nil];+ NSLog(@"[harness] %@ touch at the card's middle lands on %@, in the now playing bar: %d", moment, NSStringFromClass(hit.class), [hit isDescendantOfView:chrome.npb]);+ }+ for (UIView *v in stock.subviews) {+ if ([NSStringFromClass(v.class) isEqualToString:@"SGRBarFade"]) NSLog(@"[harness] %@ fade %@", moment, NSStringFromCGRect([v convertRect:v.bounds toView:window]));+ }}#pragma mark - the app@@ -503,6 +512,12 @@ static void after(double seconds, dispatch_block_t block) {after(4.5, ^{ report(chrome, @"left the jam"); });}if ([mode isEqualToString:@"away"]) [chrome setBanner:YES animated:NO];+ // `mini`: the bar minimized at 1 s and logged at 2.5 s, expanded again at 3.5 s and logged at 5 s.+ if ([mode isEqualToString:@"mini"]) {+ after(1.0, ^{ SGRSetTabBarMinimized(YES, YES); });+ after(3.5, ^{ SGRSetTabBarMinimized(NO, YES); });+ after(5.0, ^{ report(chrome, @"expanded again"); });+ }// `pick`: Search picked at 2 s and Home at 4 s, which bar selects what logged after each.if ([mode isEqualToString:@"pick"]) {after(2.0, ^{ pick(chrome, @"Search"); });diff --git a/harness/tabbar/minimize-check.c b/harness/tabbar/minimize-check.cnew file mode 100644index 00000000..c5580615--- /dev/null+++ b/harness/tabbar/minimize-check.c@@ -0,0 +1,31 @@+// SGRMinimizeStep on the Mac: cc -I../../tweak/Sources/Redesigned/Navbar minimize-check.c -o build/minimize-check && build/minimize-check+#include <assert.h>+#include <stdio.h>+#include "MinimizeStep.h"++// A page from -100 (its top, under a 100 pt header inset) to 2000.+static bool step(SGRMinimizeTrack *t, CGFloat offset) { return SGRMinimizeStep(t, offset, -100, 2000); }++int main(void) {+ SGRMinimizeTrack t = {-100, false};+ assert(!step(&t, -90)); // a little way down: a finger resting+ assert(!step(&t, -77));+ assert(step(&t, -76)); // 24 down from the top: minimized+ assert(step(&t, 600)); // further down+ assert(step(&t, 590)); // a jitter back up is not a scroll up+ assert(!step(&t, 576)); // 24 back up from the lowest point, mid-list: expanded+ assert(!step(&t, 560)); // still going up+ assert(step(&t, 584)); // down again from where it turned+ assert(step(&t, 2000)); // the foot+ assert(step(&t, 2080)); // pulled past it+ assert(step(&t, 2000)); // springing back is not a scroll up+ assert(!step(&t, -100)); // the top always expands+ assert(!step(&t, -140)); // pulled past the top++ SGRMinimizeTrack s = {0, false}; // a page with almost nothing to scroll+ assert(!SGRMinimizeStep(&s, 80, 0, 100));+ s.minimized = true; // and one that cannot scroll leaves a minimized bar minimized+ assert(SGRMinimizeStep(&s, 0, 0, 100));+ puts("minimize-check: ok");+ return 0;+}diff --git a/harness/tabbar/stubs.m b/harness/tabbar/stubs.mindex c328a7fd..68144f1c 100644--- a/harness/tabbar/stubs.m+++ b/harness/tabbar/stubs.m@@ -22,3 +22,5 @@ BOOL SGRTabIsApart(UIView *item) {}void SGRLogTabBarRow(UIView *tabBar) {}void SGOpenModSettings(UIView *source) {}+// Shared/Player/PlayerEvents.x, which TabBarMinimize.x listens to.+NSString *const SGPlayerTransitionNotification = @"spotifyglass.playerTransition";diff --git a/tweak/Sources/Redesigned/Kit/SGRKit.h b/tweak/Sources/Redesigned/Kit/SGRKit.hindex 899b6bed..36c63ce6 100644--- a/tweak/Sources/Redesigned/Kit/SGRKit.h+++ b/tweak/Sources/Redesigned/Kit/SGRKit.h@@ -33,3 +33,4 @@#import "SGRBridges.h"#import "SGRRepaint.h"#import "SGRAccent.h"+#import "SGRMarquee.h"diff --git a/tweak/Sources/Redesigned/Kit/SGRMarquee.h b/tweak/Sources/Redesigned/Kit/SGRMarquee.hnew file mode 100644index 00000000..cf10b057--- /dev/null+++ b/tweak/Sources/Redesigned/Kit/SGRMarquee.h@@ -0,0 +1,12 @@+// A line of text that scrolls side to side when it does not fit, the way the Music app's titles do: it+// rests at its start, glides to show its end, rests, and glides back, its overflowing edge faded. Text+// that fits stands still. Under Reduce Motion it ends in "…" instead.+//+// Threading: main thread only.+#import <UIKit/UIKit.h>++@interface SGRMarqueeLabel : UIView+@property (nonatomic, copy) NSString *text;+@property (nonatomic, strong) UIFont *font;+@property (nonatomic, strong) UIColor *textColor;+@enddiff --git a/tweak/Sources/Redesigned/Kit/SGRMarquee.m b/tweak/Sources/Redesigned/Kit/SGRMarquee.mnew file mode 100644index 00000000..b1015f56--- /dev/null+++ b/tweak/Sources/Redesigned/Kit/SGRMarquee.m@@ -0,0 +1,103 @@+#import "SGRMarquee.h"++// Points a second the text moves at, the rest at each end, and the fade over the edge it runs past.+static const CGFloat kSpeed = 30, kFade = 16;+static const CFTimeInterval kRest = 2;+static NSString *const kScroll = @"sg.marquee";++@implementation SGRMarqueeLabel {+ UILabel *_label;+ CAGradientLayer *_fade;+ CGFloat _scrolled; // how far the running animation travels, 0 while still+}++- (instancetype)initWithFrame:(CGRect)frame {+ if (!(self = [super initWithFrame:frame])) return nil;+ self.clipsToBounds = YES;+ self.isAccessibilityElement = YES;+ self.accessibilityTraits = UIAccessibilityTraitStaticText;+ _label = [UILabel new];+ [self addSubview:_label];+ _fade = [CAGradientLayer layer];+ _fade.startPoint = CGPointMake(0, 0.5);+ _fade.endPoint = CGPointMake(1, 0.5);+ [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(setNeedsLayout)+ name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];+ return self;+}++- (void)dealloc {+ [NSNotificationCenter.defaultCenter removeObserver:self];+}++- (NSString *)text { return _label.text; }+- (UIFont *)font { return _label.font; }+- (UIColor *)textColor { return _label.textColor; }++- (void)setText:(NSString *)text {+ if ([text isEqualToString:_label.text]) return;+ _label.text = text;+ self.accessibilityLabel = text;+ _scrolled = -1; // starts over from its start+ [self setNeedsLayout];+}++- (void)setFont:(UIFont *)font {+ _label.font = font;+ _scrolled = -1;+ [self setNeedsLayout];+}++- (void)setTextColor:(UIColor *)textColor {+ _label.textColor = textColor;+}++- (void)didMoveToWindow {+ [super didMoveToWindow];+ // A view out of its window loses its animations; back in one, it scrolls again.+ _scrolled = -1;+ [self setNeedsLayout];+}++- (void)layoutSubviews {+ [super layoutSubviews];+ CGSize size = self.bounds.size;+ CGFloat textWidth = ceil([_label sizeThatFits:CGSizeMake(CGFLOAT_MAX, size.height)].width);+ CGFloat overflow = textWidth - size.width;+ BOOL scrolls = overflow > 0.5 && !UIAccessibilityIsReduceMotionEnabled() && self.window;+ _label.lineBreakMode = scrolls ? NSLineBreakByClipping : NSLineBreakByTruncatingTail;+ CGRect frame = CGRectMake(0, 0, scrolls ? textWidth : size.width, size.height);+ if (!CGRectEqualToRect(_label.frame, frame)) _label.frame = frame;++ self.layer.mask = scrolls ? _fade : nil;+ if (scrolls) {+ _fade.frame = self.bounds;+ CGFloat edge = MIN(kFade / size.width, 0.2);+ // The trailing edge fades, where the text runs on; its start stays crisp at rest.+ _fade.colors = @[(id)UIColor.blackColor.CGColor, (id)UIColor.blackColor.CGColor, (id)UIColor.clearColor.CGColor];+ _fade.locations = @[@0, @(1 - edge), @1];+ }++ CGFloat travel = scrolls ? overflow + kFade : 0;+ if (travel == _scrolled && [_label.layer animationForKey:kScroll]) return;+ _scrolled = travel;+ [_label.layer removeAnimationForKey:kScroll];+ if (!scrolls) return;+ CFTimeInterval glide = travel / kSpeed, total = 2 * (kRest + glide);+ CAKeyframeAnimation *scroll = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];+ scroll.values = @[@0, @0, @(-travel), @(-travel), @0];+ scroll.keyTimes = @[@0, @(kRest / total), @((kRest + glide) / total), @((2 * kRest + glide) / total), @1];+ scroll.timingFunctions = @[+ [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],+ [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],+ [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],+ [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],+ ];+ scroll.duration = total;+ scroll.repeatCount = HUGE_VALF;+ // A text's glide needs no more than the display's base rate.+ if (@available(iOS 15.0, *)) scroll.preferredFrameRateRange = CAFrameRateRangeMake(30, 60, 60);+ [_label.layer addAnimation:scroll forKey:kScroll];+}++@enddiff --git a/tweak/Sources/Redesigned/Navbar/MinimizeStep.h b/tweak/Sources/Redesigned/Navbar/MinimizeStep.hnew file mode 100644index 00000000..09ef8643--- /dev/null+++ b/tweak/Sources/Redesigned/Navbar/MinimizeStep.h@@ -0,0 +1,35 @@+// When a page's scroll minimizes the glass bar and when it brings it back (TabBarMinimize.x), apart from+// UIKit so harness/tabbar/minimize-check.c runs it on the Mac.+//+// A scroll down of kSGRMinimizeTravel from where the page last turned minimizes the bar, and a scroll back up+// of as much expands it again, anywhere in the list: the Music app's bar does the same. Less than that is a+// finger resting on the glass, not a scroll. Reaching the top always expands it. Pulling past either end is+// not counted, so the page springing back from its foot does not read as a scroll up, and a page with less+// than kSGRMinimizeRange to scroll leaves the bar as it is.+#include <CoreGraphics/CGBase.h>+#include <math.h>+#include <stdbool.h>++static const CGFloat kSGRMinimizeTravel = 24;+static const CGFloat kSGRMinimizeRange = 120;++typedef struct {+ CGFloat turn; // where the scroll last turned: its lowest offset while expanded, its highest while minimized+ bool minimized;+} SGRMinimizeTrack;++// One step of a scroll: `offset` the content offset, `top` and `bottom` the least and most it rests at.+static inline bool SGRMinimizeStep(SGRMinimizeTrack *track, CGFloat offset, CGFloat top, CGFloat bottom) {+ if (bottom - top < kSGRMinimizeRange) return track->minimized;+ offset = fmin(fmax(offset, top), bottom);+ if (offset <= top + 1) {+ track->minimized = false;+ track->turn = offset;+ } else if (track->minimized ? offset > track->turn : offset < track->turn) {+ track->turn = offset;+ } else if (fabs(offset - track->turn) >= kSGRMinimizeTravel) {+ track->minimized = !track->minimized;+ track->turn = offset;+ }+ return track->minimized;+}diff --git a/tweak/Sources/Redesigned/Navbar/Navbar.h b/tweak/Sources/Redesigned/Navbar/Navbar.hindex 9d50d439..b1dc648d 100644--- a/tweak/Sources/Redesigned/Navbar/Navbar.h+++ b/tweak/Sources/Redesigned/Navbar/Navbar.h@@ -35,5 +35,15 @@ void SGRRefreshTabBar(void);// Whether a tab of the composed row is one of the split tabs at its trailing end, for TabBar.x's second bar.BOOL SGRTabIsApart(UIView *item);+// The glass bar minimizes as a page scrolls down (TabBarMinimize.x): it shrinks to two of its tabs, the+// now playing card coming down between them. On unless switched off; read as each scroll goes.+#define SGRKeyNavbarMinimize @"spotifyglass.redesign.navbar.minimize"+BOOL SGRTabBarMinimized(void);+// TabBar.x lays both bars out for it, the now playing bar in the same animation; `animated` NO is a cut.+void SGRSetTabBarMinimized(BOOL minimized, BOOL animated);+// The room between the minimized bar's two tabs, `height` high and centred on them, in `host`'s+// coordinates: where the now playing card goes. CGRectNull while the bar is not minimized or not on screen.+CGRect SGRTabBarInlineSlot(UIView *host, CGFloat height);+UIViewController *SGRNavbarSettingsPage(void); // the tab editor, in Mod SettingsUIViewController *SGRNavbarEditorPage(void); // the tab editor alone, for the welcome tourdiff --git a/tweak/Sources/Redesigned/Navbar/NavbarSettings.m b/tweak/Sources/Redesigned/Navbar/NavbarSettings.mindex ad63e19e..d8b09973 100644--- a/tweak/Sources/Redesigned/Navbar/NavbarSettings.m+++ b/tweak/Sources/Redesigned/Navbar/NavbarSettings.m@@ -147,6 +147,10 @@ typedef NS_ENUM(NSInteger, SGRNavbarSection) {SGRNavbarSectionCount,};+static NSString *switchKey(NSInteger row) {+ return row == 2 ? SGRKeyNavbarMinimize : row == 1 ? SGRKeyNavbarHideLabels : SGRKeyNavbar;+}+// The tabs, in the order the bar shows them: drag to reorder, tap to show or hide, swipe a tab of// your own away. Spotify's own tabs can only be hidden, never removed. Mod Settings and the welcome// tour show the same editor.@@ -201,7 +205,7 @@ typedef NS_ENUM(NSInteger, SGRNavbarSection) {}- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {- if (section == SGRNavbarSectionSwitch) return 2;+ if (section == SGRNavbarSectionSwitch) return 3;return section == SGRNavbarSectionTabs ? (NSInteger)_entries.count : 1;}@@ -227,12 +231,13 @@ typedef NS_ENUM(NSInteger, SGRNavbarSection) {UITableViewCell *cell = SGDequeueCell(table, @"navbar");switch (path.section) {case SGRNavbarSectionSwitch: {- BOOL labels = path.row == 1;- SGFillCell(cell, labels ? @"Hide labels" : @"Custom navbar", labels ? @"Icons only" : nil, nil, nil);+ static NSString *const titles[] = {@"Custom navbar", @"Hide labels", @"Minimize on scroll"};+ static NSString *const subtitles[] = {nil, @"Icons only", @"Two tabs and the now playing bar in one row as a page scrolls down"};+ SGFillCell(cell, titles[path.row], subtitles[path.row], nil, nil);UISwitch *toggle = [UISwitch new];toggle.onTintColor = SGGreen();toggle.tag = path.row;- toggle.on = labels ? SGHidden(SGRKeyNavbarHideLabels) : SGEnabled(SGRKeyNavbar);+ toggle.on = path.row == 1 ? SGHidden(SGRKeyNavbarHideLabels) : SGEnabled(switchKey(path.row));[toggle addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventValueChanged];cell.accessoryView = toggle;break;@@ -315,7 +320,8 @@ typedef NS_ENUM(NSInteger, SGRNavbarSection) {}- (void)toggled:(UISwitch *)toggle {- SGSetEnabled(toggle.tag == 1 ? SGRKeyNavbarHideLabels : SGRKeyNavbar, toggle.on);+ SGSetEnabled(switchKey(toggle.tag), toggle.on);+ if (!toggle.on && toggle.tag == 2) SGRSetTabBarMinimized(NO, NO);SGRRefreshTabBar();}diff --git a/tweak/Sources/Redesigned/Navbar/TabBar.x b/tweak/Sources/Redesigned/Navbar/TabBar.xindex 6c692bf5..70d84668 100644--- a/tweak/Sources/Redesigned/Navbar/TabBar.x+++ b/tweak/Sources/Redesigned/Navbar/TabBar.x@@ -13,6 +13,7 @@#import "Core/SGCore.h"#import "Navbar.h"#import "Redesigned/Kit/SGRTokens.h"+#import "Redesigned/NowPlayingBar/NowPlayingBar.h"#import "Settings/SGPage.h"#import "Headers/SPTEncoreIconView.h"#import <objc/message.h>@@ -20,6 +21,8 @@static char kBarKey, kApartBarKey, kHostKey, kFadeKey;static __weak UIView *sg_stockBar;static CGFloat sg_room, sg_glassHeight; // see "room for the glass bar"+// See "minimized". sg_keepApart holds the second bar on screen while the main one grows back under it.+static BOOL sg_minimized, sg_keepApart;@interface SGRSystemTabBar : UITabBar <UITabBarDelegate, UIGestureRecognizerDelegate>@property (nonatomic, weak) UIView *stockBar;@@ -28,6 +31,8 @@ static CGFloat sg_room, sg_glassHeight; // see "room for the glass bar"@property (nonatomic) BOOL holding;// The other bar, when the split tabs have one of their own: a tab picked on one bar clears the other's.@property (nonatomic, weak) SGRSystemTabBar *partner;+// The item last shown selected, so a tap on it can be told from a tap that changes the tab.+@property (nonatomic, weak) UITabBarItem *shown;@endstatic void syncBar(UIView *stockBar);@@ -186,9 +191,20 @@ static void forwardTap(UIView *item) {- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {NSUInteger index = [self.items indexOfObject:item];if (index == NSNotFound || index >= self.sources.count) return;+ BOOL again = item == self.shown;+ self.shown = item;+ // On the minimized bar the leading circle brings the whole bar back, as the Music app's does; passed on,+ // the tap would take Spotify's stack back to its root. Minimizing builds the circle's item anew, so it+ // is told by the bar it is on, not by being the item shown before.+ BOOL leading = self.stockBar && objc_getAssociatedObject(self.stockBar, &kBarKey) == self;+ if (sg_minimized && (again || leading)) {+ SGRSetTabBarMinimized(NO, YES);+ return;+ }// Home tapped while on Home pops Spotify's stack, which would take Mod Settings straight off it.if (!self.holding) forwardTap(self.sources[index]);self.partner.selectedItem = nil;+ self.partner.shown = nil;// Spotify repaints its labels a moment later; a tap it did not take snaps the selection back.UIView *stockBar = self.stockBar;dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{@@ -426,6 +442,13 @@ static void selectActive(SGRSystemTabBar *bar, UIView *active) {NSUInteger index = active ? [bar.sources indexOfObject:active] : NSNotFound;UITabBarItem *item = index == NSNotFound ? nil : bar.items[index];if (active && bar.selectedItem != item) bar.selectedItem = item;+ if (active && item) bar.shown = item;+}++// The tab a bar shows selected, when Spotify paints none: a tab of the mod's own.+static UIView *selectedSource(SGRSystemTabBar *bar) {+ NSUInteger index = bar.selectedItem ? [bar.items indexOfObject:bar.selectedItem] : NSNotFound;+ return index < bar.sources.count ? bar.sources[index] : nil;}// Split tabs stand on a glass bar of their own at the trailing end, the way the Music app sets Search@@ -460,6 +483,10 @@ static void syncBar(UIView *stockBar) {if (!sources.count) return;// An item with no title is drawn by UIKit as its glyph alone, centred, on a bar of the same height.BOOL hideLabels = SGHidden(SGRKeyNavbarHideLabels);+ SGRSystemTabBar *apartBar = objc_getAssociatedObject(stockBar, &kApartBarKey);+ UIView *active = nil;+ for (UIView *source in sources) if (!active && isActive(source)) active = source;+ active = active ?: selectedSource(bar) ?: selectedSource(apartBar);NSMutableArray<UIView *> *main = [NSMutableArray array], *apart = [NSMutableArray array];for (UIView *source in sources) [(SGRTabIsApart(source) ? apart : main) addObject:source];@@ -467,7 +494,16 @@ static void syncBar(UIView *stockBar) {main = [sources mutableCopy];[apart removeAllObjects];}- SGRSystemTabBar *apartBar = objc_getAssociatedObject(stockBar, &kApartBarKey);+ // Minimized, the bar keeps the tab it is on, glyph only, on a circle at the leading end, and the last+ // split tab on one at the trailing end when there are any, the way the Music app keeps Search. Without+ // split tabs the now playing card has the rest of the row.+ BOOL minimized = sg_minimized && sources.count >= 2;+ if (minimized) {+ UIView *last = apart.lastObject;+ main = [NSMutableArray arrayWithObject:active && active != last ? active : main.firstObject];+ apart = last ? [NSMutableArray arrayWithObject:last] : [NSMutableArray array];+ hideLabels = YES;+ }if (apart.count && !apartBar) {apartBar = makeBar(stockBar);objc_setAssociatedObject(stockBar, &kApartBarKey, apartBar, OBJC_ASSOCIATION_RETAIN_NONATOMIC);@@ -475,13 +511,11 @@ static void syncBar(UIView *stockBar) {bar.partner = apartBar;[host addSubview:apartBar];}- apartBar.hidden = !apart.count;- if (!apart.count) apartBar.sources = nil;+ apartBar.hidden = !apart.count && !sg_keepApart;+ if (apartBar.hidden) apartBar.sources = nil;BOOL missing = fillBar(bar, main, hideLabels);if (apart.count) missing |= fillBar(apartBar, apart, hideLabels);- UIView *active = nil;- for (UIView *source in sources) if (!active && isActive(source)) active = source;selectActive(bar, active);if (apart.count) selectActive(apartBar, active);// An icon view Spotify has not built yet is looked for again shortly, not on the next touch.@@ -499,7 +533,11 @@ static void syncBar(UIView *stockBar) {if (!CGRectEqualToRect(host.frame, frame)) host.frame = frame;placeFade(stockBar, frame);CGRect mainFrame = host.bounds, apartFrame = CGRectZero;- if (apart.count) {+ if (minimized) {+ CGFloat side = kApartItemWidth + 2 * kPlatterInset;+ mainFrame.size.width = side;+ if (apart.count) apartFrame = CGRectMake(width - side, 0, side, height);+ } else if (apart.count) {CGFloat apartWidth = MIN(width / 2, apart.count * kApartItemWidth + 2 * kPlatterInset);CGRectDivide(host.bounds, &apartFrame, &mainFrame, apartWidth, CGRectMaxXEdge);mainFrame.size.width += 2 * kPlatterInset - kPlatterGap;@@ -512,6 +550,87 @@ static void syncBar(UIView *stockBar) {makeRoom(containerOf(stockBar));}+#pragma mark - minimized++// A page scrolled down minimizes the bar (TabBarMinimize.x), the way the Music app's does. Spotify's tab bar+// container is a UIViewController of its own, not a UITabBarController (the binary's ObjC metadata), so+// UIKit's tabBarMinimizeBehavior and bottomAccessory have nothing to act on. The minimized bar is built+// from the two bars this file already has: the main bar narrowed to one circle at the leading end, the+// second bar to one at the trailing end, and the now playing card between them (NowPlayingBar.x). The+// items are swapped at once and the bars' frames then move from where they were, so UIKit's platters+// shrink and grow in the spring; nothing fades a bar's glass.+BOOL SGRTabBarMinimized(void) {+ return sg_minimized;+}++void SGRSetTabBarMinimized(BOOL minimized, BOOL animated) {+ UIView *stockBar = sg_stockBar;+ if (minimized == sg_minimized) return;+ // Spotify's regular width bar is not the glass one's row of tabs; it stays as it is.+ if (minimized && (!stockBar.window || stockBar.traitCollection.horizontalSizeClass != UIUserInterfaceSizeClassCompact)) return;+ sg_minimized = minimized;+ sg_keepApart = !minimized;+ SGLog(@"tab bar: %@", minimized ? @"minimized" : @"expanded");+ if (!stockBar) return;+ UIView *host = objc_getAssociatedObject(stockBar, &kHostKey);+ UIView *bar = objc_getAssociatedObject(stockBar, &kBarKey);+ UIView *apartBar = objc_getAssociatedObject(stockBar, &kApartBarKey);+ BOOL apartShown = apartBar && !apartBar.hidden;+ CGRect fromMain = bar.frame, fromApart = apartBar.frame;+ [UIView performWithoutAnimation:^{ syncBar(stockBar); }];+ apartBar = objc_getAssociatedObject(stockBar, &kApartBarKey);+ CGRect toMain = bar.frame, toApart = apartBar.frame;+ void (^settle)(BOOL) = ^(BOOL finished) {+ if (sg_minimized != minimized) return;+ sg_keepApart = NO;+ // The items made for the full bar were laid out while it was a circle, and UIKit kept their titles cut+ // short to that width once it had grown (harness/tabbar, `mini`): they are made again at full width.+ if (!minimized) ((SGRSystemTabBar *)bar).sources = nil;+ syncBar(stockBar);+ };+ if (!animated || !host.window) {+ [UIView performWithoutAnimation:^{ SGRNowPlayingBarFollowTabBar(); }];+ settle(YES);+ return;+ }+ [UIView performWithoutAnimation:^{+ bar.frame = fromMain;+ if (apartShown) apartBar.frame = fromApart;+ [host layoutIfNeeded];+ }];+ SGRAnimate(SGRMotionLayout, ^{+ bar.frame = toMain;+ apartBar.frame = toApart;+ [host layoutIfNeeded];+ SGRNowPlayingBarFollowTabBar();+ }, settle);+}++CGRect SGRTabBarInlineSlot(UIView *host, CGFloat height) {+ UIView *stockBar = sg_stockBar;+ UIView *bar = stockBar ? objc_getAssociatedObject(stockBar, &kBarKey) : nil;+ UIView *apartBar = stockBar ? objc_getAssociatedObject(stockBar, &kApartBarKey) : nil;+ if (!sg_minimized || !host || !bar.window || stockBar.hidden || stockBar.alpha < 0.01) return CGRectNull;+ // The frames the bars are going to, not what is on screen mid-spring. Without a split tab's circle the+ // card runs to where the trailing circle's glass would end.+ CGRect lead = [bar.superview convertRect:bar.frame toView:host];+ CGFloat left = CGRectGetMinX(lead) + kPlatterInset + kApartItemWidth + SGRGrid;+ CGFloat right;+ if (apartBar && !apartBar.hidden) {+ CGRect trail = [apartBar.superview convertRect:apartBar.frame toView:host];+ right = CGRectGetMaxX(trail) - kPlatterInset - kApartItemWidth - SGRGrid;+ } else {+ CGRect whole = [stockBar convertRect:stockBar.bounds toView:host];+ right = CGRectGetMaxX(whole) - kPlatterInset;+ }+ CGFloat middle = CGRectGetMinY(lead) + kApartItemWidth / 2;+ CGRect slot = CGRectMake(left, middle - height / 2, right - left, height);+ // A bar Spotify has slid away for a page takes the slot off the screen with it.+ CGRect inWindow = [host convertRect:slot toView:nil];+ if (slot.size.width < 100 || CGRectGetMaxY(inWindow) > CGRectGetMaxY(bar.window.bounds)) return CGRectNull;+ return slot;+}+#pragma mark - hooksstatic UIView *tabBarOf(UIView *item) {@@ -562,6 +681,8 @@ static void itemDidLayOut(UIView *item) {- (void)setSelectedViewController:(UIViewController *)controller {%orig;dispatch_async(dispatch_get_main_queue(), ^{+ // Another tab brings the minimized bar back (HIG, Tab bars).+ SGRSetTabBarMinimized(NO, YES);UIView *bar = sg_stockBar;if (bar) syncBar(bar);});diff --git a/tweak/Sources/Redesigned/Navbar/TabBarMinimize.x b/tweak/Sources/Redesigned/Navbar/TabBarMinimize.xnew file mode 100644index 00000000..7b572bd7--- /dev/null+++ b/tweak/Sources/Redesigned/Navbar/TabBarMinimize.x@@ -0,0 +1,56 @@+// What minimizes the glass bar and what brings it back (TabBar.x draws it): a page scrolled down by a+// finger or the fling after it, and scrolled back up or to its top (MinimizeStep.h); another tab (TabBar.x);+// and the full screen player opening or closing, which takes Spotify's pictures of the bars to move with it+// and would have moved the card from the tab bar's row back up to its place above the bar.+//+// Only a page's own scroll views count: those inside Spotify's tab bar container. The player and the now+// playing bar are outside it, and a shelf scrolling sideways has nothing to scroll down.+#import "Core/SGCore.h"+#import "Navbar.h"+#import "MinimizeStep.h"+#import "Shared/Player/PlayerEvents.h"++static Class sg_containerClass;+static __weak UIScrollView *sg_page, *sg_other;+static SGRMinimizeTrack sg_track;++static BOOL inContainer(UIView *view) {+ for (UIResponder *r = view.nextResponder; r; r = r.nextResponder) if ([r isKindOfClass:sg_containerClass]) return YES;+ return NO;+}++static void scrolled(UIScrollView *scrollView) {+ if ((!scrollView.isTracking && !scrollView.isDecelerating) || scrollView == sg_other) return;+ CGFloat offset = scrollView.contentOffset.y;+ if (scrollView != sg_page) {+ if (!inContainer(scrollView)) {+ sg_other = scrollView;+ return;+ }+ sg_page = scrollView;+ sg_track = (SGRMinimizeTrack){offset, SGRTabBarMinimized()};+ }+ // The bar changed some other way (a tab, the player): the scroll counts from here.+ if (sg_track.minimized != SGRTabBarMinimized()) sg_track = (SGRMinimizeTrack){offset, SGRTabBarMinimized()};+ UIEdgeInsets inset = scrollView.adjustedContentInset;+ CGFloat top = -inset.top, bottom = scrollView.contentSize.height + inset.bottom - scrollView.bounds.size.height;+ BOOL minimized = SGRMinimizeStep(&sg_track, offset, top, bottom);+ if (minimized == SGRTabBarMinimized() || (minimized && !SGEnabled(SGRKeyNavbarMinimize))) return;+ SGRSetTabBarMinimized(minimized, YES);+}++%hook UIScrollView+- (void)setContentOffset:(CGPoint)offset {+ %orig;+ scrolled(self);+}+%end++%ctor {+ if (!SGRedesignedUI()) return;+ sg_containerClass = NSClassFromString(@"_TtC23NavigationUI_TabBarImpl19TabBarContainerImpl");+ if (!sg_containerClass) return;+ %init;+ [NSNotificationCenter.defaultCenter addObserverForName:SGPlayerTransitionNotification object:nil queue:nil+ usingBlock:^(NSNotification *note) { SGRSetTabBarMinimized(NO, NO); }];+}diff --git a/tweak/Sources/Redesigned/NowPlayingBar/NowPlayingBar.h b/tweak/Sources/Redesigned/NowPlayingBar/NowPlayingBar.hindex 7f3d0180..43e2b39f 100644--- a/tweak/Sources/Redesigned/NowPlayingBar/NowPlayingBar.h+++ b/tweak/Sources/Redesigned/NowPlayingBar/NowPlayingBar.h@@ -15,3 +15,6 @@ UIViewController *SGRNowPlayingBarSettingsPage(void);CGRect SGRNowPlayingCardFrameIn(UIView *host, CGFloat *radius);// The round artwork on that card in `host`'s coordinates; CGRectNull when none was found.CGRect SGRNowPlayingArtworkFrameIn(UIView *host);+// Lays the bar out again at once, into the minimized tab bar's slot or back above the bar+// (Navbar.h's SGRTabBarInlineSlot); TabBar.x calls it inside its own animation.+void SGRNowPlayingBarFollowTabBar(void);diff --git a/tweak/Sources/Redesigned/NowPlayingBar/NowPlayingBar.x b/tweak/Sources/Redesigned/NowPlayingBar/NowPlayingBar.xindex 86a8dddf..8dc97d0b 100644--- a/tweak/Sources/Redesigned/NowPlayingBar/NowPlayingBar.x+++ b/tweak/Sources/Redesigned/NowPlayingBar/NowPlayingBar.x@@ -22,6 +22,7 @@#import "Redesigned/Kit/SGRGlass.h"#import "Redesigned/Kit/SGRTokens.h"#import "NowPlayingBar.h"+#import "Redesigned/Navbar/Navbar.h"static const CGFloat kCardRadius = 24;// The strip's pane is this much smaller than the strip at each end, so a gap parts it from the card's glass.@@ -31,6 +32,10 @@ static __weak UIView *sg_card;static CGRect sg_stripFrame;static __weak UIVisualEffectView *sg_cardGlass;static __weak UIView *sg_cardArtwork;+static __weak UIView *sg_progress;+static __weak UIViewController *sg_container;+// The container's view while it stands in the minimized tab bar's row, below the page that holds it.+static __weak UIView *sg_inline;CGRect SGRNowPlayingCardFrameIn(UIView *host, CGFloat *radius) {UIVisualEffectView *glass = sg_cardGlass;@@ -137,15 +142,22 @@ static void restyleCardContent(UIView *card) {}sg_cardArtwork = outer;});- SGForEachView(card, ^(UIView *v) {- CGRect f = v.frame;- if (inStrip(v, card) || f.size.height > 3 || f.size.width < 200 || v.superview.bounds.size.height < 40) return;- CGRect target = CGRectMake(52, card.bounds.size.height - 6, 226, 2);- if (CGRectEqualToRect(f, target)) return;- v.frame = target;- [v setNeedsLayout];- [v layoutIfNeeded];- });+ __block UIView *progress = sg_progress;+ if (![progress isDescendantOfView:card]) {+ progress = nil;+ SGForEachView(card, ^(UIView *v) {+ CGRect f = v.frame;+ if (!progress && !inStrip(v, card) && f.size.height <= 3 && f.size.width >= 200 && v.superview.bounds.size.height >= 40) progress = v;+ });+ sg_progress = progress;+ }+ // Under the text, 226pt on a full width card, shorter on the one in the minimized tab bar.+ CGRect target = CGRectMake(52, card.bounds.size.height - 6, MAX(0, card.bounds.size.width - 160), 2);+ if (progress && !CGRectEqualToRect(progress.frame, target)) {+ progress.frame = target;+ [progress setNeedsLayout];+ [progress layoutIfNeeded];+ }}// The strip's own pane, a strip high less the gaps, on the card's side the strip is on. It is measured from@@ -171,9 +183,117 @@ static void placeStripGlass(UIView *host, UIView *strip, CGRect card, BOOL aboveif (!pane.effect) SGRAnimate(SGRMotionRespond, ^{ SGRShowGlass(pane, YES); }, nil);}+// The bar's left and right edges in its superview, set through the constants of the constraints that hold+// them there (their constants as Spotify set them kept to go back to), or through its frame when it is laid+// out by frame. A frame alone does not move a view laid out by constraints, nor what is constrained inside+// it (harness/tabbar). NO, with nothing changed, when its edges are held some other way, or right to left.+static NSMapTable<NSLayoutConstraint *, NSNumber *> *sg_constants;+static CGRect sg_fullFrame, sg_narrowFrame;++static void restoreEdges(UIView *bar) {+ for (NSLayoutConstraint *constraint in sg_constants) constraint.constant = [[sg_constants objectForKey:constraint] doubleValue];+ [sg_constants removeAllObjects];+ if (bar.translatesAutoresizingMaskIntoConstraints && CGRectEqualToRect(bar.frame, sg_narrowFrame)) bar.frame = sg_fullFrame;+ sg_narrowFrame = CGRectNull;+}++static BOOL setEdges(UIView *bar, CGFloat left, CGFloat right) {+ UIView *superview = bar.superview;+ if (bar.translatesAutoresizingMaskIntoConstraints) {+ CGRect frame = CGRectMake(left, bar.frame.origin.y, right - left, bar.frame.size.height);+ if (!CGRectEqualToRect(bar.frame, sg_narrowFrame)) sg_fullFrame = bar.frame;+ sg_narrowFrame = frame;+ if (!CGRectEqualToRect(bar.frame, frame)) bar.frame = frame;+ return YES;+ }+ if (superview.effectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) return NO;+ if (!sg_constants) sg_constants = [NSMapTable weakToStrongObjectsMapTable];+ NSUInteger held = 0;+ for (NSLayoutConstraint *constraint in superview.constraints) {+ NSLayoutAttribute attribute = constraint.firstAttribute;+ BOOL barFirst = constraint.firstItem == bar && constraint.secondItem == superview;+ if (!constraint.active || constraint.relation != NSLayoutRelationEqual || constraint.multiplier != 1 || attribute != constraint.secondAttribute+ || (!barFirst && !(constraint.secondItem == bar && constraint.firstItem == superview))) continue;+ BOOL isLeft = attribute == NSLayoutAttributeLeading || attribute == NSLayoutAttributeLeft;+ if (!isLeft && attribute != NSLayoutAttributeTrailing && attribute != NSLayoutAttributeRight) continue;+ if (![sg_constants objectForKey:constraint]) [sg_constants setObject:@(constraint.constant) forKey:constraint];+ CGFloat edge = isLeft ? 0 : superview.bounds.size.width, value = isLeft ? left : right;+ CGFloat constant = barFirst ? value - edge : edge - value;+ if (constraint.constant != constant) constraint.constant = constant;+ held |= isLeft ? 1 : 2;+ }+ if (held == 3) return YES;+ restoreEdges(bar);+ static dispatch_once_t once;+ dispatch_once(&once, ^{ SGLog(@"now playing bar: its edges are not held by its superview's constraints, so it stays above the tab bar"); });+ return NO;+}++// In the row the card keeps the cover, the title and play, as the Music app's does: the device and add+// buttons stand aside while it is there and come back with the full card. Only what this hid is shown again.+static NSHashTable<UIView *> *sg_tucked;++static void tuckExtras(UIView *bar, BOOL tuck) {+ if (!sg_tucked) sg_tucked = [NSHashTable weakObjectsHashTable];+ if (!tuck) {+ for (UIView *item in sg_tucked) item.hidden = NO;+ [sg_tucked removeAllObjects];+ return;+ }+ SGForEachView(bar, ^(UIView *v) {+ NSString *name = v.accessibilityIdentifier;+ if (![name isEqualToString:@"Components.ConnectButtonOutputSwitcher"] && ![name isEqualToString:@"Components.UI.AddToButton"]) return;+ // The stack's own item, so the stack closes the gap.+ UIView *item = v;+ while (item.superview && item.superview != bar && ![item.superview isKindOfClass:UIStackView.class]) item = item.superview;+ if (![item.superview isKindOfClass:UIStackView.class] || item.hidden) return;+ item.hidden = YES;+ [sg_tucked addObject:item];+ });+}++// In the minimized tab bar's row (TabBar.x): the bar narrowed to the slot by its edges, so Spotify's content+// lays itself out to the width, and moved down by a transform on the container's view, which Spotify's+// layout leaves alone. Outside a Jam only: its strip has no room in the row.+static void placeInline(UIViewController *container) {+ UIView *view = container.view;+ UIView *bar = container.childViewControllers.firstObject.viewIfLoaded;+ UIView *strip = bar ? stripIn(bar) : nil;+ BOOL jam = strip && !strip.hidden && strip.alpha >= 0.01 && strip.window && strip.bounds.size.height >= 1;+ CGRect slot = !bar || bar.superview != view || jam ? CGRectNull : SGRTabBarInlineSlot(view.superview, bar.bounds.size.height);+ // Where the view stands untransformed, in the slot's coordinates.+ CGPoint origin = CGPointMake(view.center.x - view.bounds.size.width / 2, view.center.y - view.bounds.size.height / 2);+ if (CGRectIsNull(slot) || !setEdges(bar, CGRectGetMinX(slot) - origin.x, CGRectGetMaxX(slot) - origin.x)) {+ if (sg_inline) restoreEdges(bar);+ if (sg_inline) tuckExtras(bar, NO);+ sg_inline = nil;+ if (!CGAffineTransformIsIdentity(view.transform)) view.transform = CGAffineTransformIdentity;+ return;+ }+ CGAffineTransform move = CGAffineTransformMakeTranslation(0, CGRectGetMidY(slot) - origin.y - CGRectGetMidY(bar.frame));+ if (!CGAffineTransformEqualToTransform(view.transform, move)) view.transform = move;+ tuckExtras(bar, YES);+ sg_inline = view;+ static dispatch_once_t once;+ dispatch_once(&once, ^{+ NSMutableString *clips = [NSMutableString string];+ for (UIView *v = view.superview; v; v = v.superview) if (v.clipsToBounds) [clips appendFormat:@" %@", v.class];+ SGLog(@"now playing bar in the tab bar's row at %@, clipped by:%@", NSStringFromCGRect(slot), clips.length ? clips : @" nothing");+ });+}++void SGRNowPlayingBarFollowTabBar(void) {+ UIViewController *container = sg_container;+ if (!container.isViewLoaded) return;+ placeInline(container);+ [container.view setNeedsLayout];+ [container.view layoutIfNeeded];+}+static void styleNowPlayingBar(UIViewController *container) {UIViewController *barVC = container.childViewControllers.firstObject;UIView *bar = barVC.viewIfLoaded ?: container.view;+ sg_container = container;if (!sgr_nowPlayingPainted) sgr_nowPlayingPainted = [NSHashTable weakObjectsHashTable];sgr_nowPlayingRoot = bar;@@ -201,6 +321,7 @@ static void styleNowPlayingBar(UIViewController *container) {dispatch_async(dispatch_get_main_queue(), ^{ [host setNeedsLayout]; });}if (strip.bounds.size.height < 1) strip = nil;+ placeInline(container);CGRect frame = card ? SGFrameIn(card, container.view) : contentBounds(bar, container.view);if (CGRectIsNull(frame)) return;@@ -250,6 +371,18 @@ static void styleNowPlayingBar(UIViewController *container) {}%end+// The page the bar stands in passes touches outside the bar through, and the bar in the tab bar's row is+// below the page's bounds: a touch there reaches the bar only through this.+%hook _TtC22NowPlaying_BarPageImplP33_CCC0D2EEA6D4725EECD8965E8C38C86D20TouchPassthroughView+- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {+ UIView *hit = %orig;+ UIView *moved = sg_inline;+ if ((hit && hit != (UIView *)self) || ![moved isDescendantOfView:(UIView *)self]) return hit;+ CGPoint inMoved = [(UIView *)self convertPoint:point toView:moved];+ return [moved pointInside:inMoved withEvent:event] ? ([moved hitTest:inMoved withEvent:event] ?: hit) : hit;+}+%end+%hook _TtC18NowPlaying_BarImpl27NowPlayingBarViewController- (void)viewDidLayoutSubviews {%orig;@@ -264,5 +397,6 @@ static void styleNowPlayingBar(UIViewController *container) {SGRequireClasses(@[@"_TtC18NowPlaying_BarImpl36NowPlayingBarContainerViewController",@"_TtC18NowPlaying_BarImpl27NowPlayingBarViewController",+ @"_TtC22NowPlaying_BarPageImplP33_CCC0D2EEA6D4725EECD8965E8C38C86D20TouchPassthroughView",]);}diff --git a/tweak/Sources/Redesigned/Player/PlayerLandscape.x b/tweak/Sources/Redesigned/Player/PlayerLandscape.xindex 34aa7d26..fbe98f40 100644--- a/tweak/Sources/Redesigned/Player/PlayerLandscape.x+++ b/tweak/Sources/Redesigned/Player/PlayerLandscape.x@@ -32,7 +32,7 @@ static BOOL sg_shut;@implementation SGRLandscapeLyricsController {SGRArtworkField *_field;UIImageView *_cover;- UILabel *_title, *_artist;+ SGRMarqueeLabel *_title, *_artist;UIStackView *_controls;UIButton *_play, *_close;UIView *_stage; // the lines' own view: the karaoke view dims every sibling it has@@ -102,9 +102,10 @@ static UIButton *controlButton(NSString *symbol, CGFloat size, NSString *label,_cover.image = art;[self.view addSubview:_cover];- _title = [UILabel new];+ // A title or artist too long for the column scrolls, as the player's own do.+ _title = [SGRMarqueeLabel new];_title.textColor = UIColor.whiteColor;- _artist = [UILabel new];+ _artist = [SGRMarqueeLabel new];_artist.textColor = [UIColor colorWithWhite:1 alpha:0.6];[self applyFonts];[self.view addSubview:_title];