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.

55 lines
1.6KB

  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. // We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView”
  9. %hook ZNGrabberAccessoryView
  10. // this is called when iOS 13's dark mode is enabled!
  11. -(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
  12. %orig(previousTraitCollection);
  13. if (@available(iOS 13, *)) {
  14. if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
  15. [self setBackgroundColor:kDarkModeColor];
  16. }
  17. else {
  18. [self setBackgroundColor:kLightModeColor];
  19. }
  20. }
  21. }
  22. // the method we modify is this method that is called from UIImageView to set the backgroundColor of the image view.
  23. // Since the grabber view is of type UIImageView we can modify this method :)
  24. -(void)setBackgroundColor:(UIColor *)backgroundColor {
  25. // by default have our tweak overide this.
  26. if (@available(iOS 13, *)) {
  27. if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
  28. %orig(kDarkModeColor);
  29. }
  30. else {
  31. %orig;
  32. }
  33. }
  34. }
  35. // 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
  36. %end
  37. // our constructor
  38. %ctor {
  39. // We use this to make sure we load Zenith's dynamic library at runtime so we can modify it with our tweak.
  40. dlopen ("/Library/MobileSubstrate/DynamicLibraries/Zenith.dylib", RTLD_NOW);
  41. }