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.

118 lines
4.2KB

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