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 redesigned library, one large title and no filter pills over Spotify's own list

Vojtěch Škopek63b5f12fc08f
diff --git a/AGENTS.md b/AGENTS.md
index e79a0ece..4958f0ce 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -11,8 +11,8 @@ A Theos tweak (Objective-C + Logos) injected into the decrypted Spotify iOS app.
Home gradient, AMOLED switch, accent colour...).
- **Redesigned**: the mod's own Liquid Glass look, from a clean sheet. It includes the glass tab bar,
search field and now playing bar, the redesigned player and lyrics page with Apple Music style lyrics
- always on, a decluttered Home, Search's categories on tinted glass, black throughout, and its own accent
- colour. No native tweak runs.
+ always on, a decluttered Home, Search's categories on tinted glass, a Library with one large title and no
+ filter pills, black throughout, and its own accent colour. No native tweak runs.
Anything that doesn't draw on Spotify's screens works the same under both: ads, privacy, lyrics
sources, gestures, blocked artists, flags.
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 37faeb2b..97e8a6e5 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -118,6 +118,11 @@ Redesigned:
carousels and promos collapse, and the cards move up by the spacing they leave), the header the way Home
has it without the camera, and each card as Liquid Glass tinted by its own colour, read off the Box's
shape layer (Search.h lists its files)
+ Library/ Your Library the way Home and Search have their headers: a large title at the leading edge, the avatar
+ at the trailing edge with the search and create buttons before it, the filter chips and the header's
+ scrim gone and the header closed up by the band they leave, each row's artwork at the Kit's radius
+ with a circular one left round, a hairline between the rows, and the search inside the library on
+ glass capsules (Library.h lists its files)
Playlist/ the playlist page (Liked Songs and one's own too, all three being the same page) the way the Music
app lays one out: the cover full bleed across the top dissolving into the page's field with no seam,
the title, the creator and the length centred under it, one row of glass controls (shuffle, a
diff --git a/tweak/Sources/Redesigned/Kit/SGRTokens.h b/tweak/Sources/Redesigned/Kit/SGRTokens.h
index 10974216..9c7d8fb5 100644
--- a/tweak/Sources/Redesigned/Kit/SGRTokens.h
+++ b/tweak/Sources/Redesigned/Kit/SGRTokens.h
@@ -32,6 +32,9 @@ UIColor *SGRNeutralField(void); // #121212, the field before a colour arrives; S
UIColor *SGRSolidGlassFill(void);
// A content surface on the field (a card), a step lighter than the field it sits on.
UIColor *SGRElevated(UIColor *field);
+// The line between two rows of a list, drawn a pixel thick from the text's leading edge: white 12%, 20% with
+// Increase Contrast. Never a border around anything -- the redesign's surfaces are told apart by their fill.
+UIColor *SGRHairline(void);
// The system font at the size `style` has for the current content size category, but never larger
// than it has at `largest`, in `weight`. Callers re-ask on traitCollectionDidChange:.
diff --git a/tweak/Sources/Redesigned/Kit/SGRTokens.m b/tweak/Sources/Redesigned/Kit/SGRTokens.m
index a0f4911b..c6f17fe1 100644
--- a/tweak/Sources/Redesigned/Kit/SGRTokens.m
+++ b/tweak/Sources/Redesigned/Kit/SGRTokens.m
@@ -44,6 +44,10 @@ UIColor *SGRSolidGlassFill(void) {
return [UIColor colorWithWhite:1 alpha:0.16];
}
+UIColor *SGRHairline(void) {
+ return [UIColor colorWithWhite:1 alpha:SGRIncreaseContrast() ? 0.20 : 0.12];
+}
+
UIColor *SGRElevated(UIColor *field) {
CGFloat r = 0, g = 0, b = 0, a = 1;
if (![field getRed:&r green:&g blue:&b alpha:&a]) return [UIColor colorWithWhite:1 alpha:0.08];
diff --git a/tweak/Sources/Redesigned/Library/Library.h b/tweak/Sources/Redesigned/Library/Library.h
new file mode 100644
index 00000000..7447289a
--- /dev/null
+++ b/tweak/Sources/Redesigned/Library/Library.h
@@ -0,0 +1,23 @@
+// The Library redesign: Spotify's Your Library kept, with its controllers, its list and its rows, decluttered
+// to a library on black and restyled from the Kit. No settings of its own.
+//
+// LibraryHeader.x the header the way Home and Search have theirs: a large title at the leading edge, the
+// avatar at the trailing edge, the filter chips gone and the header closed up by what
+// they leave. A folder opened from the library is the same header, its back button and
+// its own controls kept
+// LibraryRows.x every row and grid card: the artwork at the Kit's radius with continuous corners, a
+// circular one left round, and a hairline between the rows
+// LibrarySearch.x the search inside the library: its field a glass capsule, the way the Search tab's is
+// (Redesigned/Navbar/SearchField.x)
+//
+// Every hook installs only while Redesigned UI is on (SGRedesignedUI).
+// Threading: main thread only.
+#import <UIKit/UIKit.h>
+
+// The list of every library page (trees/clean/library/03.txt:25).
+extern NSString *const SGRLibraryListIdentifier;
+
+// LibraryHeader.x. The scrim Spotify lays behind a library header taken out, so the soft scroll edge
+// (Kit/SGREdgeEffect.x) is what keeps the header clear of the list under it. A header without one is left
+// alone; the folder's has none.
+void SGRLibraryClearScrim(UIView *header);
diff --git a/tweak/Sources/Redesigned/Library/LibraryHeader.x b/tweak/Sources/Redesigned/Library/LibraryHeader.x
new file mode 100644
index 00000000..194d9aa8
--- /dev/null
+++ b/tweak/Sources/Redesigned/Library/LibraryHeader.x
@@ -0,0 +1,292 @@
+// Library redesign: the header of Your Library and of a folder inside it, the way Home and Search have theirs
+// (Redesigned/Home/HomeHeader.x, Redesigned/Search/SearchPage.x). A large title at the leading edge, the avatar
+// that opens the side drawer at the trailing edge, the filter chips gone, and the scrim Spotify lays behind the
+// header gone with them, the soft scroll edge (Kit/SGREdgeEffect.x) being what keeps the header clear of the
+// list scrolling under it.
+//
+// Tree (trees/clean/library/03.txt:1159-1247): YourLibraryView holds YourLibraryContentView, the size of the
+// page, and after it -- so over it -- YourLibraryHeaderView 402x159.33: LiquidGlass.GradientView (the scrim), a
+// 402x48 row at {0, 62} holding an AutoLayoutStackView {8, 0} 390x48 of
+// ListeningActivity_ElementsKit.AdaptiveFaceContainer (the avatar, id=Components.UI.SideDrawerButton),
+// id=YourLibraryHeader.title ("Your Library", 21pt), a spacer, a hidden id=YourLibraryHeader.recents,
+// id=YourLibraryHeader.search and id=YourLibraryHeader.plus; and under the row
+// YourLibraryHeaderContentFiltersView {0, 110} 402x49.33, the chips. A folder (trees/continuous/1.txt:325-344)
+// is the same header under YourLibrary_FolderImpl, with id=YourLibraryFolderHeader.back at the leading edge,
+// its title, then contextMenu, plus and play or pause, and the chips at {0, 118}.
+//
+// The header neither moves nor shrinks as the list scrolls -- 03.txt, 05.txt and 06.txt hold it at
+// {0, 0} 402x159.33 at three scroll positions -- so there is nothing here to follow: the row is laid out once a
+// pass and stays where it is put.
+//
+// Each control moves by a transform rather than by a frame. Spotify's stack lays them out from constraints of
+// its own on every pass, and Auto Layout sets a view's centre and bounds and leaves its transform alone, so the
+// move outlives the pass that made it (Search moves the Browse cells the same way). Nothing leaves the stack:
+// an arranged view of Spotify's that hides traps its stack in updateConstraints (Kit/SGRRestyle.h), so what
+// goes is alpha, touches and accessibility, and the title Spotify draws goes that way while ours is a subview
+// of the header the stack does not arrange.
+//
+// The chips leaving takes 49pt off the bottom of the header. What the header is shrunk to is the bottom of its
+// control row, which hangs off the safe area rather than off the header and so answers the same on every pass,
+// shrunk header or not; the chips' own top would move with the header and shrink it again pass after pass. The
+// page under it is then closed up the way that page holds its list: the root insets the list's top by the
+// header's height, a folder puts its content view below the header instead.
+#import "Core/SGCore.h"
+#import "Redesigned/Kit/SGRKit.h"
+#import "Library.h"
+
+NSString *const SGRLibraryListIdentifier = @"YourLibraryContent.collectionView";
+
+// Spotify's own inset for the header's controls: a 48pt button flush against the header's trailing edge has its
+// 24pt glyph 20pt from the screen, and the 32pt avatar inside its own 48pt box 16pt from it, which is the
+// margin Home gives the avatar.
+static const CGFloat kRowInset = 8;
+// A header shorter than this has not been laid out yet, and nothing is resized from it.
+static const CGFloat kHeaderFloor = 88;
+
+static char kTitleKey, kListKey, kInsetKey;
+static char kSearchKey, kPlusKey, kHeaderTitleKey;
+static char kBackKey, kMenuKey, kFolderPlusKey, kPlayKey, kPauseKey, kFolderTitleKey;
+
+static void vanish(UIView *view) {
+ if (!view) return;
+ if (view.alpha != 0) view.alpha = 0;
+ if (view.userInteractionEnabled) view.userInteractionEnabled = NO;
+ view.accessibilityElementsHidden = YES;
+}
+
+static UIView *childNamed(UIView *host, NSString *marker) {
+ for (UIView *sub in host.subviews) {
+ if ([NSStringFromClass(sub.class) containsString:marker]) return sub;
+ }
+ return nil;
+}
+
+void SGRLibraryClearScrim(UIView *header) {
+ vanish(childNamed(header, @"GradientView"));
+}
+
+#pragma mark - the controls
+
+// The header's controls, in the order they are to read from the leading edge, leaving out what this build does
+// not have, what Spotify has hidden (a folder shows play or pause, never both) and what has not been laid out.
+static NSMutableArray<UIView *> *controlsIn(UIView *header, NSArray<NSString *> *identifiers, const void **keys) {
+ NSMutableArray<UIView *> *found = [NSMutableArray array];
+ for (NSUInteger i = 0; i < identifiers.count; i++) {
+ UIView *control = SGRFindByIdentifier(header, identifiers[i], keys[i]);
+ if (control && !control.hidden && control.alpha > 0.01 && control.bounds.size.width > 1) [found addObject:control];
+ }
+ return found;
+}
+
+// Puts the controls at the header's trailing edge, the last of them flush against it and each keeping the width
+// it has, and answers where the leading edge of the first of them fell.
+static CGFloat placeTrailing(UIView *header, NSArray<UIView *> *controls) {
+ CGFloat right = header.bounds.size.width - kRowInset;
+ for (UIView *control in controls.reverseObjectEnumerator) {
+ CGFloat width = control.bounds.size.width;
+ // The centre is where Auto Layout put the control, whatever transform is on it; its frame is not.
+ CGFloat natural = [control.superview convertPoint:CGPointZero toView:header].x + control.center.x - width / 2;
+ CGAffineTransform move = CGAffineTransformMakeTranslation(right - width - natural, 0);
+ if (!CGAffineTransformEqualToTransform(control.transform, move)) control.transform = move;
+ right -= width;
+ }
+ return right;
+}
+
+#pragma mark - the title
+
+static NSString *textIn(UIView *label) {
+ __block NSString *text = nil;
+ SGForEachView(label, ^(UIView *view) {
+ if (!text && [view isKindOfClass:UILabel.class] && ((UILabel *)view).text.length) text = ((UILabel *)view).text;
+ });
+ return text;
+}
+
+static UILabel *titleIn(UIView *header) {
+ UILabel *title = objc_getAssociatedObject(header, &kTitleKey);
+ if (!title) {
+ title = [UILabel new];
+ title.textColor = SGRPrimary();
+ title.accessibilityTraits = UIAccessibilityTraitHeader;
+ title.adjustsFontSizeToFitWidth = YES;
+ title.minimumScaleFactor = 0.6;
+ title.userInteractionEnabled = NO;
+ objc_setAssociatedObject(header, &kTitleKey, title, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ if (title.superview != header) [header addSubview:title];
+ return title;
+}
+
+// The title Spotify's own says, so it follows the app's language, in the Music app's size on the row's middle.
+static void layoutTitle(UIView *header, UIView *spotifyTitle, CGFloat leading, CGFloat trailing, CGFloat middle) {
+ UILabel *title = titleIn(header);
+ NSString *text = textIn(spotifyTitle);
+ if (text.length && ![title.text isEqualToString:text]) {
+ title.text = text;
+ title.accessibilityLabel = text;
+ }
+ UIFont *font = SGRFont(UIFontTextStyleLargeTitle, UIFontWeightBold, UIContentSizeCategoryLarge);
+ if (![title.font isEqual:font]) title.font = font;
+
+ CGFloat height = ceil(font.lineHeight);
+ CGRect frame = CGRectMake(leading, round(middle - height / 2), MAX(0, trailing - SGRGrid - leading), height);
+ if (!CGRectEqualToRect(title.frame, frame)) title.frame = frame;
+}
+
+#pragma mark - the page closing up
+
+// The header without its chips, and the page under it closed up by what they leave. `control` is any of the
+// header's 48pt controls: they fill its control row, so the bottom of one is the bottom of the row.
+static void resize(UIView *page, UIView *header, UIView *control, UIView *filters) {
+ if (!filters || !control) return;
+ CGFloat wanted = CGRectGetMaxY(SGFrameIn(control, header));
+ if (wanted < kHeaderFloor || wanted > header.bounds.size.height + 0.5) return;
+
+ CGRect frame = header.frame;
+ if (fabs(frame.size.height - wanted) > 0.5) {
+ frame.size.height = wanted;
+ header.frame = frame;
+ }
+
+ UIView *content = childNamed(page, @"YourLibraryContentView");
+ if (!content) return;
+ if (CGRectGetMinY(content.frame) > 0.5) {
+ // A folder: its content view starts under the header rather than behind it.
+ CGRect wantedFrame = CGRectMake(0, wanted, page.bounds.size.width, page.bounds.size.height - wanted);
+ if (!CGRectEqualToRect(content.frame, wantedFrame)) content.frame = wantedFrame;
+ return;
+ }
+
+ // The root: the list rests under the header by an inset of its own. The inset is lowered by the band the
+ // chips had rather than set to the header's height, since what Spotify counts into it is its own business,
+ // and it is taken once -- after this pass the header no longer says how tall it was -- and then held by the
+ // setter hook below, so Spotify setting it again from its own pass is not something to answer pass after
+ // pass.
+ UIView *found = SGRFindByIdentifier(content, SGRLibraryListIdentifier, &kListKey);
+ if (![found isKindOfClass:UIScrollView.class]) return;
+ UIScrollView *list = (UIScrollView *)found;
+ if (objc_getAssociatedObject(list, &kInsetKey)) return;
+ CGFloat drop = CGRectGetMaxY(SGFrameIn(filters, header)) - wanted;
+ CGFloat top = list.contentInset.top;
+ // Nothing is taken off an inset that does not hold a header yet: the next pass has one.
+ if (drop < 1 || top < kHeaderFloor || top < drop) return;
+ objc_setAssociatedObject(list, &kInsetKey, @(top - drop), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ BOOL atTop = list.contentOffset.y <= -top + 0.5;
+ UIEdgeInsets inset = list.contentInset;
+ inset.top = top - drop;
+ list.contentInset = inset;
+ // A list resting at its top rests that much higher; one scrolled into its rows does not move at all.
+ if (atTop) list.contentOffset = CGPointMake(list.contentOffset.x, -inset.top);
+ SGLog(@"redesign library: the chips took %.0fpt off the header, the list rests at %.0f", drop, inset.top);
+}
+
+#pragma mark - the two headers
+
+static void layoutRoot(UIView *page) {
+ UIView *header = childNamed(page, @"YourLibraryHeaderView");
+ if (!header) return;
+ [header layoutIfNeeded];
+ SGRLibraryClearScrim(header);
+ UIView *filters = childNamed(header, @"YourLibraryHeaderContentFiltersView");
+ vanish(filters);
+
+ UIView *spotifyTitle = SGRFindByIdentifier(header, @"YourLibraryHeader.title", &kHeaderTitleKey);
+ vanish(spotifyTitle);
+ static const void *keys[] = {&kSearchKey, &kPlusKey};
+ NSMutableArray<UIView *> *trailing = controlsIn(header, @[@"YourLibraryHeader.search", @"YourLibraryHeader.plus"], keys);
+ static Class faceClass;
+ if (!faceClass) faceClass = NSClassFromString(@"_TtC29ListeningActivity_ElementsKit21AdaptiveFaceContainer");
+ __block UIView *face = nil;
+ SGForEachView(header, ^(UIView *view) {
+ if (!face && faceClass && [view isKindOfClass:faceClass] && view.bounds.size.width > 1) face = view;
+ });
+ if (face) [trailing addObject:face];
+ if (!trailing.count) return;
+
+ CGFloat leading = placeTrailing(header, trailing);
+ CGRect row = SGFrameIn(trailing.firstObject, header);
+ layoutTitle(header, spotifyTitle, SGRSideMargin, leading, CGRectGetMidY(row));
+ resize(page, header, trailing.firstObject, filters);
+
+ // The first pass that laid the header out, not the first pass at all: a page appearing lays out before
+ // its controls have a size, and a line off that pass would say the header was left as Spotify's.
+ static BOOL logged;
+ if (!logged && header.window && face) {
+ logged = YES;
+ SGLog(@"redesign library: header %@, %lu controls at the trailing edge, avatar %@, chips %@",
+ NSStringFromCGRect(header.frame), (unsigned long)trailing.count, face ? @"found" : @"not found",
+ filters ? @"gone" : @"not found");
+ }
+}
+
+static void layoutFolder(UIView *page) {
+ UIView *header = childNamed(page, @"FolderHeaderView");
+ if (!header) return;
+ [header layoutIfNeeded];
+ SGRLibraryClearScrim(header);
+ UIView *filters = childNamed(header, @"YourLibraryHeaderContentFiltersView");
+ vanish(filters);
+
+ UIView *spotifyTitle = SGRFindByIdentifier(header, @"YourLibraryFolderHeader.title", &kFolderTitleKey);
+ vanish(spotifyTitle);
+ UIView *back = SGRFindByIdentifier(header, @"YourLibraryFolderHeader.back", &kBackKey);
+ static const void *keys[] = {&kMenuKey, &kFolderPlusKey, &kPlayKey, &kPauseKey};
+ NSMutableArray<UIView *> *trailing = controlsIn(header, @[
+ @"YourLibraryFolderHeader.contextMenu", @"YourLibraryFolderHeader.plus",
+ @"YourLibraryFolderHeader.play", @"YourLibraryFolderHeader.pause",
+ ], keys);
+ if (!trailing.count && !back) return;
+
+ CGFloat trailingEdge = trailing.count ? placeTrailing(header, trailing) : header.bounds.size.width - kRowInset;
+ UIView *row = back ?: trailing.firstObject;
+ CGRect rowFrame = SGFrameIn(row, header);
+ CGFloat leading = back ? CGRectGetMaxX(rowFrame) + SGRGrid : SGRSideMargin;
+ layoutTitle(header, spotifyTitle, leading, trailingEdge, CGRectGetMidY(rowFrame));
+ resize(page, header, row, filters);
+
+ static BOOL logged;
+ if (!logged && header.window && trailing.count) {
+ logged = YES;
+ SGLog(@"redesign library: folder header %@, back %@, %lu controls at the trailing edge, chips %@",
+ NSStringFromCGRect(header.frame), back ? @"found" : @"not found", (unsigned long)trailing.count,
+ filters ? @"gone" : @"not found");
+ }
+}
+
+// Spotify works the list's top inset out from the header it had before the chips went, and sets it again
+// whenever it lays the page out. The list keeps the one this file took instead, so the two never take turns
+// setting it: a scroll view laying out again from every set of ours is a loop the page cannot settle out of.
+%hook _TtC21YourLibrary_CommonKit25YourLibraryCollectionView
+- (void)setContentInset:(UIEdgeInsets)inset {
+ NSNumber *held = objc_getAssociatedObject(self, &kInsetKey);
+ if (held) inset.top = held.doubleValue;
+ %orig(inset);
+}
+%end
+
+%hook _TtC28YourLibrary_YourLibraryXImpl15YourLibraryView
+- (void)layoutSubviews {
+ %orig;
+ layoutRoot((UIView *)self);
+}
+%end
+
+%hook _TtC22YourLibrary_FolderImpl10FolderView
+- (void)layoutSubviews {
+ %orig;
+ layoutFolder((UIView *)self);
+}
+%end
+
+%ctor {
+ if (!SGRedesignedUI()) return;
+ %init;
+ SGRequireClasses(@[
+ @"_TtC28YourLibrary_YourLibraryXImpl15YourLibraryView",
+ @"_TtC22YourLibrary_FolderImpl10FolderView",
+ @"_TtC21YourLibrary_CommonKit25YourLibraryCollectionView",
+ @"_TtC21YourLibrary_CommonKit35YourLibraryHeaderContentFiltersView",
+ @"_TtC29ListeningActivity_ElementsKit21AdaptiveFaceContainer",
+ ]);
+}
diff --git a/tweak/Sources/Redesigned/Library/LibraryRows.x b/tweak/Sources/Redesigned/Library/LibraryRows.x
new file mode 100644
index 00000000..476d94b9
--- /dev/null
+++ b/tweak/Sources/Redesigned/Library/LibraryRows.x
@@ -0,0 +1,92 @@
+// Library redesign: the rows of Your Library and of a folder inside it, and the cards of its grid.
+//
+// Tree (trees/clean/library/03.txt:30-73, 06.txt:28-40): every cell of the list is a
+// YourLibrarySwipeableCollectionViewCellContainer holding either a 402x80 row -- id=Playlist.Row.Library,
+// Album.Row.Library or Podcast.Row.Library, all three an AutoLayoutStackView {16, 8} 370x64 of
+// id=Artwork.Row.Library 64x64 r=4 and, 12pt after it, the title over its kind and its owner -- or a
+// 112.67x161.33 card, id=Components.UI.CardLibrary, over id=Components.UI.CardLibrary.Artwork r=4.
+//
+// Two things are changed, both of them the Music app's library. The artwork takes the Kit's radius for its
+// size with continuous corners, Spotify's 4pt being the square corner of its own look; an artist's picture
+// already carries a radius half its side and is left the circle it is (r=32 in the trees, 2 of the 90 rows
+// recorded). And a hairline runs between the rows from the text's leading edge, which is where a library list
+// draws one -- a layer rather than a view, since the rows are reused as fast as the list scrolls, with its
+// actions off so a reused row does not slide its line into place.
+#import "Core/SGCore.h"
+#import "Redesigned/Kit/SGRKit.h"
+#import "Library.h"
+
+// What a row leaves between its artwork and its text (03.txt:36 and :39: the artwork ends at 64, the text
+// starts at 76), and where the hairline starts with it.
+static const CGFloat kTextGap = 12;
+
+static char kThumbKey, kCoverKey, kLineKey;
+
+// Spotify gives a cover a square corner and an artist's picture a circle. Only the square becomes the Kit's.
+static void roundCorners(UIView *artwork, CGFloat radius) {
+ if (!artwork) return;
+ CGFloat side = MIN(artwork.bounds.size.width, artwork.bounds.size.height);
+ CALayer *layer = artwork.layer;
+ if (side < 1 || layer.cornerRadius >= side / 2 - 0.5) return;
+ if (layer.cornerRadius != radius) layer.cornerRadius = radius;
+ if (layer.cornerCurve != kCACornerCurveContinuous) layer.cornerCurve = kCACornerCurveContinuous;
+ if (!layer.masksToBounds) layer.masksToBounds = YES;
+}
+
+// The line under a row, from its text's leading edge to the trailing edge of the page. A cell holding a card
+// has none, and one reused from a row into a card loses the line it was left with.
+static void hairline(UIView *cell, UIView *thumb) {
+ CALayer *line = objc_getAssociatedObject(cell, &kLineKey);
+ CGSize size = cell.bounds.size;
+ CGRect artwork = thumb ? SGFrameIn(thumb, cell) : CGRectZero;
+ BOOL wanted = thumb && size.width > 300 && size.height <= 120 && artwork.size.width > 1;
+ if (!wanted) {
+ if (line && !line.hidden) line.hidden = YES;
+ return;
+ }
+ if (!line) {
+ line = [CALayer layer];
+ line.backgroundColor = SGRHairline().CGColor;
+ objc_setAssociatedObject(cell, &kLineKey, line, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+ if (line.superlayer != cell.layer) [cell.layer addSublayer:line];
+
+ CGFloat thickness = 1.0 / MAX(1, cell.window.screen.scale ?: UIScreen.mainScreen.scale);
+ CGFloat leading = CGRectGetMaxX(artwork) + kTextGap;
+ CGRect frame = CGRectMake(leading, size.height - thickness, MAX(0, size.width - leading), thickness);
+ if (line.hidden || !CGRectEqualToRect(line.frame, frame)) {
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ line.hidden = NO;
+ line.frame = frame;
+ [CATransaction commit];
+ }
+}
+
+static void style(UIView *cell) {
+ UIView *thumb = SGRFindByIdentifier(cell, @"Artwork.Row.Library", &kThumbKey);
+ if (thumb) roundCorners(thumb, SGRRadiusThumb);
+ else roundCorners(SGRFindByIdentifier(cell, @"Components.UI.CardLibrary.Artwork", &kCoverKey), SGRRadiusCover);
+ hairline(cell, thumb);
+
+ // The first cell that held an artwork, so the line says what was found rather than what had not loaded yet.
+ static BOOL logged;
+ if (!logged && thumb && thumb.bounds.size.width > 1) {
+ logged = YES;
+ SGLog(@"redesign library: rows styled, first cell %@, thumbnail %@ at r=%.1f",
+ NSStringFromCGSize(cell.bounds.size), NSStringFromCGSize(thumb.bounds.size), thumb.layer.cornerRadius);
+ }
+}
+
+%hook _TtC21YourLibrary_CommonKit47YourLibrarySwipeableCollectionViewCellContainer
+- (void)layoutSubviews {
+ %orig;
+ style((UIView *)self);
+}
+%end
+
+%ctor {
+ if (!SGRedesignedUI()) return;
+ %init;
+ SGRequireClasses(@[@"_TtC21YourLibrary_CommonKit47YourLibrarySwipeableCollectionViewCellContainer"]);
+}
diff --git a/tweak/Sources/Redesigned/Library/LibrarySearch.x b/tweak/Sources/Redesigned/Library/LibrarySearch.x
new file mode 100644
index 00000000..8dd3a2b2
--- /dev/null
+++ b/tweak/Sources/Redesigned/Library/LibrarySearch.x
@@ -0,0 +1,61 @@
+// Library redesign: the search inside the library, the page the header's magnifier opens.
+//
+// Tree (trees/clean/library/04.txt:21-63): YourLibrarySearchView holds the same YourLibraryContentView and list
+// as the library itself, and over them YourLibrarySearchHeaderView 402x142 -- LiquidGlass.GradientView (the
+// scrim) and, at {0, 94}, a SearchHeaderLibraryLayout of two shapes 32pt tall: the field,
+// id=Components.Header.UI.Toolbar.SearchField 320x32 r=4, and id=Components.Header.UI.Toolbar.ButtonContainer
+// 58x32 r=4 around Cancel. Both already draw Reprise_LiquidGlassKit's LiquidGlass.SearchBarView inside
+// themselves, so there is nothing to put behind them: what Spotify's own glass is missing here is the shape.
+// They become capsules, which is the shape the Search tab's field has (Redesigned/Navbar/SearchField.x), and
+// the scrim goes the way it goes on every other redesigned page.
+//
+// The header is 142pt and holds no filter chips, so there is nothing here to close up: LibraryHeader.x shrinks
+// a header only where chips leave a band behind.
+#import "Core/SGCore.h"
+#import "Redesigned/Kit/SGRKit.h"
+#import "Library.h"
+
+static char kFieldKey, kCancelKey;
+
+static UIView *childNamed(UIView *host, NSString *marker) {
+ for (UIView *sub in host.subviews) {
+ if ([NSStringFromClass(sub.class) containsString:marker]) return sub;
+ }
+ return nil;
+}
+
+static void capsule(UIView *shape) {
+ CGFloat height = shape.bounds.size.height;
+ if (height < 24) return;
+ CALayer *layer = shape.layer;
+ if (layer.cornerRadius != height / 2) layer.cornerRadius = height / 2;
+ if (layer.cornerCurve != kCACornerCurveContinuous) layer.cornerCurve = kCACornerCurveContinuous;
+ if (!layer.masksToBounds) layer.masksToBounds = YES;
+}
+
+%hook _TtC28YourLibrary_YourLibraryXImpl21YourLibrarySearchView
+- (void)layoutSubviews {
+ %orig;
+ UIView *header = childNamed((UIView *)self, @"YourLibrarySearchHeaderView");
+ if (!header) return;
+ SGRLibraryClearScrim(header);
+ UIView *field = SGRFindByIdentifier(header, @"Components.Header.UI.Toolbar.SearchField", &kFieldKey);
+ UIView *cancel = SGRFindByIdentifier(header, @"Components.Header.UI.Toolbar.ButtonContainer", &kCancelKey);
+ capsule(field);
+ capsule(cancel);
+
+ // The first pass the field had a size on: before that there is no shape to report.
+ static BOOL logged;
+ if (!logged && field.bounds.size.height > 1) {
+ logged = YES;
+ SGLog(@"redesign library: search field %@ at r=%.1f, cancel %@", NSStringFromCGRect(field.bounds),
+ field.layer.cornerRadius, cancel ? @"a capsule too" : @"not found");
+ }
+}
+%end
+
+%ctor {
+ if (!SGRedesignedUI()) return;
+ %init;
+ SGRequireClasses(@[@"_TtC28YourLibrary_YourLibraryXImpl21YourLibrarySearchView"]);
+}