[Themes] Hook native colors earlier

This commit is contained in:
Jack Matthews 2023-05-13 04:05:05 -04:00
parent 0619eaa176
commit 815d03d03d
No known key found for this signature in database

View file

@ -89,10 +89,6 @@ class LoadHook: ClassHook<RCTCxxBridge> {
{
orig.executeApplicationScript(
"globalThis.__vendetta_theme=\(themeString)".data(using: .utf8)!, url: source, async: false)
let theme = try? JSONDecoder().decode(Theme.self, from: themeString.data(using: .utf8)!)
if let semanticColors = theme?.data.semanticColors { swizzleDCDThemeColor(semanticColors) }
if let rawColors = theme?.data.rawColors { swizzleUIColor(rawColors) }
}
if vendetta != nil {
@ -103,3 +99,14 @@ class LoadHook: ClassHook<RCTCxxBridge> {
}
}
}
struct VendettaTweak: Tweak {
func tweakDidActivate() {
if let themeData = try? Data(
contentsOf: documentDirectory.appendingPathComponent("vendetta_theme.json")) {
let theme = try? JSONDecoder().decode(Theme.self, from: themeData)
if let semanticColors = theme?.data.semanticColors { swizzleDCDThemeColor(semanticColors) }
if let rawColors = theme?.data.rawColors { swizzleUIColor(rawColors) }
}
}
}