mirror of
https://github.com/Burrit0z/kai
synced 2025-07-01 17:46:47 +00:00
work but trash
This commit is contained in:
@ -26,6 +26,7 @@
|
|||||||
@property (nonatomic, assign) NSInteger number;
|
@property (nonatomic, assign) NSInteger number;
|
||||||
@property (nonatomic, assign) BOOL isUpdating;
|
@property (nonatomic, assign) BOOL isUpdating;
|
||||||
+(KAIBattery *)sharedInstance;
|
+(KAIBattery *)sharedInstance;
|
||||||
|
-(void)darkLightMode;
|
||||||
-(instancetype)initWithFrame:(CGRect)arg1;
|
-(instancetype)initWithFrame:(CGRect)arg1;
|
||||||
-(void)updateBattery;
|
-(void)updateBattery;
|
||||||
@end
|
@end
|
@ -13,6 +13,7 @@ KAIBattery *instance;
|
|||||||
self.batteryLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
self.batteryLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||||
self.batteryLabel.numberOfLines = 0;*/
|
self.batteryLabel.numberOfLines = 0;*/
|
||||||
[self updateBattery];
|
[self updateBattery];
|
||||||
|
[self darkLightMode];
|
||||||
//[self addSubview:self.batteryLabel];
|
//[self addSubview:self.batteryLabel];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@ -46,7 +47,16 @@ long long lastPercentage;
|
|||||||
|
|
||||||
if(charging) {
|
if(charging) {
|
||||||
|
|
||||||
UIVisualEffectView *blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
|
UIVisualEffectView *blank;
|
||||||
|
if(@available(iOS 12.0, *)) {
|
||||||
|
if(self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
|
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
|
||||||
|
} else {
|
||||||
|
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
|
||||||
|
}
|
||||||
blank.frame = CGRectMake(0, 0 + y, self.frame.size.width, 80);
|
blank.frame = CGRectMake(0, 0 + y, self.frame.size.width, 80);
|
||||||
blank.layer.masksToBounds = YES;
|
blank.layer.masksToBounds = YES;
|
||||||
blank.layer.cornerRadius = 13;
|
blank.layer.cornerRadius = 13;
|
||||||
@ -101,6 +111,7 @@ long long lastPercentage;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.isUpdating = NO;
|
self.isUpdating = NO;
|
||||||
|
[self darkLightMode];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -109,4 +120,17 @@ long long lastPercentage;
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)darkLightMode {
|
||||||
|
for(UIVisualEffectView *view in self.subviews) {
|
||||||
|
if(@available(iOS 12.0, *)) {
|
||||||
|
if(self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
|
if([view respondsToSelector:@selector(setEffect:)]) view.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if([view respondsToSelector:@selector(setEffect:)]) view.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
62
Kai.xm
62
Kai.xm
@ -11,20 +11,26 @@
|
|||||||
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2;
|
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CSMainPageView : UIView
|
@interface CSCoverSheetViewBase : UIView
|
||||||
@property (nonatomic, strong) KAIBattery *battery;
|
@property (nonatomic, strong) KAIBattery *battery;
|
||||||
-(void)KaiUpdate;
|
-(void)KaiUpdate;
|
||||||
|
-(void)KaiInit;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface SBCoverSheetPrimarySlidingViewController
|
@interface SBCoverSheetPrimarySlidingViewController
|
||||||
-(void)KaiUpdate;
|
-(void)KaiUpdate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface CSMainPageView : UIView
|
||||||
|
@end
|
||||||
|
|
||||||
@interface _CSSingleBatteryChargingView : UIView
|
@interface _CSSingleBatteryChargingView : UIView
|
||||||
@end
|
@end
|
||||||
|
|
||||||
BOOL setFrame = NO;
|
BOOL setFrame = NO;
|
||||||
CSMainPageView *batteryWidget;
|
UIView *batteryWidgetController;
|
||||||
|
KAIBattery *batteryWidget;
|
||||||
|
CSCoverSheetViewBase *base;
|
||||||
CGRect original;
|
CGRect original;
|
||||||
CGRect originalBattery;
|
CGRect originalBattery;
|
||||||
|
|
||||||
@ -54,6 +60,18 @@ CGRect originalBattery;
|
|||||||
|
|
||||||
%end*/
|
%end*/
|
||||||
|
|
||||||
|
%hook CSMainPageView
|
||||||
|
|
||||||
|
-(void)updateForPresentation:(id)arg1 {
|
||||||
|
if(!setFrame) {
|
||||||
|
if([self.subviews count] > 0) {
|
||||||
|
CSCoverSheetViewBase *base = [self.subviews objectAtIndex:0];
|
||||||
|
[base KaiInit];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%end
|
||||||
|
|
||||||
%hook SBCoverSheetPrimarySlidingViewController
|
%hook SBCoverSheetPrimarySlidingViewController
|
||||||
|
|
||||||
-(void)viewWillAppear:(BOOL)arg1 {
|
-(void)viewWillAppear:(BOOL)arg1 {
|
||||||
@ -67,8 +85,8 @@ CGRect originalBattery;
|
|||||||
|
|
||||||
%new
|
%new
|
||||||
-(void)KaiUpdate {
|
-(void)KaiUpdate {
|
||||||
[batteryWidget.battery updateBattery];
|
[batteryWidget updateBattery];
|
||||||
[batteryWidget KaiUpdate];
|
[base KaiUpdate];
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
-(void)viewWillDisappear:(BOOL)arg1 {
|
-(void)viewWillDisappear:(BOOL)arg1 {
|
||||||
@ -79,40 +97,56 @@ CGRect originalBattery;
|
|||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%hook CSMainPageView
|
%hook CSCoverSheetViewBase
|
||||||
%property (nonatomic, strong) KAIBattery *battery;
|
%property (nonatomic, strong) KAIBattery *battery;
|
||||||
|
|
||||||
-(void)updateForPresentation:(id)arg1 {
|
-(void)traitCollectionDidChange:(id)arg1 {
|
||||||
%orig;
|
%orig;
|
||||||
|
[batteryWidget darkLightMode];
|
||||||
|
}
|
||||||
|
|
||||||
|
%new
|
||||||
|
-(void)KaiInit {
|
||||||
if(!setFrame) {
|
if(!setFrame) {
|
||||||
original = self.frame;
|
original = self.frame;
|
||||||
self.battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, self.frame.origin.y + 150, self.frame.size.width - 16, self.frame.size.height)];
|
UIView *scroller;
|
||||||
originalBattery = self.battery.frame;
|
if([self.subviews count] > 1) {
|
||||||
[self addSubview:self.battery];
|
UIView *temp = [self.subviews objectAtIndex:1];
|
||||||
|
if([temp.subviews count] > 0) {
|
||||||
|
scroller = [temp.subviews objectAtIndex:0];
|
||||||
|
base = self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KAIBattery *battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 0, self.frame.size.width - 16, self.frame.size.height)];
|
||||||
|
originalBattery = battery.frame;
|
||||||
|
[scroller addSubview:battery];
|
||||||
setFrame = YES;
|
setFrame = YES;
|
||||||
batteryWidget = self;
|
batteryWidgetController = scroller;
|
||||||
|
batteryWidget = battery;
|
||||||
}
|
}
|
||||||
[self KaiUpdate];
|
[self KaiUpdate];
|
||||||
|
[batteryWidget darkLightMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
%new
|
%new
|
||||||
-(void)KaiUpdate {
|
-(void)KaiUpdate {
|
||||||
[UIView animateWithDuration:0.3 animations:^{
|
[UIView animateWithDuration:0.3 animations:^{
|
||||||
self.frame = CGRectMake(
|
batteryWidgetController.frame = CGRectMake(
|
||||||
original.origin.x,
|
original.origin.x,
|
||||||
original.origin.y + (self.battery.number * 85),
|
original.origin.y + (batteryWidget.number * 85),
|
||||||
original.size.width,
|
original.size.width,
|
||||||
original.size.height
|
original.size.height
|
||||||
);
|
);
|
||||||
|
|
||||||
self.battery.frame = CGRectMake(
|
batteryWidget.frame = CGRectMake(
|
||||||
originalBattery.origin.x,
|
originalBattery.origin.x,
|
||||||
originalBattery.origin.y - (self.battery.number * 85) + 85,
|
originalBattery.origin.y - (batteryWidget.number * 85),
|
||||||
originalBattery.size.width,
|
originalBattery.size.width,
|
||||||
originalBattery.size.height
|
originalBattery.size.height
|
||||||
);
|
);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
[batteryWidget darkLightMode];
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user