From 633eb4ec21d7c29352640a9f3f86ec310f83aefa Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 18 Feb 2020 15:19:28 -0500 Subject: [PATCH 1/9] adding a new action type. updated action map flow. --- MVMCoreUI/Atoms/Buttons/Link.swift | 4 +++ MVMCoreUI/Atoms/Buttons/LinkModel.swift | 26 ++++++++++++++++++- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 2 +- MVMCoreUI/BaseClasses/Button.swift | 9 +++++-- .../MoleculeModelProtocol.swift | 2 +- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index b4c00c94..5dbbed16 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -36,6 +36,10 @@ import UIKit context?.strokePath() } + //-------------------------------------------------- + // MARK: - ModelMoleculeViewProtocol + //-------------------------------------------------- + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? LinkModel else { return } diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index f4fab34c..a3dc940c 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -9,20 +9,37 @@ import UIKit public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { - public static var identifier: String = "link" + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public class var identifier: String { + return "link" + } + public var backgroundColor: Color? public var title: String public var action: ActionModelProtocol public var enabled = true public var textColor = Color(uiColor: .mvmBlack) public var disabledColor = Color(uiColor: .mvmCoolGray6) + public var moleculeName: String? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- public init(title: String, action: ActionModelProtocol) { self.title = title self.action = action } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case title case action @@ -31,11 +48,17 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { case disabledColor } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) 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) + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { self.enabled = enabled } @@ -54,6 +77,7 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) try container.encode(enabled, forKey: .enabled) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(textColor, forKey: .textColor) try container.encode(disabledColor, forKey: .disabledColor) } diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 5e8cedc8..0f2f65d0 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -301,7 +301,7 @@ import UIKit let fallbackImageName = customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback") if let format = format, format.lowercased().contains("gif") { // Gifs aren't supported by default and need special handling - MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, completionHandler: finishedLoadingBlock) + MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: false, completionHandler: finishedLoadingBlock) } else { MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, completionHandler: finishedLoadingBlock) } diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 60e0ab1a..c0ff0e81 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -12,6 +12,7 @@ public typealias ButtonAction = (Button) -> () //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var model: MoleculeModelProtocol? open var actionModel: ActionModelProtocol? @@ -67,7 +68,7 @@ public typealias ButtonAction = (Button) -> () addTarget(self, action: #selector(callActionBlock(_:)), for: event) } - @objc private func callActionBlock(_ sender: Button) { + @objc func callActionBlock(_ sender: Button) { buttonAction?(self) } @@ -88,11 +89,13 @@ public typealias ButtonAction = (Button) -> () // MARK:- ModelMoleculeViewProtocol open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model + if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor } guard let model = model as? ButtonModelProtocol else { return } + isEnabled = model.enabled set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } @@ -113,7 +116,7 @@ public typealias ButtonAction = (Button) -> () // MARK: - MVMCoreViewProtocol extension Button: MVMCoreViewProtocol { - open func updateView(_ size: CGFloat) {} + open func updateView(_ size: CGFloat) { } /// Will be called only once. open func setupView() { @@ -126,6 +129,7 @@ extension Button: MVMCoreViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol extension Button: MVMCoreUIMoleculeViewProtocol { + open func reset() { backgroundColor = .clear } @@ -133,6 +137,7 @@ extension Button: MVMCoreUIMoleculeViewProtocol { // MARK: AppleGuidelinesProtocol extension Button: AppleGuidelinesProtocol { + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { return Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift index 1ec0d13c..cec7b90a 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift @@ -3,7 +3,7 @@ import Foundation public protocol MoleculeModelProtocol: Model { var moleculeName: String? { get } - var backgroundColor: Color? { get set} + var backgroundColor: Color? { get set } } public extension MoleculeModelProtocol { From 29f89154f89c68db06d11144366d46ad0013366b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 18 Feb 2020 16:55:56 -0500 Subject: [PATCH 2/9] small model fix for images --- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index fa7d369e..156e187d 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -210,6 +210,9 @@ import UIKit } public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + self.delegateObject = delegateObject + // TODO: Temporary, should be moved to init once we have type erasure ready. + setAsMolecule() guard let imageModel = model as? ImageViewModel else { return } From cbe01463d9a50905de0b618f3246c29f547f7b66 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 19 Feb 2020 11:26:24 -0500 Subject: [PATCH 3/9] moleculeName --- .../Atoms/TextFields/BaseDropdownEntryFieldModel.swift | 2 +- MVMCoreUI/Atoms/TextFields/TextFieldModel.swift | 2 +- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 2 ++ MVMCoreUI/Atoms/Views/CheckboxModel.swift | 2 ++ MVMCoreUI/Atoms/Views/DashLineModel.swift | 2 ++ MVMCoreUI/Atoms/Views/ImageViewModel.swift | 1 + MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift | 5 +++++ MVMCoreUI/Atoms/Views/MultiProgressModel.swift | 2 ++ MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift | 2 ++ .../HorizontalCombinationViews/ImageHeadlineBodyModel.swift | 1 + MVMCoreUI/Molecules/Items/StackItemModel.swift | 1 + .../LeftRightViews/ActionDetailWithImageModel.swift | 1 + .../ToggleMolecules/HeadlineBodyLinkToggleModel.swift | 1 + .../ToggleMolecules/HeadlineBodyToggleModel.swift | 1 + .../LeftRightViews/ToggleMolecules/LabelToggleModel.swift | 6 ++++++ MVMCoreUI/Molecules/ScrollerModel.swift | 1 + .../EyebrowHeadlineBodyLinkModel.swift | 2 +- .../VerticalCombinationViews/HeadlineBodyButtonModel.swift | 1 + .../VerticalCombinationViews/HeadlineBodyLinkModel.swift | 1 + .../VerticalCombinationViews/HeadlineBodyModel.swift | 1 + 20 files changed, 34 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift index e6e7cb24..496625dc 100644 --- a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift @@ -37,9 +37,9 @@ } public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(caretView, forKey: .caretView) } } diff --git a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift index 6caa70b0..e26995d6 100644 --- a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift @@ -12,7 +12,7 @@ import UIKit public static var identifier: String = "textField" public var backgroundColor: Color? - public var moleculeName: String + public var moleculeName: String? = TextFieldModel.identifier public var editable: Bool? public var disabled: Bool? public var errorMsg: String? diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index 58291984..cf90496f 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -18,6 +18,7 @@ import Foundation public var lineWidth: CGFloat? private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case strokeColor case isHidden @@ -38,6 +39,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(strokeColor, forKey: .strokeColor) try container.encodeIfPresent(isHidden, forKey: .isHidden) try container.encodeIfPresent(isOpaque, forKey: .isOpaque) diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index aa5dedb4..de79c6c6 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -39,6 +39,7 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case groupName case value case fieldKey @@ -85,6 +86,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(groupName, forKey: .groupName) try container.encodeIfPresent(value, forKey: .value) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 1346b5c2..7f5ac992 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -20,6 +20,7 @@ import Foundation } private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case dashColor case isHidden @@ -36,6 +37,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(dashColor, forKey: .dashColor) try container.encodeIfPresent(isHidden, forKey: .isHidden) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 97f31ad2..d23289bf 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,6 +11,7 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeModelProtocol { public static var identifier: String = "image" public var backgroundColor: Color? + public var moleculeName: String? = ImageViewModel.identifier public var image: String public var accessibilityText: String? public var fallbackImage: String? diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index 325611ec..d7ee1553 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -10,7 +10,12 @@ import UIKit @objcMembers public class LeftRightLabelModel: MoleculeModelProtocol { public static var identifier: String = "leftRightLabelView" + public var moleculeName: String? = LeftRightLabelModel.identifier public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel? + + init(_ leftText: LabelModel) { + self.leftText = leftText + } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 6dd05b0b..4033fd28 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -26,6 +26,7 @@ import Foundation public var roundedRect: Bool? private enum CodingKeys: String, CodingKey { + case moleculeName case progressList case thickness case roundedRect @@ -46,6 +47,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(progressList, forKey: .progressList) try container.encodeIfPresent(thickness, forKey: .thickness) try container.encodeIfPresent(roundedRect, forKey: .roundedRect) diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift index 42acd2f0..af6100ac 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift @@ -11,6 +11,7 @@ import Foundation @objcMembers public class DoughnutChartModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChart" + public var moleculeName: String? = DoughnutChartModel.identifier public var title: LabelModel? public var subtitle: LabelModel? public var sections: [DoughnutChartItemModel] @@ -24,6 +25,7 @@ import Foundation @objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChartItem" + public var moleculeName: String? = DoughnutChartItemModel.identifier public var label: LabelModel @Percent public var percent: CGFloat public var color: Color diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift index 4966ce58..7f3d52dc 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift @@ -10,6 +10,7 @@ import Foundation public struct ImageHeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "imageHeadlineBody" + public var moleculeName: String? = ImageHeadlineBodyModel.identifier public var backgroundColor: Color? public var image: ImageViewModel public var headlineBody: HeadlineBodyModel diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index 2058353c..b7d1a269 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -10,6 +10,7 @@ import Foundation @objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol { public static var identifier: String = "simpleStackItem" + public var moleculeName: String? = StackItemModel.identifier public var backgroundColor: Color? public var spacing: CGFloat? public var percent: Int? diff --git a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift index a397c1a1..9dbf53c0 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift @@ -10,6 +10,7 @@ import Foundation public struct ActionDetailWithImageModel: MoleculeModelProtocol { public static var identifier: String = "actionDetailWithImage" + public var moleculeName: String? = ActionDetailWithImageModel.identifier public var backgroundColor: Color? public var headlineBodyButton: HeadlineBodyButtonModel public var image: ImageViewModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift index 5ce04f9c..aad8ec06 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift @@ -9,6 +9,7 @@ import Foundation public struct HeadlineBodyLinkToggleModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyLinkToggle" + public var moleculeName: String? = HeadlineBodyLinkToggleModel.identifier public var backgroundColor: Color? public var headlineBodyLink: HeadlineBodyLinkModel public var toggle: ToggleModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift index dd7c2b1c..bb3391a6 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift @@ -11,6 +11,7 @@ import Foundation open class HeadlineBodyToggleModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyToggle" + public var moleculeName: String? = HeadlineBodyToggleModel.identifier open var backgroundColor: Color? open var headlineBody: HeadlineBodyModel open var toggle: ToggleModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift index 7ed5857e..526ac6b9 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift @@ -10,7 +10,13 @@ import Foundation public class LabelToggleModel: MoleculeModelProtocol { public static var identifier: String = "labelToggle" + public var moleculeName: String? = LabelToggleModel.identifier public var backgroundColor: Color? public var label: LabelModel public var toggle: ToggleModel + + init(_ label: LabelModel, _ toggle: ToggleModel) { + self.label = label + self.toggle = toggle + } } diff --git a/MVMCoreUI/Molecules/ScrollerModel.swift b/MVMCoreUI/Molecules/ScrollerModel.swift index f92fe13b..91dc2e1c 100644 --- a/MVMCoreUI/Molecules/ScrollerModel.swift +++ b/MVMCoreUI/Molecules/ScrollerModel.swift @@ -10,5 +10,6 @@ import UIKit public class ScrollerModel: MoleculeContainerModel, MoleculeModelProtocol { public static var identifier: String = "scroller" + public var moleculeName: String? = ScrollerModel.identifier public var backgroundColor: Color? } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index e9341535..81a38111 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -11,7 +11,7 @@ import Foundation struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { static var identifier: String = "eyebrowHeadlineBodyLink" var backgroundColor: Color? - + var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier public var eyeBrow: LabelModel? public var headline: LabelModel? public var body: LabelModel? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift index 74e85ea9..ec97fda0 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift @@ -10,6 +10,7 @@ import Foundation public struct HeadlineBodyButtonModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyButton" + public var moleculeName: String? = HeadlineBodyButtonModel.identifier public var backgroundColor: Color? public var headlineBody: HeadlineBodyModel diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift index 9eae8e03..27f0d670 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift @@ -10,6 +10,7 @@ import Foundation public struct HeadlineBodyLinkModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyLink" + public var moleculeName: String? = HeadlineBodyLinkModel.identifier public var headlineBody: HeadlineBodyModel public var link: LinkModel public var backgroundColor: Color? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index fd5be23a..d7a08091 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -10,6 +10,7 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "headlineBody" + public var moleculeName: String? = HeadlineBodyModel.identifier public var headline: LabelModel? public var body: LabelModel? public var style: String? From 23fa0c5badf8f03228ee0ab034d19045f2595d89 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 19 Feb 2020 12:36:28 -0500 Subject: [PATCH 4/9] reverting --- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index a3dc940c..28fc8596 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -13,9 +13,7 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { // MARK: - Properties //-------------------------------------------------- - public class var identifier: String { - return "link" - } + public static var identifier: String = "link" public var backgroundColor: Color? public var title: String @@ -23,7 +21,6 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { public var enabled = true public var textColor = Color(uiColor: .mvmBlack) public var disabledColor = Color(uiColor: .mvmCoolGray6) - public var moleculeName: String? //-------------------------------------------------- // MARK: - Initializer @@ -54,7 +51,6 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) 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) From 08cf275ba4d0c0a8b1b82708ef6fd0ea2f1dcbf5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 19 Feb 2020 13:59:28 -0500 Subject: [PATCH 5/9] space --- MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift index af6100ac..1e5c7dce 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class DoughnutChartModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChart" - public var moleculeName: String? = DoughnutChartModel.identifier + public var moleculeName: String? = DoughnutChartModel.identifier public var title: LabelModel? public var subtitle: LabelModel? public var sections: [DoughnutChartItemModel] From b5ac3b0b763efe79c0053616bf37b10a7bfa5769 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 19 Feb 2020 14:09:34 -0500 Subject: [PATCH 6/9] fixes --- MVMCoreUI/Molecules/Items/CarouselItemModel.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift index f2c88e9b..9fc218a7 100644 --- a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift @@ -14,7 +14,6 @@ import Foundation public var backgroundColor: Color? public var peakingUI: Bool? public var peakingArrowColor: Color? - public var moleculeName: String? private enum CodingKeys: String, CodingKey { case moleculeName @@ -25,7 +24,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI) peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor) From f38b577321743965583ab9cfeb8d48047f4c996d Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 19 Feb 2020 14:26:52 -0500 Subject: [PATCH 7/9] add missing moleculeName --- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 2 ++ MVMCoreUI/Atoms/Buttons/LinkModel.swift | 2 ++ MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift | 2 -- MVMCoreUI/Atoms/Views/CircleProgressModel.swift | 2 ++ MVMCoreUI/Atoms/Views/ToggleModel.swift | 1 - MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift | 2 ++ MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift | 2 ++ .../Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift | 1 + MVMCoreUI/Organisms/CarouselModel.swift | 2 +- MVMCoreUI/Organisms/StackModel.swift | 1 + 10 files changed, 13 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index defe6816..4b28fc8c 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -30,6 +30,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol { case enabledColor case disabledColor case enabled + case moleculeName } required public init(from decoder: Decoder) throws { @@ -50,6 +51,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(title, forKey: .title) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index f4fab34c..1092289f 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -29,6 +29,7 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { case enabled case textColor case disabledColor + case moleculeName } required public init(from decoder: Decoder) throws { @@ -56,5 +57,6 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { try container.encode(enabled, forKey: .enabled) try container.encode(textColor, forKey: .textColor) try container.encode(disabledColor, forKey: .disabledColor) + try container.encode(moleculeName, forKey: .moleculeName) } } diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift index 1030fb8c..e4a794bc 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -19,7 +19,6 @@ import Foundation } public var backgroundColor: Color? - public var moleculeName: String? public var title: String? public var feedback: String? public var errorMessage: String = "" @@ -54,7 +53,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decodeIfPresent(String.self, forKey: .title) feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback) diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift index c4f55bef..9a1908f8 100644 --- a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -48,6 +48,7 @@ public class CircleProgressModel: MoleculeModelProtocol { case duration case colors case backgroundColor + case moleculeName } required public init(from decoder: Decoder) throws { @@ -78,6 +79,7 @@ public class CircleProgressModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(style, forKey: .style) try container.encode(size, forKey: .size) try container.encode(diameter, forKey: .diameter) diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 9cd96f45..aafacec8 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -10,7 +10,6 @@ import UIKit public class ToggleModel: MoleculeModelProtocol { public static var identifier: String = "toggle" - public var moleculeName: String? public var backgroundColor: Color? public var state: Bool = true public var action: ActionModelProtocol? diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift index f45c771d..8b69c590 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -22,6 +22,7 @@ public class TabsModel: MoleculeModelProtocol { case backgroundColor case selectedColor case selectedIndex + case moleculeName } public init(with tabs: [LabelModel]) { @@ -42,6 +43,7 @@ public class TabsModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) try container.encode(backgroundColor, forKey: .backgroundColor) try container.encode(selectedColor, forKey: .selectedColor) diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift index f4b67216..bb3e6f17 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -28,6 +28,7 @@ public class CornerLabelsModel: MoleculeModelProtocol { case bottomLeftLabel case bottomRightLabel case molecule + case moleculeName } required public init(from decoder: Decoder) throws { @@ -48,5 +49,6 @@ public class CornerLabelsModel: MoleculeModelProtocol { try container.encodeIfPresent(topRightLabel, forKey: .topRightLabel) try container.encodeIfPresent(bottomLeftLabel, forKey: .bottomLeftLabel) try container.encodeIfPresent(bottomRightLabel, forKey: .bottomRightLabel) + try container.encode(moleculeName, forKey: .moleculeName) } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index caa00021..c66f27b8 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -38,5 +38,6 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(string, forKey: .string) try container.encodeModel(molecule, forKey: .molecule) + try container.encode(moleculeName, forKey: .moleculeName) } } diff --git a/MVMCoreUI/Organisms/CarouselModel.swift b/MVMCoreUI/Organisms/CarouselModel.swift index e43e6caa..79693135 100644 --- a/MVMCoreUI/Organisms/CarouselModel.swift +++ b/MVMCoreUI/Organisms/CarouselModel.swift @@ -53,7 +53,7 @@ import UIKit public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(molecules, forKey: .molecules) try container.encode(spacing, forKey: .spacing) diff --git a/MVMCoreUI/Organisms/StackModel.swift b/MVMCoreUI/Organisms/StackModel.swift index 741946c5..8d670efb 100644 --- a/MVMCoreUI/Organisms/StackModel.swift +++ b/MVMCoreUI/Organisms/StackModel.swift @@ -45,5 +45,6 @@ import Foundation try container.encodeIfPresent(molecules, forKey: .molecules) try container.encodeIfPresent(axis.rawValueString, forKey: .axis) try container.encodeIfPresent(spacing, forKey: .spacing) + try container.encode(moleculeName, forKey: .moleculeName) } } From 5c42c4bf28d5206aa52848b183b48fe7e90be470 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 19 Feb 2020 14:45:51 -0500 Subject: [PATCH 8/9] remove typo --- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index 590cdbf7..a4fe6cf2 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -43,7 +43,6 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { case enabled case textColor case disabledColor - case moleculeName } //-------------------------------------------------- @@ -74,9 +73,7 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) try container.encode(enabled, forKey: .enabled) - try container.encode(moleculeName, forKey: .moleculeName) try container.encode(textColor, forKey: .textColor) try container.encode(disabledColor, forKey: .disabledColor) - try container.encode(moleculeName, forKey: .moleculeName) } } From 6b1a02c369518e4e9739b6ec0a1b563f0f7f4d0e Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 19 Feb 2020 14:48:31 -0500 Subject: [PATCH 9/9] fix typo --- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index a4fe6cf2..7094a038 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -70,6 +70,7 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(title, forKey: .title) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) try container.encode(enabled, forKey: .enabled)