1
0
mirror of https://github.com/Burrit0z/kai synced 2025-07-01 17:06:47 +00:00

almost good

This commit is contained in:
Burrit0z
2020-05-03 10:52:03 -04:00
parent 69bb08d6d1
commit 4043dad2e3

72
Kai.xm
View File

@ -28,8 +28,13 @@
@interface _CSSingleBatteryChargingView : UIView @interface _CSSingleBatteryChargingView : UIView
@end @end
@interface NCNotificationListView : UIView
@property (nonatomic, assign) BOOL hasKai;
@property (nonatomic, assign) NSInteger previousKaiCount;
@end
BOOL setFrame = NO; BOOL setFrame = NO;
UIView *batteryWidgetController; NCNotificationListView *batteryWidgetController;
KAIBattery *batteryWidget; KAIBattery *batteryWidget;
CSCoverSheetViewBase *base; CSCoverSheetViewBase *base;
CGRect original; CGRect original;
@ -70,7 +75,7 @@ CGRect originalBattery;
[base KaiInit]; [base KaiInit];
} }
} }
[base KaiUpdate]; //[base KaiUpdate];
} }
%end %end
@ -83,7 +88,7 @@ CGRect originalBattery;
name:@"KaiInfoChanged" name:@"KaiInfoChanged"
object:nil]; object:nil];
[self KaiUpdate]; //[self KaiUpdate];
} }
@ -105,17 +110,17 @@ CGRect originalBattery;
-(void)setNeedsLayout { -(void)setNeedsLayout {
%orig; %orig;
[self KaiUpdate]; //[self KaiUpdate];
} }
%new %new
-(void)KaiInit { -(void)KaiInit {
if(!setFrame) { if(!setFrame) {
UIView *scroller; NCNotificationListView *scroller;
if([self.subviews count] > 1) { if([self.subviews count] > 1) {
UIView *temp = [self.subviews objectAtIndex:1]; UIView *temp = [self.subviews objectAtIndex:1];
if([temp.subviews count] > 0) { if([temp.subviews count] > 0) {
scroller = [temp.subviews objectAtIndex:0]; scroller = [[temp.subviews objectAtIndex:0].subviews objectAtIndex:0];
base = self; base = self;
} }
} }
@ -130,6 +135,7 @@ CGRect originalBattery;
setFrame = YES; setFrame = YES;
batteryWidgetController = scroller; batteryWidgetController = scroller;
batteryWidget = battery; batteryWidget = battery;
batteryWidgetController.previousKaiCount = 0;
} }
[self KaiUpdate]; [self KaiUpdate];
[batteryWidget darkLightMode]; [batteryWidget darkLightMode];
@ -137,18 +143,27 @@ CGRect originalBattery;
%new %new
-(void)KaiUpdate { -(void)KaiUpdate {
dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.3 animations:^{ [UIView animateWithDuration:0.3 animations:^{
/*UIView *notiView; /*UIView *notiView;
if([self.subviews count] > 0) { if([self.subviews count] > 0) {
notiView = [self.subviews objectAtIndex:0]; notiView = [self.subviews objectAtIndex:0];
}*/ }*/
batteryWidgetController.frame = CGRectMake( batteryWidgetController.translatesAutoresizingMaskIntoConstraints = NO;
original.origin.x,
original.origin.y + (batteryWidget.number * 85), for(UIView *view in batteryWidgetController.subviews) {
original.size.width, view.bounds = CGRectMake(
original.size.height view.bounds.origin.x,
view.bounds.origin.y - (batteryWidget.number * 85) + (batteryWidgetController.previousKaiCount * 85),
view.bounds.size.width,
view.bounds.size.height
); );
}
batteryWidgetController.previousKaiCount = batteryWidget.number;
/*[batteryWidgetController.topAnchor constraintEqualToAnchor:batteryWidgetController.superview.topAnchor constant:(batteryWidget.number * 85)].active = YES;
batteryWidgetController.translatesAutoresizingMaskIntoConstraints = NO;*/
batteryWidget.frame = CGRectMake( batteryWidget.frame = CGRectMake(
originalBattery.origin.x, originalBattery.origin.x,
@ -158,15 +173,48 @@ CGRect originalBattery;
); );
}]; }];
[batteryWidget darkLightMode]; [batteryWidget darkLightMode];
});
} }
%end %end
%hook NCNotificationListView
%property (nonatomic, assign) BOOL hasKai;
%property (nonatomic, assign) NSInteger previousKaiCount;
//-(void)setBounds:(CGRect)arg1 {
/*if(batteryWidgetController==self) {
arg1 = (CGRectMake(
original.origin.x,
original.origin.y - (batteryWidget.number * 85),
original.size.width,
original.size.height
));
batteryWidget.frame = CGRectMake(
originalBattery.origin.x,
originalBattery.origin.y - (batteryWidget.number * 85),
originalBattery.size.width,
originalBattery.size.height
);
[batteryWidget darkLightMode];
}*/
// %orig;
//}
%end
%hook BCBatteryDevice %hook BCBatteryDevice
- (id)initWithIdentifier:(id)arg1 vendor:(long long)arg2 productIdentifier:(long long)arg3 parts:(unsigned long long)arg4 matchIdentifier:(id)arg5 { - (id)initWithIdentifier:(id)arg1 vendor:(long long)arg2 productIdentifier:(long long)arg3 parts:(unsigned long long)arg4 matchIdentifier:(id)arg5 {
[self addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil]; [self addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"charging" options:NSKeyValueObservingOptionNew context:nil]; [self addObserver:self forKeyPath:@"charging" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"powerSourceState" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"batterySaverModeActive" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"percentCharge" options:NSKeyValueObservingOptionNew context:nil];
//[self setValue:@"crash" forKeyPath:@"euhidehuud"]; //[self setValue:@"crash" forKeyPath:@"euhidehuud"];