From f33fd320ad26310c4f0acd0c24a62758d3ae54c2 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 11 Mar 2020 16:22:48 +0530 Subject: [PATCH] Refactored code as per the changes in confluence. --- .../TwoColumn/ListTwoColumnPriceDetails.swift | 30 ++++++++----------- .../ListTwoColumnPriceDetailsModel.swift | 7 +---- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnPriceDetails.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnPriceDetails.swift index 8b033f27..2d9051d7 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnPriceDetails.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnPriceDetails.swift @@ -12,25 +12,23 @@ import UIKit let leftLabel = Label.commonLabelB2(true) let rightLabel = Label.commonLabelB2(true) - let rightSubLabel = Label.commonLabelB2(true) - let containerView = View() - let verticalStack = UIStackView() + var stack: Stack + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.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 open override func setupView() { super.setupView() - - rightLabel.numberOfLines = 1 - 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) + addMolecule(stack) + stack.restack() } // MARK: - MVMCoreUIMoleculeViewProtocol @@ -39,14 +37,12 @@ import UIKit guard let model = model as? ListTwoColumnPriceDetailsModel else { return } leftLabel.set(with: model.leftLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) - rightSubLabel.set(with: model.rightSubLabel, delegateObject, additionalData) } open override func reset() { super.reset() leftLabel.styleB2(true) rightLabel.styleB2(true) - rightSubLabel.styleB2(true) } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnPriceDetailsModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnPriceDetailsModel.swift index 78665414..cd5b5d54 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnPriceDetailsModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnPriceDetailsModel.swift @@ -12,12 +12,10 @@ public class ListTwoColumnPriceDetailsModel: ListItemModel, MoleculeModelProtoco public static var identifier: String = "list2CTxtPrc2" public var leftLabel: 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.rightLabel = rightLabel - self.rightSubLabel = rightSubLabel super.init() } @@ -31,14 +29,12 @@ public class ListTwoColumnPriceDetailsModel: ListItemModel, MoleculeModelProtoco case moleculeName case leftLabel case rightLabel - case rightSubLabel } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - rightSubLabel = try typeContainer.decode(LabelModel.self, forKey: .rightSubLabel) try super.init(from: decoder) } @@ -48,6 +44,5 @@ public class ListTwoColumnPriceDetailsModel: ListItemModel, MoleculeModelProtoco try container.encode(moleculeName, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(rightLabel, forKey: .rightLabel) - try container.encode(rightSubLabel, forKey: .rightSubLabel) } }