Dark tabs for Zenith! Mirror of https://github.com/mac-user669/ZenithDark
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
před 4 roky
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Dark Mode for Zenith's Grabber view!
  3. Copyright 2020 J.K. Hayslip (@iKilledAppl3) & ToxicAppl3 INSDC/iKilledAppl3 LLC.
  4. All code was written for learning purposes and credit must be given to the original author.
  5. Written for Cooper Hull, @(mac-user669).
  6. */
  7. #import "ZenithDark.h"
  8. static BOOL enabled;
  9. static BOOL replaceOriginalView;
  10. static BOOL notificationBadgesEnabled;
  11. static void loadPrefs() {
  12. static NSMutableDictionary *settings;
  13. CFArrayRef keyList = CFPreferencesCopyKeyList(CFSTR("com.mac-user669.zenithdarkprefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  14. if (keyList) {
  15. settings = (NSMutableDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, CFSTR("com.mac-user669.zenithdarkprefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  16. CFRelease(keyList);
  17. } else {
  18. settings = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.mac-user669.zenithdarkprefs.plist"];
  19. }
  20. enabled = [([settings objectForKey:@"enabled"] ? [settings objectForKey:@"enabled"] : @(YES)) boolValue];
  21. replaceOriginalView = [([settings objectForKey:@"replaceoriginalview"] ? [settings objectForKey:@"replaceoriginalview"] : @(YES)) boolValue];
  22. notificationBadgesEnabled = [([settings objectForKey:@"notificationBadgesEnabled"] ? [settings objectForKey:@"notificationBadgesEnabled"] : NO) boolValue];
  23. }
  24. // We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView”
  25. %hook ZNGrabberAccessoryView
  26. // this is called when iOS 13's dark mode is enabled!
  27. -(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
  28. %orig(previousTraitCollection);
  29. if (@available(iOS 13, *)) {
  30. if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
  31. [self setBackgroundColor:kDarkModeColor];
  32. }
  33. else {
  34. [self setBackgroundColor:kLightModeColor];
  35. }
  36. }
  37. }
  38. // the method we modify is this method that is called from UIImageView to set the backgroundColor of the image view.
  39. // Since the grabber view is of type UIImageView we can modify this method :)
  40. -(void)setBackgroundColor:(UIColor *)backgroundColor {
  41. // by default have our tweak overide this.
  42. if (@available(iOS 13, *)) {
  43. if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
  44. %orig(kDarkModeColor);
  45. }
  46. else {
  47. %orig;
  48. }
  49. }
  50. }
  51. // we need to make sure we tell theos that we are finished hooking this class not doing so with cause the end of the world :P
  52. %end
  53. // our constructor
  54. %ctor {
  55. loadPrefs();
  56. // We use this to make sure we load Zenith's dynamic library at runtime so we can modify it with our tweak.
  57. dlopen ("/Library/MobileSubstrate/DynamicLibraries/Zenith.dylib", RTLD_NOW);
  58. }