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.

188 lines
7.9KB

  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.735 blue: 0.965 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:@"Apply" 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. CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.burritoz.kaiprefs/reload"), nil, nil, true);
  54. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Kai"
  55. message:@"Your settings have been applied. You can now go back to your lockscreen (CoverSheet) to see the changes. \n \n If some of your options did not apply, a respring might be necessary."
  56. preferredStyle:UIAlertControllerStyleAlert];
  57. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Amazing!" style:UIAlertActionStyleDefault
  58. handler:^(UIAlertAction * action) {}];
  59. [alert addAction:defaultAction];
  60. [self presentViewController:alert animated:YES completion:nil];
  61. }
  62. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  63. CGFloat offsetY = scrollView.contentOffset.y;
  64. if (offsetY > 120) {
  65. [UIView animateWithDuration:0.2 animations:^{
  66. self.iconView.alpha = 1.0;
  67. self.titleLabel.alpha = 0.0;
  68. }];
  69. } else {
  70. [UIView animateWithDuration:0.2 animations:^{
  71. self.iconView.alpha = 0.0;
  72. self.titleLabel.alpha = 1.0;
  73. }];
  74. }
  75. }
  76. @end
  77. @implementation KaiHeaderCell // Header Cell
  78. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(id)reuseIdentifier specifier:(id)specifier {
  79. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier specifier:specifier];
  80. if (self) {
  81. packageNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,90,self.contentView.bounds.size.width+30,50)];
  82. [packageNameLabel setTextAlignment:NSTextAlignmentRight];
  83. [packageNameLabel setFont:[UIFont systemFontOfSize:50 weight: UIFontWeightSemibold] ];
  84. packageNameLabel.textColor = [UIColor whiteColor];
  85. packageNameLabel.text = @"kai";
  86. developerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,50,self.contentView.bounds.size.width+30,50)];
  87. [developerLabel setTextAlignment:NSTextAlignmentRight];
  88. [developerLabel setFont:[UIFont systemFontOfSize:22.5 weight: UIFontWeightMedium] ];
  89. developerLabel.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.85];
  90. developerLabel.alpha = 0.8;
  91. developerLabel.text = @"Burrit0z";
  92. versionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,130,self.contentView.bounds.size.width+30,50)];
  93. [versionLabel setTextAlignment:NSTextAlignmentRight];
  94. [versionLabel setFont:[UIFont systemFontOfSize:22 weight: UIFontWeightMedium] ];
  95. versionLabel.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.8];
  96. versionLabel.alpha = 0.8;
  97. versionLabel.text = @"alpha";
  98. NSBundle *bundle = [[NSBundle alloc]initWithPath:@"/Library/PreferenceBundles/kaiPrefs.bundle"];
  99. UIImage *phone = [UIImage imageWithContentsOfFile:[bundle pathForResource:@"kai" ofType:@"png"]];
  100. UIImageView *phoneImage = [[UIImageView alloc]initWithImage:phone];
  101. [phoneImage setFrame:CGRectMake(40,40,190,160)];
  102. phoneImage.clipsToBounds = YES;
  103. bgView.backgroundColor = [UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00];
  104. [self addSubview:packageNameLabel];
  105. [self addSubview:developerLabel];
  106. [self addSubview:versionLabel];
  107. [self addSubview:phoneImage];
  108. }
  109. return self;
  110. }
  111. - (instancetype)initWithSpecifier:(PSSpecifier *)specifier {
  112. return [self initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"KaiHeaderCell" specifier:specifier];
  113. }
  114. - (void)setFrame:(CGRect)frame {
  115. frame.origin.x = 0;
  116. //frame.origin.y = 43;
  117. [super setFrame:frame];
  118. }
  119. - (CGFloat)preferredHeightForWidth:(CGFloat)arg1{
  120. return 200.0f;
  121. }
  122. -(void)layoutSubviews{
  123. [super layoutSubviews];
  124. bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.bounds.size.width, 200)];
  125. UIColor *topColor = [UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00];
  126. UIColor *bottomColor = [UIColor colorWithRed: 0.23 green: 0.48 blue: 0.84 alpha: 1.00];
  127. CAGradientLayer *theViewGradient = [CAGradientLayer layer];
  128. theViewGradient.colors = [NSArray arrayWithObjects: (id)topColor.CGColor, (id)bottomColor.CGColor, nil];
  129. theViewGradient.startPoint = CGPointMake(0.5, 0.0);
  130. theViewGradient.endPoint = CGPointMake(0.5, 1.0);
  131. theViewGradient.frame = bgView.bounds;
  132. //Add gradient to view
  133. [bgView.layer insertSublayer:theViewGradient atIndex:0];
  134. [self insertSubview:bgView atIndex:0];
  135. }
  136. - (CGFloat)preferredHeightForWidth:(CGFloat)width inTableView:(id)tableView {
  137. return [self preferredHeightForWidth:width];
  138. }
  139. @end