1
0
mirror of https://github.com/Burrit0z/kai synced 2025-07-01 21:46:48 +00:00
This commit is contained in:
Burrit0z
2020-05-20 12:43:34 -04:00
parent 168bd6d3dc
commit 4a9d95086d
7 changed files with 288 additions and 21 deletions

View File

@ -8,7 +8,17 @@
-(void)setFrame:(CGRect)frame;
@end
@interface NSTask : NSObject
@property(copy) NSArray *arguments;
@property(copy) NSString *launchPath;
- (id)init;
- (void)waitUntilExit;
- (void)launch;
@end
@interface KAIRootListController : PSListController
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *iconView;
@end
@protocol PreferencesTableCustomView

View File

@ -32,6 +32,80 @@ NSBundle *tweakBundle;
}
-(void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *applyButton = [[UIBarButtonItem alloc] initWithTitle:@"Respring" style:UIBarButtonItemStylePlain target:self action:@selector(respring:)];
self.navigationItem.rightBarButtonItem = applyButton;
self.navigationItem.titleView = [UIView new];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,10,10)];
self.titleLabel.font = [UIFont systemFontOfSize:17.5];
self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
self.titleLabel.text = @"kai";
self.titleLabel.alpha = 0.0;
self.titleLabel.textAlignment = NSTextAlignmentCenter;
[self.navigationItem.titleView addSubview:self.titleLabel];
self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,10,10)];
self.iconView.contentMode = UIViewContentModeScaleAspectFit;
self.iconView.image = [UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/kaiPrefs.bundle/icon.png"];
self.iconView.translatesAutoresizingMaskIntoConstraints = NO;
self.iconView.alpha = 1.0;
[self.navigationItem.titleView addSubview:self.iconView];
[NSLayoutConstraint activateConstraints:@[
[self.titleLabel.topAnchor constraintEqualToAnchor:self.navigationItem.titleView.topAnchor],
[self.titleLabel.leadingAnchor constraintEqualToAnchor:self.navigationItem.titleView.leadingAnchor],
[self.titleLabel.trailingAnchor constraintEqualToAnchor:self.navigationItem.titleView.trailingAnchor],
[self.titleLabel.bottomAnchor constraintEqualToAnchor:self.navigationItem.titleView.bottomAnchor],
[self.iconView.topAnchor constraintEqualToAnchor:self.navigationItem.titleView.topAnchor],
[self.iconView.leadingAnchor constraintEqualToAnchor:self.navigationItem.titleView.leadingAnchor],
[self.iconView.trailingAnchor constraintEqualToAnchor:self.navigationItem.titleView.trailingAnchor],
[self.iconView.bottomAnchor constraintEqualToAnchor:self.navigationItem.titleView.bottomAnchor],
]];
}
-(void)respring:(id)sender {
tweakBundle = [NSBundle bundleWithPath:@"/Library/PreferenceBundles/MultiplaPrefs.bundle"];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Respring"
message:@"Are you sure you want to respring now?"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {}];
UIAlertAction* yes = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action) {
NSTask *t = [[NSTask alloc] init];
[t setLaunchPath:@"usr/bin/killall"];
[t setArguments:[NSArray arrayWithObjects:@"backboardd", nil]];
[t launch];
}];
[alert addAction:defaultAction];
[alert addAction:yes];
[self presentViewController:alert animated:YES completion:nil];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat offsetY = scrollView.contentOffset.y;
if (offsetY > 140) {
[UIView animateWithDuration:0.2 animations:^{
self.iconView.alpha = 1.0;
self.titleLabel.alpha = 0.0;
}];
} else {
[UIView animateWithDuration:0.2 animations:^{
self.iconView.alpha = 0.0;
self.titleLabel.alpha = 1.0;
}];
}
}
@end
@implementation KaiHeaderCell // Header Cell

View File

@ -24,6 +24,130 @@
<key>label</key>
<string>Enable</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.burritoz.kaiprefs</string>
<key>key</key>
<string>disableGlyphs</string>
<key>label</key>
<string>Hide Device Glyphs</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.burritoz.kaiprefs</string>
<key>key</key>
<string>hidePercent</string>
<key>label</key>
<string>Hide Percent Label</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Banner Height (80)</string>
</dict>
<dict>
<key>default</key>
<real>80</real>
<key>cell</key>
<string>PSSliderCell</string>
<key>min</key>
<real>20</real>
<key>max</key>
<real>200</real>
<key>isSegmented</key>
<false/>
<key>showValue</key>
<true/>
<key>defaults</key>
<string>com.burritoz.kaiprefs</string>
<key>key</key>
<string>bannerHeight</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Banner Spacing (5)</string>
</dict>
<dict>
<key>default</key>
<real>5</real>
<key>cell</key>
<string>PSSliderCell</string>
<key>min</key>
<real>0.0</real>
<key>max</key>
<real>100</real>
<key>isSegmented</key>
<false/>
<key>showValue</key>
<true/>
<key>defaults</key>
<string>com.burritoz.kaiprefs</string>
<key>key</key>
<string>spacing</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Glyph Size (40)</string>
</dict>
<dict>
<key>default</key>
<real>40</real>
<key>cell</key>
<string>PSSliderCell</string>
<key>min</key>
<real>10</real>
<key>max</key>
<real>100</real>
<key>isSegmented</key>
<false/>
<key>showValue</key>
<true/>
<key>defaults</key>
<string>com.burritoz.kaiprefs</string>
<key>key</key>
<string>glyphSize</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Corner Radius (13)</string>
</dict>
<dict>
<key>default</key>
<real>13</real>
<key>cell</key>
<string>PSSliderCell</string>
<key>min</key>
<real>0.1</real>
<key>max</key>
<real>100</real>
<key>isSegmented</key>
<false/>
<key>showValue</key>
<true/>
<key>defaults</key>
<string>com.burritoz.kaiprefs</string>
<key>key</key>
<string>cornerRadius</string>
</dict>
</array>
<key>title</key>
<string>kai</string>