Device battery indicators on your Lock Screen
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KAIRootListController.m 8.0KB

4 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. #include "KAIRootListController.h"
  2. NSBundle *tweakBundle;
  3. @implementation KAIRootListController
  4. - (NSArray *)specifiers {
  5. if (!_specifiers) {
  6. _specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self];
  7. }
  8. return _specifiers;
  9. }
  10. -(void)viewWillAppear:(BOOL)arg1 {
  11. self.navigationController.navigationController.navigationBar.barTintColor = [UIColor colorWithRed: 0.00 green: 0.77 blue: 0.95 alpha: 1.00];
  12. [self.navigationController.navigationController.navigationBar setShadowImage: [UIImage new]];
  13. self.navigationController.navigationController.navigationBar.tintColor = [UIColor whiteColor];
  14. self.navigationController.navigationController.navigationBar.translucent = NO;
  15. [[UISegmentedControl appearanceWhenContainedInInstancesOfClasses:@[self.class]] setTintColor:[UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00]];
  16. [[UISwitch appearanceWhenContainedInInstancesOfClasses:@[self.class]] setOnTintColor:[UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00]];
  17. [[UISlider appearanceWhenContainedInInstancesOfClasses:@[self.class]] setTintColor:[UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00]];
  18. }
  19. - (void)viewWillDisappear:(BOOL)animated {
  20. [super viewWillDisappear:animated];
  21. [self.navigationController.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]}];
  22. }
  23. -(void)viewDidLoad {
  24. [super viewDidLoad];
  25. UIBarButtonItem *applyButton = [[UIBarButtonItem alloc] initWithTitle:@"Respring" style:UIBarButtonItemStylePlain target:self action:@selector(respring:)];
  26. self.navigationItem.rightBarButtonItem = applyButton;
  27. self.navigationItem.titleView = [UIView new];
  28. self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,10,10)];
  29. self.titleLabel.font = [UIFont systemFontOfSize:17.5];
  30. self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  31. self.titleLabel.text = @"kai";
  32. self.titleLabel.alpha = 0.0;
  33. self.titleLabel.textAlignment = NSTextAlignmentCenter;
  34. [self.navigationItem.titleView addSubview:self.titleLabel];
  35. self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,10,10)];
  36. self.iconView.contentMode = UIViewContentModeScaleAspectFit;
  37. self.iconView.image = [UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/kaiPrefs.bundle/icon.png"];
  38. self.iconView.translatesAutoresizingMaskIntoConstraints = NO;
  39. self.iconView.alpha = 1.0;
  40. [self.navigationItem.titleView addSubview:self.iconView];
  41. [NSLayoutConstraint activateConstraints:@[
  42. [self.titleLabel.topAnchor constraintEqualToAnchor:self.navigationItem.titleView.topAnchor],
  43. [self.titleLabel.leadingAnchor constraintEqualToAnchor:self.navigationItem.titleView.leadingAnchor],
  44. [self.titleLabel.trailingAnchor constraintEqualToAnchor:self.navigationItem.titleView.trailingAnchor],
  45. [self.titleLabel.bottomAnchor constraintEqualToAnchor:self.navigationItem.titleView.bottomAnchor],
  46. [self.iconView.topAnchor constraintEqualToAnchor:self.navigationItem.titleView.topAnchor],
  47. [self.iconView.leadingAnchor constraintEqualToAnchor:self.navigationItem.titleView.leadingAnchor],
  48. [self.iconView.trailingAnchor constraintEqualToAnchor:self.navigationItem.titleView.trailingAnchor],
  49. [self.iconView.bottomAnchor constraintEqualToAnchor:self.navigationItem.titleView.bottomAnchor],
  50. ]];
  51. }
  52. -(void)respring:(id)sender {
  53. tweakBundle = [NSBundle bundleWithPath:@"/Library/PreferenceBundles/MultiplaPrefs.bundle"];
  54. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Respring"
  55. message:@"Are you sure you want to respring now?"
  56. preferredStyle:UIAlertControllerStyleActionSheet];
  57. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel
  58. handler:^(UIAlertAction * action) {}];
  59. UIAlertAction* yes = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive
  60. handler:^(UIAlertAction * action) {
  61. NSTask *t = [[NSTask alloc] init];
  62. [t setLaunchPath:@"usr/bin/killall"];
  63. [t setArguments:[NSArray arrayWithObjects:@"backboardd", nil]];
  64. [t launch];
  65. }];
  66. [alert addAction:defaultAction];
  67. [alert addAction:yes];
  68. [self presentViewController:alert animated:YES completion:nil];
  69. }
  70. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  71. CGFloat offsetY = scrollView.contentOffset.y;
  72. if (offsetY > 140) {
  73. [UIView animateWithDuration:0.2 animations:^{
  74. self.iconView.alpha = 1.0;
  75. self.titleLabel.alpha = 0.0;
  76. }];
  77. } else {
  78. [UIView animateWithDuration:0.2 animations:^{
  79. self.iconView.alpha = 0.0;
  80. self.titleLabel.alpha = 1.0;
  81. }];
  82. }
  83. }
  84. @end
  85. @implementation KaiHeaderCell // Header Cell
  86. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(id)reuseIdentifier specifier:(id)specifier {
  87. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier specifier:specifier];
  88. if (self) {
  89. packageNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,90,self.contentView.bounds.size.width+30,50)];
  90. [packageNameLabel setTextAlignment:NSTextAlignmentRight];
  91. [packageNameLabel setFont:[UIFont systemFontOfSize:50 weight: UIFontWeightSemibold] ];
  92. packageNameLabel.textColor = [UIColor whiteColor];
  93. packageNameLabel.text = @"kai";
  94. developerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,50,self.contentView.bounds.size.width+30,50)];
  95. [developerLabel setTextAlignment:NSTextAlignmentRight];
  96. [developerLabel setFont:[UIFont systemFontOfSize:22.5 weight: UIFontWeightMedium] ];
  97. developerLabel.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.85];
  98. developerLabel.alpha = 0.8;
  99. developerLabel.text = @"Burrit0z";
  100. versionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,130,self.contentView.bounds.size.width+30,50)];
  101. [versionLabel setTextAlignment:NSTextAlignmentRight];
  102. [versionLabel setFont:[UIFont systemFontOfSize:22 weight: UIFontWeightMedium] ];
  103. versionLabel.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.8];
  104. versionLabel.alpha = 0.8;
  105. versionLabel.text = @"alpha";
  106. NSBundle *bundle = [[NSBundle alloc]initWithPath:@"/Library/PreferenceBundles/KaiPrefs.bundle"];
  107. UIImage *phone = [UIImage imageWithContentsOfFile:[bundle pathForResource:@"kai" ofType:@"png"]];
  108. UIImageView *phoneImage = [[UIImageView alloc]initWithImage:phone];
  109. [phoneImage setFrame:self.frame];
  110. bgView.backgroundColor = [UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00];
  111. [self addSubview:packageNameLabel];
  112. [self addSubview:developerLabel];
  113. [self addSubview:versionLabel];
  114. [self addSubview:phoneImage];
  115. }
  116. return self;
  117. }
  118. - (instancetype)initWithSpecifier:(PSSpecifier *)specifier {
  119. return [self initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"KaiHeaderCell" specifier:specifier];
  120. }
  121. - (void)setFrame:(CGRect)frame {
  122. frame.origin.x = 0;
  123. //frame.origin.y = 43;
  124. [super setFrame:frame];
  125. }
  126. - (CGFloat)preferredHeightForWidth:(CGFloat)arg1{
  127. return 200.0f;
  128. }
  129. -(void)layoutSubviews{
  130. [super layoutSubviews];
  131. bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.bounds.size.width, 200)];
  132. UIColor *topColor = [UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00];
  133. UIColor *bottomColor = [UIColor colorWithRed: 0.23 green: 0.48 blue: 0.84 alpha: 1.00];
  134. CAGradientLayer *theViewGradient = [CAGradientLayer layer];
  135. theViewGradient.colors = [NSArray arrayWithObjects: (id)topColor.CGColor, (id)bottomColor.CGColor, nil];
  136. theViewGradient.startPoint = CGPointMake(0.5, 0.0);
  137. theViewGradient.endPoint = CGPointMake(0.5, 1.0);
  138. theViewGradient.frame = bgView.bounds;
  139. //Add gradient to view
  140. [bgView.layer insertSublayer:theViewGradient atIndex:0];
  141. [self insertSubview:bgView atIndex:0];
  142. }
  143. - (CGFloat)preferredHeightForWidth:(CGFloat)width inTableView:(id)tableView {
  144. return [self preferredHeightForWidth:width];
  145. }
  146. @end