mirror of
				https://github.com/Burrit0z/kai
				synced 2025-10-31 03:26:19 +00:00 
			
		
		
		
	move height calculations to another method
This commit is contained in:
		| @ -9,4 +9,5 @@ | ||||
| -(instancetype)initWithFrame:(CGRect)arg1; | ||||
| -(void)refreshForPrefs; | ||||
| -(void)updateBattery; | ||||
| -(void)calculateHeight; | ||||
| @end | ||||
| @ -124,36 +124,7 @@ long long lastPercentage; | ||||
|  | ||||
| -(void)setNumber:(NSInteger)arg1 { | ||||
|     _number = arg1; | ||||
|     [UIView animateWithDuration:0.3 animations:^{ | ||||
|  | ||||
| 		if(!self.heightConstraint) { | ||||
|  | ||||
| 			self.heightConstraint = [self.heightAnchor constraintEqualToConstant:(self.number * (bannerHeight + spacing))]; | ||||
|             self.stack.heightConstraint = [self.heightAnchor constraintEqualToConstant:(self.number * (bannerHeight + spacing))]; | ||||
| 			self.heightConstraint.active = YES; | ||||
|             self.stack.heightConstraint.active = YES; | ||||
|             [self setContentSize:self.stack.frame.size]; | ||||
|  | ||||
| 		} else { | ||||
|             int height = (self.number * (bannerHeight + spacing)); | ||||
|             if(kaiAlign==0) { | ||||
|                 height = (self.number * (bannerHeight + spacing)); | ||||
|             } else { | ||||
|                 height = bannerHeight + spacing; | ||||
|             } | ||||
|  | ||||
|             if([self.superview.subviews count]>1) { | ||||
|                 height = height - spacing; | ||||
|             } | ||||
| 			self.heightConstraint.constant = height; | ||||
|             self.stack.heightConstraint.constant = height; | ||||
|  | ||||
| 			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)); | ||||
| 			//literally does nothing but makes the stack view lay itself out (doesnt adjust frame because translatesAutoreszingMaskIntoConstraints = NO on stack views) | ||||
| 		} | ||||
|  | ||||
|         }]; | ||||
|     [self calculateHeight]; | ||||
| } | ||||
|  | ||||
| -(void)addSubview:(UIView *)view { | ||||
| @ -186,6 +157,39 @@ long long lastPercentage; | ||||
|  | ||||
| } | ||||
|  | ||||
| -(void)calculateHeight { | ||||
|     [UIView animateWithDuration:0.3 animations:^{ | ||||
|  | ||||
| 		if(!self.heightConstraint) { | ||||
|  | ||||
| 			self.heightConstraint = [self.heightAnchor constraintEqualToConstant:(self.number * (bannerHeight + spacing))]; | ||||
|             self.stack.heightConstraint = [self.heightAnchor constraintEqualToConstant:(self.number * (bannerHeight + spacing))]; | ||||
| 			self.heightConstraint.active = YES; | ||||
|             self.stack.heightConstraint.active = YES; | ||||
|             [self setContentSize:self.stack.frame.size]; | ||||
|  | ||||
| 		} else { | ||||
|             int height = (self.number * (bannerHeight + spacing)); | ||||
|             if(kaiAlign==0) { | ||||
|                 height = (self.number * (bannerHeight + spacing)); | ||||
|             } else { | ||||
|                 height = bannerHeight + spacing; | ||||
|             } | ||||
|  | ||||
|             if([self.superview.subviews count]>1) { | ||||
|                 height = height - spacing; | ||||
|             } | ||||
| 			self.heightConstraint.constant = height; | ||||
|             self.stack.heightConstraint.constant = height; | ||||
|  | ||||
| 			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)); | ||||
| 			//literally does nothing but makes the stack view lay itself out (doesnt adjust frame because translatesAutoreszingMaskIntoConstraints = NO on stack views) | ||||
| 		} | ||||
|  | ||||
|         }]; | ||||
| } | ||||
|  | ||||
| -(void)refreshForPrefs { | ||||
|     self.stack.spacing = kaiAlign==0 ? 0 : spacingHorizontal; | ||||
|     [self setContentSize:self.stack.frame.size]; | ||||
|  | ||||
							
								
								
									
										12
									
								
								Kai.xm
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Kai.xm
									
									
									
									
									
								
							| @ -21,11 +21,21 @@ | ||||
|         [(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame]; | ||||
|     } | ||||
|  | ||||
| 	[[KAIBatteryPlatter sharedInstance] setNumber:[KAIBatteryPlatter sharedInstance].number]; | ||||
| 	[[KAIBatteryPlatter sharedInstance] calculateHeight]; | ||||
|  | ||||
| 	%orig; | ||||
| } | ||||
|  | ||||
| -(void)removeArrangedSubview:(id)arg1 { | ||||
| 	%orig; | ||||
| 	[[KAIBatteryPlatter sharedInstance] calculateHeight]; | ||||
| } | ||||
|  | ||||
| -(void)addArrangedSubview:(id)arg1 { | ||||
| 	%orig; | ||||
| 	[[KAIBatteryPlatter sharedInstance] calculateHeight]; | ||||
| } | ||||
|  | ||||
| -(void)setStackView:(UIStackView *)arg1 { | ||||
|  | ||||
| 	if(!KAISelf.hasKai) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user