Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
fix: an artist logo fades across from its name
My-Name-Is-Jefff40c24504d7f
diff --git a/harness/artist/README.md b/harness/artist/README.mdindex ce62bfcd..6e89483a 100644--- a/harness/artist/README.md+++ b/harness/artist/README.md@@ -13,5 +13,10 @@ The Music list is a real self-sizing collection view holding the sections in thethe two video sections included, so `ArtistSections.x` drops them the way it does on the phone: the shelffirst, then its heading and spacer once the list lays out again. At 2 s the log lists every cell's height.+`logo` on the launch line, with `-spotifyglass.redesign.artist.logo NO` after it so Apple Music's own logo does+not arrive as well, hands the header a logo at 2.5 s and takes it away at 4.5 s, with the page on screen. The log+says, before, as each arrives or leaves and a second later, where the logo and the name are and whether they are+fading and moving: the two cross over, the logo grows out of the name's place, and gone, the logo is hidden.+What it does not cover: the repaint hook (so the mock's cells are left unpainted), the real z-order of thepinned header bar against the list, and the element framework's own sizing.diff --git a/harness/artist/main.m b/harness/artist/main.mindex 0fa883d6..9844768d 100644--- a/harness/artist/main.m+++ b/harness/artist/main.m@@ -356,6 +356,46 @@ static NSArray<NSArray *> *musicList(void) {[self.window makeKeyAndVisible];+ // `logo`: an artist's logo arriving with the page on screen, at 2.5 s, and taken away again at 4.5 s (run+ // with `-spotifyglass.redesign.artist.logo NO` so Apple Music's own does not arrive too). The logo and the+ // name cross over while the block makes room, the logo starting from the name's place.+ if ([NSProcessInfo.processInfo.arguments containsObject:@"logo"]) {+ UIView *rootView = root.view;+ __block UIView *info = nil;+ UIImage *logo = [[[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(600, 200)] imageWithActions:^(UIGraphicsImageRendererContext *context) {+ [UIColor.whiteColor setFill];+ [[UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 600, 200) cornerRadius:40] fill];+ }];+ void (^report)(NSString *) = ^(NSString *when) {+ UIView *picture = [info valueForKey:@"_logo"], *title = [info valueForKey:@"_title"];+ NSLog(@"[harness] logo %@: logo %@ alpha %.2f hidden %d at %@ (fading %@, moving %@), name alpha %.2f at %@", when,+ [(UIImageView *)picture image] ? @"drawn" : @"empty", picture.alpha, picture.hidden, NSStringFromCGRect(picture.frame),+ [picture.layer animationForKey:@"opacity"] ? @"yes" : @"no", [picture.layer animationForKey:@"position"] ? @"yes" : @"no",+ title.alpha, NSStringFromCGRect(title.frame));+ };+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ NSMutableArray<UIView *> *queue = [NSMutableArray arrayWithObject:rootView];+ while (queue.count && !info) {+ UIView *v = queue.firstObject;+ [queue removeObjectAtIndex:0];+ if ([NSStringFromClass(v.class) isEqualToString:@"SGRHeaderInfo"]) info = v;+ [queue addObjectsFromArray:v.subviews];+ }+ report(@"before");+#pragma clang diagnostic push+#pragma clang diagnostic ignored "-Warc-performSelector-leaks"+ [info performSelector:NSSelectorFromString(@"showTitleImage:") withObject:logo];+ report(@"arriving");+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ report(@"arrived"); });+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ [info performSelector:NSSelectorFromString(@"showTitleImage:") withObject:nil];+ report(@"leaving");+ });+#pragma clang diagnostic pop+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ report(@"gone"); });+ });+ }+// What the redesign's Follow draws: nothing before the state, then the glyph for it. A tap on it at// 2.5 s, which Spotify answers with Following.for (NSNumber *when in @[@0.5, @1.5, @2.5, @3.0]) {diff --git a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.mindex 35a92f68..8a8d1a07 100644--- a/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m+++ b/tweak/Sources/Redesigned/Kit/SGRHeaderInfo.m@@ -37,6 +37,7 @@ static const CGFloat kLogoWidthShare = 0.8, kLogoMaxHeight = 64;@implementation SGRHeaderInfo {UILabel *_title, *_creator, *_length, *_about;UIImageView *_logo;+ UIImage *_titleImage; // what the title's place is laid out for; the logo keeps its picture while it fades outSGRMirrorButton *_shuffle, *_trailing;SGRPlayCapsule *_play;__weak UIView *_creatorLink;@@ -80,32 +81,55 @@ static const CGFloat kLogoWidthShare = 0.8, kLogoMaxHeight = 64;return hit;}+// The picture often arrives from the network with the page already on screen. There the picture and the+// title cross over, and the block makes room for the picture in one move rather than in a frame, the picture+// growing out of the title's place; out of a window it all happens at once.- (void)showTitleImage:(UIImage *)image {- if (_logo.image == image) return;+ if (_titleImage == image) return;if (!_logo) {_logo = [UIImageView new];_logo.contentMode = UIViewContentModeScaleAspectFit;_logo.isAccessibilityElement = YES;_logo.accessibilityTraits = UIAccessibilityTraitHeader;+ _logo.alpha = 0;[self addSubview:_logo];}- _logo.image = image;- _logo.hidden = image == nil;- _title.alpha = image ? 0 : 1;+ _titleImage = image;_title.accessibilityElementsHidden = image != nil;+ if (image) {+ if (!_logo.image) [UIView performWithoutAnimation:^{ self->_logo.frame = self->_title.frame; }];+ _logo.image = image;+ _logo.hidden = NO;+ }[self setNeedsLayout];+ void (^fade)(void) = ^{+ self->_logo.alpha = image ? 1 : 0;+ self->_title.alpha = image ? 0 : 1;+ };+ void (^faded)(BOOL) = ^(BOOL finished) {+ if (self->_titleImage) return;+ self->_logo.image = nil;+ self->_logo.hidden = YES;+ };+ if (!self.window) {+ fade();+ faded(YES);+ return;+ }+ SGRAnimate(SGRMotionFade, fade, faded);+ SGRAnimate(SGRMotionLayout, ^{ [self layoutIfNeeded]; }, nil);}// The space under a line: a picture needs more room under it than a line of text does.- (CGFloat)sgr_gapAfter:(UILabel *)label {- if (label == _title && _logo.image) return 8;+ if (label == _title && _titleImage) return 8;return label == _creator ? 4 : 2;}// The title's line: the picture's fitted height where there is a picture, the label's otherwise.- (CGSize)sgr_sizeOf:(UILabel *)label width:(CGFloat)text {- if (label != _title || !_logo.image) return [label sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)];- CGSize image = _logo.image.size;+ if (label != _title || !_titleImage) return [label sizeThatFits:CGSizeMake(text, CGFLOAT_MAX)];+ CGSize image = _titleImage.size;if (image.width <= 0 || image.height <= 0) return CGSizeZero;CGFloat scale = MIN(text * kLogoWidthShare / image.width, kLogoMaxHeight / image.height);return CGSizeMake(round(image.width * scale), round(image.height * scale));@@ -207,7 +231,7 @@ static const CGFloat kLogoWidthShare = 0.8, kLogoMaxHeight = 64;CGSize size = [self sgr_sizeOf:label width:text];CGFloat height = ceil(size.height);label.frame = CGRectMake(kSide, y, text, height);- if (label == _title && _logo.image) {+ if (label == _title && _titleImage) {_logo.frame = CGRectMake(round((width - size.width) / 2), y, size.width, height);_logo.accessibilityLabel = _title.text;}