diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6387a69 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +ARCHS = arm64 arm64e +SDK = iPhoneOS13.0 +FINALPACKAGE = 1 +export TARGET = iphone:clang:13.0:latest + +include $(THEOS)/makefiles/common.mk + +TWEAK_NAME = ZenithDark + +ZenithDark_FILES = Tweak.xm +ZenithDark_CFLAGS = -fobjc-arc +ZenithDark_FRAMEWORKS = UIKit CoreGraphics + +include $(THEOS_MAKE_PATH)/tweak.mk + +after-install:: + install.exec "sbreload" +SUBPROJECTS += zenithdarkprefs +include $(THEOS_MAKE_PATH)/aggregate.mk diff --git a/README.md b/README.md new file mode 100644 index 0000000..c0a434e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# ZenithDark +Dark tabs for Zenith! Availible on [mac-user669's repo](https://mac-user669.github.io/repo/) \ No newline at end of file diff --git a/Tweak.xm b/Tweak.xm new file mode 100644 index 0000000..fbd9fd6 --- /dev/null +++ b/Tweak.xm @@ -0,0 +1,79 @@ +/* + +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. + +Written for Cooper Hull, @(mac-user669). + + +*/ + +#import "ZenithDark.h" + +static BOOL enabled; +static void loadPrefs() { + static NSMutableDictionary *settings; + + CFArrayRef keyList = CFPreferencesCopyKeyList(CFSTR("com.mac-user669.zenithdarkprefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (keyList) { + settings = (NSMutableDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, CFSTR("com.mac-user669.zenithdarkprefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost)); + CFRelease(keyList); + } else { + settings = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.mac-user669.zenithdarkprefs.plist"]; + } + + enabled = [([settings objectForKey:@"enabled"] ? [settings objectForKey:@"enabled"] : @(YES)) boolValue]; +} + +// 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 { + if (enabled) { + %orig(previousTraitCollection); + if (@available(iOS 13, *)) { + if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { + [self setBackgroundColor:kDarkModeColor]; + } + + else { + [self setBackgroundColor:kLightModeColor]; + } + } + } + %orig; +} + +// 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 { + if (enabled) { + // by default have our tweak overide this. + if (@available(iOS 13, *)) { + if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { + %orig(kDarkModeColor); + } + + else { + %orig; + } + } + } + %orig; +} + + +// 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 + + +// our constructor +%ctor { + +loadPrefs(); + +// We use this to make sure we load Zenith's dynamic library at runtime so we can modify it with our tweak. +dlopen ("/Library/MobileSubstrate/DynamicLibraries/Zenith.dylib", RTLD_NOW); + +} \ No newline at end of file diff --git a/ZenithDark.h b/ZenithDark.h new file mode 100644 index 0000000..c14944a --- /dev/null +++ b/ZenithDark.h @@ -0,0 +1,26 @@ +/* + +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. + +Written for Cooper Hull, @(mac-user669). + +ZenithDark Header file to keep the tweak.x file clean! + + +*/ + + +// 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 + +// 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] + +// 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] diff --git a/ZenithDark.plist b/ZenithDark.plist new file mode 100644 index 0000000..10dc654 --- /dev/null +++ b/ZenithDark.plist @@ -0,0 +1 @@ +{ Filter = { Bundles = ( "com.apple.springboard" ); }; } diff --git a/control b/control new file mode 100644 index 0000000..d98404b --- /dev/null +++ b/control @@ -0,0 +1,11 @@ +Package: com.mac-user669.zenithdark +Version: 1.0 +Architecture: iphoneos-arm +Maintainer: mac-user669 +Depends: mobilesubstrate, com.muirey03.zenith, firmware (>=13.0) +Section: Tweaks +Description: Changes Zeniths tabs to a dark blur +Author: mac-user669 +Name: ZenithDark +Sileodepiction: https://raw.githubusercontent.com/mac-user669/repo/master/sileodepictions/ZenithDark.json +Depiction: https://mac-user669.github.io/repo/depictions/?p=com.mac-user669.zenithdark/ diff --git a/packages/com.mac-user669.zenithdark_1.0_iphoneos-arm.deb b/packages/com.mac-user669.zenithdark_1.0_iphoneos-arm.deb new file mode 100644 index 0000000..6ac9a87 Binary files /dev/null and b/packages/com.mac-user669.zenithdark_1.0_iphoneos-arm.deb differ diff --git a/zenithdarkprefs/Makefile b/zenithdarkprefs/Makefile new file mode 100644 index 0000000..aab3c31 --- /dev/null +++ b/zenithdarkprefs/Makefile @@ -0,0 +1,17 @@ +include $(THEOS)/makefiles/common.mk + +ARCHS = arm64 arm64e +export TARGET = iphone:clang:13.0:latest +BUNDLE_NAME = ZenithDarkPrefs + +ZenithDarkPrefs_FILES = ZnthDrkRootListController.m +ZenithDarkPrefs_INSTALL_PATH = /Library/PreferenceBundles +ZenithDarkPrefs_FRAMEWORKS = UIKit +ZenithDarkPrefs_PRIVATE_FRAMEWORKS = Preferences +ZenithDarkPrefs_CFLAGS = -fobjc-arc + +include $(THEOS_MAKE_PATH)/bundle.mk + +internal-stage:: + $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) + $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/ZenithDarkPrefs.plist$(ECHO_END) diff --git a/zenithdarkprefs/Resources/Info.plist b/zenithdarkprefs/Resources/Info.plist new file mode 100644 index 0000000..86d931a --- /dev/null +++ b/zenithdarkprefs/Resources/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ZenithDarkPrefs + CFBundleIdentifier + com.mac-user669.zenithdarkprefs + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + ZnthDrkRootListController + + diff --git a/zenithdarkprefs/Resources/Root.plist b/zenithdarkprefs/Resources/Root.plist new file mode 100644 index 0000000..727bd0f --- /dev/null +++ b/zenithdarkprefs/Resources/Root.plist @@ -0,0 +1,42 @@ + + + + + items + + + cell + PSGroupCell + label + Enable + + + cell + PSSwitchCell + default + + defaults + com.mac-user669.zenithdarkprefs + key + enabled + label + Enable + + + + cell + PSGroupCell + + + cell + PSButtonCell + label + @mac_user669 + action + openTwitter + + + title + ZenithDark + + \ No newline at end of file diff --git a/zenithdarkprefs/ZnthDrkRootListController.h b/zenithdarkprefs/ZnthDrkRootListController.h new file mode 100644 index 0000000..07cc78a --- /dev/null +++ b/zenithdarkprefs/ZnthDrkRootListController.h @@ -0,0 +1,5 @@ +#import + +@interface ZnthDrkRootListController : PSListController + +@end diff --git a/zenithdarkprefs/ZnthDrkRootListController.m b/zenithdarkprefs/ZnthDrkRootListController.m new file mode 100644 index 0000000..4c559f8 --- /dev/null +++ b/zenithdarkprefs/ZnthDrkRootListController.m @@ -0,0 +1,40 @@ +#import "ZnthDrkRootListController.h" +#import +@implementation ZnthDrkRootListController + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + UIBarButtonItem *applyButton = [[UIBarButtonItem alloc] initWithTitle:@"Apply" style:UIBarButtonItemStylePlain target:self action:@selector(respringDevice)]; + self.navigationItem.rightBarButtonItem = applyButton; +} + +- (NSArray *)specifiers { + if (!_specifiers) { + _specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self]; + } + + return _specifiers; +} + +- (void) respringDevice { + UIAlertController *confirmRespringAlert = [UIAlertController alertControllerWithTitle:@"Apply settings?" message:@"This will respring your device" preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + pid_t pid; + const char *argv[] = {"sbreload", NULL}; + posix_spawn(&pid, "/usr/bin/sbreload", NULL, NULL, (char* const*)argv, NULL); + }]; + + UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; + + [confirmRespringAlert addAction:cancel]; + [confirmRespringAlert addAction:confirm]; + + [self presentViewController:confirmRespringAlert animated:YES completion:nil]; +} + +-(void)openTwitter { + NSURL *twitter = [NSURL URLWithString:@"https://twitter.com/mac_user669"]; + [[UIApplication sharedApplication] openURL:twitter options:@{} completionHandler:nil]; +} + +@end diff --git a/zenithdarkprefs/entry.plist b/zenithdarkprefs/entry.plist new file mode 100644 index 0000000..9b0cc13 --- /dev/null +++ b/zenithdarkprefs/entry.plist @@ -0,0 +1,21 @@ + + + + + entry + + bundle + ZenithDarkPrefs + cell + PSLinkCell + detail + ZnthDrkRootListController + icon + icon.png + isController + + label + ZenithDarkPrefs + + +