From 4bcfdb96db51ad11ac998c223dcb81ddee23d2a1 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Wed, 5 Feb 2020 13:17:50 +0530 Subject: [PATCH 01/11] 18936 - Left Variable Icon - with - Right Caret - initial commit. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ .../LeftVariableIconRightCaretList.swift | 115 ++++++++++++++++++ .../LeftVariableIconRightCaretListModel.swift | 39 ++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 163 insertions(+) create mode 100644 MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift create mode 100644 MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index a35514cb..7cc6f284 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -95,6 +95,8 @@ 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; + 8D24041123E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift */; }; + 8D24041523E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift */; }; 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; @@ -408,6 +410,8 @@ 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxLabelModel.swift; sourceTree = ""; }; 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; + 8D24041023E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftVariableIconRightCaretList.swift; sourceTree = ""; }; + 8D24041423E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftVariableIconRightCaretListModel.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; @@ -881,6 +885,8 @@ isa = PBXGroup; children = ( D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */, + 8D24041023E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift */, + 8D24041423E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift */, 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, 01509D902327ECE600EF99AA /* CornerLabels.swift */, @@ -1673,6 +1679,7 @@ C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, + 8D24041523E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, @@ -1685,6 +1692,7 @@ D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */, + 8D24041123E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, 0A21DB89235E06EF00C160A2 /* MFMdnTextField.m in Sources */, diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift new file mode 100644 index 00000000..ba540437 --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift @@ -0,0 +1,115 @@ +// +// LeftVariableIconRightCaretList.swift +// MVMCoreUI +// +// Created by Kruthika KP on 03/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +import UIKit + +@objcMembers public class LeftVariableIconRightCaretList : TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + + let leftImage = MFLoadImageView() + let leftLabel = Label.commonLabelB2(true) + let rightLabel = Label.commonLabelB2(true) + + + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------- + let spaceBetweenLabels : CGFloat = 40 + let horizontalPadding : CGFloat = 10 + let rightLabelTrailing : CGFloat = 20 + let cellHeight : CGFloat = 60 + let imageSize : CGFloat = 30 + + + //------------------------------------------------------ + // 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 + //------------------------------------------------------- + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + leftImage.updateView(size) + leftLabel.updateView(size) + rightLabel.updateView(size) + + } + + override open func setupView() { + super.setupView() + guard leftImage.superview == nil else { + return + } + + addSubview(leftImage) + addSubview(leftLabel) + addSubview(rightLabel) + + + contentView.heightAnchor.constraint(equalToConstant: cellHeight).isActive = true + + leftImage.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor, constant: horizontalPadding).isActive = true + leftImage.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true + leftImage.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true + leftImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true + leftImage.heightAnchor.constraint(equalToConstant: imageSize).isActive = true + + leftLabel.leadingAnchor.constraint(equalTo: leftImage.trailingAnchor, constant: horizontalPadding).isActive = true + leftLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true + leftLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true + + + rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leftLabel.trailingAnchor, constant: spaceBetweenLabels).isActive = true + rightLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true + rightLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true + layoutMarginsGuide.trailingAnchor.constraint(equalTo: rightLabel.trailingAnchor, constant: rightLabelTrailing).isActive = true + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + + override open func reset() { + super.reset() + + leftImage.reset() + leftLabel.reset() + rightLabel.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? LeftVariableIconRightCaretListModel else { return} + + leftImage.setWithModel(model.image, delegateObject, additionalData) + leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) + rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) + } +} diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift new file mode 100644 index 00000000..e0ee0fcb --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift @@ -0,0 +1,39 @@ +// +// LeftVariableIconRightCaretListModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 03/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class LeftVariableIconRightCaretListModel: ListItemModelProtocol { + + public var horizontalAlignment: UIStackView.Alignment? + public var verticalAlignment: UIStackView.Alignment? + public var useHorizontalMargins: Bool? + public var useVerticalMargins: Bool? + public var topMarginPadding: CGFloat? + public var bottomMarginPadding: CGFloat? + + + public var line: LineModel? = LineModel(type: .standard) + public var hideArrow: Bool? = false + public var backgroundColor: Color? + + public static var identifier: String = "listLVImg" + public var image: ImageViewModel + public var leftLabel: LabelModel + public var rightLabel: LabelModel + + + + public init(image: ImageViewModel, leftLabel: LabelModel, rightLabel: LabelModel) { + self.image = image + self.leftLabel = leftLabel + self.rightLabel = rightLabel + } + +} + diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index d3523ccf..0bb12509 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -70,6 +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: LeftVariableIconRightCaretList.self, viewModelClass: LeftVariableIconRightCaretListModel.self) // List items MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: ListItemModel.self) From 8ca15468f4e993134070f6ccc3d0feb7d461bef5 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Thu, 6 Feb 2020 16:30:20 +0530 Subject: [PATCH 02/11] changes to image leading space --- .../LeftRightViews/LeftVariableIconRightCaretList.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift index ba540437..def62ef8 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift @@ -24,7 +24,7 @@ import UIKit // MARK: - Properties //------------------------------------------------------- let spaceBetweenLabels : CGFloat = 40 - let horizontalPadding : CGFloat = 10 + let horizontalPadding : CGFloat = 12 let rightLabelTrailing : CGFloat = 20 let cellHeight : CGFloat = 60 let imageSize : CGFloat = 30 @@ -70,7 +70,7 @@ import UIKit contentView.heightAnchor.constraint(equalToConstant: cellHeight).isActive = true - leftImage.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor, constant: horizontalPadding).isActive = true + leftImage.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).isActive = true leftImage.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true leftImage.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true leftImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true From 5f2abffba04f1dfba8b38d26cb70a75d5861b994 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Thu, 6 Feb 2020 18:43:53 +0530 Subject: [PATCH 03/11] Changed TableViewCell to Container in Molecule class and ListItemModelProtocol to MoleculeModelProtocol --- .../LeftVariableIconRightCaretList.swift | 58 ++++++------------- .../LeftVariableIconRightCaretListModel.swift | 27 ++++++++- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift index def62ef8..f7b08220 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift @@ -9,42 +9,25 @@ import Foundation import UIKit -@objcMembers public class LeftVariableIconRightCaretList : TableViewCell { +@objcMembers public class LeftVariableIconRightCaretList : Container { //----------------------------------------------------- // MARK: - Outlets //------------------------------------------------------- let leftImage = MFLoadImageView() - let leftLabel = Label.commonLabelB2(true) - let rightLabel = Label.commonLabelB2(true) + let leftLabel = Label(frame: .zero) + let rightLabel = Label(frame: .zero) //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------- - let spaceBetweenLabels : CGFloat = 40 - let horizontalPadding : CGFloat = 12 - let rightLabelTrailing : CGFloat = 20 - let cellHeight : CGFloat = 60 + let spaceBetweenLabels : CGFloat = 180 + let horizontalPadding : CGFloat = 14 let imageSize : CGFloat = 30 - //------------------------------------------------------ - // 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 //------------------------------------------------------- @@ -63,28 +46,29 @@ import UIKit return } - addSubview(leftImage) - addSubview(leftLabel) - addSubview(rightLabel) + let container = MVMCoreUICommonViewsUtility.commonView() + addAndContain(container) + container.addSubview(leftImage) + container.addSubview(leftLabel) + container.addSubview(rightLabel) - contentView.heightAnchor.constraint(equalToConstant: cellHeight).isActive = true + self.translatesAutoresizingMaskIntoConstraints = false - leftImage.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).isActive = true - leftImage.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true - leftImage.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true + leftImage.leadingAnchor.constraint(equalTo: container.leadingAnchor).isActive = true + leftImage.topAnchor.constraint(equalTo: container.topAnchor).isActive = true + leftImage.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true leftImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true leftImage.heightAnchor.constraint(equalToConstant: imageSize).isActive = true leftLabel.leadingAnchor.constraint(equalTo: leftImage.trailingAnchor, constant: horizontalPadding).isActive = true - leftLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true - leftLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true + leftLabel.topAnchor.constraint(equalTo: container.topAnchor).isActive = true + leftLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true - rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leftLabel.trailingAnchor, constant: spaceBetweenLabels).isActive = true - rightLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true - rightLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true - layoutMarginsGuide.trailingAnchor.constraint(equalTo: rightLabel.trailingAnchor, constant: rightLabelTrailing).isActive = true + rightLabel.leadingAnchor.constraint(equalTo: leftLabel.trailingAnchor,constant: spaceBetweenLabels).isActive = true + rightLabel.topAnchor.constraint(equalTo: container.topAnchor).isActive = true + rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true } //---------------------------------------------------- @@ -99,10 +83,6 @@ import UIKit rightLabel.reset() } - open func setAsMolecule() { - setupView() - } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift index e0ee0fcb..152f8128 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift @@ -8,7 +8,7 @@ import Foundation -public class LeftVariableIconRightCaretListModel: ListItemModelProtocol { +public class LeftVariableIconRightCaretListModel: MoleculeModelProtocol { public var horizontalAlignment: UIStackView.Alignment? public var verticalAlignment: UIStackView.Alignment? @@ -19,7 +19,7 @@ public class LeftVariableIconRightCaretListModel: ListItemModelProtocol { public var line: LineModel? = LineModel(type: .standard) - public var hideArrow: Bool? = false + public var hideArrow: Bool? public var backgroundColor: Color? public static var identifier: String = "listLVImg" @@ -35,5 +35,28 @@ public class LeftVariableIconRightCaretListModel: ListItemModelProtocol { self.rightLabel = rightLabel } + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case rightLabel + case image + } + + 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) + image = try typeContainer.decode(ImageViewModel.self, forKey: .image) + } + + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(LeftVariableIconRightCaretListModel.identifier, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(rightLabel, forKey: .rightLabel) + try container.encodeIfPresent(image, forKey: .image) + } + } From 66f0cf6b8e2bc428302d1dea1055c1911588c0d3 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 11 Feb 2020 08:39:09 +0530 Subject: [PATCH 04/11] Modified code based on review comments Molecule class conforming to TableViewCell instead of Container. Model class conforming to ListItemModelProtocol instead of MoleculeModelProtocol Removed extra spaces and added comments --- .../LeftVariableIconRightCaretList.swift | 77 ++++++++++++------- .../LeftVariableIconRightCaretListModel.swift | 49 ++++++++---- 2 files changed, 80 insertions(+), 46 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift index f7b08220..c35678a2 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift @@ -9,24 +9,40 @@ import Foundation import UIKit -@objcMembers public class LeftVariableIconRightCaretList : Container { +@objcMembers public class LeftVariableIconRightCaretList: TableViewCell { //----------------------------------------------------- // MARK: - Outlets //------------------------------------------------------- let leftImage = MFLoadImageView() - let leftLabel = Label(frame: .zero) - let rightLabel = Label(frame: .zero) - + let leftLabel = Label.commonLabelB2(true) + let rightLabel = Label.commonLabelB2(true) + let containerView = ViewConstrainingView() //------------------------------------------------------ // MARK: - Properties - //------------------------------------------------------- - let spaceBetweenLabels : CGFloat = 180 - let horizontalPadding : CGFloat = 14 - let imageSize : CGFloat = 30 + //------------------------------------------------------ + let cellHeight: CGFloat = 79 + let leftPadding: CGFloat = 35 + let spaceBetweenImageAndLeftLabel: CGFloat = 16 + let imageSize: CGFloat = 30 + let spaceBetweenLabels: CGFloat = 40 + let rightPadding: CGFloat = 54 + + //------------------------------------------------------ + // 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) + } //----------------------------------------------------- // MARK: - View Lifecycle @@ -34,10 +50,10 @@ import UIKit open override func updateView(_ size: CGFloat) { super.updateView(size) + containerView.updateView(size) leftImage.updateView(size) leftLabel.updateView(size) rightLabel.updateView(size) - } override open func setupView() { @@ -45,30 +61,36 @@ import UIKit guard leftImage.superview == nil else { return } + containerView.translatesAutoresizingMaskIntoConstraints = false + contentView.heightAnchor.constraint(equalToConstant: cellHeight).isActive = true + contentView.addSubview(containerView) - let container = MVMCoreUICommonViewsUtility.commonView() + //containerView constraints + containerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true + containerView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true + containerView.topAnchor.constraint(equalTo: topAnchor).isActive = true + containerView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true - addAndContain(container) - container.addSubview(leftImage) - container.addSubview(leftLabel) - container.addSubview(rightLabel) + containerView.addSubview(leftImage) + containerView.addSubview(leftLabel) + containerView.addSubview(rightLabel) - self.translatesAutoresizingMaskIntoConstraints = false - - leftImage.leadingAnchor.constraint(equalTo: container.leadingAnchor).isActive = true - leftImage.topAnchor.constraint(equalTo: container.topAnchor).isActive = true - leftImage.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true + //leftImage constraints + leftImage.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: leftPadding).isActive = true + leftImage.centerYAnchor.constraint(equalTo: leftLabel.centerYAnchor).isActive = true leftImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true leftImage.heightAnchor.constraint(equalToConstant: imageSize).isActive = true - leftLabel.leadingAnchor.constraint(equalTo: leftImage.trailingAnchor, constant: horizontalPadding).isActive = true - leftLabel.topAnchor.constraint(equalTo: container.topAnchor).isActive = true - leftLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true + //leftLabel constraints + leftLabel.leadingAnchor.constraint(equalTo: leftImage.trailingAnchor, constant: spaceBetweenImageAndLeftLabel).isActive = true + leftLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true + leftLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true - - rightLabel.leadingAnchor.constraint(equalTo: leftLabel.trailingAnchor,constant: spaceBetweenLabels).isActive = true - rightLabel.topAnchor.constraint(equalTo: container.topAnchor).isActive = true - rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true + //rightLabel constraints + rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leftLabel.trailingAnchor, constant: spaceBetweenLabels).isActive = true + rightLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true + rightLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true + containerView.trailingAnchor.constraint(equalTo: rightLabel.trailingAnchor,constant: rightPadding).isActive = true } //---------------------------------------------------- @@ -77,17 +99,14 @@ import UIKit override open func reset() { super.reset() - leftImage.reset() leftLabel.reset() rightLabel.reset() } public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.setWithModel(model, delegateObject, additionalData) guard let model = model as? LeftVariableIconRightCaretListModel else { return} - leftImage.setWithModel(model.image, delegateObject, additionalData) leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift index 152f8128..dab0b153 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift @@ -8,31 +8,38 @@ import Foundation -public class LeftVariableIconRightCaretListModel: MoleculeModelProtocol { +public class LeftVariableIconRightCaretListModel: ContainerModel, ListItemModelProtocol { - public var horizontalAlignment: UIStackView.Alignment? - public var verticalAlignment: UIStackView.Alignment? - public var useHorizontalMargins: Bool? - public var useVerticalMargins: Bool? - public var topMarginPadding: CGFloat? - public var bottomMarginPadding: CGFloat? - - - public var line: LineModel? = LineModel(type: .standard) - public var hideArrow: Bool? + public var line: LineModel? + public var hideArrow: Bool? = false public var backgroundColor: Color? - + public var action: ActionModelProtocol? public static var identifier: String = "listLVImg" public var image: ImageViewModel public var leftLabel: LabelModel public var rightLabel: LabelModel - + func setDefaults() { + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } + if topMarginPadding == nil { + topMarginPadding = 24 + } + if bottomMarginPadding == nil { + bottomMarginPadding = 0 + } + } public init(image: ImageViewModel, leftLabel: LabelModel, rightLabel: LabelModel) { self.image = image self.leftLabel = leftLabel self.rightLabel = rightLabel + super.init() + setDefaults() } private enum CodingKeys: String, CodingKey { @@ -40,6 +47,8 @@ public class LeftVariableIconRightCaretListModel: MoleculeModelProtocol { case leftLabel case rightLabel case image + case action + case hideArrow } required public init(from decoder: Decoder) throws { @@ -47,16 +56,22 @@ public class LeftVariableIconRightCaretListModel: MoleculeModelProtocol { leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) 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 func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(LeftVariableIconRightCaretListModel.identifier, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(rightLabel, forKey: .rightLabel) - try container.encodeIfPresent(image, forKey: .image) + try container.encode(image, forKey: .image) + try container.encodeModelIfPresent(action, forKey: .action) + try container.encodeIfPresent(hideArrow, forKey: .hideArrow) } - } + From 965dcf538b5239929f94dab4b6df0705dafbde50 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Tue, 11 Feb 2020 12:18:45 +0530 Subject: [PATCH 05/11] Class naming convention changed and removed init methods where not required. --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++++++------ ... ListLeftVariableIconWithRightCaret.swift} | 26 +++++-------------- ...LeftVariableIconWithRightCaretModel.swift} | 10 +++---- .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- 4 files changed, 18 insertions(+), 36 deletions(-) rename MVMCoreUI/Molecules/LeftRightViews/{LeftVariableIconRightCaretList.swift => ListLeftVariableIconWithRightCaret.swift} (83%) rename MVMCoreUI/Molecules/LeftRightViews/{LeftVariableIconRightCaretListModel.swift => ListLeftVariableIconWithRightCaretModel.swift} (83%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index e17401e0..e02f3542 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -95,8 +95,8 @@ 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; - 8D24041123E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift */; }; - 8D24041523E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift */; }; + 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; + 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; }; 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; @@ -414,8 +414,8 @@ 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxLabelModel.swift; sourceTree = ""; }; 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; - 8D24041023E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftVariableIconRightCaretList.swift; sourceTree = ""; }; - 8D24041423E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftVariableIconRightCaretListModel.swift; sourceTree = ""; }; + 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; + 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; @@ -897,8 +897,8 @@ isa = PBXGroup; children = ( D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */, - 8D24041023E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift */, - 8D24041423E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift */, + 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, + 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, 01509D902327ECE600EF99AA /* CornerLabels.swift */, @@ -1694,7 +1694,7 @@ 94AF4A3F23E9D13900676048 /* MFCaretButton.m in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, - 8D24041523E7FC0B009E23BE /* LeftVariableIconRightCaretListModel.swift in Sources */, + 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, @@ -1707,7 +1707,7 @@ D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */, - 8D24041123E7FB9E009E23BE /* LeftVariableIconRightCaretList.swift in Sources */, + 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, 0A21DB89235E06EF00C160A2 /* MFMdnTextField.m in Sources */, diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift similarity index 83% rename from MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift rename to MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift index c35678a2..7a6ac9be 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretList.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift @@ -1,5 +1,5 @@ // -// LeftVariableIconRightCaretList.swift +// ListLeftVariableIconWithRightCaret.swift // MVMCoreUI // // Created by Kruthika KP on 03/02/20. @@ -9,7 +9,7 @@ import Foundation import UIKit -@objcMembers public class LeftVariableIconRightCaretList: TableViewCell { +@objcMembers public class ListLeftVariableIconWithRightCaret: TableViewCell { //----------------------------------------------------- // MARK: - Outlets @@ -18,7 +18,7 @@ import UIKit let leftImage = MFLoadImageView() let leftLabel = Label.commonLabelB2(true) let rightLabel = Label.commonLabelB2(true) - let containerView = ViewConstrainingView() + let containerView = Container() //------------------------------------------------------ // MARK: - Properties @@ -29,21 +29,7 @@ import UIKit let spaceBetweenImageAndLeftLabel: CGFloat = 16 let imageSize: CGFloat = 30 let spaceBetweenLabels: CGFloat = 40 - let rightPadding: CGFloat = 54 - - //------------------------------------------------------ - // 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) - } - + //----------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- @@ -90,7 +76,7 @@ import UIKit rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leftLabel.trailingAnchor, constant: spaceBetweenLabels).isActive = true rightLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true rightLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true - containerView.trailingAnchor.constraint(equalTo: rightLabel.trailingAnchor,constant: rightPadding).isActive = true + containerView.trailingAnchor.constraint(equalTo: rightLabel.trailingAnchor,constant: PaddingNine).isActive = true } //---------------------------------------------------- @@ -106,7 +92,7 @@ import UIKit public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let model = model as? LeftVariableIconRightCaretListModel else { return} + guard let model = model as? ListLeftVariableIconWithRightCaretModel else { return} leftImage.setWithModel(model.image, delegateObject, additionalData) leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift similarity index 83% rename from MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift rename to MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift index dab0b153..b29affb8 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/LeftVariableIconRightCaretListModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift @@ -1,5 +1,5 @@ // -// LeftVariableIconRightCaretListModel.swift +// ListLeftVariableIconWithRightCaretModel.swift // MVMCoreUI // // Created by Kruthika KP on 03/02/20. @@ -8,7 +8,7 @@ import Foundation -public class LeftVariableIconRightCaretListModel: ContainerModel, ListItemModelProtocol { +public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemModelProtocol { public var line: LineModel? public var hideArrow: Bool? = false @@ -39,7 +39,6 @@ public class LeftVariableIconRightCaretListModel: ContainerModel, ListItemModelP self.leftLabel = leftLabel self.rightLabel = rightLabel super.init() - setDefaults() } private enum CodingKeys: String, CodingKey { @@ -48,7 +47,6 @@ public class LeftVariableIconRightCaretListModel: ContainerModel, ListItemModelP case rightLabel case image case action - case hideArrow } required public init(from decoder: Decoder) throws { @@ -57,7 +55,6 @@ public class LeftVariableIconRightCaretListModel: ContainerModel, ListItemModelP rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) 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() } @@ -65,12 +62,11 @@ public class LeftVariableIconRightCaretListModel: ContainerModel, ListItemModelP public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(LeftVariableIconRightCaretListModel.identifier, forKey: .moleculeName) + try container.encode(ListLeftVariableIconWithRightCaretModel.identifier, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(rightLabel, forKey: .rightLabel) 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 a87dac90..34af5083 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: LeftVariableIconRightCaretList.self, viewModelClass: LeftVariableIconRightCaretListModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) // List items MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: ListItemModel.self) From fed9b8ff92187f4c6a5a277c397ae8de25382963 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Wed, 12 Feb 2020 16:45:09 +0530 Subject: [PATCH 06/11] added default horizontal padding --- .../LeftRightViews/ListLeftVariableIconWithRightCaret.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift index 7a6ac9be..43a3b5da 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift @@ -29,6 +29,7 @@ import UIKit let spaceBetweenImageAndLeftLabel: CGFloat = 16 let imageSize: CGFloat = 30 let spaceBetweenLabels: CGFloat = 40 + let horizontalPadding = MFStyler.defaultHorizontalPaddingForApplicationWidth() //----------------------------------------------------- // MARK: - View Lifecycle @@ -62,11 +63,12 @@ import UIKit containerView.addSubview(rightLabel) //leftImage constraints - leftImage.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: leftPadding).isActive = true + leftImage.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: horizontalPadding).isActive = true leftImage.centerYAnchor.constraint(equalTo: leftLabel.centerYAnchor).isActive = true leftImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true leftImage.heightAnchor.constraint(equalToConstant: imageSize).isActive = true + //leftLabel constraints leftLabel.leadingAnchor.constraint(equalTo: leftImage.trailingAnchor, constant: spaceBetweenImageAndLeftLabel).isActive = true leftLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true @@ -76,7 +78,7 @@ import UIKit rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leftLabel.trailingAnchor, constant: spaceBetweenLabels).isActive = true rightLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true rightLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true - containerView.trailingAnchor.constraint(equalTo: rightLabel.trailingAnchor,constant: PaddingNine).isActive = true + rightLabel.trailingAnchor.constraint(equalTo: containerView.trailingAnchor,constant: -horizontalPadding - 20).isActive = true } //---------------------------------------------------- From c30a0012394b1b1f855243e62817872532aa643d Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Wed, 12 Feb 2020 23:01:02 +0530 Subject: [PATCH 07/11] Code Changes after reimplementing the molecule class. --- .../Molecules/Items/StackItemModel.swift | 2 +- .../ListLeftVariableIconWithRightCaret.swift | 70 ++++++------------- ...tLeftVariableIconWithRightCaretModel.swift | 8 +-- 3 files changed, 25 insertions(+), 55 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index f296986e..9d193f17 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class StackItemModel: StackItemModelProtocol, MoleculeModelProtocol { +@objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol { public static var identifier: String = "simpleStackItem" public var backgroundColor: Color? public var spacing: CGFloat? diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift index 43a3b5da..9cdf9cee 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift @@ -14,30 +14,15 @@ import UIKit //----------------------------------------------------- // MARK: - Outlets //------------------------------------------------------- - let leftImage = MFLoadImageView() let leftLabel = Label.commonLabelB2(true) let rightLabel = Label.commonLabelB2(true) - let containerView = Container() - - //------------------------------------------------------ - // MARK: - Properties - //------------------------------------------------------ - - let cellHeight: CGFloat = 79 - let leftPadding: CGFloat = 35 - let spaceBetweenImageAndLeftLabel: CGFloat = 16 - let imageSize: CGFloat = 30 - let spaceBetweenLabels: CGFloat = 40 - let horizontalPadding = MFStyler.defaultHorizontalPaddingForApplicationWidth() - + let stack = Stack(frame: .zero) //----------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- - open override func updateView(_ size: CGFloat) { super.updateView(size) - containerView.updateView(size) leftImage.updateView(size) leftLabel.updateView(size) rightLabel.updateView(size) @@ -48,48 +33,23 @@ import UIKit guard leftImage.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 - containerView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true - - containerView.addSubview(leftImage) - containerView.addSubview(leftLabel) - containerView.addSubview(rightLabel) - - //leftImage constraints - leftImage.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: horizontalPadding).isActive = true - leftImage.centerYAnchor.constraint(equalTo: leftLabel.centerYAnchor).isActive = true - leftImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true - leftImage.heightAnchor.constraint(equalToConstant: imageSize).isActive = true - - - //leftLabel constraints - leftLabel.leadingAnchor.constraint(equalTo: leftImage.trailingAnchor, constant: spaceBetweenImageAndLeftLabel).isActive = true - leftLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true - leftLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true - - //rightLabel constraints - rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leftLabel.trailingAnchor, constant: spaceBetweenLabels).isActive = true - rightLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true - rightLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true - rightLabel.trailingAnchor.constraint(equalTo: containerView.trailingAnchor,constant: -horizontalPadding - 20).isActive = true + stack.translatesAutoresizingMaskIntoConstraints = false + stack.stackItems = [StackItem(andContain: leftImage),StackItem(andContain: leftLabel),StackItem(andContain: rightLabel)] + contentView.addSubview(stack) + containerHelper.constrainView(stack) + leftLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 901), for: .horizontal) + rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 902), for: .horizontal) + } - //---------------------------------------------------- // MARK: - Molecule //------------------------------------------------------ - override open func reset() { super.reset() leftImage.reset() leftLabel.reset() rightLabel.reset() + stack.reset() } public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { @@ -98,5 +58,17 @@ import UIKit leftImage.setWithModel(model.image, delegateObject, additionalData) leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) + + // Create a stack model to use for the internal stack and set the alignment of labels + let leftImage = StackItemModel() + leftImage.horizontalAlignment = .fill + let leftLabel = StackItemModel() + leftLabel.horizontalAlignment = .fill + let rightLabel = StackItemModel() + rightLabel.horizontalAlignment = .trailing + let stackModel = StackModel(molecules: [leftImage,leftLabel,rightLabel]) + stackModel.axis = .horizontal + stack.model = stackModel + stack.restack() } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift index b29affb8..1ad7afbc 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift @@ -11,6 +11,7 @@ import Foundation public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemModelProtocol { public var line: LineModel? + public var style: String? = "standard" public var hideArrow: Bool? = false public var backgroundColor: Color? public var action: ActionModelProtocol? @@ -26,11 +27,8 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo if useVerticalMargins == nil { useVerticalMargins = true } - if topMarginPadding == nil { - topMarginPadding = 24 - } - if bottomMarginPadding == nil { - bottomMarginPadding = 0 + if image.height == nil { + image.height = 30.0 } } From 692689a90056914342d652b69ed4d6d25c80e758 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Thu, 13 Feb 2020 00:34:41 +0530 Subject: [PATCH 08/11] Code clean up for stack and removed line break. --- .../ListLeftVariableIconWithRightCaret.swift | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift index 9cdf9cee..9fd26d4a 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift @@ -23,9 +23,7 @@ import UIKit //------------------------------------------------------- open override func updateView(_ size: CGFloat) { super.updateView(size) - leftImage.updateView(size) - leftLabel.updateView(size) - rightLabel.updateView(size) + stack.updateView(size) } override open func setupView() { @@ -39,16 +37,12 @@ import UIKit containerHelper.constrainView(stack) leftLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 901), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 902), for: .horizontal) - } //---------------------------------------------------- // MARK: - Molecule //------------------------------------------------------ override open func reset() { super.reset() - leftImage.reset() - leftLabel.reset() - rightLabel.reset() stack.reset() } From 0113387f008ae0815e407661db8fd69c37fe62c8 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 12 Feb 2020 15:31:45 -0500 Subject: [PATCH 09/11] add new image method --- MVMCoreUI/Atoms/Views/Label/Label.swift | 2 +- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index 576f66b9..9a4d4612 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -752,7 +752,7 @@ extension Label { /// Applied to existing text. Removes underlines of tappable links and assoated actionable clauses. @objc public func clearActionableClauses() { - + MVMCoreUICommonViewsUtility.commonView() guard let attributedText = attributedText else { return } let mutableAttributedString = NSMutableAttributedString(attributedString: attributedText) diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 242e299a..1c54b891 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -357,6 +357,10 @@ import UIKit loadImage(withName: imageName, format: nil, width: width, height: height, customFallbackImage: nil, completionHandler: completionHandler) } + public func loadImage(withName imageName: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?, completionHandler: @escaping MVMCoreGetImageBlock) { + loadImage(withName: imageName, format: nil, width: width, height: height, customFallbackImage: customFallbackImage, completionHandler: completionHandler) + } + public func loadImage(withName imageName: String?, format: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?) { loadImage(withName: imageName, format: format, width: width, height: height, customFallbackImage: customFallbackImage, completionHandler: defaultCompletionBlock()) } From e1d56bcc0cbe7a16a22cbb79327b9e6ae26ddf4e Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 12 Feb 2020 15:32:33 -0500 Subject: [PATCH 10/11] update image method --- MVMCoreUI/Atoms/Views/Label/Label.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index 9a4d4612..013f7f11 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -752,7 +752,6 @@ extension Label { /// Applied to existing text. Removes underlines of tappable links and assoated actionable clauses. @objc public func clearActionableClauses() { - MVMCoreUICommonViewsUtility.commonView() guard let attributedText = attributedText else { return } let mutableAttributedString = NSMutableAttributedString(attributedString: attributedText) From 5cecd5f031d02d5b4d546b89dd57020220138ec2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 12 Feb 2020 20:36:05 -0500 Subject: [PATCH 11/11] Minor fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- .../ListLeftVariableIconWithRightCaret.swift | 8 +++++++- .../ListLeftVariableIconWithRightCaretModel.swift | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index e02f3542..efe433b4 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -896,9 +896,9 @@ D224798F2316A99F003FCCF9 /* LeftRightViews */ = { isa = PBXGroup; children = ( - D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */, - 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, + 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, + D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */, 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, 01509D902327ECE600EF99AA /* CornerLabels.swift */, diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift index 9fd26d4a..62a19d01 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaret.swift @@ -14,10 +14,11 @@ import UIKit //----------------------------------------------------- // MARK: - Outlets //------------------------------------------------------- - let leftImage = MFLoadImageView() + let leftImage = MFLoadImageView(pinnedEdges: .all) let leftLabel = Label.commonLabelB2(true) let rightLabel = Label.commonLabelB2(true) let stack = Stack(frame: .zero) + //----------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- @@ -38,6 +39,7 @@ import UIKit leftLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 901), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 902), for: .horizontal) } + //---------------------------------------------------- // MARK: - Molecule //------------------------------------------------------ @@ -65,4 +67,8 @@ import UIKit stack.model = stackModel stack.restack() } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift index 1ad7afbc..cac928d3 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableIconWithRightCaretModel.swift @@ -37,6 +37,7 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo self.leftLabel = leftLabel self.rightLabel = rightLabel super.init() + setDefaults() } private enum CodingKeys: String, CodingKey { @@ -45,6 +46,7 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo case rightLabel case image case action + case backgroundColor } required public init(from decoder: Decoder) throws { @@ -53,6 +55,7 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) image = try typeContainer.decode(ImageViewModel.self, forKey: .image) action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) setDefaults() } @@ -60,10 +63,11 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(ListLeftVariableIconWithRightCaretModel.identifier, forKey: .moleculeName) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(rightLabel, forKey: .rightLabel) try container.encode(image, forKey: .image) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) } }