Parcourir la source

YES DUDE

pull/1/head
Burrit0z il y a 4 ans
Parent
révision
5bd0d5495c
5 fichiers modifiés avec 57 ajouts et 14 suppressions
  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 Voir le fichier

@@ -1,4 +1,4 @@
@interface KAIBatteryPlatter : UIStackView
@interface KAIBatteryPlatter : UIScrollView <UIScrollViewDelegate>
@property (nonatomic, assign) NSInteger number;
@property (nonatomic, assign) NSInteger oldCountOfDevices;
@property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
@@ -6,7 +6,7 @@
@property (nonatomic, assign) BOOL isUpdating;
@property (nonatomic, assign) BOOL queued;
+(KAIBatteryPlatter *)sharedInstance;
-(instancetype)init;
-(instancetype)initWithFrame:(CGRect)arg1;
-(void)refreshForPrefs;
-(void)updateBattery;
@end

+ 23
- 10
KAIBatteryPlatter.mm Voir le fichier

@@ -5,18 +5,25 @@ NSTimer *queueTimer = nil;

@implementation KAIBatteryPlatter

-(instancetype)init {
self = [super init];
-(instancetype)initWithFrame:(CGRect)arg1 {
self = [super initWithFrame:arg1];
instance = self;
if (self) {
self.stack = [[KAIStackView alloc] init];
self.stack.axis = kaiAlign==0 ? 1 : 0;
self.stack.distribution = 0;
self.stack.spacing = kaiAlign==0 ? 0 : spacing;
self.stack.spacing = kaiAlign==0 ? 0 : spacingHorizontal;
self.stack.alignment = 0;
self.oldCountOfDevices = -100;
self.queued = NO;

[self setMinimumZoomScale:1];
[self setMaximumZoomScale:1];
[self addSubview:self.stack];
[self setContentSize:self.stack.frame.size];
[self setContentOffset:CGPointMake(0,0)];
//[self setDelegate:self];

[self updateBattery];
}
return self;
@@ -107,6 +114,10 @@ long long lastPercentage;

}

-(void)setContentOffset:(CGPoint)arg1 {
[super setContentOffset:CGPointMake(arg1.x, 0)];
}

-(void)setNumber:(NSInteger)arg1 {
_number = arg1;
[UIView animateWithDuration:0.3 animations:^{
@@ -117,13 +128,14 @@ long long lastPercentage;
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 && [self.superview.subviews count]>1) {
height = (self.number * (bannerHeight + spacing)) - spacing;
} else {
height = bannerHeight;
height = bannerHeight + spacing;
}
self.heightConstraint.constant = height;
self.stack.heightConstraint.constant = height;
@@ -131,19 +143,20 @@ long long lastPercentage;
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 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];
if([self.superview.superview.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
[(NCNotificationListView *)(self.superview.superview.superview) fixComplicationsViewFrame];
}

if(textColor==0) {
if(textColor==0 && [view respondsToSelector:@selector(updateInfo)]) {
KAIBatteryCell *cell = (KAIBatteryCell *)view;
if(@available(iOS 12.0, *)) {
if(self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
@@ -157,9 +170,7 @@ long long lastPercentage;
}
}

-(void)removeArrangedSubview:(UIView *)view {
[super removeArrangedSubview:view];
self.number = [self.stack.subviews count];
-(void)layoutSubviews {
if([self.superview.superview.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
[(NCNotificationListView *)(self.superview.superview.superview) fixComplicationsViewFrame];
}
@@ -167,6 +178,8 @@ long long lastPercentage;
}

-(void)refreshForPrefs {
self.stack.spacing = kaiAlign==0 ? 0 : spacingHorizontal;
[self setContentSize:self.stack.frame.size];
for( UIView *view in self.stack.subviews ) {
@try {
[view removeFromSuperview];

+ 2
- 0
Kai.h Voir le fichier

@@ -58,6 +58,7 @@ double bannerWidthFactor;
double horizontalOffset;
double bannerAlpha;
double kaiAlign;
double spacingHorizontal;

//by importing here, I can use vars in the .mm files
#import "KAIBatteryCell.mm"
@@ -129,6 +130,7 @@ static void preferencesChanged()
bannerAlpha = numberForValue(@"bannerAlpha", 1);
showAllMinusInternal = boolValueForKey(@"showAllMinusInternal", NO);
kaiAlign = numberForValue(@"kaiAlign", 0);
spacingHorizontal = numberForValue(@"spacingHorizontal", 8);

if(disableGlyphs) {
glyphSize = 0;

+ 1
- 1
Kai.xm Voir le fichier

@@ -29,7 +29,7 @@
-(void)setStackView:(UIStackView *)arg1 {

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

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

+ 29
- 1
kaiprefs/Resources/Root.plist Voir le fichier

@@ -276,7 +276,9 @@
<key>cell</key>
<string>PSGroupCell</string>
<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>
<key>default</key>
@@ -296,6 +298,32 @@
<key>key</key>
<string>spacing</string>
</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>
<key>cell</key>
<string>PSGroupCell</string>

Chargement…
Annuler
Enregistrer