// // CarouselModel.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 11/25/19. // Copyright © 2019 Verizon Wireless. All rights reserved. // import UIKit @objcMembers public class CarouselModel: MoleculeModelProtocol { public static var identifier: String = "carousel" public var backgroundColor: Color? public var molecules: [CarouselItemModel] public var spacing: Float? public var border: Bool? public var loop: Bool? public var height: Float? public var itemWidthPercent: Float? public var itemAlignment: String? public var pagingMolecule: CarouselPagingModelProtocol? public init(molecules: [CarouselItemModel]){ self.molecules = molecules } private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case molecules case spacing case border case loop case height case itemWidthPercent case itemAlignment case pagingMolecule } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.spacing = try typeContainer.decode(Float.self, forKey: .spacing) self.border = try typeContainer.decode(Bool.self, forKey: .border) self.loop = try typeContainer.decode(Bool.self, forKey: .loop) self.height = try typeContainer.decode(Float.self, forKey: .height) self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent) self.itemAlignment = try typeContainer.decode(String.self, forKey: .itemAlignment) self.pagingMolecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .pagingMolecule) as? CarouselPagingModelProtocol } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(molecules, forKey: .molecules) try container.encode(spacing, forKey: .spacing) try container.encode(border, forKey: .border) try container.encode(loop, forKey: .loop) try container.encode(height, forKey: .height) try container.encode(itemWidthPercent, forKey: .itemWidthPercent) try container.encode(itemAlignment, forKey: .itemAlignment) try container.encodeModelIfPresent(pagingMolecule, forKey: .pagingMolecule) } }