Browse Source

CENTER % LABEL

pull/1/head
Burrit0z 4 years ago
parent
commit
86aa53089b
4 changed files with 29 additions and 18 deletions
  1. +7
    -7
      KAIBatteryCell.mm
  2. +7
    -0
      KAIBatteryPlatter.mm
  3. +1
    -0
      KAIStackView.h
  4. +14
    -11
      Kai.xm

+ 7
- 7
KAIBatteryCell.mm View File

@@ -126,23 +126,23 @@
[self.glyphView.heightAnchor constraintEqualToConstant:glyphSize].active = YES;

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.widthAnchor constraintEqualToConstant:20].active = YES;
[self.battery.heightAnchor constraintEqualToConstant:10].active = YES;

[self.percentLabel.rightAnchor constraintEqualToAnchor:self.battery.leftAnchor constant:-4.5].active = YES;
if(!hideDeviceLabel) {
[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) {
[self.label.rightAnchor constraintEqualToAnchor:self.battery.leftAnchor constant:-4.5].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;

}


+ 7
- 0
KAIBatteryPlatter.mm View File

@@ -159,11 +159,18 @@ long long lastPercentage;
self.heightConstraint.active = YES;
self.stack.heightConstraint.active = YES;
[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 {
int height = (self.number * (bannerHeight + spacing));
if(kaiAlign!=0) {
height = bannerHeight + spacing;
self.widthConstraint.constant = (self.number * (self.frame.size.width + bannerWidthFactor));
}

if([self.superview.subviews count]>1) {

+ 1
- 0
KAIStackView.h View File

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

+ 14
- 11
Kai.xm View File

@@ -11,19 +11,22 @@ CSAdjunctListView *list;
-(void)_layoutStackView {

//this code is used to determine if kai is at the bottom of the stack view
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.
//and insert into last slot.
[[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
[[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:([[self stackView].subviews count] -1)];
} else if([[self stackView].subviews objectAtIndex:0] != [KAIBatteryPlatter sharedInstance] && !belowMusic) {
[[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
[[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:0];
}
@try {
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.
//and insert into last slot.
[[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
[[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:([[self stackView].subviews count] -1)];
}/* else if([[self stackView].subviews objectAtIndex:0] != [KAIBatteryPlatter sharedInstance] && !belowMusic) {
[[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
[[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:0];
}*/

} @catch (NSException *exc) {}

if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
[(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame];
}
[(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame];
}

[[KAIBatteryPlatter sharedInstance] calculateHeight];


Loading…
Cancel
Save