Bring the 3D Touch tick sound for Apps from iOS 13 to iOS 12 and lower
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

153 lines
6.6KB

  1. #include "TCKRootListController.h"
  2. @implementation TCKRootListController
  3. - (instancetype)init {
  4. self = [super init];
  5. if (self) {
  6. TCKAppearanceSettings *appearanceSettings = [[TCKAppearanceSettings alloc] init];
  7. self.hb_appearanceSettings = appearanceSettings;
  8. self.respringButton = [[UIBarButtonItem alloc] initWithTitle:@"ReSpring"
  9. style:UIBarButtonItemStylePlain
  10. target:self
  11. action:@selector(respring)];
  12. self.respringButton.tintColor = [UIColor whiteColor];
  13. self.navigationItem.rightBarButtonItem = self.respringButton;
  14. self.navigationItem.titleView = [UIView new];
  15. self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,10,10)];
  16. self.titleLabel.font = [UIFont boldSystemFontOfSize:17];
  17. self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  18. self.titleLabel.text = @"Tick";
  19. self.titleLabel.textColor = [UIColor whiteColor];
  20. self.titleLabel.textAlignment = NSTextAlignmentCenter;
  21. [self.navigationItem.titleView addSubview:self.titleLabel];
  22. self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,10,10)];
  23. self.iconView.contentMode = UIViewContentModeScaleAspectFit;
  24. self.iconView.image = [UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/TickPrefs.bundle/icon@2x.png"];
  25. self.iconView.translatesAutoresizingMaskIntoConstraints = NO;
  26. self.iconView.alpha = 0.0;
  27. [self.navigationItem.titleView addSubview:self.iconView];
  28. [NSLayoutConstraint activateConstraints:@[
  29. [self.titleLabel.topAnchor constraintEqualToAnchor:self.navigationItem.titleView.topAnchor],
  30. [self.titleLabel.leadingAnchor constraintEqualToAnchor:self.navigationItem.titleView.leadingAnchor],
  31. [self.titleLabel.trailingAnchor constraintEqualToAnchor:self.navigationItem.titleView.trailingAnchor],
  32. [self.titleLabel.bottomAnchor constraintEqualToAnchor:self.navigationItem.titleView.bottomAnchor],
  33. [self.iconView.topAnchor constraintEqualToAnchor:self.navigationItem.titleView.topAnchor],
  34. [self.iconView.leadingAnchor constraintEqualToAnchor:self.navigationItem.titleView.leadingAnchor],
  35. [self.iconView.trailingAnchor constraintEqualToAnchor:self.navigationItem.titleView.trailingAnchor],
  36. [self.iconView.bottomAnchor constraintEqualToAnchor:self.navigationItem.titleView.bottomAnchor],
  37. ]];
  38. }
  39. return self;
  40. }
  41. -(NSArray *)specifiers {
  42. if (_specifiers == nil) {
  43. _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
  44. }
  45. return _specifiers;
  46. }
  47. - (void)viewDidLoad {
  48. [super viewDidLoad];
  49. self.headerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
  50. self.headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,200,200)];
  51. self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
  52. self.headerImageView.image = [UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/TickPrefs.bundle/Banner.png"];
  53. self.headerImageView.translatesAutoresizingMaskIntoConstraints = NO;
  54. [self.headerView addSubview:self.headerImageView];
  55. [NSLayoutConstraint activateConstraints:@[
  56. [self.headerImageView.topAnchor constraintEqualToAnchor:self.headerView.topAnchor],
  57. [self.headerImageView.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor],
  58. [self.headerImageView.trailingAnchor constraintEqualToAnchor:self.headerView.trailingAnchor],
  59. [self.headerImageView.bottomAnchor constraintEqualToAnchor:self.headerView.bottomAnchor],
  60. ]];
  61. _table.tableHeaderView = self.headerView;
  62. }
  63. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  64. tableView.tableHeaderView = self.headerView;
  65. return [super tableView:tableView cellForRowAtIndexPath:indexPath];
  66. }
  67. - (void)viewWillAppear:(BOOL)animated {
  68. [super viewWillAppear:animated];
  69. CGRect frame = self.table.bounds;
  70. frame.origin.y = -frame.size.height;
  71. self.navigationController.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.64 green:0.67 blue:1.00 alpha:1.0];
  72. [self.navigationController.navigationController.navigationBar setShadowImage: [UIImage new]];
  73. self.navigationController.navigationController.navigationBar.tintColor = [UIColor whiteColor];
  74. self.navigationController.navigationController.navigationBar.translucent = NO;
  75. }
  76. - (void)viewDidAppear:(BOOL)animated {
  77. [super viewDidAppear:animated];
  78. [self.navigationController.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
  79. }
  80. - (void)viewWillDisappear:(BOOL)animated {
  81. [super viewWillDisappear:animated];
  82. [self.navigationController.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]}];
  83. }
  84. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  85. CGFloat offsetY = scrollView.contentOffset.y;
  86. if (offsetY > 200) {
  87. [UIView animateWithDuration:0.2 animations:^{
  88. self.iconView.alpha = 1.0;
  89. self.titleLabel.alpha = 0.0;
  90. }];
  91. } else {
  92. [UIView animateWithDuration:0.2 animations:^{
  93. self.iconView.alpha = 0.0;
  94. self.titleLabel.alpha = 1.0;
  95. }];
  96. }
  97. if (offsetY > 0) offsetY = 0;
  98. self.headerImageView.frame = CGRectMake(0, offsetY, self.headerView.frame.size.width, 200 - offsetY);
  99. }
  100. -(void)respring {
  101. UIAlertController *respring = [UIAlertController alertControllerWithTitle:@"Tick"
  102. message:@"Do you really want to ReSpring?"
  103. preferredStyle:UIAlertControllerStyleAlert];
  104. UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"Confirm" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) {
  105. [self respringUtil];
  106. }];
  107. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
  108. [respring addAction:confirmAction];
  109. [respring addAction:cancelAction];
  110. [self presentViewController:respring animated:YES completion:nil];
  111. }
  112. -(void)respringUtil {
  113. NSTask *t = [[NSTask alloc] init];
  114. [t setLaunchPath:@"/usr/bin/killall"];
  115. [t setArguments:[NSArray arrayWithObjects:@"backboardd", nil]];
  116. [t launch];
  117. }
  118. -(IBAction)twitterEsquilli {
  119. NSURL *URL = [NSURL URLWithString: @"https://github.com/ShyMemoriees"];
  120. [[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
  121. }
  122. @end