-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTweak.xm
executable file
·83 lines (67 loc) · 2.39 KB
/
Tweak.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
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
@interface UIView (Tweak)
- (id)_viewControllerForAncestor;
@end
@interface BCUIChargeRing : UIView
@property(nonatomic, assign, readwrite) NSInteger *percentCharge;
@property(nonatomic, retain) UILabel *ringPercentLabel;
@end
@interface BCUIGlyphImageView : UIImageView
@end
@implementation BCUIGlyphImageView
@end
%hook BCUIGlyphImageView
-(void)setFrame:(CGRect)arg1
{
if (([self.superview class] == objc_getClass("BCUIChargeRing")) && arg1.origin.y >= 0 && ([[self _viewControllerForAncestor] isKindOfClass:%c(BCUI2x2AvocadoViewController)]))
{
arg1.origin.y = 20;
//Attempt to fix the huge bluetooth icon by standardizing the size
BCUIChargeRing *parentView = (BCUIChargeRing*)self.superview;
double standardSize = parentView.frame.size.height - 26;
arg1.origin.x = parentView.frame.size.width/2 - standardSize/2;
arg1.size.width = standardSize;
arg1.size.height = standardSize;
}
%orig;
}
%end
%hook BCUIChargeRing
%property (nonatomic, retain) UILabel *ringPercentLabel;
-(id)_glyphImageView {
UIImageView *orig = %orig;
object_setClass(orig, [BCUIGlyphImageView class]);
return orig;
}
-(void)setGlyph:(id)arg1
{
%orig;
if(!self.ringPercentLabel && ([[self _viewControllerForAncestor] isKindOfClass:%c(BCUI2x2AvocadoViewController)])){
self.ringPercentLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[self addSubview:self.ringPercentLabel];
//Add constraints to the label
self.ringPercentLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.ringPercentLabel.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
[self.ringPercentLabel.topAnchor constraintEqualToAnchor:self.topAnchor constant:7].active = YES;
[self.ringPercentLabel.widthAnchor constraintEqualToConstant:40].active = YES;
[self.ringPercentLabel.heightAnchor constraintEqualToConstant:20].active = YES;
[self.ringPercentLabel setFont:[UIFont boldSystemFontOfSize:12]];
self.ringPercentLabel.text = [NSString stringWithFormat:@"%ld", (long)self.percentCharge];
[self.ringPercentLabel sizeToFit];
self.ringPercentLabel.textAlignment = NSTextAlignmentCenter;
}
}
-(void)setPercentCharge:(int)arg1
{
%orig;
if (self.ringPercentLabel)
{
if (arg1 > 0)
{
self.ringPercentLabel.text = [NSString stringWithFormat:@"%d", arg1];
self.ringPercentLabel.hidden = NO;
}
else
self.ringPercentLabel.hidden = YES;
}
}
%end