Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: Plain checkmark shows a saved song's tick without its circle
My-Name-Is-Jeff873a4e4fdbb8
diff --git a/tweak/Sources/Redesigned/Kit/SGRAccent.h b/tweak/Sources/Redesigned/Kit/SGRAccent.hindex 0981caf5..067b1375 100644--- a/tweak/Sources/Redesigned/Kit/SGRAccent.h+++ b/tweak/Sources/Redesigned/Kit/SGRAccent.h@@ -11,5 +11,12 @@UIColor *SGRAccentColor(void); // nil while Spotify's own green is keptNSInteger SGRAccentRGB(void); // the color in effect, 0xRRGGBB, Spotify's green included+// Plain checkmark (SGRPlainCheck.x): a saved song's circled tick as a plain checkmark in the accent. Off until switched+// on, read at launch.+#define SGRKeyPlainCheck @"spotifyglass.redesign.plainCheck"+BOOL SGRPlainCheckOn(void);+// The plain checkmark's view, a template image: Follow the cover (Player/PlayerCoverAccent.x) sets its tint.+#define SGRPlainCheckIdentifier @"spotifyglass.plainCheck"+@class SGModRow;NSArray<SGModRow *> *SGRAppearanceRows(void); // the accent color, for the Appearance pagediff --git a/tweak/Sources/Redesigned/Kit/SGRAppearanceSettings.m b/tweak/Sources/Redesigned/Kit/SGRAppearanceSettings.mindex c69edc4d..ef376eab 100644--- a/tweak/Sources/Redesigned/Kit/SGRAppearanceSettings.m+++ b/tweak/Sources/Redesigned/Kit/SGRAppearanceSettings.m@@ -39,5 +39,6 @@ NSArray<SGModRow *> *SGRAppearanceRows(void) {return @[SGWithSymbol(menu, @"paintpalette"),SGWithSymbol(colour, @"eyedropper"),+ SGWithSymbol(SGOptionRow(@"Plain checkmark", @"A saved song's tick without its circle, in the accent", SGRKeyPlainCheck), @"checkmark"),];}diff --git a/tweak/Sources/Redesigned/Kit/SGRPlainCheck.x b/tweak/Sources/Redesigned/Kit/SGRPlainCheck.xnew file mode 100644index 00000000..2cb5b04f--- /dev/null+++ b/tweak/Sources/Redesigned/Kit/SGRPlainCheck.x@@ -0,0 +1,74 @@+// Plain checkmark (Appearance): Spotify's circled tick on a saved song swapped for a plain checkmark in the accent.+//+// The Add button (id=Components.UI.AddToButton, a UIButton) draws its state with a Lottie animation in a+// StateMicroInteractionView<AddToButtonState> (trees: player 1434-1436, the rows' buttons the same): a plus when the+// song is not saved, an accent circle with a tick when it is. Spotify marks a saved song's button selected ("Added to+// playlist"), so the button's own selected state tells which. Saved, the animation goes transparent and a checkmark of+// the Kit's stands in its place; not saved, Spotify's plus shows as it is.+#import <objc/runtime.h>+#import "Core/SGCore.h"+#import "SGRKit.h"++static const CGFloat kCheckSize = 19;+static char kCheckKey, kAnimationKey;++BOOL SGRPlainCheckOn(void) {+ static BOOL on;+ static dispatch_once_t once;+ dispatch_once(&once, ^{ on = SGHidden(SGRKeyPlainCheck); });+ return on;+}++static UIView *animationIn(UIButton *button) {+ UIView *found = objc_getAssociatedObject(button, &kAnimationKey);+ if (found.superview) return found;+ static Class lottie;+ if (!lottie) lottie = NSClassFromString(@"Lottie.LottieAnimationView");+ found = nil;+ for (UIView *child in button.subviews) {+ for (UIView *inner in child.subviews) {+ if (lottie && [inner isKindOfClass:lottie]) found = inner;+ }+ }+ objc_setAssociatedObject(button, &kAnimationKey, found, OBJC_ASSOCIATION_ASSIGN);+ return found;+}++static void showState(UIButton *button) {+ UIView *animation = animationIn(button);+ if (!animation) return;+ UIImageView *check = objc_getAssociatedObject(button, &kCheckKey);+ BOOL saved = button.isSelected;+ if (saved && !check) {+ UIImageSymbolConfiguration *configuration = [UIImageSymbolConfiguration configurationWithPointSize:kCheckSize weight:UIImageSymbolWeightBold];+ check = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:@"checkmark" withConfiguration:configuration]];+ check.tintColor = SGRAccent();+ check.accessibilityIdentifier = SGRPlainCheckIdentifier;+ check.contentMode = UIViewContentModeCenter;+ check.userInteractionEnabled = NO;+ check.isAccessibilityElement = NO;+ objc_setAssociatedObject(button, &kCheckKey, check, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ if (check && check.superview != button) [button addSubview:check];+ check.frame = button.bounds;+ check.alpha = saved ? 1 : 0;+ // Alpha, not hidden: Lottie's own state keeps running under it.+ animation.alpha = saved ? 0 : 1;+}++%hook UIButton+- (void)layoutSubviews {+ %orig;+ if ([self.accessibilityIdentifier isEqualToString:@"Components.UI.AddToButton"]) showState(self);+}++- (void)setSelected:(BOOL)selected {+ %orig;+ if ([self.accessibilityIdentifier isEqualToString:@"Components.UI.AddToButton"]) showState(self);+}+%end++%ctor {+ if (!SGRedesignedUI() || !SGRPlainCheckOn()) return;+ %init;+}