@@ -9,7 +9,7 @@ TWEAK_NAME = ZenithDark | |||
ZenithDark_FILES = Tweak.xm | |||
ZenithDark_FRAMEWORKS = UIKit CoreGraphics | |||
ZenithDark_EXTRA_FRAMEWORKS += Cephei | |||
ZenithDark_LIBRARIES = sparkcolourpicker | |||
$(TWEAK_NAME)_LDFLAGS += -lCSColorPicker | |||
include $(THEOS_MAKE_PATH)/tweak.mk | |||
@@ -7,60 +7,53 @@ All code was written for learning purposes and credit must be given to the origi | |||
Written for Cooper Hull, @mac-user669. | |||
*/ | |||
%group Adaptive | |||
// We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView” | |||
BOOL kEnabled; | |||
BOOL kCustomDarkColorEnabled; | |||
BOOL kCustomLightColorEnabled; | |||
inline NSString *StringForPreferenceKey(NSString *key) { | |||
NSDictionary *prefs = [NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] ? : [NSDictionary new]; | |||
return prefs[key]; | |||
} | |||
%group TweakGroup | |||
%hook ZNGrabberAccessoryView | |||
// this is called when iOS 13's dark mode is enabled! | |||
-(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { | |||
%orig(previousTraitCollection); | |||
if (kEnabled) { | |||
NSString* colourString = NULL; | |||
NSDictionary* preferencesDictionary = [NSDictionary dictionaryWithContentsOfFile: @"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist"]; | |||
if(preferencesDictionary) | |||
{ | |||
colourString = [preferencesDictionary objectForKey: @"kCustomLightColor"]; | |||
} | |||
UIColor* lightColor = [SparkColourPickerUtils colourWithString: colourString withFallback: @"#FFFFFF:0.7"]; | |||
// if the tweak is enabled and the version is iOS 13 or later run our code | |||
%orig(previousTraitCollection); | |||
if (@available(iOS 13, *)) { | |||
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { | |||
[self setBackgroundColor:kColor1]; | |||
[self setBackgroundColor:[UIColor cscp_colorFromHexString:StringForPreferenceKey(@"kDarkCustomColor")]]; | |||
} | |||
else { | |||
[self setBackgroundColor:lightColor]; | |||
if (kCustomLightColorEnabled) { | |||
[self setBackgroundColor:[UIColor cscp_colorFromHexString:StringForPreferenceKey(@"kLightCustomColor")]]; | |||
} | |||
else { | |||
[self setBackgroundColor:kLightModeColor]; | |||
} | |||
} | |||
} | |||
} | |||
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) { | |||
NSString* colourString = NULL; | |||
NSDictionary* preferencesDictionary = [NSDictionary dictionaryWithContentsOfFile: @"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist"]; | |||
if(preferencesDictionary) | |||
{ | |||
colourString = [preferencesDictionary objectForKey: @"kCustomDarkColor"]; | |||
} | |||
UIColor* darkColor = [SparkColourPickerUtils colourWithString: colourString withFallback: @"#000000:0.44"]; | |||
// by default have our tweak overide this. | |||
if (@available(iOS 13, *)) { | |||
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { | |||
%orig(darkColor); | |||
if (kCustomDarkColorEnabled) { | |||
%orig([UIColor cscp_colorFromHexString:StringForPreferenceKey(@"kDarkCustomColor")]); | |||
} | |||
else { | |||
%orig(kDarkModeColor); | |||
} | |||
} | |||
} | |||
else { | |||
%orig; | |||
@@ -68,7 +61,9 @@ else { | |||
} | |||
} | |||
%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 | |||
// 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 | |||
@@ -86,7 +81,11 @@ static void loadPrefs() { // Load preferences to make sure changes are written | |||
prefs = [NSMutableDictionary dictionaryWithContentsOfFile:PLIST_PATH]; | |||
} | |||
kEnabled = [([prefs objectForKey:@"kEnabled"] ?: @(YES)) boolValue]; //our preference values that write to a plist file when a user selects somethings | |||
kCustomDarkColorEnabled = [([prefs objectForKey:@"kCustomDarkColorEnabled"] ?: @(NO)) boolValue]; //our preference values that write to a plist file when a user selects somethings | |||
kCustomLightColorEnabled = [([prefs objectForKey:@"kCustomLightColorEnabled"] ?: @(NO)) boolValue]; //our preference values that write to a plist file when a user selects somethings | |||
} | |||
@@ -95,16 +94,16 @@ static void PreferencesChangedCallback(CFNotificationCenterRef center, void *obs | |||
loadPrefs(); | |||
} | |||
%ctor { // Our constructor | |||
loadPrefs(); // Load our prefs | |||
if (kEnabled) { // If enabled | |||
%init(Adaptive); // Enable the group "Adaptive" | |||
%init(TweakGroup); // Enable the group "TweakGroup" | |||
} | |||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback) PreferencesChangedCallback, CFSTR("com.mac-user669.zenithdark.prefschanged"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); | |||
dlopen ("/Library/MobileSubstrate/DynamicLibraries/Zenith.dylib", RTLD_NOW); // We use this to make sure we load Zenith's dynamic library at runtime so we can modify it with our tweak. | |||
} |
@@ -1,5 +1,4 @@ | |||
/* | |||
Dark Mode for Zenith's Grabber view! | |||
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. | |||
@@ -7,36 +6,29 @@ All code was written for learning purposes and credit must be given to the origi | |||
Written for Cooper Hull, (@mac-user669). | |||
ZenithDark Header file to keep the tweak.x file clean! | |||
*/ | |||
#import <Cephei/HBPreferences.h> | |||
#import <CepheiPrefs/HBRootListController.h> | |||
#import <CepheiPrefs/HBAppearanceSettings.h> | |||
#import "SparkColourPickerUtils.h" | |||
#include <CSColorPicker/CSColorPicker.h> | |||
// We then import UIKit so we can override the color property without this Theos doesn't have a clue what those properties are. | |||
@import UIKit; | |||
// We make an interface to let Theos know that ZNGrabberAccessoryView is of type UIImageView. | |||
@interface ZNGrabberAccessoryView : UIImageView | |||
@end | |||
// a boolean value to store to the tweak's property list path to see if the user has enabled or disabled the tweak. | |||
BOOL kEnabled; | |||
//Prefs dictionary | |||
NSMutableDictionary *prefs; | |||
// Dark Zenith color we are using macros so we can call it later if need be. | |||
#define kDarkColor [UIColor colorWithWhite:0.0 alpha:0.44] | |||
#define kDarkModeColor [UIColor colorWithWhite:0.0 alpha:0.44] | |||
// Stock Zenith color we are using macros so we can call it later if need be. | |||
#define kLightColor [UIColor colorWithWhite:1.0 alpha:0.7] | |||
#define kLightModeColor [UIColor colorWithWhite:1.0 alpha:0.7] | |||
#define kColor1 [UIColor redColor] // Color used for testing | |||
#define kColor1 [UIColor redColor] // Color used for testing | |||
#define kColor2 [UIColor greenColor] // Color used for testing | |||
#define kColor3 [UIColor blueColor] // Color used for testing | |||
#define kColor4 [UIColor cyanColor] // Color used for testing | |||
// the PLIST path where all user settings are stored. | |||
#define PLIST_PATH @"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist" |
@@ -2,7 +2,7 @@ Package: com.mac-user669.zenithdark | |||
Version: 1.5 | |||
Architecture: iphoneos-arm | |||
Maintainer: mac-user669 <cooper@cooperhull.com> | |||
Depends: mobilesubstrate, preferenceloader, com.muirey03.zenith, ws.hbang.common (>= 1.11), firmware (>=13.0), com.spark.libsparkcolourpicker | |||
Depends: mobilesubstrate, preferenceloader, com.muirey03.zenith, ws.hbang.common (>= 1.11), firmware (>=13.0) | |||
Section: Tweaks | |||
Description: Changes Zeniths tabs to a dark blur | |||
Author: mac-user669 <cooper@cooperhull.com> |
@@ -12,7 +12,7 @@ ZenithDarkPrefs_INSTALL_PATH = /Library/PreferenceBundles | |||
ZenithDarkPrefs_FRAMEWORKS = UIKit | |||
ZenithDarkPrefs_PRIVATE_FRAMEWORKS = Preferences | |||
ZenithDarkPrefs_EXTRA_FRAMEWORKS = Cephei CepheiPrefs | |||
ZenithDarkPrefs_LIBRARIES = sparkcolourpicker | |||
$(BUNDLE_NAME)_LDFLAGS += -lCSColorPicker | |||
include $(THEOS_MAKE_PATH)/bundle.mk | |||
@@ -45,66 +45,91 @@ | |||
<key>cell</key> | |||
<string>PSGroupCell</string> | |||
<key>label</key> | |||
<string>Color Options</string> | |||
<string></string> | |||
<key>footerText</key> | |||
<string>Default: #000000:0.44</string> | |||
<string></string> | |||
</dict> | |||
<dict> | |||
<key>cell</key> | |||
<string>PSLinkCell</string> | |||
<key>cellClass</key> | |||
<string>SparkColourPickerCell</string> | |||
<key>libsparkcolourpicker</key> | |||
<string>PSSwitchCell</string> | |||
<key>default</key> | |||
<false/> | |||
<key>defaults</key> | |||
<string>com.mac-user669.zenithdark</string> | |||
<key>key</key> | |||
<string>kCustomDarkColorEnabled</string> | |||
<key>label</key> | |||
<string>Custom Dark Color</string> | |||
<key>PostNotification</key> | |||
<string>com.mac-user669.zenithdark.prefschanged</string> | |||
</dict> | |||
<dict> | |||
<key>PostNotification</key> | |||
<string>com.mac-user669.zenithdark.prefschanged</string> | |||
<key>cell</key> | |||
<string>PSLinkCell</string> | |||
<key>cellClass</key> | |||
<string>CSColorDisplayCell</string> | |||
<key>defaults</key> | |||
<string>com.mac-user669.zenithdark</string> | |||
<string>com.mac-user669.zenithdark</string> | |||
<key>defaultsPath</key> | |||
<string>/Library/PreferenceBundles/ZenithDark.bundle</string> | |||
<key>key</key> | |||
<string>kCustomDarkColor</string> | |||
<key>fallback</key> | |||
<string>#000000:0.44</string> | |||
<string>kDarkCustomColor</string> | |||
<key>label</key> | |||
<string>Dark Color</string> | |||
<key>fallback</key> | |||
<string>70000000</string> | |||
<key>alpha</key> | |||
<true/> | |||
</dict> | |||
<key>label</key> | |||
<string>Dark Color</string> | |||
<key>key</key> | |||
<string>kCustomDarkColor</string> | |||
<key>PostNotification</key> | |||
<string>com.mac-user669.zenithdark.prefschanged</string> | |||
</dict> | |||
<dict> | |||
<key>cell</key> | |||
<string>PSGroupCell</string> | |||
<key>label</key> | |||
<string></string> | |||
<key>footerText</key> | |||
<string>Default: #FFFFFF:0.7</string> | |||
<string></string> | |||
</dict> | |||
<dict> | |||
<key>cell</key> | |||
<string>PSLinkCell</string> | |||
<key>cellClass</key> | |||
<string>SparkColourPickerCell</string> | |||
<key>libsparkcolourpicker</key> | |||
<string>PSSwitchCell</string> | |||
<key>default</key> | |||
<false/> | |||
<key>defaults</key> | |||
<string>com.mac-user669.zenithdark</string> | |||
<key>key</key> | |||
<string>kCustomLightColorEnabled</string> | |||
<key>label</key> | |||
<string>Custom Light Color</string> | |||
<key>PostNotification</key> | |||
<string>com.mac-user669.zenithdark.prefschanged</string> | |||
</dict> | |||
<dict> | |||
<key>PostNotification</key> | |||
<string>com.mac-user669.zenithdark.prefschanged</string> | |||
<key>cell</key> | |||
<string>PSLinkCell</string> | |||
<key>cellClass</key> | |||
<string>CSColorDisplayCell</string> | |||
<key>defaults</key> | |||
<string>com.mac-user669.zenithdark</string> | |||
<string>com.mac-user669.zenithdark</string> | |||
<key>defaultsPath</key> | |||
<string>/Library/PreferenceBundles/ZenithDark.bundle</string> | |||
<key>key</key> | |||
<string>kCustomLightColor</string> | |||
<key>fallback</key> | |||
<string>#FFFFFF:0.7</string> | |||
<string>kLightCustomColor</string> | |||
<key>label</key> | |||
<string>Light Color</string> | |||
<key>fallback</key> | |||
<string>B3FFFFFF</string> | |||
<key>alpha</key> | |||
<true/> | |||
</dict> | |||
<key>label</key> | |||
<string>Light Color</string> | |||
<key>key</key> | |||
<string>kCustomLightColor</string> | |||
<key>PostNotification</key> | |||
<string>com.mac-user669.zenithdark.prefschanged</string> | |||
</dict> | |||
<dict> | |||
<key>cell</key> | |||
@@ -157,6 +182,8 @@ | |||
<dict> | |||
<key>cell</key> | |||
<string>PSButtonCell</string> | |||
<key>cellClass</key> | |||
<string>HBTintedTableCell</string> | |||
<key>label</key> | |||
<string>Reset Settings</string> | |||
<key>action</key> |
@@ -1,6 +1,7 @@ | |||
#import <Preferences/PSListController.h> | |||
#import <CepheiPrefs/HBRootListController.h> | |||
#import <CepheiPrefs/HBAppearanceSettings.h> | |||
#import <Cephei/HBRespringController.h> | |||
#import <Cephei/HBPreferences.h> | |||
@import UIKit; |
@@ -1,8 +1,5 @@ | |||
#import "ZNDarkPrefsRootListController.h" | |||
#import <CepheiPrefs/HBAppearanceSettings.h> | |||
#import <Cephei/HBRespringController.h> | |||
#import <Cephei/HBPreferences.h> | |||
#import "SparkColourPickerUtils.h" | |||
#include <CSColorPicker/CSColorPicker.h> | |||
#define THEME_COLOR \ | |||
[UIColor colorWithRed:0.82 \ | |||
@@ -91,6 +88,7 @@ | |||
return _specifiers; | |||
} | |||
- (void)respring { | |||
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; // Dismisses keyboard | |||
[HBRespringController respringAndReturnTo:[NSURL URLWithString:@"prefs:root=ZenithDark"]]; |