Bläddra i källkod

Revert "Work on adding iKA's pull. I feel like i'm not doing something right..."

This reverts commit 2e26dc9082.
master
mac-user669 4 år sedan
förälder
incheckning
fbd2b19bc8
13 ändrade filer med 287 tillägg och 0 borttagningar
  1. +19
    -0
      Makefile
  2. +2
    -0
      README.md
  3. +79
    -0
      Tweak.xm
  4. +26
    -0
      ZenithDark.h
  5. +1
    -0
      ZenithDark.plist
  6. +11
    -0
      control
  7. Binär
      packages/com.mac-user669.zenithdark_1.0_iphoneos-arm.deb
  8. +17
    -0
      zenithdarkprefs/Makefile
  9. +24
    -0
      zenithdarkprefs/Resources/Info.plist
  10. +42
    -0
      zenithdarkprefs/Resources/Root.plist
  11. +5
    -0
      zenithdarkprefs/ZnthDrkRootListController.h
  12. +40
    -0
      zenithdarkprefs/ZnthDrkRootListController.m
  13. +21
    -0
      zenithdarkprefs/entry.plist

+ 19
- 0
Makefile Visa fil

@@ -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

+ 2
- 0
README.md Visa fil

@@ -0,0 +1,2 @@
# ZenithDark
Dark tabs for Zenith! Availible on [mac-user669's repo](https://mac-user669.github.io/repo/)

+ 79
- 0
Tweak.xm Visa fil

@@ -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);

}

+ 26
- 0
ZenithDark.h Visa fil

@@ -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]

+ 1
- 0
ZenithDark.plist Visa fil

@@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.apple.springboard" ); }; }

+ 11
- 0
control Visa fil

@@ -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/

Binär
packages/com.mac-user669.zenithdark_1.0_iphoneos-arm.deb Visa fil


+ 17
- 0
zenithdarkprefs/Makefile Visa fil

@@ -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)

+ 24
- 0
zenithdarkprefs/Resources/Info.plist Visa fil

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>ZenithDarkPrefs</string>
<key>CFBundleIdentifier</key>
<string>com.mac-user669.zenithdarkprefs</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string>ZnthDrkRootListController</string>
</dict>
</plist>

+ 42
- 0
zenithdarkprefs/Resources/Root.plist Visa fil

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Enable</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.mac-user669.zenithdarkprefs</string>
<key>key</key>
<string>enabled</string>
<key>label</key>
<string>Enable</string>
</dict>

<dict>
<key>cell</key>
<string>PSGroupCell</string>
</dict>
<dict>
<key>cell</key>
<string>PSButtonCell</string>
<key>label</key>
<string>@mac_user669</string>
<key>action</key>
<string>openTwitter</string>
</dict>
</array>
<key>title</key>
<string>ZenithDark</string>
</dict>
</plist>

+ 5
- 0
zenithdarkprefs/ZnthDrkRootListController.h Visa fil

@@ -0,0 +1,5 @@
#import <Preferences/PSListController.h>

@interface ZnthDrkRootListController : PSListController

@end

+ 40
- 0
zenithdarkprefs/ZnthDrkRootListController.m Visa fil

@@ -0,0 +1,40 @@
#import "ZnthDrkRootListController.h"
#import <spawn.h>
@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

+ 21
- 0
zenithdarkprefs/entry.plist Visa fil

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>entry</key>
<dict>
<key>bundle</key>
<string>ZenithDarkPrefs</string>
<key>cell</key>
<string>PSLinkCell</string>
<key>detail</key>
<string>ZnthDrkRootListController</string>
<key>icon</key>
<string>icon.png</string>
<key>isController</key>
<true/>
<key>label</key>
<string>ZenithDarkPrefs</string>
</dict>
</dict>
</plist>

Laddar…
Avbryt
Spara