mirror of
https://github.com/Burrit0z/kai
synced 2025-07-05 22:46:47 +00:00
align the view, right align is broken
This commit is contained in:
@ -8,6 +8,7 @@ NSTimer *queueTimer = nil;
|
|||||||
self = [super initWithFrame:arg1];
|
self = [super initWithFrame:arg1];
|
||||||
instance = self;
|
instance = self;
|
||||||
if (self) {
|
if (self) {
|
||||||
|
self.stackHolder = [[UIView alloc] initWithFrame:arg1];
|
||||||
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;
|
||||||
@ -15,13 +16,33 @@ NSTimer *queueTimer = nil;
|
|||||||
self.stack.alignment = 0;
|
self.stack.alignment = 0;
|
||||||
self.oldCountOfDevices = -100;
|
self.oldCountOfDevices = -100;
|
||||||
self.queued = NO;
|
self.queued = NO;
|
||||||
|
|
||||||
[self setMinimumZoomScale:1];
|
[self setMinimumZoomScale:1];
|
||||||
[self setMaximumZoomScale:1];
|
[self setMaximumZoomScale:1];
|
||||||
[self addSubview:self.stack];
|
[self addSubview:self.stackHolder];
|
||||||
|
[self.stackHolder addSubview:self.stack];
|
||||||
[self setContentSize:self.stack.frame.size];
|
[self setContentSize:self.stack.frame.size];
|
||||||
[self setContentOffset:CGPointMake(0,0)];
|
[self setContentOffset:CGPointMake(0,0)];
|
||||||
|
|
||||||
|
//Keeping this link here to leak...
|
||||||
|
//https://cdn.discordapp.com/attachments/683698397634756646/718122118990266518/unknown.png
|
||||||
|
|
||||||
|
self.stackHolder.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
|
||||||
|
if(bannerAlign==2) { //center
|
||||||
|
self.subviewAligner = [self.stackHolder.centerXAnchor constraintEqualToAnchor:self.centerXAnchor];
|
||||||
|
} else if(bannerAlign==1) { //left
|
||||||
|
self.subviewAligner = [self.stackHolder.leftAnchor constraintEqualToAnchor:self.leftAnchor];
|
||||||
|
} else if(bannerAlign==3) { //right
|
||||||
|
self.subviewAligner = [self.stackHolder.rightAnchor constraintEqualToAnchor:self.rightAnchor];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self.stackHolder.heightAnchor constraintEqualToAnchor:self.heightAnchor].active = YES;
|
||||||
|
[self.stackHolder.widthAnchor constraintEqualToAnchor:self.stack.widthAnchor].active = YES;
|
||||||
|
[self.stackHolder.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
|
||||||
|
|
||||||
|
self.subviewAligner.active = YES;
|
||||||
|
|
||||||
[self updateBattery];
|
[self updateBattery];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@ -191,9 +212,12 @@ long long lastPercentage;
|
|||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
self.stackHolder.frame = self.frame;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)refreshForPrefs {
|
-(void)refreshForPrefs {
|
||||||
|
|
||||||
self.stack.spacing = kaiAlign==0 ? 0 : spacingHorizontal;
|
self.stack.spacing = kaiAlign==0 ? 0 : spacingHorizontal;
|
||||||
[self setContentSize:self.stack.frame.size];
|
[self setContentSize:self.stack.frame.size];
|
||||||
for( UIView *view in self.stack.subviews ) {
|
for( UIView *view in self.stack.subviews ) {
|
||||||
@ -210,6 +234,18 @@ long long lastPercentage;
|
|||||||
[device resetKaiCellForNewPrefs];
|
[device resetKaiCellForNewPrefs];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.subviewAligner.active = NO;
|
||||||
|
[self.stackHolder removeConstraint:self.subviewAligner];
|
||||||
|
if(bannerAlign==2) { //center
|
||||||
|
self.subviewAligner = [self.stackHolder.centerXAnchor constraintEqualToAnchor:self.centerXAnchor];
|
||||||
|
} else if(bannerAlign==1) { //left
|
||||||
|
self.subviewAligner = [self.stackHolder.leftAnchor constraintEqualToAnchor:self.leftAnchor];
|
||||||
|
} else if(bannerAlign==3) { //right
|
||||||
|
self.subviewAligner = [self.stackHolder.rightAnchor constraintEqualToAnchor:self.rightAnchor];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.subviewAligner.active = YES;
|
||||||
|
|
||||||
[self updateBattery];
|
[self updateBattery];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
@interface KAIStackView : UIStackView
|
@interface KAIStackView : UIStackView
|
||||||
@property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
|
@property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
|
||||||
@property (nonatomic, strong) NSLayoutConstraint *widthConstraint;
|
|
||||||
@property (nonatomic, strong) NSLayoutConstraint *aligner;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface KAIBatteryPlatter : UIScrollView <UIScrollViewDelegate>
|
@interface KAIBatteryPlatter : UIScrollView <UIScrollViewDelegate>
|
||||||
|
@property (nonatomic, strong) UIView *stackHolder;
|
||||||
@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) NSLayoutConstraint *widthConstraint;
|
||||||
|
@property (nonatomic, strong) NSLayoutConstraint *subviewAligner;
|
||||||
@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;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
-(void)addSubview:(UIView *)view {
|
-(void)addSubview:(UIView *)view {
|
||||||
[super addSubview:view];
|
[super addSubview:view];
|
||||||
[(UIScrollView *)self.superview setContentSize:self.frame.size];
|
[(UIScrollView *)self.superview.superview setContentSize:self.frame.size];
|
||||||
|
|
||||||
if(textColor==0 && [view respondsToSelector:@selector(updateInfo)]) {
|
if(textColor==0 && [view respondsToSelector:@selector(updateInfo)]) {
|
||||||
KAIBatteryCell *cell = (KAIBatteryCell *)view;
|
KAIBatteryCell *cell = (KAIBatteryCell *)view;
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
-(void)layoutSubviews {
|
-(void)layoutSubviews {
|
||||||
[super layoutSubviews];
|
[super layoutSubviews];
|
||||||
[(KAIBatteryPlatter *)(self.superview) calculateHeight];
|
[(KAIBatteryPlatter *)(self.superview.superview) calculateHeight];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
7
Kai.xm
7
Kai.xm
@ -9,6 +9,7 @@ CSAdjunctListView *list;
|
|||||||
%property (nonatomic, assign) BOOL hasKai;
|
%property (nonatomic, assign) BOOL hasKai;
|
||||||
|
|
||||||
-(void)_layoutStackView {
|
-(void)_layoutStackView {
|
||||||
|
%orig;
|
||||||
|
|
||||||
//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 {
|
@try {
|
||||||
@ -17,10 +18,7 @@ CSAdjunctListView *list;
|
|||||||
//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) {
|
}
|
||||||
[[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
|
|
||||||
[[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:0];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
} @catch (NSException *exc) {}
|
} @catch (NSException *exc) {}
|
||||||
|
|
||||||
@ -30,7 +28,6 @@ CSAdjunctListView *list;
|
|||||||
|
|
||||||
[[KAIBatteryPlatter sharedInstance] calculateHeight];
|
[[KAIBatteryPlatter sharedInstance] calculateHeight];
|
||||||
|
|
||||||
%orig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setStackView:(UIStackView *)arg1 {
|
-(void)setStackView:(UIStackView *)arg1 {
|
||||||
|
Reference in New Issue
Block a user