reorganizing defaults
This commit is contained in:
parent
6f36d161cb
commit
c276b09d74
@ -23,4 +23,33 @@ public protocol MoleculeDelegateProtocol: AnyObject {
|
||||
extension MoleculeDelegateProtocol {
|
||||
|
||||
public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { }
|
||||
|
||||
public func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? {
|
||||
let moduleJSON: [AnyHashable: Any]? = getModuleWithName(moleculeName)
|
||||
guard let moduleJSON = moduleJSON as? [String: Any],
|
||||
let moleculeName = moduleJSON.optionalStringForKey("moleculeName"),
|
||||
let modelType = ModelRegistry.getType(for: moleculeName, with: MoleculeModelProtocol.self)
|
||||
else { return nil }
|
||||
|
||||
do {
|
||||
return try modelType.decode(jsonDict: moduleJSON as [String : Any]) as? MoleculeModelProtocol
|
||||
} catch {
|
||||
MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
extension MoleculeDelegateProtocol where Self: TemplateProtocol {
|
||||
public func getRootMolecules() -> [MoleculeModelProtocol] {
|
||||
templateModel?.rootMolecules ?? []
|
||||
}
|
||||
}
|
||||
|
||||
extension MoleculeDelegateProtocol where Self: MVMCoreViewControllerProtocol {
|
||||
public func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? {
|
||||
guard let name = name else { return nil }
|
||||
return loadObject??.modulesJSON?.optionalDictionaryForKey(name)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user