Dark tabs for Zenith! Mirror of https://github.com/mac-user669/ZenithDark
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.

ZNDarkPrefsRootListController.m 4.0KB

4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #import "ZNDarkPrefsRootListController.h"
  2. #include <CSColorPicker/CSColorPicker.h>
  3. #import "NSTask.h"
  4. #define THEME_COLOR \
  5. [UIColor colorWithRed:0.96 \
  6. green:0.74 \
  7. blue:0.00 \
  8. alpha:1.00];
  9. @implementation ZNDarkPrefsRootListController
  10. + (UIColor *)hb_tintColor {
  11. return THEME_COLOR;
  12. }
  13. -(void)viewWillAppear:(BOOL)animated {
  14. [super viewWillAppear:animated];
  15. // share button for our tweak :P
  16. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareTapped)];
  17. }
  18. // Hide Large Title
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. if (@available(iOS 11, *)) {
  22. self.navigationController.navigationBar.prefersLargeTitles = false;
  23. self.navigationController.navigationItem.largeTitleDisplayMode =
  24. UINavigationItemLargeTitleDisplayModeNever;
  25. }
  26. }
  27. - (void)viewDidAppear:(BOOL)animated {
  28. [super viewDidAppear:animated];
  29. if (@available(iOS 11, *)) {
  30. self.navigationController.navigationBar.prefersLargeTitles = false;
  31. self.navigationController.navigationItem.largeTitleDisplayMode =
  32. UINavigationItemLargeTitleDisplayModeNever;
  33. }
  34. }
  35. // End of "Hide Large Title"
  36. //share button action
  37. - (void)shareTapped {
  38. NSString *shareText = @"Turn off the lights! It's too bright! Get dark tabs for #Zenith (@Muirey03) by using #ZenithDark from @mac_user669 and @iKilledAppl3! https://mac-user669.github.io/repo/";
  39. UIImage *image = [UIImage imageWithContentsOfFile:kImagePath];
  40. NSArray * itemsToShare = @[shareText, image];
  41. UIActivityViewController *controller = [[UIActivityViewController alloc]initWithActivityItems:itemsToShare applicationActivities:nil];
  42. // and present it
  43. [self presentActivityController:controller];
  44. }
  45. - (void)presentActivityController:(UIActivityViewController *)controller {
  46. // for iPad: make the presentation a Popover
  47. controller.modalPresentationStyle = UIModalPresentationPopover;
  48. [self presentViewController:controller animated:YES completion:nil];
  49. UIPopoverPresentationController *popController = [controller popoverPresentationController];
  50. popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
  51. popController.barButtonItem = self.navigationItem.rightBarButtonItem;
  52. }
  53. - (NSArray *)specifiers {
  54. if (!_specifiers) {
  55. _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
  56. }
  57. return _specifiers;
  58. }
  59. -(void)respring {
  60. UIAlertController *respring = [UIAlertController alertControllerWithTitle:@"ZenithDark"
  61. message:@"Do you want to Respring?"
  62. preferredStyle:UIAlertControllerStyleAlert];
  63. UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"Confirm" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) {
  64. [self respringUtil];
  65. }];
  66. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
  67. [respring addAction:confirmAction];
  68. [respring addAction:cancelAction];
  69. [self presentViewController:respring animated:YES completion:nil];
  70. }
  71. -(void)respringUtil {
  72. NSTask *t = [[NSTask alloc] init];
  73. [t setLaunchPath:@"/usr/bin/killall"];
  74. [t setArguments:[NSArray arrayWithObjects:@"backboardd", nil]];
  75. [t launch];
  76. }
  77. - (void)resetSettings {
  78. CFArrayRef keyList = CFPreferencesCopyKeyList(CFSTR("com.mac-user669.zenithdark"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  79. if (keyList) {
  80. CFPreferencesSetMultiple(nil, keyList, CFSTR("com.mac-user669.zenithdark"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  81. CFRelease(keyList);
  82. }
  83. [[NSFileManager defaultManager] removeItemAtPath:@"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist" error:nil];
  84. [self respringUtil];
  85. }
  86. @end