Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
chore: new harness
Vojtěch Škopeke618f3d73541
diff --git a/harness/glass/README.md b/harness/glass/README.mdnew file mode 100644index 00000000..46519738--- /dev/null+++ b/harness/glass/README.md@@ -0,0 +1,25 @@+# Glass harness++Spotify's round header button mocked as what the trees show it to be -- a 48x48 control whose glyph is a+subview of its own (`trees/clean/player/01.txt:103`) -- with the real `SGRGlassInside` behind it, over a+colour field, so what the glass does to the glyph can be looked at on the Mac.++ THEOS=$HOME/theos ./build.sh+ xcrun simctl install booted build/GlassHarness.app+ xcrun simctl launch booted com.vojta.glassharness+ xcrun simctl io booted screenshot shot.png++Four glyphs in three rows, the same button and the same shape each time, differing only in how the shape is+put behind the button:++| row | how |+|---|---|+| `as shipped` | first in the button's subviews, what `SGRGlassInside` does now |+| `by depth` | added last and pushed back with `zPosition = -1`, what it did before issue #39 |+| `outside` | a sibling of the button, behind it in its superview |++**What it does not cover: the bug it was written for.** Issue #39 is a glyph that comes out as a soft ghost+seen through the glass with nothing crisp over it, which is glass taking the glyph into its backdrop. The+simulator's glass does not refract, so all three rows look right here and only a phone tells them apart. The+harness is worth keeping for what it does prove: that the shape still lands centred and behind the glyph, in+each arrangement, so a change to the ordering can be seen not to have moved anything.diff --git a/harness/glass/build.sh b/harness/glass/build.shnew file mode 100755index 00000000..92cdaf22--- /dev/null+++ b/harness/glass/build.sh@@ -0,0 +1,34 @@+#!/bin/sh+# Builds the glass harness for the simulator: the real SGRGlassInside behind a mock of Spotify's round+# header button, three ways of putting it there side by side.+set -e+SRC=$(cd "$(dirname "$0")/../../tweak/Sources" && pwd)+OUT=$(dirname "$0")/build+rm -rf "$OUT"; mkdir -p "$OUT/GlassHarness.app"++SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)+xcrun -sdk iphonesimulator clang -target arm64-apple-ios26.0-simulator -fobjc-arc -g -O0 \+ -I"$SRC" -isysroot "$SDK" -Wno-deprecated-declarations \+ "$(dirname "$0")/main.m" \+ "$SRC"/Redesigned/Kit/SGRGlass.m "$SRC"/Redesigned/Kit/SGRTokens.m \+ "$SRC"/Core/SGLog.m "$SRC"/Core/SGPrefs.m "$SRC"/Core/SGGlass.m "$SRC"/Core/SGUIMode.m \+ -framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreText -framework Foundation \+ -o "$OUT/GlassHarness.app/GlassHarness"++cat > "$OUT/GlassHarness.app/Info.plist" <<'PLIST'+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0"><dict>+<key>CFBundleExecutable</key><string>GlassHarness</string>+<key>CFBundleIdentifier</key><string>com.vojta.glassharness</string>+<key>CFBundleName</key><string>GlassHarness</string>+<key>CFBundleVersion</key><string>1</string>+<key>CFBundleShortVersionString</key><string>1.0</string>+<key>UIUserInterfaceStyle</key><string>Dark</string>+<key>UILaunchScreen</key><dict/>+<key>UIApplicationSceneManifest</key><dict>+ <key>UIApplicationSupportsMultipleScenes</key><false/>+</dict>+</dict></plist>+PLIST+echo "built $OUT/GlassHarness.app"diff --git a/harness/glass/main.m b/harness/glass/main.mnew file mode 100644index 00000000..1543edf7--- /dev/null+++ b/harness/glass/main.m@@ -0,0 +1,102 @@+// A round button of Spotify's mocked the way the player's header holds one -- a 48x48 control whose glyph is+// its own subview -- with the real SGRGlassInside behind it, so what the glass does to the glyph can be looked+// at on the Mac. Issue #39: the glyph comes out blurred and unreadable on the phone.+//+// Three columns, all the same button and the same shape, differing only in how the shape is put behind it:+//+// as shipped the shape first in the button's subviews (Redesigned/Kit/SGRGlass.m)+// by depth the shape added last and pushed back with zPosition -1, the way it used to be+// outside the shape a sibling of the button, behind it in its superview+//+// A UIVisualEffectView takes its backdrop from what is drawn beneath it *in its own backdrop group*, which is+// the nearest ancestor that gathers one. A shape inside the button is in the button's group, so the glyph can+// be in its backdrop however the shape is ordered; a shape outside cannot be. The three columns are here to+// show which of those actually happens.+#import <UIKit/UIKit.h>+#import "Redesigned/Kit/SGRGlass.h"+#import "Redesigned/Kit/SGRTokens.h"++// The accent is the only thing the Kit's tokens reach out for and it is not what is being looked at here.+UIColor *SGRAccentColor(void) { return nil; }++static const CGFloat kButton = 48;++// Spotify's header button: a control with the glyph as a subview of its own, which is what a shape inside has+// to sit behind (trees/clean/player/01.txt:103, id=now-playing-minimize-button 48x48).+static UIView *mockButton(NSString *symbol) {+ UIView *button = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kButton, kButton)];+ UIImageConfiguration *weight = [UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightSemibold];+ UIImageView *glyph = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:symbol withConfiguration:weight]];+ glyph.tintColor = UIColor.whiteColor;+ glyph.contentMode = UIViewContentModeCenter;+ glyph.frame = button.bounds;+ [button addSubview:glyph];+ return button;+}++@interface SGRGlassHarnessDelegate : UIResponder <UIApplicationDelegate>+@property (nonatomic, strong) UIWindow *window;+@end++@implementation SGRGlassHarnessDelegate++- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options {+ self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];+ UIViewController *root = [UIViewController new];+ self.window.rootViewController = root;+ self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;+ UIView *page = root.view;+ page.backgroundColor = UIColor.blackColor;++ // Something with colour and detail under the glass, so a shape that is refracting the page reads as glass+ // rather than as a flat disc. The player's field is artwork blurred behind the header the same way.+ CAGradientLayer *field = [CAGradientLayer layer];+ field.frame = CGRectMake(0, 0, page.bounds.size.width, 420);+ field.colors = @[(id)[UIColor colorWithRed:0.42 green:0.05 blue:0.09 alpha:1].CGColor,+ (id)[UIColor colorWithRed:0.10 green:0.02 blue:0.03 alpha:1].CGColor];+ [page.layer addSublayer:field];++ NSArray<NSString *> *symbols = @[@"chevron.down", @"ellipsis", @"shuffle", @"arrow.down"];+ NSArray<NSString *> *ways = @[@"as shipped", @"by depth", @"outside"];++ for (NSUInteger way = 0; way < ways.count; way++) {+ UILabel *caption = [UILabel new];+ caption.text = ways[way];+ caption.font = [UIFont monospacedSystemFontOfSize:13 weight:UIFontWeightRegular];+ caption.textColor = [UIColor colorWithWhite:1 alpha:0.55];+ caption.frame = CGRectMake(24, 60 + way * 120, 200, 18);+ [page addSubview:caption];++ for (NSUInteger i = 0; i < symbols.count; i++) {+ UIView *holder = [[UIView alloc] initWithFrame:CGRectMake(24 + i * 70, 88 + way * 120, kButton, kButton)];+ [page addSubview:holder];+ UIView *button = mockButton(symbols[i]);+ [holder addSubview:button];++ static char keys[3][4];+ UIView *shape = SGRGlassInside(button, &keys[way][i], SGRGlassCircleSize);+ if (way == 1) {+ // Pushed back by depth while sitting last in the subviews, the way it used to be.+ shape.layer.zPosition = -1;+ [button addSubview:shape];+ } else if (way == 2) {+ // A sibling of the button, so the button's content is not in the shape's backdrop group at all.+ shape.layer.zPosition = 0;+ shape.center = CGPointMake(CGRectGetMidX(holder.bounds), CGRectGetMidY(holder.bounds));+ [holder insertSubview:shape belowSubview:button];+ }+ }+ }++ [self.window makeKeyAndVisible];+ [page layoutIfNeeded];+ return YES;+}++@end++int main(int argc, char *argv[]) {+ @autoreleasepool {+ return UIApplicationMain(argc, argv, nil, NSStringFromClass(SGRGlassHarnessDelegate.class));+ }+}