stack model fixes
This commit is contained in:
parent
f9620e4bc7
commit
824e077097
@ -18,7 +18,41 @@ import Foundation
|
|||||||
|
|
||||||
public var isAtomicTabs: Bool?
|
public var isAtomicTabs: Bool?
|
||||||
|
|
||||||
public var header: HeaderModel?
|
public var header: MoleculeProtocol?
|
||||||
public var moleculeStack: MoleculeStackModel?
|
public var moleculeStack: MoleculeStackModel
|
||||||
public var footer: FooterModel?
|
public var footer: MoleculeProtocol?
|
||||||
|
|
||||||
|
public init(pageType: String, moleculeStack: MoleculeStackModel) {
|
||||||
|
self.pageType = pageType
|
||||||
|
self.moleculeStack = moleculeStack
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case pageType
|
||||||
|
case screenHeading
|
||||||
|
case header
|
||||||
|
case footer
|
||||||
|
case moleculeStack
|
||||||
|
case isAtomicTabs
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
||||||
|
moleculeStack = try typeContainer.decode(MoleculeStackModel.self, forKey: .moleculeStack)
|
||||||
|
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
||||||
|
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
||||||
|
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
||||||
|
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(pageType, forKey: .pageType)
|
||||||
|
try container.encode(moleculeStack, forKey: .moleculeStack)
|
||||||
|
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
|
||||||
|
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
|
||||||
|
try container.encodeModelIfPresent(header, forKey: .header)
|
||||||
|
try container.encodeModelIfPresent(footer, forKey: .footer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user