ModuleMolecule fixes

This commit is contained in:
Suresh, Kamlesh 2020-01-08 16:50:47 -05:00
parent b97416e7d6
commit 54d0ea3e5c
2 changed files with 39 additions and 31 deletions

View File

@ -12,6 +12,7 @@ public protocol ModelMoleculeViewProtocol {
func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?)
func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String?
static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat?
static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]?
} }
extension ModelMoleculeViewProtocol { extension ModelMoleculeViewProtocol {
@ -21,4 +22,7 @@ extension ModelMoleculeViewProtocol {
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil return nil
} }
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
} }

View File

@ -47,36 +47,40 @@ open class ModuleMolecule: Container {
} }
} }
#warning("Kamlesh: uncomment below code") public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
//TODO: Kamlesh: uncomment below code
// public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { guard let moduleMolecule = molecule as? ModuleMoleculeModel,
// guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol,
// // Critical error let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type,
// return 0 let height = classType.estimatedHeight(forRow: moduleModel, delegateObject: delegateObject)else {
// } // Critical error
// return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.estimatedHeight?(forRow: module, delegateObject: delegateObject) ?? 0 return 0
// } }
// return height
// 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 public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
// return "moduleMolecule<>" guard let moduleMolecule = model as? ModuleMoleculeModel,
// } let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol,
// return "moduleMolecule<" + (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.name?(forReuse: module, delegateObject: delegateObject) ?? module.stringForkey(KeyMoleculeName)) + ">" let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol,
// } let name = classType.nameForReuse(moduleModel, delegateObject) else {
// // Critical error
// public override class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { return "moduleMolecule<>"
// let moduleName = json?.optionalStringForKey("moduleName") }
// if moduleName == nil || delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) == nil { return name
// 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) //TODO: Scottt please check this.
// } public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
// }
// if let moduleName = moduleName { guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName,
// return [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)) {
// return nil error?.pointee = errorObject
// } MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject)
}
return nil
}
return [moduleName]
}
} }