-
Notifications
You must be signed in to change notification settings - Fork 7
/
iOS83UI.x
129 lines (99 loc) · 3.24 KB
/
iOS83UI.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#import <EmojiLibrary/Header.h>
#import <PSHeader/Misc.h>
#import <UIKit/UIKeyboardImpl.h>
#import <theos/IOSMacros.h>
#import <substrate.h>
#import <version.h>
@interface UIKeyboardEmojiScrollView (iOS83UI)
@property(retain, nonatomic) UILabel *_mycategoryLabel;
- (void)updateLabel:(NSInteger)categoryType;
@end
#define LABEL_HEIGHT (IS_IPAD ? 44.0 : 21.0)
#define FONT_SIZE (IS_IPAD ? 18.0 : 12.0)
void configureScrollView(UIKeyboardEmojiScrollView *self, CGRect frame) {
if (self._mycategoryLabel == nil) {
NSInteger orientation = [UIKeyboardImpl.activeInstance interfaceOrientation];
CGPoint margin = [%c(UIKeyboardEmojiGraphics) margin:orientation == 1 || orientation == 2];
self._mycategoryLabel = [[UILabel alloc] initWithFrame:CGRectMake(margin.x, 0.0, frame.size.width / 2, LABEL_HEIGHT)];
self._mycategoryLabel.alpha = 0.4;
CGFloat fontSize = FONT_SIZE;
if (IS_IOS_OR_NEWER(iOS_8_2))
self._mycategoryLabel.font = [UIFont systemFontOfSize:fontSize weight:UIFontWeightSemibold];
else {
if (!IS_IOS_OR_NEWER(iOS_7_0))
fontSize -= 1.0;
self._mycategoryLabel.font = [UIFont boldSystemFontOfSize:fontSize];
}
self._mycategoryLabel.backgroundColor = UIColor.clearColor;
[self updateLabel:((UIKeyboardEmojiCategory *)[self valueForKey:@"_category"]).categoryType];
[self addSubview:self._mycategoryLabel];
}
}
%hook UIKeyboardEmojiScrollView
%property(retain, nonatomic) UILabel *_mycategoryLabel;
%new
- (void)updateLabel:(NSInteger)categoryType {
self._mycategoryLabel.text = [[[%c(UIKeyboardEmojiCategory) categoryForType:categoryType] displayName] uppercaseStringWithLocale:[NSLocale currentLocale]];
}
- (void)layoutRecents {
%orig;
((UILabel *)[self valueForKey:@"_categoryLabel"]).hidden = YES;
}
- (void)reloadForCategory:(UIKeyboardEmojiCategory *)category {
%orig;
[self updateLabel:category.categoryType];
}
- (void)doLayout {
%orig;
[self updateLabel:((UIKeyboardEmojiCategory *)[self valueForKey:@"_category"]).categoryType];
}
%end
%group iOS7Up
%hook UIKeyboardEmojiScrollView
- (id)initWithFrame:(CGRect)frame keyplane:(UIKBTree *)keyplane key:(UIKBTree *)key {
self = %orig;
configureScrollView(self, frame);
return self;
}
- (void)setRenderConfig:(UIKBRenderConfig *)config {
%orig;
self._mycategoryLabel.textColor = config.whiteText ? UIColor.whiteColor : [UIColor colorWithWhite:0.2 alpha:1.0];
}
%end
%end
%hook PSEmojiLayout
+ (CGFloat)dotHeight {
return LABEL_HEIGHT;
}
%end
#if !__LP64__
%group iOS6
%hook EmojiPageControl
- (void)setHidden:(BOOL)hidden {
%orig(YES);
}
%end
%hook UIKeyboardEmojiScrollView
- (id)initWithFrame:(CGRect)frame keyboard:(UIKBTree *)keyplane key:(UIKBTree *)key state:(NSInteger)state {
self = %orig;
configureScrollView(self, frame);
return self;
}
%end
%end
#endif
%ctor {
id r = [NSDictionary dictionaryWithContentsOfFile:realPrefPath(@"com.PS.EmojiPortLegacy")][@"enabled"];
BOOL enabled = r ? [r boolValue] : YES;
if (enabled) {
%init;
if (IS_IOS_OR_NEWER(iOS_7_0)) {
%init(iOS7Up);
}
#if !__LP64__
else {
%init(iOS6);
}
#endif
}
}