diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 61ee1780..d9f4c2ff 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -12,6 +12,9 @@ 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; + 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */; }; + 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */; }; + 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F323A2CCC80085F53C /* DropDownModel.swift */; }; 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */; }; 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */; }; 012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */; }; @@ -261,6 +264,9 @@ 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; + 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModelProtocol.swift; sourceTree = ""; }; + 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownListItemModel.swift; sourceTree = ""; }; + 011B58F323A2CCC80085F53C /* DropDownModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownModel.swift; sourceTree = ""; }; 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModelProtocol.swift; sourceTree = ""; }; 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateProtocol.swift; sourceTree = ""; }; 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselModel.swift; sourceTree = ""; }; @@ -521,10 +527,24 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 011B58EE23A2AA850085F53C /* ModelProtocols */ = { + isa = PBXGroup; + children = ( + 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, + 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */, + 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */, + 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, + 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, + 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, + 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, + 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */, + ); + path = ModelProtocols; + sourceTree = ""; + }; 012A889A238898C600FE3DA1 /* Template */ = { isa = PBXGroup; children = ( - 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, 012CA9DD2388723E003F810F /* ListPageTemplateModel.swift */, 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */, 012CA9E123888AED003F810F /* StackCenteredPageTemplateModel.swift */, @@ -544,12 +564,8 @@ 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( + 011B58EE23A2AA850085F53C /* ModelProtocols */, 012A88EF23985E0100FE3DA1 /* Primitive Models */, - 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, - 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, - 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, - 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */, - 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */, 012A889A238898C600FE3DA1 /* Template */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, @@ -573,12 +589,13 @@ children = ( 012CA98823849699003F810F /* SeperatorModel.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, + 011B58F323A2CCC80085F53C /* DropDownModel.swift */, + 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, - 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, 017BEB7A236763000024EF95 /* LineModel.swift */, 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, @@ -1352,6 +1369,7 @@ 012CA9E223888AED003F810F /* StackCenteredPageTemplateModel.swift in Sources */, 012A88DA238ED42E00FE3DA1 /* StackPageTemplateModel.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, + 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, @@ -1364,6 +1382,7 @@ D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, + 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, @@ -1407,6 +1426,7 @@ D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, + 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift similarity index 100% rename from MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift diff --git a/MVMCoreUI/Models/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ContainerMoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift diff --git a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/FormModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/Molecules/FormModelProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/FormModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift new file mode 100644 index 00000000..ccd8884b --- /dev/null +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -0,0 +1,14 @@ +// +// ListItemModelProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ListItemModelProtocol: ContainerMoleculeProtocol { + var molecule: MoleculeProtocol? { get } + var separator: SeperatorModel? { get set } +} diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift similarity index 100% rename from MVMCoreUI/Models/MoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift diff --git a/MVMCoreUI/Models/PagingMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PagingMoleculeProtocol.swift similarity index 100% rename from MVMCoreUI/Models/PagingMoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/PagingMoleculeProtocol.swift diff --git a/MVMCoreUI/Models/Template/TemplateModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/Template/TemplateModelProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift diff --git a/MVMCoreUI/Models/TemplateProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift similarity index 100% rename from MVMCoreUI/Models/TemplateProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift new file mode 100644 index 00000000..c6c109fe --- /dev/null +++ b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift @@ -0,0 +1,46 @@ +// +// DropDownListItemModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class DropDownListItemModel: ListItemModelProtocol { + public static var identifier: String = "dropDownListItem" + public var molecules: [[ListItemModel]] + public var backgroundColor: String? + public var separator: SeperatorModel? + public var dropDown: DropDownModel + + public init(molecules: [[ListItemModel]], dropDown: DropDownModel) { + self.molecules = molecules + self.dropDown = dropDown + } + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecules + case separator + case backgroundColor + case dropDown + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) + self.separator = try typeContainer.decode(SeperatorModel.self, forKey: .separator) + self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(molecules, forKey: .molecules) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(dropDown, forKey: .dropDown) + } +} diff --git a/MVMCoreUI/Models/Molecules/DropDownModel.swift b/MVMCoreUI/Models/Molecules/DropDownModel.swift new file mode 100644 index 00000000..b28eda5d --- /dev/null +++ b/MVMCoreUI/Models/Molecules/DropDownModel.swift @@ -0,0 +1,17 @@ +// +// DropDownModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class DropDownModel: MoleculeProtocol { + public static var identifier: String = "dropDownModel" + public var backgroundColor: String? + public var label: String + public var options: [String] +} diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index 9bfe704a..72556dae 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ListItemModel: ContainerMoleculeProtocol { +@objcMembers public class ListItemModel: ListItemModelProtocol { public static var identifier: String = "listItem" public var molecule: MoleculeProtocol? public var backgroundColor: String? @@ -40,9 +40,9 @@ import Foundation self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) - self.hideArrow = try typeContainer.decode(Bool.self, forKey: .hideArrow) - self.separator = try typeContainer.decode(SeperatorModel.self, forKey: .hideArrow) - self.style = try typeContainer.decode(String.self, forKey: .style) + self.hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) + self.separator = try typeContainer.decodeIfPresent(SeperatorModel.self, forKey: .separator) + self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) } public func encode(to encoder: Encoder) throws { @@ -50,5 +50,6 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(action, forKey: .action) + try container.encodeIfPresent(hideArrow, forKey: .hideArrow) } } diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift index 2ad31cdc..fa8b96a2 100644 --- a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift @@ -11,14 +11,53 @@ import Foundation @objcMembers public class ListPageTemplateModel: TemplateModelProtocol { public static var identifier: String = "listTemplate" - + public var pageType: String - public var screenHeading: String - public var isAtomicTabs: Bool? - public var header: MoleculeStackModel? - public var molecules: [ListItemModel]? + public var header: HeaderModel? + public var molecules: [ListItemModelProtocol] public var footer: MoleculeStackModel? + + public init(pageType: String, screenHeading: String, molecules: [ListItemModelProtocol]) { + self.pageType = pageType + self.screenHeading = screenHeading + self.molecules = molecules + } + + enum CodingKeys: String, CodingKey { + case moleculeName + case pageType + case screenHeading + case molecules + case header + case footer + case isAtomicTabs + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.pageType = try typeContainer.decode(String.self, forKey: .pageType) + self.screenHeading = try typeContainer.decode(String.self, forKey: .screenHeading) + guard let list = try typeContainer.decodeArray(codingKey: .molecules) as? [ListItemModelProtocol] else { + throw JSONError.pathNotFound + } + self.molecules = list + self.isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) + self.header = try typeContainer.decodeIfPresent(HeaderModel.self, forKey: .header) + self.footer = try typeContainer.decodeIfPresent(MoleculeStackModel.self, forKey: .footer) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(pageType, forKey: .pageType) + try container.encode(screenHeading, forKey: .screenHeading) + + try container.encodeArray(molecules, forKey: .molecules) + try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) + try container.encodeIfPresent(header, forKey: .header) + try container.encodeIfPresent(footer, forKey: .footer) + } } +