change the base decode functions
This commit is contained in:
parent
2e99d980e8
commit
4b9cd27cab
@ -124,7 +124,6 @@
|
|||||||
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; };
|
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, ); }; };
|
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 */; };
|
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 */; };
|
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, ); }; };
|
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 */; };
|
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 = "<group>"; };
|
9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = "<group>"; };
|
||||||
9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIFont+FontWrapping.h"; sourceTree = "<group>"; };
|
9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIFont+FontWrapping.h"; sourceTree = "<group>"; };
|
||||||
9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIFont+FontWrapping.m"; sourceTree = "<group>"; };
|
9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIFont+FontWrapping.m"; sourceTree = "<group>"; };
|
||||||
946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeModelHelper.swift; sourceTree = "<group>"; };
|
|
||||||
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
||||||
94AF4A3C23E9D13900676048 /* MFCaretButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFCaretButton.h; sourceTree = "<group>"; };
|
94AF4A3C23E9D13900676048 /* MFCaretButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFCaretButton.h; sourceTree = "<group>"; };
|
||||||
94AF4A3D23E9D13900676048 /* MFCaretButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFCaretButton.m; sourceTree = "<group>"; };
|
94AF4A3D23E9D13900676048 /* MFCaretButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFCaretButton.m; sourceTree = "<group>"; };
|
||||||
@ -760,7 +758,6 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
011B58EE23A2AA850085F53C /* ModelProtocols */,
|
011B58EE23A2AA850085F53C /* ModelProtocols */,
|
||||||
946EE1B5237B663A0036751F /* Extensions */,
|
|
||||||
);
|
);
|
||||||
path = Models;
|
path = Models;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -825,14 +822,6 @@
|
|||||||
path = FourColumn;
|
path = FourColumn;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
946EE1B5237B663A0036751F /* Extensions */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */,
|
|
||||||
);
|
|
||||||
path = Extensions;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
94C2D9822386F3E30006CF46 /* Label */ = {
|
94C2D9822386F3E30006CF46 /* Label */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -1966,7 +1955,6 @@
|
|||||||
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
|
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
|
||||||
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,
|
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,
|
||||||
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
||||||
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
|
|
||||||
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
||||||
D260106523D0CEA700764D80 /* StackModel.swift in Sources */,
|
D260106523D0CEA700764D80 /* StackModel.swift in Sources */,
|
||||||
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
|
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
|||||||
|
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
title = try typeContainer.decode(String.self, forKey: .title)
|
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)
|
required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required)
|
||||||
requiredGroups = try typeContainer.decodeIfPresent([String].self, forKey: .requiredGroups)
|
requiredGroups = try typeContainer.decodeIfPresent([String].self, forKey: .requiredGroups)
|
||||||
if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) {
|
if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) {
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol {
|
|||||||
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||||
self.enabled = 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 {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -55,7 +55,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol {
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
title = try typeContainer.decode(String.self, forKey: .title)
|
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) {
|
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||||
self.enabled = enabled
|
self.enabled = enabled
|
||||||
|
|||||||
@ -83,7 +83,7 @@ import Foundation
|
|||||||
isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) ?? true
|
isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) ?? true
|
||||||
isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) ?? false
|
isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) ?? false
|
||||||
isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) ?? true
|
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 {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ open class LabelAttributeActionModel: LabelAttributeModel {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
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)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ import Foundation
|
|||||||
fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
|
fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
|
||||||
fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
|
fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
|
||||||
textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment)
|
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)
|
html = try typeContainer.decodeIfPresent(String.self, forKey: .html)
|
||||||
hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)
|
hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)
|
||||||
makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable)
|
makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable)
|
||||||
@ -91,10 +91,7 @@ import Foundation
|
|||||||
try container.encodeIfPresent(fontName, forKey: .fontName)
|
try container.encodeIfPresent(fontName, forKey: .fontName)
|
||||||
try container.encodeIfPresent(fontSize, forKey: .fontSize)
|
try container.encodeIfPresent(fontSize, forKey: .fontSize)
|
||||||
try container.encodeIfPresent(textAlignment, forKey: .textAlignment)
|
try container.encodeIfPresent(textAlignment, forKey: .textAlignment)
|
||||||
var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes)
|
try container.encodeModelsIfPresent(attributes, forKey: .attributes)
|
||||||
try attributes?.forEach { attributeModel in
|
|
||||||
try attributeContainer.encode(attributeModel)
|
|
||||||
}
|
|
||||||
try container.encodeIfPresent(html, forKey: .html)
|
try container.encodeIfPresent(html, forKey: .html)
|
||||||
try container.encodeIfPresent(hero, forKey: .hero)
|
try container.encodeIfPresent(hero, forKey: .hero)
|
||||||
try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable)
|
try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable)
|
||||||
|
|||||||
@ -36,8 +36,8 @@ public class ToggleModel: MoleculeModelProtocol {
|
|||||||
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
|
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
|
||||||
self.state = state
|
self.state = state
|
||||||
}
|
}
|
||||||
action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
action = try typeContainer.decodeModelIfPresent(codingKey: .action)
|
||||||
alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction, typeCodingKey: ActionCodingKey.actionType)
|
alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required)
|
required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required)
|
||||||
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public class MoleculeContainerModel: ContainerModel, MoleculeContainerModelProto
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
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)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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<K>.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<K>.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<K>.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<K>.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<K>.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<K>.Key) throws -> [[MoleculeModelProtocol]] {
|
|
||||||
guard let models = try decodeModels2D(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeModelProtocol]] else {
|
|
||||||
throw ModelRegistry.Error.decoderError
|
|
||||||
}
|
|
||||||
return models
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -29,10 +29,7 @@ class AccordionListItemModel: MoleculeListItemModel {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
guard let molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as? [ListItemModelProtocol & MoleculeModelProtocol] else {
|
molecules = try typeContainer.decodeModels(codingKey: .molecules)
|
||||||
throw DecodingError.typeMismatch([ListItemModelProtocol & MoleculeModelProtocol].self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Casting failed"))
|
|
||||||
}
|
|
||||||
self.molecules = molecules
|
|
||||||
if let hideLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideLineWhenExpanded) {
|
if let hideLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideLineWhenExpanded) {
|
||||||
hideLineWhenExpanded = hideLine
|
hideLineWhenExpanded = hideLine
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ import Foundation
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
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)
|
dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ import Foundation
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
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)
|
hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow)
|
||||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
||||||
style = try typeContainer.decodeIfPresent(String.self, forKey: .style)
|
style = try typeContainer.decodeIfPresent(String.self, forKey: .style)
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import MVMCore
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
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)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class TabsListItemModel: ListItemModel, MoleculeModelProtocol {
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
tabs = try typeContainer.decode(TabsModel.self, forKey: .tabs)
|
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)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class CornerLabelsModel: MoleculeModelProtocol {
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
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)
|
topLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topLeftLabel)
|
||||||
topRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topRightLabel)
|
topRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topRightLabel)
|
||||||
bottomLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomLeftLabel)
|
bottomLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomLeftLabel)
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import Foundation
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
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)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import Foundation
|
|||||||
public required init(from decoder: Decoder) throws {
|
public required init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
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] = []
|
var models: [MoleculeStackItemModel] = []
|
||||||
for (index, molecule) in list.enumerated() {
|
for (index, molecule) in list.enumerated() {
|
||||||
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule)))
|
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule)))
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
string = try typeContainer.decode(String.self, forKey: .string)
|
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 {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import Foundation
|
|||||||
self.bulletChar = bulletChar
|
self.bulletChar = bulletChar
|
||||||
}
|
}
|
||||||
|
|
||||||
let list = try typeContainer.decodeMolecules(codingKey: .list)
|
let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list)
|
||||||
var models: [MoleculeStackItemModel] = []
|
var models: [MoleculeStackItemModel] = []
|
||||||
for molecule in list {
|
for molecule in list {
|
||||||
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule)))
|
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule)))
|
||||||
|
|||||||
@ -48,7 +48,7 @@ import UIKit
|
|||||||
self.height = try typeContainer.decode(Float.self, forKey: .height)
|
self.height = try typeContainer.decode(Float.self, forKey: .height)
|
||||||
self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent)
|
self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent)
|
||||||
self.itemAlignment = try typeContainer.decode(String.self, forKey: .itemAlignment)
|
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 {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -57,10 +57,10 @@ import Foundation
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
||||||
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
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)
|
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
||||||
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
header = try typeContainer.decodeModelIfPresent(codingKey: .header)
|
||||||
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
footer = try typeContainer.decodeModelIfPresent(codingKey: .footer)
|
||||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,8 +40,8 @@ import Foundation
|
|||||||
moleculeStack = try typeContainer.decode(MoleculeStackModel.self, forKey: .stack)
|
moleculeStack = try typeContainer.decode(MoleculeStackModel.self, forKey: .stack)
|
||||||
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
||||||
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
||||||
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
header = try typeContainer.decodeModelIfPresent(codingKey: .header)
|
||||||
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
footer = try typeContainer.decodeModelIfPresent(codingKey: .footer)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -40,9 +40,9 @@ import Foundation
|
|||||||
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
||||||
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
||||||
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
||||||
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
header = try typeContainer.decodeModelIfPresent(codingKey: .header)
|
||||||
middle = try typeContainer.decodeMoleculeIfPresent(codingKey: .middle)
|
middle = try typeContainer.decodeModelIfPresent(codingKey: .middle)
|
||||||
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
footer = try typeContainer.decodeModelIfPresent(codingKey: .footer)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user