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 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

View File

@ -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
}
}
}

View File

@ -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
}
}

View File

@ -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?

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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
}
}
}

View File

@ -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?

View File

@ -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
}
}

View File

@ -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())

View File

@ -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
}
}
}

View File

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

View File

@ -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 {

View File

@ -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)

View File

@ -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)
}

View File

@ -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]
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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?
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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?

View File

@ -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 {

View File

@ -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.

View File

@ -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?

View File

@ -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