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

ZNDarkPrefsRootListController.m 4.1KB

4 anni fa
4 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #import "ZNDarkPrefsRootListController.h"
  2. #include <CSColorPicker/CSColorPicker.h>
  3. #define THEME_COLOR \
  4. [UIColor colorWithRed:0.96 \
  5. green:0.74 \
  6. blue:0.00 \
  7. alpha:1.00];
  8. @implementation ZNDarkPrefsRootListController
  9. + (UIColor *)hb_tintColor {
  10. return THEME_COLOR;
  11. }
  12. -(void)viewWillAppear:(BOOL)animated {
  13. [super viewWillAppear:animated];
  14. // share button for our tweak :P
  15. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareTapped)];
  16. }
  17. - (void)resetSettings {
  18. CFArrayRef keyList = CFPreferencesCopyKeyList(CFSTR("com.mac-user669.zenithdark"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  19. if (keyList) {
  20. CFPreferencesSetMultiple(nil, keyList, CFSTR("com.mac-user669.zenithdark"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  21. CFRelease(keyList);
  22. }
  23. [[NSFileManager defaultManager] removeItemAtPath:@"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist" error:nil];
  24. [self respring];
  25. }
  26. // Hide Large Title
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. if (@available(iOS 11, *)) {
  30. self.navigationController.navigationBar.prefersLargeTitles = false;
  31. self.navigationController.navigationItem.largeTitleDisplayMode =
  32. UINavigationItemLargeTitleDisplayModeNever;
  33. }
  34. }
  35. - (void)viewDidAppear:(BOOL)animated {
  36. [super viewDidAppear:animated];
  37. if (@available(iOS 11, *)) {
  38. self.navigationController.navigationBar.prefersLargeTitles = false;
  39. self.navigationController.navigationItem.largeTitleDisplayMode =
  40. UINavigationItemLargeTitleDisplayModeNever;
  41. }
  42. }
  43. // End of "Hide Large Title"
  44. //share button action
  45. - (void)shareTapped {
  46. 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/";
  47. UIImage *image = [UIImage imageWithContentsOfFile:kImagePath];
  48. NSArray * itemsToShare = @[shareText, image];
  49. UIActivityViewController *controller = [[UIActivityViewController alloc]initWithActivityItems:itemsToShare applicationActivities:nil];
  50. // and present it
  51. [self presentActivityController:controller];
  52. }
  53. - (void)presentActivityController:(UIActivityViewController *)controller {
  54. // for iPad: make the presentation a Popover
  55. controller.modalPresentationStyle = UIModalPresentationPopover;
  56. [self presentViewController:controller animated:YES completion:nil];
  57. UIPopoverPresentationController *popController = [controller popoverPresentationController];
  58. popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
  59. popController.barButtonItem = self.navigationItem.rightBarButtonItem;
  60. }
  61. - (NSArray *)specifiers {
  62. if (!_specifiers) {
  63. _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
  64. }
  65. return _specifiers;
  66. }
  67. - (void)respring {
  68. [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; // Dismisses keyboard
  69. [HBRespringController respringAndReturnTo:[NSURL URLWithString:@"prefs:root=ZenithDark"]];
  70. }
  71. -(void)respringPopUp {
  72. UIAlertController *confirmRespringAlert = [UIAlertController alertControllerWithTitle:@"Apply Settings?" message:@"This will respring your device." preferredStyle:UIAlertControllerStyleActionSheet];
  73. UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"Respring" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  74. [self performSelector:@selector(respring) withObject:nil afterDelay:0.0];
  75. }];
  76. UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
  77. [confirmRespringAlert addAction:cancel];
  78. [confirmRespringAlert addAction:confirm];
  79. [self presentViewController:confirmRespringAlert animated:YES completion:nil];
  80. }
  81. @end