mirror of
https://github.com/Burrit0z/kai
synced 2025-06-30 21:26:47 +00:00
better management of adding and removing platter
This commit is contained in:
@ -132,7 +132,10 @@ long long lastPercentage;
|
||||
self.number = [self.stack.subviews count];
|
||||
|
||||
if(self.number==0) {
|
||||
[(UIStackView *)(self.superview) removeArrangedSubview:self];
|
||||
UIStackView *s = (UIStackView *)(self.superview);
|
||||
s.frame = CGRectMake(s.frame.origin.x, s.frame.origin.y, s.frame.size.width, (s.frame.size.height - 1));
|
||||
[s removeArrangedSubview:self];
|
||||
[self removeFromSuperview];
|
||||
} else if(self.number!=0 && self.superview == nil) {
|
||||
[[[[objc_getClass("CSAdjunctListView") class] sharedListViewForKai] stackView] addArrangedSubview:self];
|
||||
//[self performSelector:@selector(calculateHeight) withObject:self afterDelay:0.1];
|
||||
@ -142,9 +145,17 @@ long long lastPercentage;
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
|
||||
if(!self.heightConstraint) {
|
||||
int height = (self.number * (bannerHeight + spacing));
|
||||
if(kaiAlign!=0) {
|
||||
height = bannerHeight + spacing;
|
||||
}
|
||||
|
||||
self.heightConstraint = [self.heightAnchor constraintEqualToConstant:(self.number * (bannerHeight + spacing))];
|
||||
self.stack.heightConstraint = [self.heightAnchor constraintEqualToConstant:(self.number * (bannerHeight + spacing))];
|
||||
if([self.superview.subviews count]>1) {
|
||||
height = (height - spacing) + 1;
|
||||
}
|
||||
|
||||
self.heightConstraint = [self.heightAnchor constraintEqualToConstant:height];
|
||||
self.stack.heightConstraint = [self.heightAnchor constraintEqualToConstant:height];
|
||||
self.heightConstraint.active = YES;
|
||||
self.stack.heightConstraint.active = YES;
|
||||
[self setContentSize:self.stack.frame.size];
|
||||
@ -166,7 +177,10 @@ long long lastPercentage;
|
||||
//literally does nothing but makes the stack view lay itself out (doesnt adjust frame because translatesAutoreszingMaskIntoConstraints = NO on stack views)
|
||||
}
|
||||
|
||||
[self setContentSize:self.stack.frame.size];
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)refreshForPrefs {
|
||||
|
6
Kai.xm
6
Kai.xm
@ -16,6 +16,9 @@ CSAdjunctListView *list;
|
||||
//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];
|
||||
}
|
||||
|
||||
if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
|
||||
@ -74,7 +77,6 @@ CSAdjunctListView *list;
|
||||
}
|
||||
if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
|
||||
[KAISelf.superview performSelector:@selector(fixComplicationsViewFrame) withObject:KAISelf.superview afterDelay:0.35];
|
||||
//[KAISelf.superview performSelector:@selector(fixComplicationsViewFrame) withObject:KAISelf.superview afterDelay:0.5];
|
||||
}
|
||||
|
||||
isUpdating = NO;
|
||||
@ -106,11 +108,9 @@ CSAdjunctListView *list;
|
||||
}
|
||||
|
||||
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
|
||||
//if([self isMemberOfClass:[objc_getClass("BCBatteryDevice") class]] && [self respondsToSelector:@selector(_kaiCell)] && object == self && ([keyPath isEqualToString:@"charging"] || [keyPath isEqualToString:@"percentCharge"] || [keyPath isEqualToString:@"batterySaverModeActive"])) {
|
||||
|
||||
//sends the noti to update battery info
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user