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.

117 lines
4.3KB

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