From b620a533d52b4d69a1a3a6ea56de398914193b81 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Jan 2020 11:22:34 -0500 Subject: [PATCH] Color CaretLink model change name --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++--- ...ButtonModel.swift => CaretLinkModel.swift} | 30 ++++++++++------- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 2 +- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 33 +++++++++++-------- .../ModelProtocols/MoleculeProtocol.swift | 2 +- 5 files changed, 43 insertions(+), 32 deletions(-) rename MVMCoreUI/Atoms/Buttons/{CaretButtonModel.swift => CaretLinkModel.swift} (59%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 18eaaf7b..8363aad1 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -66,7 +66,7 @@ 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368B23609801006832FA /* MoleculeStackModel.swift */; }; 01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; }; 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; }; - 01F2A03223A4498200D954D8 /* CaretButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretButtonModel.swift */; }; + 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; }; 0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */; }; @@ -326,7 +326,7 @@ 01EB368B23609801006832FA /* MoleculeStackModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackModel.swift; sourceTree = ""; }; 01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = ""; }; 01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = ""; }; - 01F2A03123A4498200D954D8 /* CaretButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretButtonModel.swift; sourceTree = ""; }; + 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretLinkModel.swift; sourceTree = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackViewAlignment+Extension.swift"; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; @@ -983,7 +983,7 @@ isa = PBXGroup; children = ( DBC4391A224421A0001AB423 /* CaretButton.swift */, - 01F2A03123A4498200D954D8 /* CaretButtonModel.swift */, + 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */, D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, @@ -1418,7 +1418,7 @@ 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, 012CA9E223888AED003F810F /* (null) in Sources */, 012A88DA238ED42E00FE3DA1 /* (null) in Sources */, - 01F2A03223A4498200D954D8 /* CaretButtonModel.swift in Sources */, + 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift similarity index 59% rename from MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift rename to MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index cf21a19b..0cd9c252 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -1,5 +1,5 @@ // -// CaretButtonModel.swift +// CaretLinkModel.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 12/13/19. @@ -9,14 +9,14 @@ import Foundation import MVMCore -public class CaretButtonModel: MoleculeProtocol { - public static var identifier: String = "caretButton" +public class CaretLinkModel: MoleculeProtocol { + public static var identifier: String = "caretLink" public var backgroundColor: String? public var label: LabelModel public var action: ActionProtocol - public var enabledColor: String? - public var disabledColor: String? - public var enabled: Bool? + public var enabledColor: UIColor = .black + public var disabledColor: UIColor = .mfSilver() + public var enabled: Bool = true public init(label: LabelModel, action: ActionProtocol) { self.label = label @@ -36,9 +36,15 @@ public class CaretButtonModel: MoleculeProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) label = try typeContainer.decode(LabelModel.self, forKey: .label) - enabledColor = try typeContainer.decodeIfPresent(String.self, forKey: .enabledColor) - disabledColor = try typeContainer.decodeIfPresent(String.self, forKey: .disabledColor) - enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor)?.uiColor { + enabledColor = color + } + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor)?.uiColor { + disabledColor = color + } + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { + self.enabled = enabled + } action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type) } @@ -47,8 +53,8 @@ public class CaretButtonModel: MoleculeProtocol { try container.encode(label, forKey: .label) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) - try container.encodeIfPresent(enabledColor, forKey: .enabledColor) - try container.encodeIfPresent(disabledColor, forKey: .disabledColor) - try container.encodeIfPresent(enabled, forKey: .enabled) + try container.encode(Color(uiColor: enabledColor), forKey: .enabledColor) + try container.encode(Color(uiColor: disabledColor), forKey: .disabledColor) + try container.encode(enabled, forKey: .enabled) } } diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index 5a8998db..8d2bc16c 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class CaretViewModel: MoleculeProtocol { public static var identifier: String = "caretView" - public var backgroundColor: String? + public var backgroundColor: Color? public var strokeColor: String? public var isHidden: Bool? public var isOpaque: Bool? diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 3450fc87..784b938c 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -10,33 +10,38 @@ import Foundation @objcMembers public class ProgressBarModel: MoleculeProtocol { public static var identifier: String = "progressbar" - public var moleculeName: String public var isRounded: Bool? public var thickness: CGFloat? ///from 0 to 100 - public var percentage: Float - public var progressColor: String? - public var backgroundColor: String? + public var percent: CGFloat + public var progressColor: Color = Color(uiColor: .mfCerulean()) + public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) enum CodingKeys: String, CodingKey { case moleculeName case isRounded = "roundRect" case thickness - case percentage = "percent" + case percent case progressColor case backgroundColor } + init(_ percent: CGFloat) { + self.percent = percent + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) - self.thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) - self.percentage = try typeContainer.decode(Float.self, forKey: .percentage) - self.progressColor = try typeContainer.decodeIfPresent(String.self, forKey: .progressColor) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) - + isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) + thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) + percent = try typeContainer.decode(CGFloat.self, forKey: .percent) + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .progressColor) { + progressColor = color + } + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) { + backgroundColor = color + } } public func encode(to encoder: Encoder) throws { @@ -44,8 +49,8 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(isRounded, forKey: .isRounded) try container.encodeIfPresent(thickness, forKey: .thickness) - try container.encodeIfPresent(percentage, forKey: .percentage) - try container.encodeIfPresent(progressColor, forKey: .progressColor) + try container.encode(percent, forKey: .percent) + try container.encode(progressColor, forKey: .progressColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift index e05f16b6..b8117e60 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift @@ -2,7 +2,7 @@ import Foundation public protocol MoleculeProtocol: Model { var moleculeName: String? { get } - var backgroundColor: String? { get set} + var backgroundColor: Color? { get set} } extension MoleculeProtocol {