model changes

This commit is contained in:
Suresh, Kamlesh 2020-01-09 15:11:03 -05:00
parent e310a2b74e
commit c8f8f8136d
4 changed files with 11 additions and 4 deletions

View File

@ -14,4 +14,9 @@ import Foundation
public var backgroundColor: Color?
public var label: String
public var options: [String]
public init(label: String, options: [String]) {
self.label = label
self.options = options
}
}

View File

@ -11,7 +11,6 @@ import Foundation
@objcMembers public class FooterModel: ContainerMoleculeProtocol {
public static var identifier: String = "footer"
public var moleculeName: String?
public var backgroundColor: Color?
public var molecule: MoleculeProtocol
@ -27,7 +26,6 @@ import Foundation
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName)
self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule)
}

View File

@ -10,19 +10,18 @@ import Foundation
@objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol {
public static var identifier: String = "header"
public var moleculeName: String?
public var backgroundColor: Color?
public var line: LineModel?
enum HeaderCodingKeys: String, CodingKey {
case moleculeName
case line
case backgroundColor
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self)
moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
// Default Values
@ -39,5 +38,6 @@ import Foundation
var container = encoder.container(keyedBy: HeaderCodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(line, forKey: .line)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
}
}

View File

@ -17,6 +17,10 @@ open class ModuleMoleculeModel: MoleculeProtocol {
case moduleName
}
public init(_ moduleName: String) {
self.moduleName = moduleName
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
moduleName = try typeContainer.decode(String.self, forKey:.moduleName)