diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 0cd9c252..4d3c6223 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -11,7 +11,7 @@ import MVMCore public class CaretLinkModel: MoleculeProtocol { public static var identifier: String = "caretLink" - public var backgroundColor: String? + public var backgroundColor: Color? public var label: LabelModel public var action: ActionProtocol public var enabledColor: UIColor = .black @@ -34,7 +34,7 @@ public class CaretLinkModel: MoleculeProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) label = try typeContainer.decode(LabelModel.self, forKey: .label) if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor)?.uiColor { enabledColor = color diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 52ed9a65..48decdf9 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -90,12 +90,12 @@ open class DashLine: View { guard let dashLineModel = model as? DashLineModel else { return } - dashColor = UIColor.mfGet(forHex: dashLineModel.dashColor) + dashColor = dashLineModel.dashColor.uiColor if let isHiddenValue = dashLineModel.isHidden { isHidden = isHiddenValue } if let backgroundColor = dashLineModel.backgroundColor { - dashLayer?.backgroundColor = UIColor.mfGet(forHex: backgroundColor).cgColor + dashLayer?.backgroundColor = backgroundColor.uiColor.cgColor } } } diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 172e5dd6..06d85f08 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -10,12 +10,12 @@ import Foundation @objcMembers public class DashLineModel: MoleculeProtocol { public static var identifier: String = "dashLine" - public var backgroundColor: String? + public var backgroundColor: Color? - public var dashColor: String + public var dashColor: Color public var isHidden: Bool? - public init(dashColor: String) { + public init(dashColor: Color) { self.dashColor = dashColor } } diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 16c32d8f..a65c946a 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeProtocol { public static var identifier: String = "image" public var moleculeName: String - public var backgroundColor: String? + public var backgroundColor: Color? public var image: String public var accessibilityText: String? diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index b37e74fb..b4b4e36a 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -235,8 +235,8 @@ public typealias ActionBlock = () -> () } makeWholeViewClickable = labelModel.makeWholeViewClickable ?? false - if let backgroundColorHex = labelModel.backgroundColor, !backgroundColorHex.isEmpty { - backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) + if let backgroundColor = labelModel.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } if let accessibilityText = labelModel.accessibilityText { accessibilityLabel = accessibilityText diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index 2b87186f..90c694a0 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -12,7 +12,7 @@ import Foundation @objcMembers public class LabelModel: MoleculeProtocol { public static var identifier: String = "label" public var moleculeName: String? - public var backgroundColor: String? + public var backgroundColor: Color? public var text: String public var accessibilityText: String? @@ -52,7 +52,7 @@ import Foundation self.text = try typeContainer.decode(String.self, forKey: .text) self.accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.fontStyle = try typeContainer.decodeIfPresent(String.self, forKey: .fontStyle) self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index 30015d70..e006afc9 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -10,7 +10,7 @@ import UIKit @objcMembers public class LeftRightLabelModel: MoleculeProtocol { public static var identifier: String = "leftRightLabel" - public var backgroundColor: String? + public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel diff --git a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift index bfeb7312..df6b09a5 100644 --- a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift @@ -11,8 +11,8 @@ import Foundation extension MFView { public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { self.model = model - if let backgroundColorString = model?.backgroundColor { - backgroundColor = UIColor.mfGet(for: backgroundColorString) + if let backgroundColor = model?.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 25522070..9d1f11fd 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -17,7 +17,7 @@ import Foundation @objcMembers public class MultiProgressBarModel: MoleculeProtocol { public static var identifier: String = "multiProgressBar" public var moleculeName: String - public var backgroundColor: String? + public var backgroundColor: Color? public var progressList: [SingleProgressBarModel] public var thickness: CGFloat? public var roundedRect: Bool? diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 90d63dfb..8a3b0bb0 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -57,12 +57,10 @@ import Foundation } isRounded = progressBarModel.isRounded ?? false thickness = progressBarModel.thickness ?? 8 - progress = (progressBarModel.percentage)/100.0 - if let progressColor = progressBarModel.progressColor { - progressTintColor = UIColor.mfGet(forHex: progressColor) - } + progress = Float((progressBarModel.percent)/100.0) + progressTintColor = progressBarModel.progressColor.uiColor if let backgroundColor = progressBarModel.backgroundColor { - trackTintColor = UIColor.mfGet(forHex: backgroundColor) + trackTintColor = backgroundColor.uiColor } } diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 784b938c..47fabb6a 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -14,7 +14,7 @@ import Foundation public var isRounded: Bool? public var thickness: CGFloat? ///from 0 to 100 - public var percent: CGFloat + @Clamping(range: 0...100) public var percent: CGFloat public var progressColor: Color = Color(uiColor: .mfCerulean()) public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 8ae6dfa7..0cb1088d 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -42,8 +42,8 @@ import UIKit open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { self.model = model - if let backgroundColorString = model?.backgroundColor { - backgroundColor = UIColor.mfGet(for: backgroundColorString) + if let backgroundColor = model?.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } } } diff --git a/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift index 81ffd123..9a303bdf 100644 --- a/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift @@ -17,7 +17,7 @@ public protocol ContainerMoleculeProtocol: MoleculeProtocol { } extension ContainerMoleculeProtocol { - public var backgroundColor: String? { + public var backgroundColor: Color? { get { return nil } } diff --git a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift index 3339ed09..1ccf898f 100644 --- a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift @@ -12,7 +12,7 @@ import Foundation @objcMembers public class CarouselItemModel: ContainerMoleculeProtocol { public static var identifier: String = "carouselItem" public var molecule: MoleculeProtocol - public var backgroundColor: String? + public var backgroundColor: Color? public init(molecule: MoleculeProtocol) { self.molecule = molecule @@ -27,7 +27,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecule = try typeContainer.decodeMolecule(codingKey: .molecule) - backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Models/Molecules/CarouselModel.swift b/MVMCoreUI/Models/Molecules/CarouselModel.swift index 56bec824..9b55f97a 100644 --- a/MVMCoreUI/Models/Molecules/CarouselModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselModel.swift @@ -10,7 +10,7 @@ import UIKit @objcMembers public class CarouselModel: MoleculeProtocol { public static var identifier: String = "carousel" - public var backgroundColor: String? + public var backgroundColor: Color? public var molecules: [CarouselItemModel] public var spacing: Float? @@ -41,7 +41,7 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.spacing = try typeContainer.decode(Float.self, forKey: .spacing) self.border = try typeContainer.decode(Bool.self, forKey: .border) self.loop = try typeContainer.decode(Bool.self, forKey: .loop) diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift index 9e447713..260e7063 100644 --- a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift @@ -12,7 +12,7 @@ import Foundation public static var identifier: String = "dropDownListItem" public var molecule: MoleculeProtocol public var molecules: [[ListItemModel]] - public var backgroundColor: String? + public var backgroundColor: Color? public var separator: LineModel? public var dropDown: DropDownModel @@ -36,7 +36,7 @@ import Foundation molecule = try typeContainer.decodeMolecule(codingKey: .molecule) self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) self.separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) } diff --git a/MVMCoreUI/Models/Molecules/DropDownModel.swift b/MVMCoreUI/Models/Molecules/DropDownModel.swift index b28eda5d..c0320737 100644 --- a/MVMCoreUI/Models/Molecules/DropDownModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class DropDownModel: MoleculeProtocol { public static var identifier: String = "dropDownModel" - public var backgroundColor: String? + public var backgroundColor: Color? public var label: String public var options: [String] } diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift index 83043f81..93f0a4e3 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -12,7 +12,7 @@ import Foundation @objcMembers public class FooterModel: ContainerMoleculeProtocol { public static var identifier: String = "footer" public var moleculeName: String? - public var backgroundColor: String? + public var backgroundColor: Color? public var molecule: MoleculeProtocol public init(molecule: MoleculeProtocol){ @@ -28,7 +28,7 @@ import Foundation 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.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule) } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index c28d7080..2f824773 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "header" public var moleculeName: String? - public var backgroundColor: String? + public var backgroundColor: Color? public var line: LineModel? enum HeaderCodingKeys: String, CodingKey { diff --git a/MVMCoreUI/Models/Molecules/LineModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift index c6a22c62..66010536 100644 --- a/MVMCoreUI/Models/Molecules/LineModel.swift +++ b/MVMCoreUI/Models/Molecules/LineModel.swift @@ -10,6 +10,6 @@ import UIKit @objcMembers public class LineModel: MoleculeProtocol { public static var identifier: String = "line" - public var backgroundColor: String? + public var backgroundColor: Color? public var type: String? } diff --git a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift index 6e170b03..35702824 100644 --- a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift +++ b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift @@ -9,7 +9,7 @@ import Foundation open class ModuleMoleculeModel: MoleculeProtocol { - public var backgroundColor: String? + public var backgroundColor: Color? public static var identifier: String = "moduleMolecule" public var moduleName: String diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index a0e7825c..106ea6e5 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "stackItem" - public var backgroundColor: String? + public var backgroundColor: Color? public var spacing: CGFloat? public var percentage: Int? = 0 public var gone: Bool = false diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 530c7393..f8012a30 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol { public static var identifier: String = "moleculeStack" - public var backgroundColor: String? + public var backgroundColor: Color? public var molecules: [MoleculeStackItemModel] public var axis: NSLayoutConstraint.Axis = .vertical public var spacing: CGFloat = 16.0 diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Models/Molecules/TextFieldModel.swift index ea6f3deb..3a76bbb3 100644 --- a/MVMCoreUI/Models/Molecules/TextFieldModel.swift +++ b/MVMCoreUI/Models/Molecules/TextFieldModel.swift @@ -11,7 +11,7 @@ import UIKit @objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol { public static var identifier: String = "textField" - public var backgroundColor: String? + public var backgroundColor: Color? public var editable: Bool? public var disabled: Bool? diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 1311e69f..bdff2842 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -12,7 +12,7 @@ import MVMCore @objcMembers public class ListItemModel: ListItemModelProtocol { public static var identifier: String = "listItem" public var molecule: MoleculeProtocol - public var backgroundColor: String? + public var backgroundColor: Color? public var action: ActionProtocol? public var hideArrow: Bool? public var separator: LineModel? diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index d532147c..b976ca64 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -87,8 +87,8 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi peakingRightArrow.tintColor = color } - if let backgroundColorString = collectionModel.backgroundColor { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) + if let backgroundColor = collectionModel.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } if molecule == nil { diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 60af3f68..d74f0ee5 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -163,8 +163,8 @@ import UIKit bottomMarginPadding = 0 } - if let backgroundColorString = model.backgroundColor { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) + if let backgroundColor = model.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } // Add the caret if there is an action and it's not declared hidden. diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 975c4851..706e4712 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -10,7 +10,7 @@ import UIKit struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { static var identifier: String = "eyebrowHeadlineBodyLink" - var backgroundColor: String? + var backgroundColor: Color? public var eyeBrow: LabelModel? public var headline: LabelModel? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index c6dbd059..6ce51d3e 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -13,7 +13,7 @@ import Foundation public var headline: LabelModel public var body: LabelModel public var style: String? - public var backgroundColor: String? + public var backgroundColor: Color? public init(headline: LabelModel, body: LabelModel) { self.headline = headline