From 24961cb50e23dff1ee6e5449b9635b8d2d70f650 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 9 Mar 2020 16:11:21 -0400 Subject: [PATCH 1/4] decode fixes --- MVMCoreUI/Atoms/Views/RadioButtonModel.swift | 34 ++++++++++++++++++++ MVMCoreUI/Atoms/Views/ToggleModel.swift | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/RadioButtonModel.swift b/MVMCoreUI/Atoms/Views/RadioButtonModel.swift index c8443691..d26e1671 100644 --- a/MVMCoreUI/Atoms/Views/RadioButtonModel.swift +++ b/MVMCoreUI/Atoms/Views/RadioButtonModel.swift @@ -13,5 +13,39 @@ public class RadioButtonModel: MoleculeModelProtocol { public static var identifier: String = "radioButton" public var backgroundColor: Color? public var state: Bool = false + public var enabled: Bool = true public var fieldKey: String? + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case state + case enabled + case fieldKey + } + + public init(_ state: Bool) { + self.state = state + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { + self.state = state + } + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { + self.enabled = enabled + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(state, forKey: .state) + try container.encode(enabled, forKey: .enabled) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + } } diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 04b45fe2..948a8e96 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -49,7 +49,7 @@ public class ToggleModel: MoleculeModelProtocol { try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(state, forKey: .state) + try container.encode(state, forKey: .state) try container.encodeIfPresent(required, forKey: .required) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) } From b30c08f467a81f5a9afd11d24272b090de56733c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 9 Mar 2020 16:33:25 -0400 Subject: [PATCH 2/4] update link to not have padding --- MVMCoreUI/Atoms/Buttons/Link/Link.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atoms/Buttons/Link/Link.swift index 1259d0d8..cd314d4b 100644 --- a/MVMCoreUI/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link/Link.swift @@ -36,6 +36,10 @@ import UIKit context?.strokePath() } + open override var intrinsicContentSize: CGSize { + return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize + } + //-------------------------------------------------- // MARK: - ModelMoleculeViewProtocol //-------------------------------------------------- From fc7a64f3df70a6302fb4a3fa0f5e3b665c8b6dfb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 9 Mar 2020 16:52:24 -0400 Subject: [PATCH 3/4] fix link --- MVMCoreUI/Atoms/Buttons/Link/Link.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atoms/Buttons/Link/Link.swift index cd314d4b..c64bd13b 100644 --- a/MVMCoreUI/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link/Link.swift @@ -37,7 +37,10 @@ import UIKit } open override var intrinsicContentSize: CGSize { - return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize + guard let size = titleLabel?.intrinsicContentSize else { + return super.intrinsicContentSize + } + return CGSize(width: size.width, height: size.height + 2) } //-------------------------------------------------- @@ -85,6 +88,7 @@ extension Link { titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left contentHorizontalAlignment = .left + contentVerticalAlignment = .top } } From 6aef009eba82bb96ba7219c7b6251956a83c37ab Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 9 Mar 2020 16:58:01 -0400 Subject: [PATCH 4/4] name update --- .../OtherHandlers/MVMCoreUIViewControllerMappingObject.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index 6a0805f3..d3db2a2d 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -23,8 +23,8 @@ @"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]], @"list" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], @"threeLayer" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]], - @"stackModal" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ModalMoleculeStackTemplate class]], - @"listModal" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ModalMoleculeListTemplate class]] + @"modalStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ModalMoleculeStackTemplate class]], + @"modalList" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ModalMoleculeListTemplate class]] } mutableCopy]; }); return viewControllerMapping;