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.

Tweak.xm.mm 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #line 1 "Tweak.xm"
  2. #import "ZenithDark.h"
  3. static BOOL enabled;
  4. static void loadPrefs() {
  5. static NSMutableDictionary *settings;
  6. CFArrayRef keyList = CFPreferencesCopyKeyList(CFSTR("com.mac-user669.zenithdarkprefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  7. if (keyList) {
  8. settings = (NSMutableDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, CFSTR("com.mac-user669.zenithdarkprefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  9. CFRelease(keyList);
  10. } else {
  11. settings = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.mac-user669.zenithdarkprefs.plist"];
  12. }
  13. enabled = [([settings objectForKey:@"enabled"] ? [settings objectForKey:@"enabled"] : @(YES)) boolValue];
  14. }
  15. #include <substrate.h>
  16. #if defined(__clang__)
  17. #if __has_feature(objc_arc)
  18. #define _LOGOS_SELF_TYPE_NORMAL __unsafe_unretained
  19. #define _LOGOS_SELF_TYPE_INIT __attribute__((ns_consumed))
  20. #define _LOGOS_SELF_CONST const
  21. #define _LOGOS_RETURN_RETAINED __attribute__((ns_returns_retained))
  22. #else
  23. #define _LOGOS_SELF_TYPE_NORMAL
  24. #define _LOGOS_SELF_TYPE_INIT
  25. #define _LOGOS_SELF_CONST
  26. #define _LOGOS_RETURN_RETAINED
  27. #endif
  28. #else
  29. #define _LOGOS_SELF_TYPE_NORMAL
  30. #define _LOGOS_SELF_TYPE_INIT
  31. #define _LOGOS_SELF_CONST
  32. #define _LOGOS_RETURN_RETAINED
  33. #endif
  34. @class ZNGrabberAccessoryView;
  35. static void (*_logos_orig$_ungrouped$ZNGrabberAccessoryView$traitCollectionDidChange$)(_LOGOS_SELF_TYPE_NORMAL ZNGrabberAccessoryView* _LOGOS_SELF_CONST, SEL, UITraitCollection *); static void _logos_method$_ungrouped$ZNGrabberAccessoryView$traitCollectionDidChange$(_LOGOS_SELF_TYPE_NORMAL ZNGrabberAccessoryView* _LOGOS_SELF_CONST, SEL, UITraitCollection *); static void (*_logos_orig$_ungrouped$ZNGrabberAccessoryView$setBackgroundColor$)(_LOGOS_SELF_TYPE_NORMAL ZNGrabberAccessoryView* _LOGOS_SELF_CONST, SEL, UIColor *); static void _logos_method$_ungrouped$ZNGrabberAccessoryView$setBackgroundColor$(_LOGOS_SELF_TYPE_NORMAL ZNGrabberAccessoryView* _LOGOS_SELF_CONST, SEL, UIColor *);
  36. #line 30 "Tweak.xm"
  37. static void _logos_method$_ungrouped$ZNGrabberAccessoryView$traitCollectionDidChange$(_LOGOS_SELF_TYPE_NORMAL ZNGrabberAccessoryView* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, UITraitCollection * previousTraitCollection) {
  38. if (enabled) {
  39. _logos_orig$_ungrouped$ZNGrabberAccessoryView$traitCollectionDidChange$(self, _cmd, previousTraitCollection);
  40. if (@available(iOS 13, *)) {
  41. if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
  42. [self setBackgroundColor:kDarkModeColor];
  43. }
  44. else {
  45. [self setBackgroundColor:kLightModeColor];
  46. }
  47. }
  48. }
  49. _logos_orig$_ungrouped$ZNGrabberAccessoryView$traitCollectionDidChange$(self, _cmd, previousTraitCollection);
  50. }
  51. static void _logos_method$_ungrouped$ZNGrabberAccessoryView$setBackgroundColor$(_LOGOS_SELF_TYPE_NORMAL ZNGrabberAccessoryView* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, UIColor * backgroundColor) {
  52. if (enabled) {
  53. if (@available(iOS 13, *)) {
  54. if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
  55. _logos_orig$_ungrouped$ZNGrabberAccessoryView$setBackgroundColor$(self, _cmd, kDarkModeColor);
  56. }
  57. else {
  58. _logos_orig$_ungrouped$ZNGrabberAccessoryView$setBackgroundColor$(self, _cmd, backgroundColor);
  59. }
  60. }
  61. }
  62. _logos_orig$_ungrouped$ZNGrabberAccessoryView$setBackgroundColor$(self, _cmd, backgroundColor);
  63. }
  64. static __attribute__((constructor)) void _logosLocalCtor_7f270ec4(int __unused argc, char __unused **argv, char __unused **envp) {
  65. loadPrefs();
  66. dlopen ("/Library/MobileSubstrate/DynamicLibraries/Zenith.dylib", RTLD_NOW);
  67. }
  68. static __attribute__((constructor)) void _logosLocalInit() {
  69. {Class _logos_class$_ungrouped$ZNGrabberAccessoryView = objc_getClass("ZNGrabberAccessoryView"); MSHookMessageEx(_logos_class$_ungrouped$ZNGrabberAccessoryView, @selector(traitCollectionDidChange:), (IMP)&_logos_method$_ungrouped$ZNGrabberAccessoryView$traitCollectionDidChange$, (IMP*)&_logos_orig$_ungrouped$ZNGrabberAccessoryView$traitCollectionDidChange$);MSHookMessageEx(_logos_class$_ungrouped$ZNGrabberAccessoryView, @selector(setBackgroundColor:), (IMP)&_logos_method$_ungrouped$ZNGrabberAccessoryView$setBackgroundColor$, (IMP*)&_logos_orig$_ungrouped$ZNGrabberAccessoryView$setBackgroundColor$);} }
  70. #line 80 "Tweak.xm"