[Themes] Begin work on swizzling DCDThemeColor
This commit is contained in:
parent
c52eda0530
commit
39cec24715
2 changed files with 48 additions and 0 deletions
46
Sources/VendettaTweak/Themes.x.swift
Normal file
46
Sources/VendettaTweak/Themes.x.swift
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import Orion
|
||||
import UIKit
|
||||
import VendettaTweakC
|
||||
import os
|
||||
|
||||
struct Author: Codable {
|
||||
let name: String
|
||||
let id: String?
|
||||
}
|
||||
|
||||
struct ThemeData: Codable {
|
||||
let name: String
|
||||
let description: String?
|
||||
let authors: [Author]?
|
||||
let spec: Int
|
||||
let semanticColors: [String: [String]]?
|
||||
let rawColors: [String: String]?
|
||||
}
|
||||
|
||||
struct Theme: Codable {
|
||||
let id: String
|
||||
let selected: Bool
|
||||
let data: ThemeData
|
||||
}
|
||||
|
||||
func swizzleDCDThemeColor() {
|
||||
os_log("Swizzling DCDThemeColor", log: vendettaLog, type: .info)
|
||||
|
||||
let DCDThemeColor: AnyClass = NSClassFromString("DCDThemeColor")!
|
||||
os_log("Found instance of DCDThemeColor", log: vendettaLog, type: .debug)
|
||||
let target: AnyClass = object_getClass(DCDThemeColor)!
|
||||
|
||||
os_log("Found DCDThemeColor", log: vendettaLog, type: .debug)
|
||||
|
||||
var methodCount: UInt32 = 0
|
||||
let methods = class_copyMethodList(target, &methodCount)
|
||||
|
||||
os_log("DCDThemeColor has %{public}d methods", log: vendettaLog, type: .debug, methodCount)
|
||||
|
||||
for i in 0..<Int(methodCount) {
|
||||
let unwrapped = methods![i]
|
||||
let methodName = NSStringFromSelector(method_getName(unwrapped))
|
||||
os_log(
|
||||
"Found method %{public}@", log: vendettaLog, type: .debug, methodName)
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +87,9 @@ class LoadHook: ClassHook<RCTCxxBridge> {
|
|||
{
|
||||
orig.executeApplicationScript(
|
||||
"this.__vendetta_theme=\(themeString)".data(using: .utf8)!, url: source, async: false)
|
||||
swizzleDCDThemeColor()
|
||||
}
|
||||
|
||||
if vendetta != nil {
|
||||
os_log("Executing vendetta.js", log: vendettaLog, type: .info)
|
||||
orig.executeApplicationScript(vendetta!, url: source, async: false)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue