forked from dayanch96/YTMusicUltimate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.x
114 lines (90 loc) · 3.67 KB
/
Settings.x
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#import <UIKit/UIKit.h>
#include "Prefs/YTMUltimateSettingsController.h"
#include "Headers/Localization.h"
@interface YTMAccountButton : UIButton
- (id)initWithTitle:(id)arg1 identifier:(id)arg2 icon:(id)arg3 actionBlock:(void (^)(BOOL finished))arg4;
@end
@interface YTMAvatarAccountView : UIView
@end
@interface UIView (Private)
- (id)_viewControllerForAncestor;
@end
@interface YTISupportedMessageRendererIcons : NSObject
@property (nonatomic, assign, readwrite) int iconType;
@end
@interface YTIMessageRenderer : NSObject
@property (nonatomic, strong, readwrite) YTISupportedMessageRendererIcons *icon;
@end
@interface YTMLightweightMessageCell : UIView
@end
@interface YTMMessageView : UIView
@property (nonatomic, weak, readwrite) YTMLightweightMessageCell *delegate;
@end
%group SettingsPage
%hook YTMAvatarAccountView
- (void)setAccountMenuUpperButtons:(id)arg1 lowerButtons:(id)arg2 {
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(24, 24)];
UIImage *icon = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
UIImage *flameImage = [UIImage systemImageNamed:@"flame"];
UIView *imageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
UIImageView *flameImageView = [[UIImageView alloc] initWithImage:flameImage];
flameImageView.contentMode = UIViewContentModeScaleAspectFit;
flameImageView.clipsToBounds = YES;
flameImageView.tintColor = [UIColor redColor];
flameImageView.frame = imageView.bounds;
[imageView addSubview:flameImageView];
[imageView.layer renderInContext:rendererContext.CGContext];
}];
//Create the YTMusicUltimate button
YTMAccountButton *button = [[%c(YTMAccountButton) alloc] initWithTitle:@"YTMusicUltimate" identifier:@"ytmult" icon:icon actionBlock:^(BOOL arg4) {
//Push YTMusicUltimate view controller.
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[YTMUltimateSettingsController alloc] init]];
[nav setModalPresentationStyle: UIModalPresentationFullScreen];
[self._viewControllerForAncestor presentViewController:nav animated:YES completion:nil];
}];
button.tintColor = [UIColor redColor];
//Add our custom button to the list.
NSMutableArray *arrDown = [[NSMutableArray alloc] init];
[arrDown addObjectsFromArray:arg2];
[arrDown addObject:button];
//Remove the subscribe to premium button on old versions
NSMutableArray *arrUp = [[NSMutableArray alloc] init];
for (YTMAccountButton *yt_button in arg1) {
if (![[yt_button.titleLabel text] containsString:@"Premium"]) {
[arrUp addObject:yt_button];
}
}
//Continue the function with our own parameters.
%orig(arrUp, arrDown);
}
%end
@interface YTMAvatarAccountViewController : UIViewController
@end
@interface YTMNavigationDrawerPromoView : UIView
@end
// Remove the subscribe to premium button on new versions
%hook YTMNavigationDrawerPromoView
- (void)loadModel:(id)model {
if ([self._viewControllerForAncestor isKindOfClass:%c(YTMAvatarAccountViewController)]) {
return [self removeFromSuperview];
}
%orig(model);
}
%end
%hook YTMMessageView
- (void)setMessageText:(id)arg1 {
if (![self.delegate isKindOfClass:%c(YTMLightweightMessageCell)]) {
return %orig;
}
YTMLightweightMessageCell *msgCell = (YTMLightweightMessageCell *)self.delegate;
YTIMessageRenderer *renderer = [msgCell valueForKey:@"_renderer"];
if (renderer.icon.iconType != 187) {
return %orig;
}
%orig(LOC(@"REGIONAL_RESTRICTION"));
}
%end
%end
%ctor {
%init(SettingsPage);
}