/
Tweak.xm
71 lines (57 loc) · 3.14 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#import <UIKit/UIKit.h>
@interface SPTNowPlayingInformationUnitViewController : UIViewController
@end
@interface NowPlayingInformationUnitViewController : UIViewController
@end
%hook SPTNowPlayingInformationUnitViewController
-(void)setupAddButtonIfNeeded {
UIView *view = self.view.subviews[0].subviews[0].subviews[0];
UIView *track = view.subviews[0].subviews[0].subviews[0].subviews[0];
UIView *artistIntermediate = view.subviews[1].subviews[0];
UIView *artist = artistIntermediate.subviews[2].subviews[0].subviews[0].subviews[0];
// fix issue with enhance/smart shuffle icon being stretched
for (UIView *subview in artistIntermediate.subviews) {
if ([subview isKindOfClass:[UIImageView class]]) {
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:16.f]];
break;
}
}
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:track attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.f constant:0.f]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:artist attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.f constant:0.f]];
%orig;
}
// This takes up too much space
// No one really uses it
// So let's remove it :)
-(void)setupMinusButtonIfNeeded {
}
%end
// a/b testing UI, written in swift
%hook NowPlayingInformationUnitViewController
-(void)viewDidLoad {
%orig;
NowPlayingInformationUnitViewController *typedSelf = (NowPlayingInformationUnitViewController *)self;
UIView *viewIntermediate = typedSelf.view.subviews[0].subviews[0];
UIView *view = viewIntermediate.subviews[0].subviews[0];
UIView *track = view.subviews[0];
UIView *artistIntermediate = view.subviews[1].subviews[0];
UIView *artist = artistIntermediate.subviews[2].subviews[0];
// hide buttons on the right side
if (viewIntermediate.subviews.count > 1) {
viewIntermediate.subviews[1].hidden = YES;
}
// fix issue with enhance/smart shuffle icon being stretched
for (UIView *subview in artistIntermediate.subviews) {
if ([subview isKindOfClass:[UIImageView class]]) {
[typedSelf.view addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:16.f]];
break;
}
}
[typedSelf.view addConstraint:[NSLayoutConstraint constraintWithItem:track attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:typedSelf.view attribute:NSLayoutAttributeCenterX multiplier:1.f constant:0.f]];
[typedSelf.view addConstraint:[NSLayoutConstraint constraintWithItem:artist attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:typedSelf.view attribute:NSLayoutAttributeCenterX multiplier:1.f constant:0.f]];
}
%end
%ctor {
// swift, yay 🗿
%init(NowPlayingInformationUnitViewController=NSClassFromString(@"NowPlaying_ViewImpl.NowPlayingInformationUnitViewController"));
}