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.

110 lines
3.9KB

  1. #import "ZNDarkPrefsRootListController.h"
  2. #import <CepheiPrefs/HBAppearanceSettings.h>
  3. #define THEME_COLOR \
  4. [UIColor colorWithRed:0.82 \
  5. green:0.64 \
  6. blue:0.00 \
  7. alpha:1.0];
  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:UIBarButtonSystemItemCompose target:self action:@selector(shareTapped)];
  16. }
  17. // Hide Large Title
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. if (@available(iOS 11, *)) {
  21. self.navigationController.navigationBar.prefersLargeTitles = false;
  22. self.navigationController.navigationItem.largeTitleDisplayMode =
  23. UINavigationItemLargeTitleDisplayModeNever;
  24. }
  25. }
  26. - (void)viewDidAppear:(BOOL)animated {
  27. [super viewDidAppear:animated];
  28. if (@available(iOS 11, *)) {
  29. self.navigationController.navigationBar.prefersLargeTitles = false;
  30. self.navigationController.navigationItem.largeTitleDisplayMode =
  31. UINavigationItemLargeTitleDisplayModeNever;
  32. }
  33. }
  34. // End of "Hide Large Title"
  35. //share button action
  36. - (void)shareTapped {
  37. 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/";
  38. UIImage *image = [UIImage imageWithContentsOfFile:kImagePath];
  39. NSArray * itemsToShare = @[shareText, image];
  40. UIActivityViewController *controller = [[UIActivityViewController alloc]initWithActivityItems:itemsToShare applicationActivities:nil];
  41. // and present it
  42. [self presentActivityController:controller];
  43. }
  44. - (void)presentActivityController:(UIActivityViewController *)controller {
  45. // for iPad: make the presentation a Popover
  46. controller.modalPresentationStyle = UIModalPresentationPopover;
  47. [self presentViewController:controller animated:YES completion:nil];
  48. UIPopoverPresentationController *popController = [controller popoverPresentationController];
  49. popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
  50. popController.barButtonItem = self.navigationItem.rightBarButtonItem;
  51. }
  52. - (NSArray *)specifiers {
  53. if (!_specifiers) {
  54. _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
  55. }
  56. return _specifiers;
  57. }
  58. -(void)doAFancyRespring {
  59. UIAlertController *confirmRespringAlert = [UIAlertController alertControllerWithTitle:@"Apply Settings?" message:@"This will respring your device." preferredStyle:UIAlertControllerStyleActionSheet];
  60. UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"Respring" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  61. // blur then respring our device!
  62. self.mainAppRootWindow = [UIApplication sharedApplication].keyWindow;
  63. self.respringBlur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
  64. self.respringEffectView = [[UIVisualEffectView alloc] initWithEffect:self.respringBlur];
  65. self.respringEffectView.frame = [[UIScreen mainScreen] bounds];
  66. [self.mainAppRootWindow addSubview:self.respringEffectView];
  67. [UIView beginAnimations:nil context:NULL];
  68. [UIView setAnimationDuration:5.0];
  69. [self.respringEffectView setAlpha:0];
  70. [UIView commitAnimations];
  71. [self performSelector:@selector(respring) withObject:nil afterDelay:3.0];
  72. }];
  73. UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
  74. [confirmRespringAlert addAction:cancel];
  75. [confirmRespringAlert addAction:confirm];
  76. [self presentViewController:confirmRespringAlert animated:YES completion:nil];
  77. }
  78. @end