ModuleMolecule fixes
This commit is contained in:
parent
b97416e7d6
commit
54d0ea3e5c
@ -12,6 +12,7 @@ public protocol ModelMoleculeViewProtocol {
|
||||
func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?)
|
||||
func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String?
|
||||
static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat?
|
||||
static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]?
|
||||
}
|
||||
|
||||
extension ModelMoleculeViewProtocol {
|
||||
@ -21,4 +22,7 @@ extension ModelMoleculeViewProtocol {
|
||||
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
return nil
|
||||
}
|
||||
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,36 +47,40 @@ open class ModuleMolecule: Container {
|
||||
}
|
||||
}
|
||||
|
||||
#warning("Kamlesh: uncomment below code")
|
||||
//TODO: Kamlesh: uncomment below code
|
||||
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
|
||||
// public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||
// guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
|
||||
// // Critical error
|
||||
// return 0
|
||||
// }
|
||||
// return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.estimatedHeight?(forRow: module, delegateObject: delegateObject) ?? 0
|
||||
// }
|
||||
//
|
||||
// public override class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||
// guard let moduleName = molecule?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
|
||||
// // Critical error
|
||||
// return "moduleMolecule<>"
|
||||
// }
|
||||
// return "moduleMolecule<" + (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.name?(forReuse: module, delegateObject: delegateObject) ?? module.stringForkey(KeyMoleculeName)) + ">"
|
||||
// }
|
||||
//
|
||||
// public override class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||
// let moduleName = json?.optionalStringForKey("moduleName")
|
||||
// if moduleName == nil || delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) == nil {
|
||||
// if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) {
|
||||
// error?.pointee = errorObject
|
||||
// MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject)
|
||||
// }
|
||||
// }
|
||||
// if let moduleName = moduleName {
|
||||
// return [moduleName]
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
guard let moduleMolecule = molecule as? ModuleMoleculeModel,
|
||||
let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol,
|
||||
let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type,
|
||||
let height = classType.estimatedHeight(forRow: moduleModel, delegateObject: delegateObject)else {
|
||||
// Critical error
|
||||
return 0
|
||||
}
|
||||
return height
|
||||
}
|
||||
|
||||
public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||
guard let moduleMolecule = model as? ModuleMoleculeModel,
|
||||
let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol,
|
||||
let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol,
|
||||
let name = classType.nameForReuse(moduleModel, delegateObject) else {
|
||||
// Critical error
|
||||
return "moduleMolecule<>"
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
//TODO: Scottt please check this.
|
||||
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||
|
||||
guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName,
|
||||
let _ = delegateObject?.moduleProtocol?.getModuleWithName(moduleName) else {
|
||||
if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) {
|
||||
error?.pointee = errorObject
|
||||
MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return [moduleName]
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user