Dark tabs for Zenith! Mirror of https://github.com/mac-user669/ZenithDark
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

109 行
4.3KB

  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"