From 4b9cd27cab53df6181c696bfc32fffe3dc0776c6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 2 Mar 2020 14:54:48 -0500 Subject: [PATCH] change the base decode functions --- MVMCoreUI.xcodeproj/project.pbxproj | 12 ----- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 2 +- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 2 +- MVMCoreUI/Atoms/Buttons/Link/LinkModel.swift | 2 +- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 2 +- .../Label/LabelAttributeActionModel.swift | 2 +- MVMCoreUI/Atoms/Views/Label/LabelModel.swift | 7 +-- MVMCoreUI/Atoms/Views/ToggleModel.swift | 4 +- .../Views/MoleculeContainerModel.swift | 2 +- .../Extensions/MoleculeModelHelper.swift | 53 ------------------- .../Items/AccordionListItemModel.swift | 5 +- .../Items/DropDownListItemModel.swift | 2 +- MVMCoreUI/Molecules/Items/ListItemModel.swift | 2 +- .../Items/MoleculeListItemModel.swift | 2 +- .../Molecules/Items/TabsListItemModel.swift | 2 +- .../LeftRightViews/CornerLabelsModel.swift | 2 +- MVMCoreUI/Molecules/MoleculeHeaderModel.swift | 2 +- .../Lists/NumberedListModel.swift | 2 +- .../StringAndMoleculeModel.swift | 2 +- .../Lists/UnOrderedListModel.swift | 2 +- MVMCoreUI/Organisms/CarouselModel.swift | 2 +- .../Templates/ListPageTemplateModel.swift | 6 +-- .../Templates/StackPageTemplateModel.swift | 4 +- .../ThreeLayerPageTemplateModel.swift | 6 +-- 24 files changed, 29 insertions(+), 100 deletions(-) delete mode 100644 MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 339735f3..a805c1a0 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -124,7 +124,6 @@ 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 9458C3172406C8FD00930963 /* UIFont+FontWrapping.h in Headers */ = {isa = PBXBuildFile; fileRef = 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */ = {isa = PBXBuildFile; fileRef = 9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */; }; - 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; 94AF4A3E23E9D13900676048 /* MFCaretButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94AF4A3C23E9D13900676048 /* MFCaretButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94AF4A3F23E9D13900676048 /* MFCaretButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94AF4A3D23E9D13900676048 /* MFCaretButton.m */; }; @@ -471,7 +470,6 @@ 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIFont+FontWrapping.h"; sourceTree = ""; }; 9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIFont+FontWrapping.m"; sourceTree = ""; }; - 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; 94AF4A3C23E9D13900676048 /* MFCaretButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFCaretButton.h; sourceTree = ""; }; 94AF4A3D23E9D13900676048 /* MFCaretButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFCaretButton.m; sourceTree = ""; }; @@ -760,7 +758,6 @@ isa = PBXGroup; children = ( 011B58EE23A2AA850085F53C /* ModelProtocols */, - 946EE1B5237B663A0036751F /* Extensions */, ); path = Models; sourceTree = ""; @@ -825,14 +822,6 @@ path = FourColumn; sourceTree = ""; }; - 946EE1B5237B663A0036751F /* Extensions */ = { - isa = PBXGroup; - children = ( - 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */, - ); - path = Extensions; - sourceTree = ""; - }; 94C2D9822386F3E30006CF46 /* Label */ = { isa = PBXGroup; children = ( @@ -1966,7 +1955,6 @@ D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, - 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, D260106523D0CEA700764D80 /* StackModel.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index f02eaf5c..db24d474 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -75,7 +75,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) - action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + action = try typeContainer.decodeModel(codingKey: .action) required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) requiredGroups = try typeContainer.decodeIfPresent([String].self, forKey: .requiredGroups) if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) { diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 4ea79ef8..8f3ee74d 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -46,7 +46,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol { if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { self.enabled = enabled } - action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + action = try typeContainer.decodeModel(codingKey: .action) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/Link/LinkModel.swift index 6e7fc83d..7a4661bd 100644 --- a/MVMCoreUI/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/Link/LinkModel.swift @@ -55,7 +55,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) - action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + action = try typeContainer.decodeModel(codingKey: .action) if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { self.enabled = enabled diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 706597ff..1bed2c97 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -83,7 +83,7 @@ import Foundation isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) ?? true isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) ?? false isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) ?? true - action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + action = try typeContainer.decodeModelIfPresent(codingKey: .action) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift index 503f00d8..3e615cdd 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift @@ -25,7 +25,7 @@ open class LabelAttributeActionModel: LabelAttributeModel { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + action = try typeContainer.decodeModel(codingKey: .action) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index 3b5f2b66..7a04c577 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -74,7 +74,7 @@ import Foundation fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment) - attributes = try typeContainer.decodeModelsIfPresent(codingKey: .attributes, typeCodingKey: AttributeTypeKey.type) as? [LabelAttributeModel] + attributes = try typeContainer.decodeModelsIfPresent(codingKey: .attributes) html = try typeContainer.decodeIfPresent(String.self, forKey: .html) hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) @@ -91,10 +91,7 @@ import Foundation try container.encodeIfPresent(fontName, forKey: .fontName) try container.encodeIfPresent(fontSize, forKey: .fontSize) try container.encodeIfPresent(textAlignment, forKey: .textAlignment) - var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes) - try attributes?.forEach { attributeModel in - try attributeContainer.encode(attributeModel) - } + try container.encodeModelsIfPresent(attributes, forKey: .attributes) try container.encodeIfPresent(html, forKey: .html) try container.encodeIfPresent(hero, forKey: .hero) try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable) diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index aafacec8..04b45fe2 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -36,8 +36,8 @@ public class ToggleModel: MoleculeModelProtocol { if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { self.state = state } - action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) - alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction, typeCodingKey: ActionCodingKey.actionType) + action = try typeContainer.decodeModelIfPresent(codingKey: .action) + alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) diff --git a/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift b/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift index 95683f8f..01116a48 100644 --- a/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift +++ b/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift @@ -22,7 +22,7 @@ public class MoleculeContainerModel: ContainerModel, MoleculeContainerModelProto required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + molecule = try typeContainer.decodeModel(codingKey: .molecule) try super.init(from: decoder) } diff --git a/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift b/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift deleted file mode 100644 index 87460640..00000000 --- a/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// MoleculeModelHelper.swift -// MVMCoreUI -// -// Created by Ryan on 11/12/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - - -extension KeyedDecodingContainer where Key: CodingKey { - - private enum TypeCodingKey: String, CodingKey { - case moleculeName - } - - /// Decodes the molecule model with the given coding key based on moleculeName - public func decodeMolecule(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeModelProtocol { - return try decodeModel(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) - } - - /// Decodes the molecule model with the given coding key based on moleculeName, optional - public func decodeMoleculeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeModelProtocol? { - return try decodeModelIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) - } - - /// Decodes the list of molecule models with the given coding key based on moleculeName - public func decodeMolecules(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeModelProtocol] { - guard let models = try decodeModels(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeModelProtocol] else { - throw ModelRegistry.Error.decoderError - } - return models - } - - /// Decodes the list of molecule models with the given coding key based on moleculeName, optional - public func decodeMoleculesIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeModelProtocol]? { - return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeModelProtocol] - } - - /// Decodes an array with arrays of molecules based on the identifiers, optional. - public func decodeMolecules2DIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [[MoleculeModelProtocol]]? { - return try decodeModels2DIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeModelProtocol]] - } - - /// Decodes an array with arrays of models based on the identifiers. - public func decodeMolecules2D(codingKey: KeyedDecodingContainer.Key) throws -> [[MoleculeModelProtocol]] { - guard let models = try decodeModels2D(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeModelProtocol]] else { - throw ModelRegistry.Error.decoderError - } - return models - } -} diff --git a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift index 60192c2d..ac299a8b 100644 --- a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift @@ -29,10 +29,7 @@ class AccordionListItemModel: MoleculeListItemModel { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - guard let molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as? [ListItemModelProtocol & MoleculeModelProtocol] else { - throw DecodingError.typeMismatch([ListItemModelProtocol & MoleculeModelProtocol].self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Casting failed")) - } - self.molecules = molecules + molecules = try typeContainer.decodeModels(codingKey: .molecules) if let hideLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideLineWhenExpanded) { hideLineWhenExpanded = hideLine } diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index b623f20e..99d493b8 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -51,7 +51,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as? [[ListItemModelProtocol & MoleculeModelProtocol]] ?? [[]] + molecules = try typeContainer.decodeModels2D(codingKey: .molecules) dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) try super.init(from: decoder) } diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 4e0ccd35..259de421 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -45,7 +45,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + action = try typeContainer.decodeModelIfPresent(codingKey: .action) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) style = try typeContainer.decodeIfPresent(String.self, forKey: .style) diff --git a/MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift index 499669c6..1384ee88 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift @@ -27,7 +27,7 @@ import MVMCore required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + molecule = try typeContainer.decodeModel(codingKey: .molecule) try super.init(from: decoder) } diff --git a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift index c89ee1a0..e49b4adb 100644 --- a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift @@ -37,7 +37,7 @@ public class TabsListItemModel: ListItemModel, MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) tabs = try typeContainer.decode(TabsModel.self, forKey: .tabs) - molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol & MoleculeModelProtocol]] + molecules = try typeContainer.decodeModels2D(codingKey: .molecules) try super.init(from: decoder) } diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift index bb3e6f17..76a56178 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -34,7 +34,7 @@ public class CornerLabelsModel: MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule) + molecule = try typeContainer.decodeModelIfPresent(codingKey: .molecule) topLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topLeftLabel) topRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topRightLabel) bottomLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomLeftLabel) diff --git a/MVMCoreUI/Molecules/MoleculeHeaderModel.swift b/MVMCoreUI/Molecules/MoleculeHeaderModel.swift index 92958ca1..b8f2144e 100644 --- a/MVMCoreUI/Molecules/MoleculeHeaderModel.swift +++ b/MVMCoreUI/Molecules/MoleculeHeaderModel.swift @@ -24,7 +24,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + molecule = try typeContainer.decodeModel(codingKey: .molecule) try super.init(from: decoder) } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 795eec7d..8a7b6125 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -23,7 +23,7 @@ import Foundation public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - let list = try typeContainer.decodeMolecules(codingKey: .list) + let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for (index, molecule) in list.enumerated() { models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule))) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index c66f27b8..3adb0bb3 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -30,7 +30,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) string = try typeContainer.decode(String.self, forKey: .string) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + molecule = try typeContainer.decodeModel(codingKey: .molecule) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 87d57927..84d23a11 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -28,7 +28,7 @@ import Foundation self.bulletChar = bulletChar } - let list = try typeContainer.decodeMolecules(codingKey: .list) + let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for molecule in list { models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule))) diff --git a/MVMCoreUI/Organisms/CarouselModel.swift b/MVMCoreUI/Organisms/CarouselModel.swift index 79693135..da12b7b8 100644 --- a/MVMCoreUI/Organisms/CarouselModel.swift +++ b/MVMCoreUI/Organisms/CarouselModel.swift @@ -48,7 +48,7 @@ import UIKit 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 + self.pagingMolecule = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index 4ce4c6f5..6bd3f332 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -57,10 +57,10 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) pageType = try typeContainer.decode(String.self, forKey: .pageType) screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) - molecules = try typeContainer.decodeMoleculesIfPresent(codingKey: .molecules) as? [ListItemModelProtocol & MoleculeModelProtocol] + molecules = try typeContainer.decodeModelsIfPresent(codingKey: .molecules) isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) - header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header) - footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer) + header = try typeContainer.decodeModelIfPresent(codingKey: .header) + footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) } diff --git a/MVMCoreUI/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Templates/StackPageTemplateModel.swift index 10a2cf6f..0eddf030 100644 --- a/MVMCoreUI/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackPageTemplateModel.swift @@ -40,8 +40,8 @@ import Foundation 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) + header = try typeContainer.decodeModelIfPresent(codingKey: .header) + footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index 689a7c62..321b07a7 100644 --- a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -40,9 +40,9 @@ import Foundation pageType = try typeContainer.decode(String.self, forKey: .pageType) screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) - header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header) - middle = try typeContainer.decodeMoleculeIfPresent(codingKey: .middle) - footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer) + header = try typeContainer.decodeModelIfPresent(codingKey: .header) + middle = try typeContainer.decodeModelIfPresent(codingKey: .middle) + footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) } public func encode(to encoder: Encoder) throws {