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.

187 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.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:@"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 Note the option to put kai below music requires a respring, as well as option to hide CoverSheet charge animations."
  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 > 140) {
  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:self.frame];
  102. bgView.backgroundColor = [UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00];
  103. [self addSubview:packageNameLabel];
  104. [self addSubview:developerLabel];
  105. [self addSubview:versionLabel];
  106. [self addSubview:phoneImage];
  107. }
  108. return self;
  109. }
  110. - (instancetype)initWithSpecifier:(PSSpecifier *)specifier {
  111. return [self initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"KaiHeaderCell" specifier:specifier];
  112. }
  113. - (void)setFrame:(CGRect)frame {
  114. frame.origin.x = 0;
  115. //frame.origin.y = 43;
  116. [super setFrame:frame];
  117. }
  118. - (CGFloat)preferredHeightForWidth:(CGFloat)arg1{
  119. return 200.0f;
  120. }
  121. -(void)layoutSubviews{
  122. [super layoutSubviews];
  123. bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.bounds.size.width, 200)];
  124. UIColor *topColor = [UIColor colorWithRed: 0.00 green: 0.82 blue: 1.00 alpha: 1.00];
  125. UIColor *bottomColor = [UIColor colorWithRed: 0.23 green: 0.48 blue: 0.84 alpha: 1.00];
  126. CAGradientLayer *theViewGradient = [CAGradientLayer layer];
  127. theViewGradient.colors = [NSArray arrayWithObjects: (id)topColor.CGColor, (id)bottomColor.CGColor, nil];
  128. theViewGradient.startPoint = CGPointMake(0.5, 0.0);
  129. theViewGradient.endPoint = CGPointMake(0.5, 1.0);
  130. theViewGradient.frame = bgView.bounds;
  131. //Add gradient to view
  132. [bgView.layer insertSublayer:theViewGradient atIndex:0];
  133. [self insertSubview:bgView atIndex:0];
  134. }
  135. - (CGFloat)preferredHeightForWidth:(CGFloat)width inTableView:(id)tableView {
  136. return [self preferredHeightForWidth:width];
  137. }
  138. @end