|
|
|
|
|
|
|
|
#import "ZenithDark.h" |
|
|
#import "ZenithDark.h" |
|
|
#import <Cephei/HBPreferences.h> |
|
|
|
|
|
#import <CepheiPrefs/HBRootListController.h> |
|
|
|
|
|
#import <CepheiPrefs/HBAppearanceSettings.h> |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
|
|
|
|
|
|
Dark Mode for Zenith's Grabber view! |
|
|
Dark Mode for Zenith's Grabber view! |
|
|
Copyright 2020 J.K. Hayslip (@iKilledAppl3) & ToxicAppl3 INSDC/iKilledAppl3 LLC. |
|
|
Copyright 2020 J.K. Hayslip (@iKilledAppl3) & ToxicAppl3 INSDC/iKilledAppl3 LLC. |
|
|
All code was written for learning purposes and credit must be given to the original author. |
|
|
All code was written for learning purposes and credit must be given to the original author. |
|
|
|
|
|
|
|
|
Written for Cooper Hull, @mac-user669. |
|
|
Written for Cooper Hull, @mac-user669. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
%group Adaptive |
|
|
%group Adaptive |
|
|
|
|
|
|
|
|
// if the tweak is enabled and the version is iOS 13 or later run our code |
|
|
// if the tweak is enabled and the version is iOS 13 or later run our code |
|
|
if (@available(iOS 13, *)) { |
|
|
if (@available(iOS 13, *)) { |
|
|
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { |
|
|
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { |
|
|
[self setBackgroundColor:kDarkColor]; |
|
|
|
|
|
|
|
|
[self setBackgroundColor:kColor1]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
else { |
|
|
else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// the method we modify is this method that is called from UIImageView to set the backgroundColor of the image view. |
|
|
// the method we modify is this method that is called from UIImageView to set the backgroundColor of the image view. |
|
|
// Since the grabber view is of type UIImageView we can modify this method :) |
|
|
// Since the grabber view is of type UIImageView we can modify this method :) |
|
|
-(void)setBackgroundColor:(UIColor *)backgroundColor { |
|
|
-(void)setBackgroundColor:(UIColor *)backgroundColor { |
|
|
%orig; |
|
|
%orig; |
|
|
if (kEnabled) { |
|
|
if (kEnabled) { |
|
|
// by default have our tweak overide this. |
|
|
|
|
|
if (@available(iOS 13, *)) { |
|
|
|
|
|
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { |
|
|
|
|
|
%orig(kDarkColor); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
%orig; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
%end // 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 |
|
|
|
|
|
%end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%group justDark |
|
|
|
|
|
|
|
|
|
|
|
//We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView” |
|
|
|
|
|
%hook ZNGrabberAccessoryView |
|
|
|
|
|
// The method we then modify is this method that is called from UIImageView to set the backgroundColor of the image view. |
|
|
|
|
|
// Since the grabber view is of type UIImageView we can modify this method :) |
|
|
|
|
|
|
|
|
|
|
|
-(void)setBackgroundColor:(UIColor *)backgroundColor { |
|
|
|
|
|
//call the original function then pass our custom argument to the backgroundColor argument as shown below. |
|
|
|
|
|
%orig(kDarkColor); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 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 |
|
|
|
|
|
%end |
|
|
|
|
|
%end |
|
|
|
|
|
|
|
|
|
|
|
%group OLEDadaptive |
|
|
|
|
|
// We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView” |
|
|
|
|
|
%hook ZNGrabberAccessoryView |
|
|
|
|
|
|
|
|
|
|
|
// this is called when iOS 13's dark mode is enabled! |
|
|
|
|
|
-(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { |
|
|
|
|
|
%orig(previousTraitCollection); |
|
|
|
|
|
if (kEnabled) { |
|
|
|
|
|
// if the tweak is enabled and the version is iOS 13 or later run our code |
|
|
|
|
|
if (@available(iOS 13, *)) { |
|
|
|
|
|
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { |
|
|
|
|
|
[self setBackgroundColor:kOLEDColor]; |
|
|
|
|
|
|
|
|
NSString* colourString = NULL; |
|
|
|
|
|
NSDictionary* preferencesDictionary = [NSDictionary dictionaryWithContentsOfFile: @"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist"]; |
|
|
|
|
|
if(preferencesDictionary) |
|
|
|
|
|
{ |
|
|
|
|
|
colourString = [preferencesDictionary objectForKey: @"kCustomDarkColor"]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
[self setBackgroundColor:kLightColor]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
UIColor* darkColor = [SparkColourPickerUtils colourWithString: colourString withFallback: @"#FF00FF"]; |
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
%orig(previousTraitCollection); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// the method we modify is this method that is called from UIImageView to set the backgroundColor of the image view. |
|
|
|
|
|
// Since the grabber view is of type UIImageView we can modify this method :) |
|
|
|
|
|
-(void)setBackgroundColor:(UIColor *)backgroundColor { |
|
|
|
|
|
%orig; |
|
|
|
|
|
if (kEnabled) { |
|
|
|
|
|
// by default have our tweak overide this. |
|
|
// by default have our tweak overide this. |
|
|
if (@available(iOS 13, *)) { |
|
|
if (@available(iOS 13, *)) { |
|
|
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { |
|
|
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { |
|
|
%orig(kOLEDColor); |
|
|
|
|
|
|
|
|
%orig(darkColor); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%end // 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 |
|
|
%end // 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 |
|
|
%end |
|
|
%end |
|
|
|
|
|
|
|
|
%group OLEDgroup |
|
|
|
|
|
|
|
|
|
|
|
//We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView” |
|
|
|
|
|
%hook ZNGrabberAccessoryView |
|
|
|
|
|
// The method we then modify is this method that is called from UIImageView to set the backgroundColor of the image view. |
|
|
|
|
|
// Since the grabber view is of type UIImageView we can modify this method :) |
|
|
|
|
|
|
|
|
|
|
|
-(void)setBackgroundColor:(UIColor *)backgroundColor { |
|
|
|
|
|
//call the original function then pass our custom argument to the backgroundColor argument as shown below. |
|
|
|
|
|
%orig(kOLEDColor); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 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 |
|
|
|
|
|
%end |
|
|
|
|
|
%end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void loadPrefs() { // Load preferences to make sure changes are written to the plist |
|
|
static void loadPrefs() { // Load preferences to make sure changes are written to the plist |
|
|
|
|
|
|
|
|
// Thanks to skittyblock! |
|
|
// Thanks to skittyblock! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
kEnabled = [([prefs objectForKey:@"kEnabled"] ?: @(YES)) boolValue]; //our preference values that write to a plist file when a user selects somethings |
|
|
kEnabled = [([prefs objectForKey:@"kEnabled"] ?: @(YES)) boolValue]; //our preference values that write to a plist file when a user selects somethings |
|
|
sortType = [([prefs objectForKey:@"sortingType"] ? [prefs objectForKey:@"sortingType"] : @"0") integerValue]; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadPrefs(); // Load our prefs |
|
|
loadPrefs(); // Load our prefs |
|
|
|
|
|
|
|
|
if (kEnabled) { // If enabled |
|
|
if (kEnabled) { // If enabled |
|
|
if (sortType == ZNDarkSortTypeAdaptive) { |
|
|
|
|
|
%init(Adaptive); // Enable the group "Adaptive" |
|
|
%init(Adaptive); // Enable the group "Adaptive" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else if (sortType == ZNDarkSortTypeDark) { |
|
|
|
|
|
%init(justDark); // Enable the group "Adaptive" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else if (sortType == ZNDarkSortTypeOLEDAdaptive) { |
|
|
|
|
|
%init(OLEDadaptive); // Enable the group "OLEDgroup" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else if (sortType == ZNDarkSortTypeOLED) { |
|
|
|
|
|
%init(OLEDgroup); // Enable the group "OLEDgroup" |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback) PreferencesChangedCallback, CFSTR("com.mac-user669.zenithdark.prefschanged"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); |
|
|
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback) PreferencesChangedCallback, CFSTR("com.mac-user669.zenithdark.prefschanged"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); |