This commit is contained in:
Pfeil, Scott Robert 2020-01-08 13:22:45 -05:00
parent b620a533d5
commit 2e514a7de5
29 changed files with 45 additions and 47 deletions

View File

@ -11,7 +11,7 @@ import MVMCore
public class CaretLinkModel: MoleculeProtocol { public class CaretLinkModel: MoleculeProtocol {
public static var identifier: String = "caretLink" public static var identifier: String = "caretLink"
public var backgroundColor: String? public var backgroundColor: Color?
public var label: LabelModel public var label: LabelModel
public var action: ActionProtocol public var action: ActionProtocol
public var enabledColor: UIColor = .black public var enabledColor: UIColor = .black
@ -34,7 +34,7 @@ public class CaretLinkModel: MoleculeProtocol {
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) 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) label = try typeContainer.decode(LabelModel.self, forKey: .label)
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor)?.uiColor { if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor)?.uiColor {
enabledColor = color enabledColor = color

View File

@ -90,12 +90,12 @@ open class DashLine: View {
guard let dashLineModel = model as? DashLineModel else { guard let dashLineModel = model as? DashLineModel else {
return return
} }
dashColor = UIColor.mfGet(forHex: dashLineModel.dashColor) dashColor = dashLineModel.dashColor.uiColor
if let isHiddenValue = dashLineModel.isHidden { if let isHiddenValue = dashLineModel.isHidden {
isHidden = isHiddenValue isHidden = isHiddenValue
} }
if let backgroundColor = dashLineModel.backgroundColor { if let backgroundColor = dashLineModel.backgroundColor {
dashLayer?.backgroundColor = UIColor.mfGet(forHex: backgroundColor).cgColor dashLayer?.backgroundColor = backgroundColor.uiColor.cgColor
} }
} }
} }

View File

@ -10,12 +10,12 @@ import Foundation
@objcMembers public class DashLineModel: MoleculeProtocol { @objcMembers public class DashLineModel: MoleculeProtocol {
public static var identifier: String = "dashLine" 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 var isHidden: Bool?
public init(dashColor: String) { public init(dashColor: Color) {
self.dashColor = dashColor self.dashColor = dashColor
} }
} }

View File

@ -11,7 +11,7 @@ import Foundation
@objcMembers public class ImageViewModel: MoleculeProtocol { @objcMembers public class ImageViewModel: MoleculeProtocol {
public static var identifier: String = "image" public static var identifier: String = "image"
public var moleculeName: String public var moleculeName: String
public var backgroundColor: String? public var backgroundColor: Color?
public var image: String public var image: String
public var accessibilityText: String? public var accessibilityText: String?

View File

@ -235,8 +235,8 @@ public typealias ActionBlock = () -> ()
} }
makeWholeViewClickable = labelModel.makeWholeViewClickable ?? false makeWholeViewClickable = labelModel.makeWholeViewClickable ?? false
if let backgroundColorHex = labelModel.backgroundColor, !backgroundColorHex.isEmpty { if let backgroundColor = labelModel.backgroundColor {
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) self.backgroundColor = backgroundColor.uiColor
} }
if let accessibilityText = labelModel.accessibilityText { if let accessibilityText = labelModel.accessibilityText {
accessibilityLabel = accessibilityText accessibilityLabel = accessibilityText

View File

@ -12,7 +12,7 @@ import Foundation
@objcMembers public class LabelModel: MoleculeProtocol { @objcMembers public class LabelModel: MoleculeProtocol {
public static var identifier: String = "label" public static var identifier: String = "label"
public var moleculeName: String? public var moleculeName: String?
public var backgroundColor: String? public var backgroundColor: Color?
public var text: String public var text: String
public var accessibilityText: String? public var accessibilityText: String?
@ -52,7 +52,7 @@ import Foundation
self.text = try typeContainer.decode(String.self, forKey: .text) self.text = try typeContainer.decode(String.self, forKey: .text)
self.accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) self.accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) 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.fontStyle = try typeContainer.decodeIfPresent(String.self, forKey: .fontStyle)
self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)

View File

@ -10,7 +10,7 @@ import UIKit
@objcMembers public class LeftRightLabelModel: MoleculeProtocol { @objcMembers public class LeftRightLabelModel: MoleculeProtocol {
public static var identifier: String = "leftRightLabel" public static var identifier: String = "leftRightLabel"
public var backgroundColor: String? public var backgroundColor: Color?
public var leftText: LabelModel public var leftText: LabelModel
public var rightText: LabelModel public var rightText: LabelModel

View File

@ -11,8 +11,8 @@ import Foundation
extension MFView { extension MFView {
public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) {
self.model = model self.model = model
if let backgroundColorString = model?.backgroundColor { if let backgroundColor = model?.backgroundColor {
backgroundColor = UIColor.mfGet(for: backgroundColorString) self.backgroundColor = backgroundColor.uiColor
} }
} }
} }

View File

@ -17,7 +17,7 @@ import Foundation
@objcMembers public class MultiProgressBarModel: MoleculeProtocol { @objcMembers public class MultiProgressBarModel: MoleculeProtocol {
public static var identifier: String = "multiProgressBar" public static var identifier: String = "multiProgressBar"
public var moleculeName: String public var moleculeName: String
public var backgroundColor: String? public var backgroundColor: Color?
public var progressList: [SingleProgressBarModel] public var progressList: [SingleProgressBarModel]
public var thickness: CGFloat? public var thickness: CGFloat?
public var roundedRect: Bool? public var roundedRect: Bool?

View File

@ -57,12 +57,10 @@ import Foundation
} }
isRounded = progressBarModel.isRounded ?? false isRounded = progressBarModel.isRounded ?? false
thickness = progressBarModel.thickness ?? 8 thickness = progressBarModel.thickness ?? 8
progress = (progressBarModel.percentage)/100.0 progress = Float((progressBarModel.percent)/100.0)
if let progressColor = progressBarModel.progressColor { progressTintColor = progressBarModel.progressColor.uiColor
progressTintColor = UIColor.mfGet(forHex: progressColor)
}
if let backgroundColor = progressBarModel.backgroundColor { if let backgroundColor = progressBarModel.backgroundColor {
trackTintColor = UIColor.mfGet(forHex: backgroundColor) trackTintColor = backgroundColor.uiColor
} }
} }

View File

@ -14,7 +14,7 @@ import Foundation
public var isRounded: Bool? public var isRounded: Bool?
public var thickness: CGFloat? public var thickness: CGFloat?
///from 0 to 100 ///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 progressColor: Color = Color(uiColor: .mfCerulean())
public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) public var backgroundColor: Color? = Color(uiColor: .mfLightSilver())

View File

@ -42,8 +42,8 @@ import UIKit
open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
self.model = model self.model = model
if let backgroundColorString = model?.backgroundColor { if let backgroundColor = model?.backgroundColor {
backgroundColor = UIColor.mfGet(for: backgroundColorString) self.backgroundColor = backgroundColor.uiColor
} }
} }
} }

View File

@ -17,7 +17,7 @@ public protocol ContainerMoleculeProtocol: MoleculeProtocol {
} }
extension ContainerMoleculeProtocol { extension ContainerMoleculeProtocol {
public var backgroundColor: String? { public var backgroundColor: Color? {
get { return nil } get { return nil }
} }

View File

@ -12,7 +12,7 @@ import Foundation
@objcMembers public class CarouselItemModel: ContainerMoleculeProtocol { @objcMembers public class CarouselItemModel: ContainerMoleculeProtocol {
public static var identifier: String = "carouselItem" public static var identifier: String = "carouselItem"
public var molecule: MoleculeProtocol public var molecule: MoleculeProtocol
public var backgroundColor: String? public var backgroundColor: Color?
public init(molecule: MoleculeProtocol) { public init(molecule: MoleculeProtocol) {
self.molecule = molecule self.molecule = molecule
@ -27,7 +27,7 @@ import Foundation
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
molecule = try typeContainer.decodeMolecule(codingKey: .molecule) 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 { public func encode(to encoder: Encoder) throws {

View File

@ -10,7 +10,7 @@ import UIKit
@objcMembers public class CarouselModel: MoleculeProtocol { @objcMembers public class CarouselModel: MoleculeProtocol {
public static var identifier: String = "carousel" public static var identifier: String = "carousel"
public var backgroundColor: String? public var backgroundColor: Color?
public var molecules: [CarouselItemModel] public var molecules: [CarouselItemModel]
public var spacing: Float? public var spacing: Float?
@ -41,7 +41,7 @@ import UIKit
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) 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.spacing = try typeContainer.decode(Float.self, forKey: .spacing)
self.border = try typeContainer.decode(Bool.self, forKey: .border) self.border = try typeContainer.decode(Bool.self, forKey: .border)
self.loop = try typeContainer.decode(Bool.self, forKey: .loop) self.loop = try typeContainer.decode(Bool.self, forKey: .loop)

View File

@ -12,7 +12,7 @@ import Foundation
public static var identifier: String = "dropDownListItem" public static var identifier: String = "dropDownListItem"
public var molecule: MoleculeProtocol public var molecule: MoleculeProtocol
public var molecules: [[ListItemModel]] public var molecules: [[ListItemModel]]
public var backgroundColor: String? public var backgroundColor: Color?
public var separator: LineModel? public var separator: LineModel?
public var dropDown: DropDownModel public var dropDown: DropDownModel
@ -36,7 +36,7 @@ import Foundation
molecule = try typeContainer.decodeMolecule(codingKey: .molecule) molecule = try typeContainer.decodeMolecule(codingKey: .molecule)
self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules)
self.separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) 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) self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown)
} }

View File

@ -11,7 +11,7 @@ import Foundation
@objcMembers public class DropDownModel: MoleculeProtocol { @objcMembers public class DropDownModel: MoleculeProtocol {
public static var identifier: String = "dropDownModel" public static var identifier: String = "dropDownModel"
public var backgroundColor: String? public var backgroundColor: Color?
public var label: String public var label: String
public var options: [String] public var options: [String]
} }

View File

@ -12,7 +12,7 @@ import Foundation
@objcMembers public class FooterModel: ContainerMoleculeProtocol { @objcMembers public class FooterModel: ContainerMoleculeProtocol {
public static var identifier: String = "footer" public static var identifier: String = "footer"
public var moleculeName: String? public var moleculeName: String?
public var backgroundColor: String? public var backgroundColor: Color?
public var molecule: MoleculeProtocol public var molecule: MoleculeProtocol
public init(molecule: MoleculeProtocol){ public init(molecule: MoleculeProtocol){
@ -28,7 +28,7 @@ import Foundation
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) 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) self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule)
} }

View File

@ -11,7 +11,7 @@ import Foundation
@objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol { @objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol {
public static var identifier: String = "header" public static var identifier: String = "header"
public var moleculeName: String? public var moleculeName: String?
public var backgroundColor: String? public var backgroundColor: Color?
public var line: LineModel? public var line: LineModel?
enum HeaderCodingKeys: String, CodingKey { enum HeaderCodingKeys: String, CodingKey {

View File

@ -10,6 +10,6 @@ import UIKit
@objcMembers public class LineModel: MoleculeProtocol { @objcMembers public class LineModel: MoleculeProtocol {
public static var identifier: String = "line" public static var identifier: String = "line"
public var backgroundColor: String? public var backgroundColor: Color?
public var type: String? public var type: String?
} }

View File

@ -9,7 +9,7 @@
import Foundation import Foundation
open class ModuleMoleculeModel: MoleculeProtocol { open class ModuleMoleculeModel: MoleculeProtocol {
public var backgroundColor: String? public var backgroundColor: Color?
public static var identifier: String = "moduleMolecule" public static var identifier: String = "moduleMolecule"
public var moduleName: String public var moduleName: String

View File

@ -10,7 +10,7 @@ import Foundation
@objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol { @objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol {
public static var identifier: String = "stackItem" public static var identifier: String = "stackItem"
public var backgroundColor: String? public var backgroundColor: Color?
public var spacing: CGFloat? public var spacing: CGFloat?
public var percentage: Int? = 0 public var percentage: Int? = 0
public var gone: Bool = false public var gone: Bool = false

View File

@ -10,7 +10,7 @@ import Foundation
@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol { @objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol {
public static var identifier: String = "moleculeStack" public static var identifier: String = "moleculeStack"
public var backgroundColor: String? public var backgroundColor: Color?
public var molecules: [MoleculeStackItemModel] public var molecules: [MoleculeStackItemModel]
public var axis: NSLayoutConstraint.Axis = .vertical public var axis: NSLayoutConstraint.Axis = .vertical
public var spacing: CGFloat = 16.0 public var spacing: CGFloat = 16.0

View File

@ -11,7 +11,7 @@ import UIKit
@objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol { @objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol {
public static var identifier: String = "textField" public static var identifier: String = "textField"
public var backgroundColor: String? public var backgroundColor: Color?
public var editable: Bool? public var editable: Bool?
public var disabled: Bool? public var disabled: Bool?

View File

@ -12,7 +12,7 @@ import MVMCore
@objcMembers public class ListItemModel: ListItemModelProtocol { @objcMembers public class ListItemModel: ListItemModelProtocol {
public static var identifier: String = "listItem" public static var identifier: String = "listItem"
public var molecule: MoleculeProtocol public var molecule: MoleculeProtocol
public var backgroundColor: String? public var backgroundColor: Color?
public var action: ActionProtocol? public var action: ActionProtocol?
public var hideArrow: Bool? public var hideArrow: Bool?
public var separator: LineModel? public var separator: LineModel?

View File

@ -87,8 +87,8 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi
peakingRightArrow.tintColor = color peakingRightArrow.tintColor = color
} }
if let backgroundColorString = collectionModel.backgroundColor { if let backgroundColor = collectionModel.backgroundColor {
backgroundColor = UIColor.mfGet(forHex: backgroundColorString) self.backgroundColor = backgroundColor.uiColor
} }
if molecule == nil { if molecule == nil {

View File

@ -163,8 +163,8 @@ import UIKit
bottomMarginPadding = 0 bottomMarginPadding = 0
} }
if let backgroundColorString = model.backgroundColor { if let backgroundColor = model.backgroundColor {
backgroundColor = UIColor.mfGet(forHex: backgroundColorString) self.backgroundColor = backgroundColor.uiColor
} }
// Add the caret if there is an action and it's not declared hidden. // Add the caret if there is an action and it's not declared hidden.

View File

@ -10,7 +10,7 @@ import UIKit
struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
static var identifier: String = "eyebrowHeadlineBodyLink" static var identifier: String = "eyebrowHeadlineBodyLink"
var backgroundColor: String? var backgroundColor: Color?
public var eyeBrow: LabelModel? public var eyeBrow: LabelModel?
public var headline: LabelModel? public var headline: LabelModel?

View File

@ -13,7 +13,7 @@ import Foundation
public var headline: LabelModel public var headline: LabelModel
public var body: LabelModel public var body: LabelModel
public var style: String? public var style: String?
public var backgroundColor: String? public var backgroundColor: Color?
public init(headline: LabelModel, body: LabelModel) { public init(headline: LabelModel, body: LabelModel) {
self.headline = headline self.headline = headline