[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; | ||||
[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) { | 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; | |||||
} | } | ||||
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) { |
@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; |
-(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 | ||||
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)]) { | if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) { | ||||
[(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame]; | |||||
} | |||||
[(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame]; | |||||
} | |||||
[[KAIBatteryPlatter sharedInstance] calculateHeight]; | [[KAIBatteryPlatter sharedInstance] calculateHeight]; | ||||