Browse Source

im so done, at least stack view works

pull/1/head
Burrit0z 4 years ago
parent
commit
b8d14801b6
3 changed files with 19 additions and 8 deletions
  1. +3
    -3
      KAIBatteryCell.mm
  2. +1
    -1
      KAIBatteryStack.mm
  3. +15
    -4
      Kai.xm

+ 3
- 3
KAIBatteryCell.mm View File

if(self && device!=nil) { if(self && device!=nil) {


self.device = device; self.device = device;
NSString *deviceName = device.name; NSString *deviceName = device.name;
double batteryPercentage = device.percentCharge; double batteryPercentage = device.percentCharge;
BOOL charging = device.charging;
BOOL LPM = device.batterySaverModeActive;
BOOL charging = MSHookIvar<long long>(device, "_charging");
BOOL LPM = MSHookIvar<BOOL>(device, "_batterySaverModeActive");


UIView *blank; UIView *blank;
if(bannerStyle==1) { if(bannerStyle==1) {

+ 1
- 1
KAIBatteryStack.mm View File

self.displayingDevices = [[NSMutableArray alloc] init]; self.displayingDevices = [[NSMutableArray alloc] init];
self.axis = 1; self.axis = 1;
self.distribution = 0; self.distribution = 0;
self.spacing = spacing;
self.spacing = 0;
self.alignment = 0; self.alignment = 0;
[self updateBattery]; [self updateBattery];
//self.clipsToBounds = YES; //self.clipsToBounds = YES;

+ 15
- 4
Kai.xm View File

} }


-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if(self && self.kaiCell == nil) {
self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,0,0) device:self]; }
((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO;
[((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight].active = YES;
@try {
if([self isMemberOfClass:[objc_getClass("BCBatteryDevice") class]] && [self respondsToSelector:@selector(_kaiCell)]) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{

if(self && self.kaiCell == nil) {
self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; }
((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO;
[((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight + spacing].active = YES;

//sends the noti to update battery info //sends the noti to update battery info
[[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
[(KAIBatteryCell *)self.kaiCell updateInfo]; [(KAIBatteryCell *)self.kaiCell updateInfo];
} }


}); });
}
} @catch (NSException *exc) {}
} }

%new
-(id)_kaiCell {
return self.kaiCell;
}
%end %end


%hook KAICSTarget //Again, not a class %hook KAICSTarget //Again, not a class

Loading…
Cancel
Save