1
0
mirror of https://github.com/Burrit0z/kai synced 2025-07-04 11:16:49 +00:00

CENTER % LABEL

This commit is contained in:
Burrit0z
2020-06-03 14:42:33 -04:00
parent ffd3608f2c
commit 86aa53089b
4 changed files with 29 additions and 18 deletions

View File

@ -126,23 +126,23 @@
[self.glyphView.heightAnchor constraintEqualToConstant:glyphSize].active = YES; [self.glyphView.heightAnchor constraintEqualToConstant:glyphSize].active = YES;
self.battery.translatesAutoresizingMaskIntoConstraints = NO; self.battery.translatesAutoresizingMaskIntoConstraints = NO;
[self.battery.leftAnchor constraintEqualToAnchor:blurPlatter.rightAnchor constant:(- 49)].active = YES; [self.battery.rightAnchor constraintEqualToAnchor:blurPlatter.rightAnchor constant:- 20.5].active = YES;
[self.battery.centerYAnchor constraintEqualToAnchor:blurPlatter.centerYAnchor].active = YES; [self.battery.centerYAnchor constraintEqualToAnchor:blurPlatter.centerYAnchor].active = YES;
[self.battery.widthAnchor constraintEqualToConstant:20].active = YES; [self.battery.widthAnchor constraintEqualToConstant:20].active = YES;
[self.battery.heightAnchor constraintEqualToConstant:10].active = YES; [self.battery.heightAnchor constraintEqualToConstant:10].active = YES;
if(!hideDeviceLabel) {
[self.percentLabel.rightAnchor constraintEqualToAnchor:self.battery.leftAnchor constant:-4.5].active = YES; [self.percentLabel.rightAnchor constraintEqualToAnchor:self.battery.leftAnchor constant:-4.5].active = YES;
} else if(hideDeviceLabel) {
[self.percentLabel.centerXAnchor constraintEqualToAnchor:blurPlatter.centerXAnchor].active = YES;
}
if(hidePercent) { if(hidePercent) {
[self.label.rightAnchor constraintEqualToAnchor:self.battery.leftAnchor constant:-4.5].active = YES; [self.label.rightAnchor constraintEqualToAnchor:self.battery.leftAnchor constant:-4.5].active = YES;
} }
[self.heightAnchor constraintEqualToConstant:(bannerHeight + spacing)].active = YES; [self.heightAnchor constraintEqualToConstant:(bannerHeight + spacing)].active = YES;
if(kaiAlign==0) {
[self.widthAnchor constraintEqualToConstant:(self.frame.size.width)].active = YES;
} else {
[self.widthAnchor constraintEqualToAnchor:blurPlatter.widthAnchor].active = YES; [self.widthAnchor constraintEqualToAnchor:blurPlatter.widthAnchor].active = YES;
}
} }

View File

@ -159,11 +159,18 @@ long long lastPercentage;
self.heightConstraint.active = YES; self.heightConstraint.active = YES;
self.stack.heightConstraint.active = YES; self.stack.heightConstraint.active = YES;
[self setContentSize:self.stack.frame.size]; [self setContentSize:self.stack.frame.size];
if(kaiAlign==0) {
[self.stack.widthAnchor constraintEqualToAnchor:self.widthAnchor].active = YES;
} else {
self.widthConstraint = [self.widthAnchor constraintEqualToConstant:(self.number * (self.frame.size.width + bannerWidthFactor))];
self.widthConstraint.active = YES;
}
} else { } else {
int height = (self.number * (bannerHeight + spacing)); int height = (self.number * (bannerHeight + spacing));
if(kaiAlign!=0) { if(kaiAlign!=0) {
height = bannerHeight + spacing; height = bannerHeight + spacing;
self.widthConstraint.constant = (self.number * (self.frame.size.width + bannerWidthFactor));
} }
if([self.superview.subviews count]>1) { if([self.superview.subviews count]>1) {

View File

@ -6,6 +6,7 @@
@property (nonatomic, assign) NSInteger number; @property (nonatomic, assign) NSInteger number;
@property (nonatomic, assign) NSInteger oldCountOfDevices; @property (nonatomic, assign) NSInteger oldCountOfDevices;
@property (nonatomic, strong) NSLayoutConstraint *heightConstraint; @property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
@property (nonatomic, strong) NSLayoutConstraint *widthConstraint;
@property (nonatomic, strong) KAIStackView *stack; @property (nonatomic, strong) KAIStackView *stack;
@property (nonatomic, assign) BOOL isUpdating; @property (nonatomic, assign) BOOL isUpdating;
@property (nonatomic, assign) BOOL queued; @property (nonatomic, assign) BOOL queued;

7
Kai.xm
View File

@ -11,15 +11,18 @@ CSAdjunctListView *list;
-(void)_layoutStackView { -(void)_layoutStackView {
//this code is used to determine if kai is at the bottom of the stack view //this code is used to determine if kai is at the bottom of the stack view
@try {
if([[self stackView].subviews objectAtIndex:([[self stackView].subviews count] -1)] != [KAIBatteryPlatter sharedInstance] && belowMusic) { if([[self stackView].subviews objectAtIndex:([[self stackView].subviews count] -1)] != [KAIBatteryPlatter sharedInstance] && belowMusic) {
//if it is not, but the option to have kai below music is on, i simply remove from it's current pos. //if it is not, but the option to have kai below music is on, i simply remove from it's current pos.
//and insert into last slot. //and insert into last slot.
[[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]]; [[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
[[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:([[self stackView].subviews count] -1)]; [[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:([[self stackView].subviews count] -1)];
} else if([[self stackView].subviews objectAtIndex:0] != [KAIBatteryPlatter sharedInstance] && !belowMusic) { }/* else if([[self stackView].subviews objectAtIndex:0] != [KAIBatteryPlatter sharedInstance] && !belowMusic) {
[[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]]; [[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
[[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:0]; [[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:0];
} }*/
} @catch (NSException *exc) {}
if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) { if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
[(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame]; [(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame];