forked from dayanch96/OledKeyboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.x
87 lines (67 loc) · 2.4 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#import <UIKit/UIKit.h>
/* To avoid breaking anything, we will apply a black background to the bottommost
transparent view if dark mode for the keyboard enabled */
@interface UIView (Private)
@property (nonatomic, assign, readonly) BOOL _mapkit_isDarkModeEnabled;
- (UIViewController *)_viewControllerForAncestor;
@end
static BOOL isDarkMode(UIView *view) {
if ([view respondsToSelector:@selector(_mapkit_isDarkModeEnabled)]) {
return view._mapkit_isDarkModeEnabled;
}
return view._viewControllerForAncestor.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark;
}
@interface UIKeyboard : UIView // Regular keyboard
+ (instancetype)activeKeyboard;
@end
%hook UIKeyboard
- (void)displayLayer:(id)arg1 {
%orig;
self.backgroundColor = isDarkMode(self) ? [UIColor blackColor] : [UIColor clearColor];
}
%end
@interface UIPredictionViewController : UIViewController // Keyboard with enabled predictions panel
@end
%hook UIPredictionViewController
- (id)_currentTextSuggestions {
UIKeyboard *keyboard = [%c(UIKeyboard) activeKeyboard];
if (isDarkMode(keyboard)) {
[self.view setBackgroundColor:[UIColor blackColor]];
keyboard.backgroundColor = [UIColor blackColor];
} else {
[self.view setBackgroundColor:[UIColor clearColor]];
keyboard.backgroundColor = [UIColor clearColor];
}
return %orig;
}
%end
@interface UIKeyboardDockView : UIView // Dock under keyboard for notched devices
@end
%hook UIKeyboardDockView
- (void)layoutSubviews {
%orig;
self.backgroundColor = isDarkMode(self) ? [UIColor blackColor] : [UIColor clearColor];
}
%end
// Since we can't hook a private framework class from UIKit, we check the class name through the nearest available from UIKit class
%hook UIInputView
- (void)layoutSubviews {
%orig;
if ([self isKindOfClass:NSClassFromString(@"TUIEmojiSearchInputView")] // Emoji searching panel
|| [self isKindOfClass:NSClassFromString(@"_SFAutoFillInputView")]) { // Autofill password
self.backgroundColor = isDarkMode(self) ? [UIColor blackColor] : [UIColor clearColor];
}
}
%end
@interface UIKBVisualEffectView : UIVisualEffectView
@property (nonatomic, copy, readwrite) NSArray *backgroundEffects;
@end
%hook UIKBVisualEffectView
- (void)layoutSubviews {
%orig;
if (isDarkMode(self)) {
self.backgroundEffects = nil;
self.backgroundColor = [UIColor blackColor];
}
}
%end