diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index 0b1e896c..c7e72204 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -354,8 +354,8 @@ public typealias ActionBlock = () -> () } } - if let textColorHex = labelModel.textColor, !textColorHex.isEmpty { - textColor = UIColor.mfGet(forHex: textColorHex) + if let color = labelModel.textColor { + textColor = color.uiColor } if let attributes = labelModel.attributes, let labelText = text { diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index cb9cc0a9..3b5f2b66 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -18,7 +18,7 @@ import Foundation public var backgroundColor: Color? public var text: String public var accessibilityText: String? - public var textColor: String? + public var textColor: Color? public var fontStyle: String? public var fontName: String? public var fontSize: CGFloat? @@ -68,7 +68,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) text = try typeContainer.decode(String.self, forKey: .text) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) + textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) fontStyle = try typeContainer.decodeIfPresent(String.self, forKey: .fontStyle) fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) diff --git a/MVMCoreUI/Atoms/Views/RadioButton.swift b/MVMCoreUI/Atoms/Views/RadioButton.swift index ac579b23..47eeb0ca 100644 --- a/MVMCoreUI/Atoms/Views/RadioButton.swift +++ b/MVMCoreUI/Atoms/Views/RadioButton.swift @@ -99,8 +99,8 @@ import UIKit accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint") } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.setWithModel(model, delegateObject, additionalData) + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) guard let model = model as? RadioButtonModel else { return } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift index f5865423..b4bb2fc3 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift @@ -12,42 +12,56 @@ import UIKit //----------------------------------------------------- // MARK: - Outlets - //------------------------------------------------------- + //----------------------------------------------------- let radioButton = RadioButton(frame: .zero) let leftImage = MFLoadImageView(pinnedEdges: .all) let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() - let stack = Stack(frame: .zero) + var stack: Stack + + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: radioButton, model: StackItemModel(horizontalAlignment: .fill)), + (view: leftImage, model: StackItemModel(horizontalAlignment: .fill)), + (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } //----------------------------------------------------- // MARK: - View Lifecycle - //------------------------------------------------------- + //----------------------------------------------------- override open func setupView() { super.setupView() - stack.stackItems = [StackItem(andContain: radioButton), - StackItem(andContain: leftImage), - StackItem(andContain: eyebrowHeadlineBodyLink)] addMolecule(stack) - } - //---------------------------------------------------- - // MARK: - Molecule - //----------------------------------------------------- - open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.setWithModel(model, delegateObject, additionalData) - guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return} - radioButton.setWithModel(model.radioButton, delegateObject, additionalData) - leftImage.setWithModel(model.image, delegateObject, additionalData) - eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData) - - // Create a stack model to use for the internal stack and set the alignment of labels - let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .leading)], - axis: .horizontal) - stack.model = stackModel stack.restack() + eyebrowHeadlineBodyLink.body.textColor = .mvmOrangeAA + eyebrowHeadlineBodyLink.headline.styleBoldBodySmall(true) } - open override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open override func reset() { + super.reset() + eyebrowHeadlineBodyLink.body.textColor = .mvmOrangeAA + eyebrowHeadlineBodyLink.headline.styleBoldBodySmall(true) + } + + //---------------------------------------------------- + // MARK: - Molecule + //---------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return} + radioButton.set(with: model.radioButton, delegateObject, additionalData) + leftImage.set(with: model.image, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 90 } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift index e7b41635..5ea28778 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift @@ -10,9 +10,9 @@ import Foundation public class ListLeftVariableRadioButtonAndPaymentMethodModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "listLVRBImg" - public var radioButton : RadioButtonModel + public var radioButton: RadioButtonModel public var image: ImageViewModel - public var eyebrowHeadlineBodyLink : EyebrowHeadlineBodyLinkModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel public init(radioButton: RadioButtonModel, image: ImageViewModel, eyebrowHeadlineBodyLink:EyebrowHeadlineBodyLinkModel) { self.radioButton = radioButton @@ -21,6 +21,14 @@ public class ListLeftVariableRadioButtonAndPaymentMethodModel: ListItemModel, Mo super.init() } + public override func setDefaults() { + super.setDefaults() + if image.width == nil, image.height == nil { + image.width = 32 + image.height = 32 + } + } + private enum CodingKeys: String, CodingKey { case moleculeName case radioButton