Browse Source

YES DUDE

pull/1/head
Burrit0z 4 years ago
parent
commit
5bd0d5495c
5 changed files with 57 additions and 14 deletions
  1. +2
    -2
      KAIBatteryPlatter.h
  2. +23
    -10
      KAIBatteryPlatter.mm
  3. +2
    -0
      Kai.h
  4. +1
    -1
      Kai.xm
  5. +29
    -1
      kaiprefs/Resources/Root.plist

+ 2
- 2
KAIBatteryPlatter.h View File

@interface KAIBatteryPlatter : UIStackView
@interface KAIBatteryPlatter : UIScrollView <UIScrollViewDelegate>
@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, assign) BOOL isUpdating; @property (nonatomic, assign) BOOL isUpdating;
@property (nonatomic, assign) BOOL queued; @property (nonatomic, assign) BOOL queued;
+(KAIBatteryPlatter *)sharedInstance; +(KAIBatteryPlatter *)sharedInstance;
-(instancetype)init;
-(instancetype)initWithFrame:(CGRect)arg1;
-(void)refreshForPrefs; -(void)refreshForPrefs;
-(void)updateBattery; -(void)updateBattery;
@end @end

+ 23
- 10
KAIBatteryPlatter.mm View File



@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];

+ 2
- 0
Kai.h View File

double horizontalOffset; double horizontalOffset;
double bannerAlpha; double bannerAlpha;
double kaiAlign; double kaiAlign;
double spacingHorizontal;


//by importing here, I can use vars in the .mm files //by importing here, I can use vars in the .mm files
#import "KAIBatteryCell.mm" #import "KAIBatteryCell.mm"
bannerAlpha = numberForValue(@"bannerAlpha", 1); bannerAlpha = numberForValue(@"bannerAlpha", 1);
showAllMinusInternal = boolValueForKey(@"showAllMinusInternal", NO); showAllMinusInternal = boolValueForKey(@"showAllMinusInternal", NO);
kaiAlign = numberForValue(@"kaiAlign", 0); kaiAlign = numberForValue(@"kaiAlign", 0);
spacingHorizontal = numberForValue(@"spacingHorizontal", 8);


if(disableGlyphs) { if(disableGlyphs) {
glyphSize = 0; glyphSize = 0;

+ 1
- 1
Kai.xm View File

-(void)setStackView:(UIStackView *)arg1 { -(void)setStackView:(UIStackView *)arg1 {


if(!KAISelf.hasKai) { if(!KAISelf.hasKai) {
KAIBatteryPlatter *battery = [[KAIBatteryPlatter alloc] init];
KAIBatteryPlatter *battery = [[KAIBatteryPlatter alloc] initWithFrame:[self stackView].frame];


//Add noti observer //Add noti observer
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self

+ 29
- 1
kaiprefs/Resources/Root.plist View File

<key>cell</key> <key>cell</key>
<string>PSGroupCell</string> <string>PSGroupCell</string>
<key>label</key> <key>label</key>
<string>Banner Spacing (5)</string>
<string>Banner Spacing - Vertical (5)</string>
<key>footerText</key>
<string>This is the spacing between cells vertically, for kai's vertical mode.</string>
</dict> </dict>
<dict> <dict>
<key>default</key> <key>default</key>
<key>key</key> <key>key</key>
<string>spacing</string> <string>spacing</string>
</dict> </dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Banner Spacing - Horizontal (8)</string>
<key>footerText</key>
<string>This is the spacing between cells horizontally, for kai's horizontal mode.</string>
</dict>
<dict>
<key>default</key>
<real>8</real>
<key>cell</key>
<string>PSSliderCell</string>
<key>min</key>
<real>-100.0</real>
<key>max</key>
<real>300</real>
<key>isSegmented</key>
<false/>
<key>showValue</key>
<true/>
<key>defaults</key>
<string>com.burritoz.kaiprefs</string>
<key>key</key>
<string>spacingHorizontal</string>
</dict>
<dict> <dict>
<key>cell</key> <key>cell</key>
<string>PSGroupCell</string> <string>PSGroupCell</string>

Loading…
Cancel
Save