57 lines
2.0 KiB
Swift
57 lines
2.0 KiB
Swift
//
|
|
// StackPageTemplate.swift
|
|
// MVMCoreUI
|
|
//
|
|
// Created by Suresh, Kamlesh on 11/22/19.
|
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
|
|
@objcMembers public class StackPageTemplateModel: TemplateModelProtocol {
|
|
public static var identifier: String = "stack"
|
|
|
|
public var pageType: String
|
|
public var screenHeading: String?
|
|
public var isAtomicTabs: Bool?
|
|
|
|
public var header: MoleculeModelProtocol?
|
|
public var moleculeStack: MoleculeStackModel
|
|
public var footer: MoleculeModelProtocol?
|
|
|
|
public init(pageType: String, moleculeStack: MoleculeStackModel) {
|
|
self.pageType = pageType
|
|
self.moleculeStack = moleculeStack
|
|
}
|
|
|
|
private enum CodingKeys: String, CodingKey {
|
|
case pageType
|
|
case screenHeading
|
|
case header
|
|
case footer
|
|
case stack
|
|
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: .stack)
|
|
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: .stack)
|
|
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
|
|
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
|
|
try container.encodeModelIfPresent(header, forKey: .header)
|
|
try container.encodeModelIfPresent(footer, forKey: .footer)
|
|
}
|
|
}
|