Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
fix: the redesigned player's cover fills the room the lyric preview left
My-Name-Is-Jeff9b4d1225293e
diff --git a/tweak/Sources/Redesigned/Player/Player.h b/tweak/Sources/Redesigned/Player/Player.hindex 98b189db..4bdf9f7f 100644--- a/tweak/Sources/Redesigned/Player/Player.h+++ b/tweak/Sources/Redesigned/Player/Player.h@@ -6,7 +6,8 @@// come to the player itself, the way the Music app shows them, when the lyrics glyph is tapped.//// PlayerField.x the switch's flags and rows, the field in the background plane, the cover it reads-// PlayerArtwork.x the cover's corners, shadow and paused shrink, the lyric preview under it hidden+// PlayerArtwork.x the cover's corners, shadow and paused shrink, the lyric preview under it gone and+// its room the cover's// PlayerHeader.x glass behind the close and more buttons// PlayerControls.x previous, play and next as bare glyphs, monospaced times// PlayerFooter.x share gone, lyrics, Connect and queue as one row of three glyphsdiff --git a/tweak/Sources/Redesigned/Player/PlayerArtwork.x b/tweak/Sources/Redesigned/Player/PlayerArtwork.xindex 4f5ee04e..554f1163 100644--- a/tweak/Sources/Redesigned/Player/PlayerArtwork.x+++ b/tweak/Sources/Redesigned/Player/PlayerArtwork.x@@ -1,5 +1,6 @@// Player redesign: the cover sits on the field with continuous corners and a soft shadow, and shrinks-// back while playback is paused, the way the Music app's does; the lyric preview under it is gone.+// back while playback is paused, the way the Music app's does; the lyric preview under it is gone, and the+// cover takes the room it left.//// Tree (trees/clean/player/01.txt:36-43): CoverArtCellImpl > ... > CoverArtTiltView 354x354 > an// ElementView the same size > ImageViewProxy > Encore.ImageView (clips) > UIImageView, with@@ -234,11 +235,50 @@ static void watchHold(UIView *tilt) {objc_setAssociatedObject(tilt, &kHoldKey, hold, OBJC_ASSOCIATION_ASSIGN);}-%hook _TtC35CreativeWorkCommons_CoverArtTiltKit16CoverArtTiltView+#pragma mark - the cover's room++// Spotify's cell keeps room under the cover for the lyric preview even with the preview gone, so a track+// with lyrics had a smaller cover with a blank band under it (issue #77). The preview takes no room+// (below), and the tilt view takes the largest square of the plain view it sits in (01.txt:35), centred.+// Bounds and a centre, not a frame, since the tilt view carries Spotify's tilt while the cover is inspected.+// A square under kCoverMinWidth is left as it is, so no small cover grows.+static void fillRoom(UIView *tilt) {+ CGRect room = tilt.superview.bounds;+ CGFloat side = MIN(room.size.width, room.size.height);+ if (side < kCoverMinWidth) return;+ // Found by its size while that is still the tilt view's.+ coverIn(tilt);+ CGPoint origin = CGPointMake(round(CGRectGetMinX(room) + (room.size.width - side) / 2),+ round(CGRectGetMinY(room) + (room.size.height - side) / 2));+ CGRect bounds = (CGRect){tilt.bounds.origin, CGSizeMake(side, side)};+ CGPoint middle = CGPointMake(origin.x + side / 2, origin.y + side / 2);+ if (CGRectEqualToRect(tilt.bounds, bounds) && CGPointEqualToPoint(tilt.center, middle)) return;+ tilt.bounds = bounds;+ tilt.center = middle;+ [tilt setNeedsLayout];+ static dispatch_once_t once;+ dispatch_once(&once, ^{ SGLog(@"redesign player: the cover fills its room, %.0fpt in %@", side, NSStringFromCGRect(room)); });+}++%hook _TtC28NowPlaying_ContentLayersImpl16CoverArtCellImpl- (void)layoutSubviews {%orig;+ static Class tiltClass;+ if (!tiltClass) tiltClass = NSClassFromString(@"_TtC35CreativeWorkCommons_CoverArtTiltKit16CoverArtTiltView");+ SGForEachView((UIView *)self, ^(UIView *view) {+ if ([view isKindOfClass:tiltClass]) fillRoom(view);+ });+}+%end++%hook _TtC35CreativeWorkCommons_CoverArtTiltKit16CoverArtTiltView+- (void)layoutSubviews {UIView *tilt = (UIView *)self;- if (tilt.bounds.size.width < kCoverMinWidth || !inCoverCell(tilt)) return;+ BOOL player = inCoverCell(tilt);+ // Again here, for a pass of Spotify's that sizes the tilt view without the cell laying out.+ if (player) fillRoom(tilt);+ %orig;+ if (tilt.bounds.size.width < kCoverMinWidth || !player) return;UIView *cover = coverIn(tilt);if (!cover) return;[sg_tilts addObject:tilt];@@ -264,11 +304,21 @@ static void watchHold(UIView *tilt) {%end// Spotify shows and hides the preview as lyrics come and go; it stays hidden, the way-// Native/Player/PlayerDeclutter.x has shipped it (its parent is a plain view, 01.txt:35, not a stack).+// Native/Player/PlayerDeclutter.x has shipped it (its parent is a plain view, 01.txt:35, not a stack),+// and it takes no room either, whatever size it is asked for or given.%hook _TtC22Lyrics_NPVContainerKit19LyricsContainerView- (void)setHidden:(BOOL)hidden {%orig(YES);}+- (CGSize)intrinsicContentSize {+ return CGSizeZero;+}+- (CGSize)sizeThatFits:(CGSize)size {+ return CGSizeZero;+}+- (void)setFrame:(CGRect)frame {+ %orig((CGRect){frame.origin, CGSizeZero});+}- (void)didMoveToWindow {%orig;((UIView *)self).hidden = YES;