|
|
|
|
|
|
|
|
|
|
|
|
|
|
@implementation KAIBatteryPlatter |
|
|
@implementation KAIBatteryPlatter |
|
|
|
|
|
|
|
|
-(instancetype)init { |
|
|
|
|
|
self = [super init]; |
|
|
|
|
|
|
|
|
-(instancetype)initWithFrame:(CGRect)arg1 { |
|
|
|
|
|
self = [super initWithFrame:arg1]; |
|
|
instance = self; |
|
|
instance = self; |
|
|
if (self) { |
|
|
if (self) { |
|
|
self.stack = [[KAIStackView alloc] init]; |
|
|
self.stack = [[KAIStackView alloc] init]; |
|
|
self.stack.axis = kaiAlign==0 ? 1 : 0; |
|
|
self.stack.axis = kaiAlign==0 ? 1 : 0; |
|
|
self.stack.distribution = 0; |
|
|
self.stack.distribution = 0; |
|
|
self.stack.spacing = kaiAlign==0 ? 0 : spacing; |
|
|
|
|
|
|
|
|
self.stack.spacing = kaiAlign==0 ? 0 : spacingHorizontal; |
|
|
self.stack.alignment = 0; |
|
|
self.stack.alignment = 0; |
|
|
self.oldCountOfDevices = -100; |
|
|
self.oldCountOfDevices = -100; |
|
|
self.queued = NO; |
|
|
self.queued = NO; |
|
|
|
|
|
|
|
|
|
|
|
[self setMinimumZoomScale:1]; |
|
|
|
|
|
[self setMaximumZoomScale:1]; |
|
|
[self addSubview:self.stack]; |
|
|
[self addSubview:self.stack]; |
|
|
|
|
|
[self setContentSize:self.stack.frame.size]; |
|
|
|
|
|
[self setContentOffset:CGPointMake(0,0)]; |
|
|
|
|
|
//[self setDelegate:self]; |
|
|
|
|
|
|
|
|
[self updateBattery]; |
|
|
[self updateBattery]; |
|
|
} |
|
|
} |
|
|
return self; |
|
|
return self; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
-(void)setContentOffset:(CGPoint)arg1 { |
|
|
|
|
|
[super setContentOffset:CGPointMake(arg1.x, 0)]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
-(void)setNumber:(NSInteger)arg1 { |
|
|
-(void)setNumber:(NSInteger)arg1 { |
|
|
_number = arg1; |
|
|
_number = arg1; |
|
|
[UIView animateWithDuration:0.3 animations:^{ |
|
|
[UIView animateWithDuration:0.3 animations:^{ |
|
|
|
|
|
|
|
|
self.stack.heightConstraint = [self.heightAnchor constraintEqualToConstant:(self.number * (bannerHeight + spacing))]; |
|
|
self.stack.heightConstraint = [self.heightAnchor constraintEqualToConstant:(self.number * (bannerHeight + spacing))]; |
|
|
self.heightConstraint.active = YES; |
|
|
self.heightConstraint.active = YES; |
|
|
self.stack.heightConstraint.active = YES; |
|
|
self.stack.heightConstraint.active = YES; |
|
|
|
|
|
[self setContentSize:self.stack.frame.size]; |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
int height = (self.number * (bannerHeight + spacing)); |
|
|
int height = (self.number * (bannerHeight + spacing)); |
|
|
if(kaiAlign==0 && [self.superview.subviews count]>1) { |
|
|
if(kaiAlign==0 && [self.superview.subviews count]>1) { |
|
|
height = (self.number * (bannerHeight + spacing)) - spacing; |
|
|
height = (self.number * (bannerHeight + spacing)) - spacing; |
|
|
} else { |
|
|
} else { |
|
|
height = bannerHeight; |
|
|
|
|
|
|
|
|
height = bannerHeight + spacing; |
|
|
} |
|
|
} |
|
|
self.heightConstraint.constant = height; |
|
|
self.heightConstraint.constant = height; |
|
|
self.stack.heightConstraint.constant = height; |
|
|
self.stack.heightConstraint.constant = height; |
|
|
|
|
|
|
|
|
UIStackView *s = (UIStackView *)(self.superview); |
|
|
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.frame = CGRectMake(s.frame.origin.x, s.frame.origin.y, s.frame.size.width, (s.frame.size.height - 1)); |
|
|
//literally does nothing but makes the stack view lay itself out (doesnt adjust frame because translatesAutoreszingMaskIntoConstraints = NO on stack views) |
|
|
//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)addArrangedSubview:(UIView *)view { |
|
|
|
|
|
[super addArrangedSubview:view]; |
|
|
|
|
|
|
|
|
-(void)addSubview:(UIView *)view { |
|
|
|
|
|
[super addSubview:view]; |
|
|
self.number = [self.stack.subviews count]; |
|
|
self.number = [self.stack.subviews count]; |
|
|
if([self.superview.superview.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) { |
|
|
if([self.superview.superview.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) { |
|
|
[(NCNotificationListView *)(self.superview.superview.superview) fixComplicationsViewFrame]; |
|
|
[(NCNotificationListView *)(self.superview.superview.superview) fixComplicationsViewFrame]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(textColor==0) { |
|
|
|
|
|
|
|
|
if(textColor==0 && [view respondsToSelector:@selector(updateInfo)]) { |
|
|
KAIBatteryCell *cell = (KAIBatteryCell *)view; |
|
|
KAIBatteryCell *cell = (KAIBatteryCell *)view; |
|
|
if(@available(iOS 12.0, *)) { |
|
|
if(@available(iOS 12.0, *)) { |
|
|
if(self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { |
|
|
if(self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
-(void)removeArrangedSubview:(UIView *)view { |
|
|
|
|
|
[super removeArrangedSubview:view]; |
|
|
|
|
|
self.number = [self.stack.subviews count]; |
|
|
|
|
|
|
|
|
-(void)layoutSubviews { |
|
|
if([self.superview.superview.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) { |
|
|
if([self.superview.superview.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) { |
|
|
[(NCNotificationListView *)(self.superview.superview.superview) fixComplicationsViewFrame]; |
|
|
[(NCNotificationListView *)(self.superview.superview.superview) fixComplicationsViewFrame]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
-(void)refreshForPrefs { |
|
|
-(void)refreshForPrefs { |
|
|
|
|
|
self.stack.spacing = kaiAlign==0 ? 0 : spacingHorizontal; |
|
|
|
|
|
[self setContentSize:self.stack.frame.size]; |
|
|
for( UIView *view in self.stack.subviews ) { |
|
|
for( UIView *view in self.stack.subviews ) { |
|
|
@try { |
|
|
@try { |
|
|
[view removeFromSuperview]; |
|
|
[view removeFromSuperview]; |