Refactored code as per the changes in confluence.
This commit is contained in:
parent
a16855527f
commit
f33fd320ad
@ -12,25 +12,23 @@ import UIKit
|
|||||||
|
|
||||||
let leftLabel = Label.commonLabelB2(true)
|
let leftLabel = Label.commonLabelB2(true)
|
||||||
let rightLabel = Label.commonLabelB2(true)
|
let rightLabel = Label.commonLabelB2(true)
|
||||||
let rightSubLabel = Label.commonLabelB2(true)
|
var stack: Stack<StackModel>
|
||||||
let containerView = View()
|
|
||||||
let verticalStack = UIStackView()
|
|
||||||
|
|
||||||
|
// MARK: - Initializers
|
||||||
|
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
|
stack = Stack<StackModel>.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 70, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .trailing))], axis: .horizontal)
|
||||||
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - MFViewProtocol
|
// MARK: - MFViewProtocol
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
addMolecule(stack)
|
||||||
rightLabel.numberOfLines = 1
|
stack.restack()
|
||||||
rightSubLabel.numberOfLines = 1
|
|
||||||
verticalStack.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
containerView.addSubview(leftLabel)
|
|
||||||
verticalStack.addArrangedSubview(rightLabel)
|
|
||||||
verticalStack.addArrangedSubview(rightSubLabel)
|
|
||||||
verticalStack.axis = .vertical
|
|
||||||
verticalStack.alignment = .trailing
|
|
||||||
containerView.addSubview(verticalStack)
|
|
||||||
addMolecule(containerView)
|
|
||||||
NSLayoutConstraint.pinViews(leftView: leftLabel, rightView: verticalStack, alignTop: true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
@ -39,14 +37,12 @@ import UIKit
|
|||||||
guard let model = model as? ListTwoColumnPriceDetailsModel else { return }
|
guard let model = model as? ListTwoColumnPriceDetailsModel else { return }
|
||||||
leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
|
leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
|
||||||
rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
|
rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
|
||||||
rightSubLabel.set(with: model.rightSubLabel, delegateObject, additionalData)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
leftLabel.styleB2(true)
|
leftLabel.styleB2(true)
|
||||||
rightLabel.styleB2(true)
|
rightLabel.styleB2(true)
|
||||||
rightSubLabel.styleB2(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||||
|
|||||||
@ -12,12 +12,10 @@ public class ListTwoColumnPriceDetailsModel: ListItemModel, MoleculeModelProtoco
|
|||||||
public static var identifier: String = "list2CTxtPrc2"
|
public static var identifier: String = "list2CTxtPrc2"
|
||||||
public var leftLabel: LabelModel
|
public var leftLabel: LabelModel
|
||||||
public var rightLabel: LabelModel
|
public var rightLabel: LabelModel
|
||||||
public var rightSubLabel: LabelModel
|
|
||||||
|
|
||||||
public init(leftLabel: LabelModel, rightLabel:LabelModel, rightSubLabel: LabelModel) {
|
public init(leftLabel: LabelModel, rightLabel:LabelModel) {
|
||||||
self.leftLabel = leftLabel
|
self.leftLabel = leftLabel
|
||||||
self.rightLabel = rightLabel
|
self.rightLabel = rightLabel
|
||||||
self.rightSubLabel = rightSubLabel
|
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,14 +29,12 @@ public class ListTwoColumnPriceDetailsModel: ListItemModel, MoleculeModelProtoco
|
|||||||
case moleculeName
|
case moleculeName
|
||||||
case leftLabel
|
case leftLabel
|
||||||
case rightLabel
|
case rightLabel
|
||||||
case rightSubLabel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)
|
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)
|
||||||
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
||||||
rightSubLabel = try typeContainer.decode(LabelModel.self, forKey: .rightSubLabel)
|
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +44,5 @@ public class ListTwoColumnPriceDetailsModel: ListItemModel, MoleculeModelProtoco
|
|||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(leftLabel, forKey: .leftLabel)
|
try container.encode(leftLabel, forKey: .leftLabel)
|
||||||
try container.encode(rightLabel, forKey: .rightLabel)
|
try container.encode(rightLabel, forKey: .rightLabel)
|
||||||
try container.encode(rightSubLabel, forKey: .rightSubLabel)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user