1
0
mirror of https://github.com/Burrit0z/kai synced 2025-07-01 14:06:47 +00:00
This commit is contained in:
Burrit0z
2020-05-18 11:09:22 -04:00
parent 3515d43797
commit e7c0f5543c

48
Kai.xm
View File

@ -41,20 +41,25 @@ CGRect originalBattery;
%property (nonatomic, assign) BOOL hasKai; %property (nonatomic, assign) BOOL hasKai;
%property (nonatomic, assign) NSInteger previousKaiCount; %property (nonatomic, assign) NSInteger previousKaiCount;
-(id)initWithFrame:(CGRect)arg1 { -(void)layoutSubviews {
original = self.frame; //%orig;
if(!self.hasKai) {
original = self.superview.superview.frame;
self.battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 0, self.frame.size.width - 16, UIScreen.mainScreen.bounds.size.width)]; self.battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 0, self.frame.size.width - 16, UIScreen.mainScreen.bounds.size.width)];
originalBattery = self.battery.frame; originalBattery = self.battery.frame;
[self addSubview:self.battery]; [self addSubview:self.battery];
setFrame = YES; setFrame = YES;
self.previousKaiCount = 0; self.previousKaiCount = 0;
self.hasKai = YES;
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(KaiUpdate) selector:@selector(KaiUpdate)
name:@"KaiInfoChanged" name:@"KaiInfoChanged"
object:nil]; object:nil];
//[self KaiUpdate];
[self.battery darkLightMode]; [self.battery darkLightMode];
}
[self KaiUpdate];
return %orig; return %orig;
} }
@ -63,24 +68,31 @@ CGRect originalBattery;
-(void)KaiUpdate { -(void)KaiUpdate {
if(self.battery) { if(self.battery) {
[self.battery updateBattery]; [self.battery updateBattery];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.3 animations:^{ [UIView animateWithDuration:0.3 animations:^{
self.translatesAutoresizingMaskIntoConstraints = NO; //self.translatesAutoresizingMaskIntoConstraints = NO;
[self.topAnchor constraintEqualToAnchor:self.superview.topAnchor constant:(self.battery.number * 85)].active = YES; // [self.topAnchor constraintEqualToAnchor:self.superview.topAnchor constant:(self.battery.number * 85)].active = YES;
self.battery.frame = CGRectMake( self.superview.superview.frame = CGRectMake(
originalBattery.origin.x, original.origin.x,
originalBattery.origin.y - (self.battery.number * 85), original.origin.y + (self.battery.number * 85),
originalBattery.size.width, original.size.width,
originalBattery.size.height original.size.height
); );
}];
[self.battery darkLightMode]; /*self.battery.frame = CGRectMake(
}); originalBattery.origin.x,
originalBattery.origin.y - (self.battery.number * 85),
originalBattery.size.width,
originalBattery.size.height
);*/
}];
[self.battery darkLightMode];
});
} }
} }