forked from dayanch96/YTMusicUltimate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NavBar.xm
55 lines (46 loc) · 1.43 KB
/
NavBar.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
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
static BOOL YTMU(NSString *key) {
NSDictionary *YTMUltimateDict = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"YTMUltimate"];
return [YTMUltimateDict[key] boolValue];
}
@interface YTMNavigationBarView : UIView
@end
@interface QTMButton : UIButton
@property (nonatomic, copy, readwrite) NSString *accessibilityIdentifier;
@end
@interface YTMSortFilterButton : UIButton
@end
%hook QTMButton
- (void)layoutSubviews {
%orig;
if (YTMU(@"YTMUltimateIsEnabled") && YTMU(@"hideHistoryButton")) {
if ([self.accessibilityIdentifier isEqualToString:@"id.navigation.history.button"]) {
self.hidden = YES;
}
}
if (YTMU(@"YTMUltimateIsEnabled") && YTMU(@"hideCastButton")) {
if ([self.accessibilityIdentifier isEqualToString:@"id.mdx.playbackroute.button"]) {
self.hidden = YES;
}
}
}
%end
%hook YTMNavigationBarView
- (void)layoutSubviews {
%orig;
NSArray *subviews = [self subviews];
UIView *sortFilterButton = nil;
for (UIView *subview in subviews) {
if ([subview isKindOfClass:NSClassFromString(@"YTMSortFilterButton")]) {
sortFilterButton = subview;
break;
}
}
if (YTMU(@"YTMUltimateIsEnabled") && YTMU(@"hideFilterButton")) {
if (sortFilterButton != nil) {
[sortFilterButton removeFromSuperview];
}
}
}
%end