From d683d420c8ee7eb19a37403340c36cbb22b5271f Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 11 Feb 2020 12:22:50 +0530 Subject: [PATCH] Code changes based on review: Modified class name according to Confluence Removed Initializers Removed extra spaces. --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++++----- ....swift => ListRightVariablePayments.swift} | 36 ++++++------------- ...t => ListRightVariablePaymentsModel.swift} | 13 ++----- .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- 4 files changed, 22 insertions(+), 45 deletions(-) rename MVMCoreUI/Molecules/LeftRightViews/{RightVariablePaymentsList.swift => ListRightVariablePayments.swift} (78%) rename MVMCoreUI/Molecules/LeftRightViews/{RightVariablePaymentsListModel.swift => ListRightVariablePaymentsModel.swift} (83%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index aacab776..aa416225 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -123,8 +123,8 @@ 94F217B723E0BF6100A47C06 /* PrimaryButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */; }; 94FB966223D797DA003D482B /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94FB966023D797DA003D482B /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; - AA11A41F23F15D3100D7962F /* RightVariablePaymentsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* RightVariablePaymentsList.swift */; }; - AA11A42123F15D7000D7962F /* RightVariablePaymentsListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* RightVariablePaymentsListModel.swift */; }; + AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; + AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; @@ -441,8 +441,8 @@ 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PrimaryButtonView.m; sourceTree = ""; }; 94FB966023D797DA003D482B /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = ""; }; 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; - AA11A41E23F15D3100D7962F /* RightVariablePaymentsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RightVariablePaymentsList.swift; sourceTree = ""; }; - AA11A42023F15D7000D7962F /* RightVariablePaymentsListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RightVariablePaymentsListModel.swift; sourceTree = ""; }; + AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; + AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; @@ -901,8 +901,8 @@ D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, 01509D902327ECE600EF99AA /* CornerLabels.swift */, D224798823142BF2003FCCF9 /* ToggleMolecules */, - AA11A41E23F15D3100D7962F /* RightVariablePaymentsList.swift */, - AA11A42023F15D7000D7962F /* RightVariablePaymentsListModel.swift */, + AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, + AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, ); path = LeftRightViews; sourceTree = ""; @@ -1562,7 +1562,7 @@ DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */, - AA11A41F23F15D3100D7962F /* RightVariablePaymentsList.swift in Sources */, + AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */, 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, @@ -1624,7 +1624,7 @@ D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, - AA11A42123F15D7000D7962F /* RightVariablePaymentsListModel.swift in Sources */, + AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, diff --git a/MVMCoreUI/Molecules/LeftRightViews/RightVariablePaymentsList.swift b/MVMCoreUI/Molecules/LeftRightViews/ListRightVariablePayments.swift similarity index 78% rename from MVMCoreUI/Molecules/LeftRightViews/RightVariablePaymentsList.swift rename to MVMCoreUI/Molecules/LeftRightViews/ListRightVariablePayments.swift index fe387ca2..5eebb1e1 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/RightVariablePaymentsList.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListRightVariablePayments.swift @@ -1,5 +1,5 @@ // -// RightVariablePaymentsList.swift +// ListRightVariablePayments.swift // MVMCoreUI // // Created by Lekshmi S on 10/02/20. @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class RightVariablePaymentsList : TableViewCell { +@objcMembers public class ListRightVariablePayments: TableViewCell { //----------------------------------------------------- // MARK: - Outlets @@ -16,7 +16,7 @@ import Foundation let leftLabel = Label.commonLabelB2(true) let rightImage = MFLoadImageView() - let containerView = ViewConstrainingView() + let containerView = Container() //------------------------------------------------------ // MARK: - Properties @@ -24,25 +24,11 @@ import Foundation let cellHeight: CGFloat = 65.0 let leftPadding: CGFloat = 35.0 - let rightPadding: CGFloat = 54.0 + let rightPadding: CGFloat = PaddingNine let spaceBetweenLabelAndImage: CGFloat = 40.0 let imageWidth: CGFloat = 56.0 let imageHeight: CGFloat = 16.0 - //------------------------------------------------------ - // MARK: - Initialization - //-------------------------------------------------------- - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - setupView() - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - setupView() - } - //----------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- @@ -59,10 +45,11 @@ import Foundation guard leftLabel.superview == nil else { return } - containerView.translatesAutoresizingMaskIntoConstraints = false contentView.heightAnchor.constraint(equalToConstant: cellHeight).isActive = true contentView.addSubview(containerView) + + //containerView constraints containerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true containerView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true containerView.topAnchor.constraint(equalTo: topAnchor).isActive = true @@ -71,11 +58,13 @@ import Foundation containerView.addSubview(leftLabel) containerView.addSubview(rightImage) + //leftLabel constraints leftLabel.leadingAnchor.constraint(equalTo: containerView.leadingAnchor,constant: leftPadding).isActive = true leftLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true leftLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true - rightImage.leadingAnchor.constraint(equalTo: leftLabel.leadingAnchor,constant: spaceBetweenLabelAndImage).isActive = true + //rightImage constraints + rightImage.leadingAnchor.constraint(greaterThanOrEqualTo: leftLabel.trailingAnchor,constant: spaceBetweenLabelAndImage).isActive = true rightImage.centerYAnchor.constraint(equalTo: leftLabel.centerYAnchor).isActive = true rightImage.widthAnchor.constraint(equalToConstant: imageWidth).isActive = true rightImage.heightAnchor.constraint(equalToConstant: imageHeight).isActive = true @@ -88,18 +77,13 @@ import Foundation override open func reset() { super.reset() - leftLabel.reset() rightImage.reset() } - open func setAsMolecule() { - setupView() - } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let model = model as? RightVariablePaymentsListModel else { return} + guard let model = model as? ListRightVariablePaymentsModel else { return} leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) rightImage.setWithModel(model.image, delegateObject, additionalData) } diff --git a/MVMCoreUI/Molecules/LeftRightViews/RightVariablePaymentsListModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ListRightVariablePaymentsModel.swift similarity index 83% rename from MVMCoreUI/Molecules/LeftRightViews/RightVariablePaymentsListModel.swift rename to MVMCoreUI/Molecules/LeftRightViews/ListRightVariablePaymentsModel.swift index e3c9e889..db4dabc4 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/RightVariablePaymentsListModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListRightVariablePaymentsModel.swift @@ -1,5 +1,5 @@ // -// RightVariablePaymentsListModel.swift +// ListRightVariablePaymentsModel.swift // MVMCoreUI // // Created by Lekshmi S on 10/02/20. @@ -8,13 +8,12 @@ import Foundation -public class RightVariablePaymentsListModel: ContainerModel, ListItemModelProtocol { +public class ListRightVariablePaymentsModel: ContainerModel, ListItemModelProtocol { public var line: LineModel? public var hideArrow: Bool? public var backgroundColor: Color? public var action: ActionModelProtocol? - public static var identifier: String = "listRVImg" public var image: ImageViewModel public var leftLabel: LabelModel @@ -38,7 +37,6 @@ public class RightVariablePaymentsListModel: ContainerModel, ListItemModelProtoc self.image = image self.leftLabel = leftLabel super.init() - setDefaults() } private enum CodingKeys: String, CodingKey { @@ -46,7 +44,6 @@ public class RightVariablePaymentsListModel: ContainerModel, ListItemModelProtoc case leftLabel case image case action - case hideArrow } required public init(from decoder: Decoder) throws { @@ -54,20 +51,16 @@ public class RightVariablePaymentsListModel: ContainerModel, ListItemModelProtoc leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) image = try typeContainer.decode(ImageViewModel.self, forKey: .image) action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) - hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) try super.init(from: decoder) setDefaults() } - public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(RightVariablePaymentsListModel.identifier, forKey: .moleculeName) + try container.encode(ListRightVariablePaymentsModel.identifier, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(image, forKey: .image) try container.encodeModelIfPresent(action, forKey: .action) - try container.encodeIfPresent(hideArrow, forKey: .hideArrow) } - } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 4c384930..c3cf76be 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -70,7 +70,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RightVariablePaymentsList.self, viewModelClass: RightVariablePaymentsListModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) // List items MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: ListItemModel.self)