Ver código fonte

Light mode color picker

master
mac-user669 4 anos atrás
pai
commit
fc83f55e00
3 arquivos alterados com 47 adições e 6 exclusões
  1. +10
    -3
      Tweak.xm
  2. +2
    -1
      ZenithDark.h
  3. +35
    -2
      zenithdarkprefs/Resources/Root.plist

+ 10
- 3
Tweak.xm Ver arquivo

@@ -4,7 +4,6 @@
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.
*/

@@ -16,6 +15,14 @@ Written for Cooper Hull, @mac-user669.
-(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
if (@available(iOS 13, *)) {
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
@@ -23,7 +30,7 @@ Written for Cooper Hull, @mac-user669.
}

else {
[self setBackgroundColor:kLightColor];
[self setBackgroundColor:lightColor];
}
}
}
@@ -100,4 +107,4 @@ static void PreferencesChangedCallback(CFNotificationCenterRef center, void *obs

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.

}
}

+ 2
- 1
ZenithDark.h Ver arquivo

@@ -36,6 +36,7 @@ NSMutableDictionary *prefs;
// 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 kColor1 [UIColor redColor]
#define kColor1 [UIColor redColor] // 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"

+ 35
- 2
zenithdarkprefs/Resources/Root.plist Ver arquivo

@@ -49,6 +49,7 @@
<key>footerText</key>
<string>Default: #000000:0.44</string>
</dict>

<dict>
<key>cell</key>
<string>PSLinkCell</string>
@@ -66,12 +67,44 @@
<true/>
</dict>
<key>label</key>
<string>Color</string>
<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>
</dict>

<dict>
<key>cell</key>
<string>PSLinkCell</string>
<key>cellClass</key>
<string>SparkColourPickerCell</string>
<key>libsparkcolourpicker</key>
<dict>
<key>defaults</key>
<string>com.mac-user669.zenithdark</string>
<key>key</key>
<string>kCustomLightColor</string>
<key>fallback</key>
<string>#FFFFFF:0.7</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>
@@ -133,7 +166,7 @@
<key>title</key>
<string>Reset</string>
<key>prompt</key>
<string>Reset all settings?</string>
<string>Reset settings?</string>
<key>okTitle</key>
<string>Reset</string>
<key>cancelTitle</key>

Carregando…
Cancelar
Salvar