-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tweak.x
72 lines (58 loc) · 2.38 KB
/
Tweak.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
#import <Foundation/Foundation.h>
#import <Foundation/NSUserDefaults+Private.h>
#import <rootless.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIColor.h>
#import <Tweak.h>
// ColorHelper is shamelessly stolen from Echo <3
#import "ColorHelper.h"
// include generated hooks file
%group SystemUI
@custom_include "generated.x"
%hook UIColor
+ (id)_systemBlueColor2 { return colors[ACCENT]; }
+ (id)_systemInteractionTintColor { return colors[ACCENT]; }
%end
%hook _UIVisualEffectBackdropView
-(void)setFilters:(NSArray *)arg1 {
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id object, NSDictionary *bindings) {
return [[object filterType] isEqualToString:@"gaussianBlur"];
}];
NSArray *filtered = [arg1 filteredArrayUsingPredicate:predicate];
self.backgroundColor = [colors[BASE] colorWithAlphaComponent:0.5];
%orig(filtered);
}
%end
%hook UIButton
-(id)_setupBackgroundView {
id res = %orig;
[self setTitleColor:colors[CRUST] forState:UIControlStateNormal];
return res;
}
%end
%end
static void loadPreferences() {
BOOL isSystem = [NSHomeDirectory() isEqualToString:@"/var/mobile"];
NSDictionary *preferences = nil;
if (isSystem) {
CFArrayRef keyList = CFPreferencesCopyKeyList((CFSTR("com.catppuccin.ios.preferences")), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if (keyList) {
preferences = CFBridgingRelease(CFPreferencesCopyMultiple(keyList, CFSTR("com.catppuccin.ios.preferences"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
if (!preferences) preferences = [NSDictionary new];
CFRelease(keyList);
}
}
if (!preferences) preferences = [NSDictionary dictionaryWithContentsOfFile:ROOT_PATH_NS(@"/var/mobile/Library/Preferences/com.catppuccin.ios.preferences.plist")];
if (preferences) {
Flavor = [preferences objectForKey:@"flavor"];
Accent = [preferences objectForKey:@"accent"];
//BOOL YouTube = [[preferences objectForKey:@"youtube"] boolValue];
//BOOL Reddit = [[preferences objectForKey:@"reddit"] boolValue];
}
[ColorHelper updateColors];
}
%ctor {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPreferences, CFSTR("com.catppuccin.ios.preferences/reload"), NULL, CFNotificationSuspensionBehaviorCoalesce);
loadPreferences();
%init(SystemUI);
}