diff --git a/MVMCoreUI/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atoms/Buttons/Link/Link.swift index 1259d0d8..c64bd13b 100644 --- a/MVMCoreUI/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link/Link.swift @@ -36,6 +36,13 @@ import UIKit context?.strokePath() } + open override var intrinsicContentSize: CGSize { + guard let size = titleLabel?.intrinsicContentSize else { + return super.intrinsicContentSize + } + return CGSize(width: size.width, height: size.height + 2) + } + //-------------------------------------------------- // MARK: - ModelMoleculeViewProtocol //-------------------------------------------------- @@ -81,6 +88,7 @@ extension Link { titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left contentHorizontalAlignment = .left + contentVerticalAlignment = .top } } diff --git a/MVMCoreUI/Atoms/Views/RadioButton.swift b/MVMCoreUI/Atoms/Views/RadioButton.swift index 2c110b4e..ce95c639 100644 --- a/MVMCoreUI/Atoms/Views/RadioButton.swift +++ b/MVMCoreUI/Atoms/Views/RadioButton.swift @@ -17,14 +17,9 @@ import UIKit } var enabledColor = UIColor.black - var disabledColor = UIColor.mfSilver() - + var disabledColor = UIColor.mfSilver() var delegateObject: MVMCoreUIDelegateObject? - var fieldKey: String? - var formValue: Bool? - var isRequired: Bool = false - var widthConstraint: NSLayoutConstraint? var heightConstraint: NSLayoutConstraint? diff --git a/MVMCoreUI/Atoms/Views/RadioButtonModel.swift b/MVMCoreUI/Atoms/Views/RadioButtonModel.swift index 0927866c..0aa56cc0 100644 --- a/MVMCoreUI/Atoms/Views/RadioButtonModel.swift +++ b/MVMCoreUI/Atoms/Views/RadioButtonModel.swift @@ -13,50 +13,54 @@ public class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { public static var identifier: String = "radioButton" public var backgroundColor: Color? - public var state: Bool? = false - public var fieldKey: String? - public var groupName: String? = FormValidator.defaultGroupName - public var fieldValue: String? - public var baseValue: AnyHashable? - - public func formFieldValue() -> AnyHashable? { - return fieldValue - } + public var state: Bool = false + public var enabled: Bool = true + public var baseValue: AnyHashable? + public var groupName: String? + public var fieldKey: String? + public var fieldValue: String? + private enum CodingKeys: String, CodingKey { case moleculeName - case state case backgroundColor + case state + case enabled case fieldKey - case groupName case fieldValue + case groupName } - + public init(_ state: Bool) { self.state = state } + public func formFieldValue() -> AnyHashable? { + return 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) + groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) - if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - self.groupName = groupName - } } - + 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.encodeIfPresent(state, forKey: .state) + try container.encode(state, forKey: .state) + try container.encode(enabled, forKey: .enabled) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(fieldValue, forKey: .fieldValue) try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encodeIfPresent(fieldValue, forKey: .fieldValue) } } diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 18022833..5e67be8a 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -24,7 +24,6 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { case state case action case backgroundColor - case required case fieldKey case alternateAction case groupName @@ -58,7 +57,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { 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(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) } 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;