1.4
This commit is contained in:
103
Tweak.xm
103
Tweak.xm
@ -9,12 +9,12 @@ 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 Tweak13
|
%group Adaptive
|
||||||
// We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView”
|
// We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView”
|
||||||
%hook ZNGrabberAccessoryView
|
%hook ZNGrabberAccessoryView
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ Written for Cooper Hull, @(mac-user669).
|
|||||||
// 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:kDarkModeColor];
|
[self setBackgroundColor:kDarkColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
[self setBackgroundColor:kLightModeColor];
|
[self setBackgroundColor:kLightColor];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ else {
|
|||||||
// 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(kDarkModeColor);
|
%orig(kDarkColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,10 +63,8 @@ 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
|
%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
|
||||||
|
|
||||||
static BOOL ios13;
|
|
||||||
|
|
||||||
|
%group justDark
|
||||||
%group Tweak12
|
|
||||||
|
|
||||||
//We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView”
|
//We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView”
|
||||||
%hook ZNGrabberAccessoryView
|
%hook ZNGrabberAccessoryView
|
||||||
@ -75,7 +73,72 @@ static BOOL ios13;
|
|||||||
|
|
||||||
-(void)setBackgroundColor:(UIColor *)backgroundColor {
|
-(void)setBackgroundColor:(UIColor *)backgroundColor {
|
||||||
//call the original function then pass our custom argument to the backgroundColor argument as shown below.
|
//call the original function then pass our custom argument to the backgroundColor argument as shown below.
|
||||||
%orig(kDarkModeColor);
|
%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];
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
[self setBackgroundColor:kLightColor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
|
if (@available(iOS 13, *)) {
|
||||||
|
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
|
||||||
|
%orig(kOLEDColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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
|
// 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
|
||||||
@ -99,6 +162,8 @@ static void loadPrefs() { // Load preferences to make sure changes are written
|
|||||||
|
|
||||||
}
|
}
|
||||||
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];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -112,12 +177,20 @@ static void PreferencesChangedCallback(CFNotificationCenterRef center, void *obs
|
|||||||
loadPrefs(); // Load our prefs
|
loadPrefs(); // Load our prefs
|
||||||
|
|
||||||
if (kEnabled) { // If enabled
|
if (kEnabled) { // If enabled
|
||||||
if (@available(iOS 13, *)) { // If the device is running iOS 13
|
if (sortType == ZNDarkSortTypeAdaptive) {
|
||||||
ios13 = YES; // Set "iOS13" to "YES"
|
%init(Adaptive); // Enable the group "Adaptive"
|
||||||
%init(Tweak13); // Enable the group "Tweak13"
|
}
|
||||||
} else {
|
|
||||||
ios13 = NO; // Set "iOS13" to "NO"
|
else if (sortType == ZNDarkSortTypeDark) {
|
||||||
%init(Tweak12); // Enable the group "Tweak12"
|
%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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
ZenithDark.h
13
ZenithDark.h
@ -19,6 +19,14 @@ ZenithDark Header file to keep the tweak.x file clean!
|
|||||||
@interface ZNGrabberAccessoryView : UIImageView
|
@interface ZNGrabberAccessoryView : UIImageView
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, ZNDarkSortType) {
|
||||||
|
ZNDarkSortTypeAdaptive,
|
||||||
|
ZNDarkSortTypeDark,
|
||||||
|
ZNDarkSortTypeOLEDAdaptive,
|
||||||
|
ZNDarkSortTypeOLED
|
||||||
|
};
|
||||||
|
|
||||||
|
static ZNDarkSortType sortType = ZNDarkSortTypeAdaptive;
|
||||||
// a boolean value to store to the tweak's property list path to see if the user has enabled or disabled the tweak.
|
// 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;
|
BOOL kEnabled;
|
||||||
|
|
||||||
@ -26,10 +34,11 @@ BOOL kEnabled;
|
|||||||
NSMutableDictionary *prefs;
|
NSMutableDictionary *prefs;
|
||||||
|
|
||||||
// Dark Zenith color we are using macros so we can call it later if need be.
|
// Dark Zenith color we are using macros so we can call it later if need be.
|
||||||
#define kDarkModeColor [UIColor colorWithWhite:0.0 alpha:0.44]
|
#define kDarkColor [UIColor colorWithWhite:0.0 alpha:0.44]
|
||||||
|
|
||||||
// Stock Zenith color we are using macros so we can call it later if need be.
|
// Stock Zenith color we are using macros so we can call it later if need be.
|
||||||
#define kLightModeColor [UIColor colorWithWhite:1.0 alpha:0.7]
|
#define kLightColor [UIColor colorWithWhite:1.0 alpha:0.7]
|
||||||
|
|
||||||
|
#define kOLEDColor [UIColor colorWithWhite:0.0 alpha:0.75]
|
||||||
// the PLIST path where all user settings are stored.
|
// the PLIST path where all user settings are stored.
|
||||||
#define PLIST_PATH @"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist"
|
#define PLIST_PATH @"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist"
|
||||||
|
2
control
2
control
@ -1,5 +1,5 @@
|
|||||||
Package: com.mac-user669.zenithdark
|
Package: com.mac-user669.zenithdark
|
||||||
Version: 1.3
|
Version: 1.4
|
||||||
Architecture: iphoneos-arm
|
Architecture: iphoneos-arm
|
||||||
Maintainer: mac-user669
|
Maintainer: mac-user669
|
||||||
Depends: mobilesubstrate, preferenceloader, com.muirey03.zenith, ws.hbang.common (>= 1.11)
|
Depends: mobilesubstrate, preferenceloader, com.muirey03.zenith, ws.hbang.common (>= 1.11)
|
||||||
|
@ -40,6 +40,45 @@
|
|||||||
<key>label</key>
|
<key>label</key>
|
||||||
<string>Enable</string>
|
<string>Enable</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>cell</key>
|
||||||
|
<string>PSGroupCell</string>
|
||||||
|
<key>label</key>
|
||||||
|
<string>Color Type</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>cell</key>
|
||||||
|
<string>PSSegmentCell</string>
|
||||||
|
<key>default</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>defaults</key>
|
||||||
|
<string>com.mac-user669.zenithdark</string>
|
||||||
|
<key>key</key>
|
||||||
|
<string>sortingType</string>
|
||||||
|
<key>validValues</key>
|
||||||
|
<array>
|
||||||
|
<integer>0</integer>
|
||||||
|
<integer>1</integer>
|
||||||
|
<integer>2</integer>
|
||||||
|
<integer>3</integer>
|
||||||
|
</array>
|
||||||
|
<key>validTitles</key>
|
||||||
|
<array>
|
||||||
|
<string>Adaptive</string>
|
||||||
|
<string>Dark</string>
|
||||||
|
<string>OLED Adaptive</string>
|
||||||
|
<string>OLED</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
|
||||||
|
<dict>
|
||||||
|
<key>cell</key>
|
||||||
|
<string>PSGroupCell</string>
|
||||||
|
<key>label</key>
|
||||||
|
<string></string>
|
||||||
|
<key>footerText</key>
|
||||||
|
<string>A respring is needed to apply changes</string>
|
||||||
|
</dict>
|
||||||
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>cell</key>
|
<key>cell</key>
|
||||||
|
Reference in New Issue
Block a user