mirror of
https://github.com/Burrit0z/kai
synced 2025-07-06 16:36:47 +00:00
alpha 0.1.0
This commit is contained in:
@ -13,7 +13,6 @@ KAIBattery *instance;
|
||||
[self.widthAnchor constraintEqualToConstant:UIScreen.mainScreen.bounds.size.width - 16].active = YES;
|
||||
[self.heightAnchor constraintEqualToConstant:(self.number * 85)].active = YES;*/
|
||||
[self updateBattery];
|
||||
[self darkLightMode];
|
||||
self.userInteractionEnabled = NO;
|
||||
//[self addSubview:self.batteryLabel];
|
||||
}
|
||||
@ -46,30 +45,35 @@ long long lastPercentage;
|
||||
BOOL charging = MSHookIvar<long long>(device, "_charging");
|
||||
BOOL LPM = MSHookIvar<BOOL>(device, "_batterySaverModeActive");
|
||||
|
||||
if(charging) {
|
||||
BOOL shouldAdd = NO;
|
||||
|
||||
/*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 {
|
||||
if(showAll) {
|
||||
shouldAdd = YES;
|
||||
} else if(!showAll && charging) {
|
||||
shouldAdd = YES;
|
||||
}
|
||||
|
||||
if(shouldAdd) {
|
||||
UIView *blank;
|
||||
if(bannerStyle==1) {
|
||||
blank = [[[objc_getClass("MTMaterialView") class] alloc] _initWithRecipe:1 configuration:1 initialWeighting:1 scaleAdjustment:nil];
|
||||
} else if(bannerStyle==2) {
|
||||
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
|
||||
} else if(bannerStyle==3) {
|
||||
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
|
||||
}*/
|
||||
MTMaterialView *blank = [[[objc_getClass("MTMaterialView") class] alloc] _initWithRecipe:1 configuration:1 initialWeighting:1 scaleAdjustment:nil];
|
||||
//blank.recipeDynamic = NO; //makes it stay light
|
||||
blank.frame = CGRectMake(0, 0 + y, self.superview.bounds.size.width - 16, bannerHeight);
|
||||
}
|
||||
blank.layer.masksToBounds = YES;
|
||||
blank.layer.continuousCorners = YES;
|
||||
blank.layer.cornerRadius = cornerRadius;
|
||||
//[blank setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1]];
|
||||
|
||||
NSString *labelText = [NSString stringWithFormat:@"%@", deviceName];
|
||||
|
||||
UILabel *label = [[UILabel alloc] init];
|
||||
if(!hideDeviceLabel) {
|
||||
[label setFont:[UIFont systemFontOfSize:16]];
|
||||
} else if(hideDeviceLabel) {
|
||||
[label setFont:[UIFont systemFontOfSize:0]];
|
||||
}
|
||||
[label setTextColor:[UIColor whiteColor]];
|
||||
label.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
label.numberOfLines = 0;
|
||||
@ -108,11 +112,31 @@ long long lastPercentage;
|
||||
[self addSubview:battery];
|
||||
[self addSubview:glyphView];
|
||||
|
||||
blank.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
if(bannerAlign==2) { //center
|
||||
[blank.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
|
||||
} else if(bannerAlign==1) { //left
|
||||
[blank.leftAnchor constraintEqualToAnchor:self.leftAnchor].active = YES;
|
||||
} else if(bannerAlign==3) { //right
|
||||
[blank.rightAnchor constraintEqualToAnchor:self.rightAnchor].active = YES;
|
||||
}
|
||||
[blank.topAnchor constraintEqualToAnchor:self.topAnchor constant:y].active = YES;
|
||||
[blank.widthAnchor constraintEqualToConstant:((self.superview.bounds.size.width - 16) + bannerWidthFactor)].active = YES;
|
||||
[blank.heightAnchor constraintEqualToConstant:bannerHeight].active = YES;
|
||||
|
||||
|
||||
//percentLabel.frame = CGRectMake(self.superview.bounds.size.width - 16 - 94,35 + y,36,12);
|
||||
percentLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[percentLabel.leftAnchor constraintEqualToAnchor:blank.rightAnchor constant:(- 94)].active = YES;
|
||||
[percentLabel.centerYAnchor constraintEqualToAnchor:blank.centerYAnchor].active = YES;
|
||||
[percentLabel.widthAnchor constraintEqualToConstant:36].active = YES;
|
||||
[percentLabel.heightAnchor constraintEqualToConstant:12].active = YES;
|
||||
|
||||
//label.frame = CGRectMake(65.5,27.5 + y,275,25);
|
||||
label.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[label.leftAnchor constraintEqualToAnchor:glyphView.rightAnchor constant:4.5].active = YES;
|
||||
[label.centerYAnchor constraintEqualToAnchor:blank.centerYAnchor].active = YES;
|
||||
[label.widthAnchor constraintEqualToConstant:275].active = YES;
|
||||
[label.rightAnchor constraintEqualToAnchor:percentLabel.leftAnchor constant:7].active = YES;
|
||||
[label.heightAnchor constraintEqualToConstant:25].active = YES;
|
||||
|
||||
//glyphView.frame = CGRectMake(20.5,18.5 + y,40,40);
|
||||
@ -126,18 +150,11 @@ long long lastPercentage;
|
||||
//battery.frame = CGRectMake(self.superview.bounds.size.width - 16 - 49,35 + y,20,10);
|
||||
|
||||
battery.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[battery.leftAnchor constraintEqualToAnchor:self.rightAnchor constant:(- 49)].active = YES;
|
||||
[battery.leftAnchor constraintEqualToAnchor:blank.rightAnchor constant:(- 49)].active = YES;
|
||||
[battery.centerYAnchor constraintEqualToAnchor:blank.centerYAnchor].active = YES;
|
||||
[battery.widthAnchor constraintEqualToConstant:20].active = YES;
|
||||
[battery.heightAnchor constraintEqualToConstant:10].active = YES;
|
||||
|
||||
//percentLabel.frame = CGRectMake(self.superview.bounds.size.width - 16 - 94,35 + y,36,12);
|
||||
percentLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[percentLabel.leftAnchor constraintEqualToAnchor:self.rightAnchor constant:(- 94)].active = YES;
|
||||
[percentLabel.centerYAnchor constraintEqualToAnchor:blank.centerYAnchor].active = YES;
|
||||
[percentLabel.widthAnchor constraintEqualToConstant:36].active = YES;
|
||||
[percentLabel.heightAnchor constraintEqualToConstant:12].active = YES;
|
||||
|
||||
y+=bannerHeight + spacing;
|
||||
self.number +=1;
|
||||
//blank.alpha = 0.8;
|
||||
@ -145,7 +162,6 @@ long long lastPercentage;
|
||||
}
|
||||
//[self.heightAnchor constraintEqualToConstant:(self.number * 85)].active = YES;
|
||||
self.isUpdating = NO;
|
||||
[self darkLightMode];
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -154,17 +170,4 @@ long long lastPercentage;
|
||||
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
|
Reference in New Issue
Block a user