This commit is contained in:
Pfeil, Scott Robert 2020-02-28 10:30:57 -05:00
parent 2b85991bfd
commit 36e34e1726
5 changed files with 54 additions and 32 deletions

View File

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

View File

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

View File

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

View File

@ -12,42 +12,56 @@ import UIKit
//-----------------------------------------------------
// MARK: - Outlets
//-------------------------------------------------------
//-----------------------------------------------------
let radioButton = RadioButton(frame: .zero)
let leftImage = MFLoadImageView(pinnedEdges: .all)
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink()
let stack = Stack<StackModel>(frame: .zero)
var stack: Stack<StackModel>
//-----------------------------------------------------
// MARK: - Initializers
//-----------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
stack = Stack<StackModel>.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
}
}

View File

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