Dark tabs for Zenith! Mirror of https://github.com/mac-user669/ZenithDark
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

117 lines
4.2KB

  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)respring {
  59. NSTask *task = [[[NSTask alloc] init] autorelease];
  60. [task setLaunchPath:@"/usr/bin/killall"];
  61. [task setArguments:[NSArray arrayWithObjects:@"backboardd", nil]];
  62. [task launch];
  63. }
  64. -(void)doAFancyRespring {
  65. UIAlertController *confirmRespringAlert = [UIAlertController alertControllerWithTitle:@"Apply Settings?" message:@"This will respring your device." preferredStyle:UIAlertControllerStyleActionSheet];
  66. UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"Respring" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  67. // blur then respring our device!
  68. self.mainAppRootWindow = [UIApplication sharedApplication].keyWindow;
  69. self.respringBlur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
  70. self.respringEffectView = [[UIVisualEffectView alloc] initWithEffect:self.respringBlur];
  71. self.respringEffectView.frame = [[UIScreen mainScreen] bounds];
  72. [self.mainAppRootWindow addSubview:self.respringEffectView];
  73. [UIView beginAnimations:nil context:NULL];
  74. [UIView setAnimationDuration:5.0];
  75. [self.respringEffectView setAlpha:0];
  76. [UIView commitAnimations];
  77. [self performSelector:@selector(respring) withObject:nil afterDelay:3.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