From 4bcfdb96db51ad11ac998c223dcb81ddee23d2a1 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Wed, 5 Feb 2020 13:17:50 +0530 Subject: [PATCH 01/26] 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/26] 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/26] 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 593bae7820b676f2ddfcbf6d3b52b063b8c4a5cb Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Mon, 10 Feb 2020 11:49:03 +0530 Subject: [PATCH 04/26] Molecule-ThreeColumnPlanDataDividerList --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ .../ThreeColumnPlanDataDividerList.swift | 91 +++++++++++++++++++ .../ThreeColumnPlanDataDividerListModel.swift | 52 +++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 2 + 4 files changed, 153 insertions(+) create mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerList.swift create mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerListModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index a35514cb..1ca8be9b 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 */; }; + 52DD6C6B23E97B040011ECB2 /* ThreeColumnPlanDataDividerListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52DD6C6A23E97B040011ECB2 /* ThreeColumnPlanDataDividerListModel.swift */; }; + 52DD6C6D23E97B5E0011ECB2 /* ThreeColumnPlanDataDividerList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52DD6C6C23E97B5E0011ECB2 /* ThreeColumnPlanDataDividerList.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 = ""; }; + 52DD6C6A23E97B040011ECB2 /* ThreeColumnPlanDataDividerListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeColumnPlanDataDividerListModel.swift; sourceTree = ""; }; + 52DD6C6C23E97B5E0011ECB2 /* ThreeColumnPlanDataDividerList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeColumnPlanDataDividerList.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 = ""; }; @@ -873,6 +877,8 @@ D28A837E23CCA96400DFE4FC /* TabsModel.swift */, 94F217B423E0BF6100A47C06 /* PrimaryButtonView.h */, 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */, + 52DD6C6A23E97B040011ECB2 /* ThreeColumnPlanDataDividerListModel.swift */, + 52DD6C6C23E97B5E0011ECB2 /* ThreeColumnPlanDataDividerList.swift */, ); path = HorizontalCombinationViews; sourceTree = ""; @@ -1636,6 +1642,7 @@ 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */, 94FB966323D797DA003D482B /* MFTextButton.m in Sources */, D260105323CEA61600764D80 /* ToggleModel.swift in Sources */, + 52DD6C6B23E97B040011ECB2 /* ThreeColumnPlanDataDividerListModel.swift in Sources */, 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */, 0A7EF86523D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, @@ -1714,6 +1721,7 @@ D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, 0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */, D28A837D23CCA86A00DFE4FC /* TabsListItemModel.swift in Sources */, + 52DD6C6D23E97B5E0011ECB2 /* ThreeColumnPlanDataDividerList.swift in Sources */, 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */, 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerList.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerList.swift new file mode 100644 index 00000000..1624095c --- /dev/null +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerList.swift @@ -0,0 +1,91 @@ +// +// ThreeColumnPlanDataDividerList.swift +// MVMCoreUI +// +// Created by Acharya, Subhankar on 04/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ThreeColumnPlanDataDividerList: TableViewCell { + + let leftHeadlineBody = HeadlineBody(frame: .zero) + let centerHeadLineBody = HeadlineBody(frame: .zero) + let rightHeadLineBody = HeadlineBody(frame: .zero) + let containerView = ViewConstrainingView() + let betweenHeadlineBodyPaddingConstant: CGFloat = 18.0 + let headlineBodyTopPaddingConstant: CGFloat = 48.0 + let containerViewPaddingConstant: CGFloat = 30.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) + } + // MARK: - MFViewProtocol + open override func updateView(_ size: CGFloat) { + super.updateView(size) + containerView.updateView(size) + leftHeadlineBody.updateView(size) + centerHeadLineBody.updateView(size) + rightHeadLineBody.updateView(size) + } + open override func setupView() { + super.setupView() + selectionStyle = .default + guard leftHeadlineBody.superview == nil else { + return + } + containerView.translatesAutoresizingMaskIntoConstraints = false + contentView.addSubview(containerView) + contentView.heightAnchor.constraint(greaterThanOrEqualToConstant: 103.0).isActive = true + containerView.pinView(toSuperView: contentView) + containerView.addSubview(leftHeadlineBody) + containerView.addSubview(centerHeadLineBody) + containerView.addSubview(rightHeadLineBody) + //width calculation of headlinebody + let constraint = rightHeadLineBody.widthAnchor.constraint(equalTo: containerView.widthAnchor, multiplier: 0.25) + constraint.isActive = true + rightHeadLineBody.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) + centerHeadLineBody.widthAnchor.constraint(equalTo: rightHeadLineBody.widthAnchor).isActive = true + leftHeadlineBody.widthAnchor.constraint(equalTo: rightHeadLineBody.widthAnchor).isActive = true + //Constraints of headlinebody to superview + leftHeadlineBody.topAnchor.constraint(equalTo: containerView.topAnchor, constant: headlineBodyTopPaddingConstant).isActive = true + centerHeadLineBody.topAnchor.constraint(equalTo: containerView.topAnchor, constant: headlineBodyTopPaddingConstant).isActive = true + rightHeadLineBody.topAnchor.constraint(equalTo: containerView.topAnchor, constant: headlineBodyTopPaddingConstant).isActive = true + + containerView.bottomAnchor.constraint(equalTo: leftHeadlineBody.bottomAnchor).isActive = true + containerView.bottomAnchor.constraint(equalTo: centerHeadLineBody.bottomAnchor).isActive = true + containerView.bottomAnchor.constraint(equalTo: rightHeadLineBody.bottomAnchor).isActive = true + + leftHeadlineBody.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: containerViewPaddingConstant).isActive = true + centerHeadLineBody.leadingAnchor.constraint(equalTo: leftHeadlineBody.trailingAnchor, constant: betweenHeadlineBodyPaddingConstant).isActive = true + rightHeadLineBody.leadingAnchor.constraint(equalTo: centerHeadLineBody.trailingAnchor, constant: betweenHeadlineBodyPaddingConstant).isActive = true + rightHeadLineBody.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -containerViewPaddingConstant).isActive = true + + } + // MARK: - MVMCoreUIMoleculeViewProtocol + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? ThreeColumnPlanDataDividerListModel else { return } + leftHeadlineBody.setWithModel(model.leftHeadlineBody, delegateObject, additionalData) + centerHeadLineBody.setWithModel(model.centerHeadlineBody, delegateObject, additionalData) + centerHeadLineBody.isHidden = model.centerHeadlineBody == nil + rightHeadLineBody.setWithModel(model.rightHeadlineBody, delegateObject, additionalData) + } + open override func reset() { + super.reset() + containerView.reset() + leftHeadlineBody.reset() + centerHeadLineBody.reset() + rightHeadLineBody.reset() + } + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 103 + } +} + diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerListModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerListModel.swift new file mode 100644 index 00000000..b9a94288 --- /dev/null +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerListModel.swift @@ -0,0 +1,52 @@ +// +// ThreeColumnPlanDataDividerListModel.swift +// MVMCoreUI +// +// Created by Acharya, Subhankar on 04/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class ThreeColumnPlanDataDividerListModel: ContainerModel, ListItemModelProtocol { + public var hideArrow: Bool? + public var style: String? + public var line: LineModel? + public var backgroundColor: Color? + public static var identifier: String = "list3CHBDiv" + public var leftHeadlineBody: HeadlineBodyModel + public var centerHeadlineBody: HeadlineBodyModel? + public var rightHeadlineBody: HeadlineBodyModel + + init(leftheadlineBody: HeadlineBodyModel, rightHeadLineBody: HeadlineBodyModel) { + self.leftHeadlineBody = leftheadlineBody + self.rightHeadlineBody = rightHeadLineBody + super.init() + } + private enum CodingKeys: String, CodingKey { + case style + case moleculeName + case leftHeadlineBody + case centerHeadlineBody + case rightHeadlineBody + } + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + leftHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .leftHeadlineBody) + centerHeadlineBody = try typeContainer.decodeIfPresent(HeadlineBodyModel.self, forKey: .centerHeadlineBody) + rightHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .rightHeadlineBody) + try super.init(from: decoder) + } + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(style, forKey: .style) + try container.encode(ThreeColumnPlanDataDividerListModel.identifier, forKey: .moleculeName) + try container.encode(leftHeadlineBody, forKey: .leftHeadlineBody) + try container.encodeIfPresent(centerHeadlineBody, forKey: .centerHeadlineBody) + try container.encode(rightHeadlineBody, forKey: .rightHeadlineBody) + } + +} + diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index d3523ccf..cbfacbb7 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -55,6 +55,8 @@ import Foundation // Horizontal Combination Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ImageHeadlineBody.self, viewModelClass: ImageHeadlineBodyModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ThreeColumnPlanDataDividerList.self, viewModelClass: ThreeColumnPlanDataDividerListModel.self) + // Vertical Combination Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self) From c94a440008a53977e4bd286aba9ba461b442a648 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Mon, 10 Feb 2020 11:54:45 +0530 Subject: [PATCH 05/26] ThreeColumnPlanDataDividerList reference file --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f97e81aa..e11334c6 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 */; }; + 5248BFEC23F12E350059236A /* ThreeColumnPlanDataDividerList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEA23F12E350059236A /* ThreeColumnPlanDataDividerList.swift */; }; + 5248BFED23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEB23F12E350059236A /* ThreeColumnPlanDataDividerListModel.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 */; }; @@ -412,6 +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 = ""; }; + 5248BFEA23F12E350059236A /* ThreeColumnPlanDataDividerList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThreeColumnPlanDataDividerList.swift; sourceTree = ""; }; + 5248BFEB23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThreeColumnPlanDataDividerListModel.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 = ""; }; @@ -880,6 +884,8 @@ D224798E2316A995003FCCF9 /* HorizontalCombinationViews */ = { isa = PBXGroup; children = ( + 5248BFEA23F12E350059236A /* ThreeColumnPlanDataDividerList.swift */, + 5248BFEB23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift */, D2E2A99B23D8D975000B42E6 /* ImageHeadlineBodyModel.swift */, D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */, D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */, @@ -1541,6 +1547,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5248BFED23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift in Sources */, 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */, 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */, @@ -1638,6 +1645,7 @@ 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, + 5248BFEC23F12E350059236A /* ThreeColumnPlanDataDividerList.swift in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, 94F217B723E0BF6100A47C06 /* PrimaryButtonView.m in Sources */, From 66f0cf6b8e2bc428302d1dea1055c1911588c0d3 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 11 Feb 2020 08:39:09 +0530 Subject: [PATCH 06/26] 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 07/26] 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 05aaac573da65c1c83d502c023ad64cebba39646 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Tue, 11 Feb 2020 17:30:34 +0530 Subject: [PATCH 08/26] Code checkin after changing way of implementation. --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++--- .../ListThreeColumnPlanDataDivider.swift | 67 +++++++++++++++++++ .../ListThreeColumnPlanDataDividerModel.swift | 52 ++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- 4 files changed, 128 insertions(+), 9 deletions(-) create mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift create mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index e11334c6..23257a31 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 */; }; - 5248BFEC23F12E350059236A /* ThreeColumnPlanDataDividerList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEA23F12E350059236A /* ThreeColumnPlanDataDividerList.swift */; }; - 5248BFED23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEB23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift */; }; + 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */; }; + 5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.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 = ""; }; - 5248BFEA23F12E350059236A /* ThreeColumnPlanDataDividerList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThreeColumnPlanDataDividerList.swift; sourceTree = ""; }; - 5248BFEB23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThreeColumnPlanDataDividerListModel.swift; sourceTree = ""; }; + 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnPlanDataDivider.swift; sourceTree = ""; }; + 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnPlanDataDividerModel.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 = ""; }; @@ -884,8 +884,8 @@ D224798E2316A995003FCCF9 /* HorizontalCombinationViews */ = { isa = PBXGroup; children = ( - 5248BFEA23F12E350059236A /* ThreeColumnPlanDataDividerList.swift */, - 5248BFEB23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift */, + 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, + 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, D2E2A99B23D8D975000B42E6 /* ImageHeadlineBodyModel.swift */, D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */, D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */, @@ -1547,7 +1547,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5248BFED23F12E350059236A /* ThreeColumnPlanDataDividerListModel.swift in Sources */, + 5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */, 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */, 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */, @@ -1645,7 +1645,7 @@ 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, - 5248BFEC23F12E350059236A /* ThreeColumnPlanDataDividerList.swift in Sources */, + 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, 94F217B723E0BF6100A47C06 /* PrimaryButtonView.m in Sources */, diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift new file mode 100644 index 00000000..c34c7a55 --- /dev/null +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift @@ -0,0 +1,67 @@ +// +// ThreeColumnPlanDataDividerList.swift +// MVMCoreUI +// +// Created by Acharya, Subhankar on 04/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListThreeColumnPlanDataDivider: TableViewCell { + + let leftHeadlineBody = HeadlineBody(frame: .zero) + let centerHeadLineBody = HeadlineBody(frame: .zero) + let rightHeadLineBody = HeadlineBody(frame: .zero) + private var stack = UIStackView() + + // MARK: - MFViewProtocol + open override func updateView(_ size: CGFloat) { + super.updateView(size) + leftHeadlineBody.updateView(size) + centerHeadLineBody.updateView(size) + rightHeadLineBody.updateView(size) + } + + open override func setupView() { + super.setupView() + guard leftHeadlineBody.superview == nil else { + return + } + //using stackView to align the three headlineBody + stack.translatesAutoresizingMaskIntoConstraints = false + contentView.addSubview(stack) + stack.addArrangedSubview(leftHeadlineBody) + stack.addArrangedSubview(centerHeadLineBody) + stack.addArrangedSubview(rightHeadLineBody) + NSLayoutConstraint.constraintPinSubview(stack, pinTop: true, topConstant: 0, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: PaddingDefaultHorizontalSpacing, pinRight: true, rightConstant: PaddingDefaultHorizontalSpacing) + stack.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 0).isActive = true + stack.axis = .horizontal + stack.spacing = 35 + stack.distribution = .fillProportionally + styleTallDivider() + } + + // MARK: - MVMCoreUIMoleculeViewProtocol + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnPlanDataDividerModel else { return } + leftHeadlineBody.setWithModel(model.leftHeadlineBody, delegateObject, additionalData) + centerHeadLineBody.setWithModel(model.centerHeadlineBody, delegateObject, additionalData) + rightHeadLineBody.setWithModel(model.rightHeadlineBody, delegateObject, additionalData) + } + + open override func reset() { + super.reset() + styleTallDivider() + leftHeadlineBody.reset() + centerHeadLineBody.reset() + rightHeadLineBody.reset() + } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 103 + } + +} + diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDividerModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDividerModel.swift new file mode 100644 index 00000000..0da1499d --- /dev/null +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDividerModel.swift @@ -0,0 +1,52 @@ +// +// ThreeColumnPlanDataDividerListModel.swift +// MVMCoreUI +// +// Created by Acharya, Subhankar on 04/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class ListThreeColumnPlanDataDividerModel: ContainerModel, ListItemModelProtocol { + public var hideArrow: Bool? + public var style: String? = "tallDivider" + public var line: LineModel? + public var backgroundColor: Color? + public static var identifier: String = "list3CHBDiv" + public var leftHeadlineBody: HeadlineBodyModel + public var centerHeadlineBody: HeadlineBodyModel + public var rightHeadlineBody: HeadlineBodyModel + + public init(leftHeadlineBody: HeadlineBodyModel, centerHeadlineBody:HeadlineBodyModel, rightHeadlineBody: HeadlineBodyModel) { + self.leftHeadlineBody = leftHeadlineBody + self.centerHeadlineBody = centerHeadlineBody + self.rightHeadlineBody = rightHeadlineBody + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftHeadlineBody + case centerHeadlineBody + case rightHeadlineBody + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .leftHeadlineBody) + centerHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .centerHeadlineBody) + rightHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .rightHeadlineBody) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftHeadlineBody, forKey: .leftHeadlineBody) + try container.encode(centerHeadlineBody, forKey: .centerHeadlineBody) + try container.encode(rightHeadlineBody, forKey: .rightHeadlineBody) + } +} + diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index b029b352..94407366 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -55,7 +55,7 @@ import Foundation // Horizontal Combination Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ImageHeadlineBody.self, viewModelClass: ImageHeadlineBodyModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ThreeColumnPlanDataDividerList.self, viewModelClass: ThreeColumnPlanDataDividerListModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) // Vertical Combination Molecules From fb65f9e9765576ac6957ed11f4249a2f7f207d2e Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Tue, 11 Feb 2020 17:31:28 +0530 Subject: [PATCH 09/26] Deleted the files after changing naming convention. --- .../ThreeColumnPlanDataDividerList.swift | 91 ------------------- .../ThreeColumnPlanDataDividerListModel.swift | 52 ----------- 2 files changed, 143 deletions(-) delete mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerList.swift delete mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerListModel.swift diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerList.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerList.swift deleted file mode 100644 index 1624095c..00000000 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerList.swift +++ /dev/null @@ -1,91 +0,0 @@ -// -// ThreeColumnPlanDataDividerList.swift -// MVMCoreUI -// -// Created by Acharya, Subhankar on 04/02/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -@objcMembers open class ThreeColumnPlanDataDividerList: TableViewCell { - - let leftHeadlineBody = HeadlineBody(frame: .zero) - let centerHeadLineBody = HeadlineBody(frame: .zero) - let rightHeadLineBody = HeadlineBody(frame: .zero) - let containerView = ViewConstrainingView() - let betweenHeadlineBodyPaddingConstant: CGFloat = 18.0 - let headlineBodyTopPaddingConstant: CGFloat = 48.0 - let containerViewPaddingConstant: CGFloat = 30.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) - } - // MARK: - MFViewProtocol - open override func updateView(_ size: CGFloat) { - super.updateView(size) - containerView.updateView(size) - leftHeadlineBody.updateView(size) - centerHeadLineBody.updateView(size) - rightHeadLineBody.updateView(size) - } - open override func setupView() { - super.setupView() - selectionStyle = .default - guard leftHeadlineBody.superview == nil else { - return - } - containerView.translatesAutoresizingMaskIntoConstraints = false - contentView.addSubview(containerView) - contentView.heightAnchor.constraint(greaterThanOrEqualToConstant: 103.0).isActive = true - containerView.pinView(toSuperView: contentView) - containerView.addSubview(leftHeadlineBody) - containerView.addSubview(centerHeadLineBody) - containerView.addSubview(rightHeadLineBody) - //width calculation of headlinebody - let constraint = rightHeadLineBody.widthAnchor.constraint(equalTo: containerView.widthAnchor, multiplier: 0.25) - constraint.isActive = true - rightHeadLineBody.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - centerHeadLineBody.widthAnchor.constraint(equalTo: rightHeadLineBody.widthAnchor).isActive = true - leftHeadlineBody.widthAnchor.constraint(equalTo: rightHeadLineBody.widthAnchor).isActive = true - //Constraints of headlinebody to superview - leftHeadlineBody.topAnchor.constraint(equalTo: containerView.topAnchor, constant: headlineBodyTopPaddingConstant).isActive = true - centerHeadLineBody.topAnchor.constraint(equalTo: containerView.topAnchor, constant: headlineBodyTopPaddingConstant).isActive = true - rightHeadLineBody.topAnchor.constraint(equalTo: containerView.topAnchor, constant: headlineBodyTopPaddingConstant).isActive = true - - containerView.bottomAnchor.constraint(equalTo: leftHeadlineBody.bottomAnchor).isActive = true - containerView.bottomAnchor.constraint(equalTo: centerHeadLineBody.bottomAnchor).isActive = true - containerView.bottomAnchor.constraint(equalTo: rightHeadLineBody.bottomAnchor).isActive = true - - leftHeadlineBody.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: containerViewPaddingConstant).isActive = true - centerHeadLineBody.leadingAnchor.constraint(equalTo: leftHeadlineBody.trailingAnchor, constant: betweenHeadlineBodyPaddingConstant).isActive = true - rightHeadLineBody.leadingAnchor.constraint(equalTo: centerHeadLineBody.trailingAnchor, constant: betweenHeadlineBodyPaddingConstant).isActive = true - rightHeadLineBody.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -containerViewPaddingConstant).isActive = true - - } - // MARK: - MVMCoreUIMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.setWithModel(model, delegateObject, additionalData) - guard let model = model as? ThreeColumnPlanDataDividerListModel else { return } - leftHeadlineBody.setWithModel(model.leftHeadlineBody, delegateObject, additionalData) - centerHeadLineBody.setWithModel(model.centerHeadlineBody, delegateObject, additionalData) - centerHeadLineBody.isHidden = model.centerHeadlineBody == nil - rightHeadLineBody.setWithModel(model.rightHeadlineBody, delegateObject, additionalData) - } - open override func reset() { - super.reset() - containerView.reset() - leftHeadlineBody.reset() - centerHeadLineBody.reset() - rightHeadLineBody.reset() - } - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 103 - } -} - diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerListModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerListModel.swift deleted file mode 100644 index b9a94288..00000000 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ThreeColumnPlanDataDividerListModel.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// ThreeColumnPlanDataDividerListModel.swift -// MVMCoreUI -// -// Created by Acharya, Subhankar on 04/02/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import UIKit - -public class ThreeColumnPlanDataDividerListModel: ContainerModel, ListItemModelProtocol { - public var hideArrow: Bool? - public var style: String? - public var line: LineModel? - public var backgroundColor: Color? - public static var identifier: String = "list3CHBDiv" - public var leftHeadlineBody: HeadlineBodyModel - public var centerHeadlineBody: HeadlineBodyModel? - public var rightHeadlineBody: HeadlineBodyModel - - init(leftheadlineBody: HeadlineBodyModel, rightHeadLineBody: HeadlineBodyModel) { - self.leftHeadlineBody = leftheadlineBody - self.rightHeadlineBody = rightHeadLineBody - super.init() - } - private enum CodingKeys: String, CodingKey { - case style - case moleculeName - case leftHeadlineBody - case centerHeadlineBody - case rightHeadlineBody - } - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - style = try typeContainer.decodeIfPresent(String.self, forKey: .style) - leftHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .leftHeadlineBody) - centerHeadlineBody = try typeContainer.decodeIfPresent(HeadlineBodyModel.self, forKey: .centerHeadlineBody) - rightHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .rightHeadlineBody) - try super.init(from: decoder) - } - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(style, forKey: .style) - try container.encode(ThreeColumnPlanDataDividerListModel.identifier, forKey: .moleculeName) - try container.encode(leftHeadlineBody, forKey: .leftHeadlineBody) - try container.encodeIfPresent(centerHeadlineBody, forKey: .centerHeadlineBody) - try container.encode(rightHeadlineBody, forKey: .rightHeadlineBody) - } - -} - From d5ac7e3e6dabc7957e58c40f9ce0f2654f928890 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Tue, 11 Feb 2020 17:33:12 +0530 Subject: [PATCH 10/26] removed line break --- .../ListThreeColumnPlanDataDivider.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift index c34c7a55..0dadc8fa 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift @@ -62,6 +62,5 @@ import Foundation public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return 103 } - } From d92c5b5679b8ccce8b7ae26cf240e47d34fd36bb Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Tue, 11 Feb 2020 22:21:07 +0530 Subject: [PATCH 11/26] Code changes using the StackModel --- .../ListThreeColumnPlanDataDivider.swift | 32 ++++++++----------- .../Molecules/Items/StackItemModel.swift | 5 +++ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift index 0dadc8fa..9e821f25 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift @@ -13,14 +13,13 @@ import Foundation let leftHeadlineBody = HeadlineBody(frame: .zero) let centerHeadLineBody = HeadlineBody(frame: .zero) let rightHeadLineBody = HeadlineBody(frame: .zero) - private var stack = UIStackView() + let stack = Stack(frame: .zero) // MARK: - MFViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) - leftHeadlineBody.updateView(size) - centerHeadLineBody.updateView(size) - rightHeadLineBody.updateView(size) + styleTallDivider() + stack.updateView(size) } open override func setupView() { @@ -28,18 +27,11 @@ import Foundation guard leftHeadlineBody.superview == nil else { return } - //using stackView to align the three headlineBody + //using stackItems to align the three headlineBody stack.translatesAutoresizingMaskIntoConstraints = false + stack.stackItems = [StackItem(andContain: leftHeadlineBody),StackItem(andContain: centerHeadLineBody),StackItem(andContain: rightHeadLineBody)] contentView.addSubview(stack) - stack.addArrangedSubview(leftHeadlineBody) - stack.addArrangedSubview(centerHeadLineBody) - stack.addArrangedSubview(rightHeadLineBody) - NSLayoutConstraint.constraintPinSubview(stack, pinTop: true, topConstant: 0, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: PaddingDefaultHorizontalSpacing, pinRight: true, rightConstant: PaddingDefaultHorizontalSpacing) - stack.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 0).isActive = true - stack.axis = .horizontal - stack.spacing = 35 - stack.distribution = .fillProportionally - styleTallDivider() + containerHelper.constrainView(stack) } // MARK: - MVMCoreUIMoleculeViewProtocol @@ -49,14 +41,18 @@ import Foundation leftHeadlineBody.setWithModel(model.leftHeadlineBody, delegateObject, additionalData) centerHeadLineBody.setWithModel(model.centerHeadlineBody, delegateObject, additionalData) rightHeadLineBody.setWithModel(model.rightHeadlineBody, delegateObject, additionalData) + + // Create a stack model to use for the internal stack. + let stackModel = StackModel(molecules: [StackItemModel(percent: 33),StackItemModel(percent: 33),StackItemModel(percent: 33)]) + stackModel.spacing = 0 + stackModel.axis = .horizontal + stack.model = stackModel + stack.restack() } open override func reset() { super.reset() - styleTallDivider() - leftHeadlineBody.reset() - centerHeadLineBody.reset() - rightHeadLineBody.reset() + stack.reset() } public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index f296986e..66c57809 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -19,4 +19,9 @@ import Foundation self.init() self.gone = gone } + + public convenience init(percent: Int) { + self.init() + self.percent = percent + } } From fed9b8ff92187f4c6a5a277c397ae8de25382963 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Wed, 12 Feb 2020 16:45:09 +0530 Subject: [PATCH 12/26] 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 394a5aba18a52dc8f87a04442c9860173e1df136 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Wed, 12 Feb 2020 21:34:47 +0530 Subject: [PATCH 13/26] Code fixes for alignment and StackItemModel conformance change. --- .../ListThreeColumnPlanDataDivider.swift | 12 ++++++++---- .../ListThreeColumnPlanDataDividerModel.swift | 12 ++++++++++++ MVMCoreUI/Molecules/Items/StackItemModel.swift | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift index 9e821f25..84361c9c 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDivider.swift @@ -18,7 +18,6 @@ import Foundation // MARK: - MFViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) - styleTallDivider() stack.updateView(size) } @@ -42,9 +41,14 @@ import Foundation centerHeadLineBody.setWithModel(model.centerHeadlineBody, delegateObject, additionalData) rightHeadLineBody.setWithModel(model.rightHeadlineBody, delegateObject, additionalData) - // Create a stack model to use for the internal stack. - let stackModel = StackModel(molecules: [StackItemModel(percent: 33),StackItemModel(percent: 33),StackItemModel(percent: 33)]) - stackModel.spacing = 0 + // Create a stack model to use for the internal stack and set the alignment of models + let leftHeadlineBodyAlignment = StackItemModel(percent: 33) + leftHeadlineBodyAlignment.horizontalAlignment = .leading + let centerHeadLineBodyAlignment = StackItemModel(percent: 34) + centerHeadLineBodyAlignment.horizontalAlignment = .center + let rightHeadLineBodyAlignment = StackItemModel(percent: 33) + rightHeadLineBodyAlignment.horizontalAlignment = .trailing + let stackModel = StackModel(molecules: [leftHeadlineBodyAlignment,centerHeadLineBodyAlignment,rightHeadLineBodyAlignment]) stackModel.axis = .horizontal stack.model = stackModel stack.restack() diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDividerModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDividerModel.swift index 0da1499d..d03d8528 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDividerModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ListThreeColumnPlanDataDividerModel.swift @@ -23,6 +23,17 @@ public class ListThreeColumnPlanDataDividerModel: ContainerModel, ListItemModelP self.centerHeadlineBody = centerHeadlineBody self.rightHeadlineBody = rightHeadlineBody super.init() + setDefaults() + } + + /// Defaults to set + func setDefaults() { + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } } private enum CodingKeys: String, CodingKey { @@ -38,6 +49,7 @@ public class ListThreeColumnPlanDataDividerModel: ContainerModel, ListItemModelP centerHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .centerHeadlineBody) rightHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .rightHeadlineBody) try super.init(from: decoder) + setDefaults() } public override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index 66c57809..2058353c 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? From e0bb0e45dc7f177ec13bff0cb9b2e7dae6230c1c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 12 Feb 2020 11:25:37 -0500 Subject: [PATCH 14/26] integrating changes to make fan out instance models into categories due to name conflicts --- .../Atoms/Views/CircleProgressModel.swift | 1 + .../Label/LabelAttributeColorModel.swift | 14 ++++++-- .../Views/Label/LabelAttributeFontModel.swift | 19 +++++++++-- .../Label/LabelAttributeImageModel.swift | 19 ++++++++--- .../Views/Label/LabelAttributeModel.swift | 26 ++++++++++++--- .../MFViewController+Model.swift | 32 ++++++++----------- .../Extensions/MoleculeModelHelper.swift | 4 ++- .../CarouselItemModelProtocol.swift | 5 +-- .../CarouselPagingModelProtocol.swift | 3 +- .../ContainerModelProtocol.swift | 1 + .../DisableableModelProtocol.swift | 1 + .../ModelProtocols/FormModelProtocol.swift | 1 + .../ListItemModelProtocol.swift | 19 +++++++++-- .../MoleculeModelProtocol.swift | 17 ++++++++-- .../ModelProtocols/PageModelProtocol.swift | 18 +++++++++++ .../TemplateModelProtocol.swift | 6 ++-- ...MoleculeMappingObject+ModelExtension.swift | 2 +- .../OtherHandlers/MoleculeObjectMapping.swift | 17 +++++----- .../Templates/ListPageTemplateModel.swift | 17 +++++++++- MVMCoreUI/Templates/TemplateProtocol.swift | 1 + 20 files changed, 169 insertions(+), 54 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift index feb69083..c4f55bef 100644 --- a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -17,6 +17,7 @@ public enum GraphStyle: String, Codable { } public class CircleProgressModel: MoleculeModelProtocol { + public static var identifier: String = "circleProgress" public var style: GraphStyle = .unlimited { didSet { diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeColorModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeColorModel.swift index 26f1fa54..01183614 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeColorModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeColorModel.swift @@ -9,6 +9,9 @@ import UIKit @objcMembers public class LabelAttributeColorModel: LabelAttributeModel { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- override public class var identifier: String { return "color" @@ -16,14 +19,21 @@ import UIKit var textColor: String? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case textColor } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) + textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeFontModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeFontModel.swift index 88ae728d..2e9e6e1c 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeFontModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeFontModel.swift @@ -8,7 +8,12 @@ import UIKit + @objcMembers public class LabelAttributeFontModel: LabelAttributeModel { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + override public class var identifier: String { return "font" } @@ -17,17 +22,25 @@ import UIKit var name: String? var size: CGFloat? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case style case name case size } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) - self.name = try typeContainer.decodeIfPresent(String.self, forKey: .name) - self.size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) + style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + name = try typeContainer.decodeIfPresent(String.self, forKey: .name) + size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeImageModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeImageModel.swift index 0095a589..1980353c 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeImageModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeImageModel.swift @@ -9,7 +9,10 @@ import UIKit class LabelAttributeImageModel: LabelAttributeModel { - + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + override public class var identifier: String { return "image" } @@ -18,17 +21,25 @@ class LabelAttributeImageModel: LabelAttributeModel { var name: String? var URL: String? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case size case name case URL } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) - self.name = try typeContainer.decodeIfPresent(String.self, forKey: .name) - self.URL = try typeContainer.decodeIfPresent(String.self, forKey: .URL) + size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) + name = try typeContainer.decodeIfPresent(String.self, forKey: .name) + URL = try typeContainer.decodeIfPresent(String.self, forKey: .URL) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift index ae2768ab..22bb10d8 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift @@ -9,6 +9,17 @@ import Foundation @objcMembers open class LabelAttributeModel: Model { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var categoryName: String { + return "\(LabelAttributeModel.self)" + } + + public static var categoryCodingKey: String { + return "type" + } public class var identifier: String { return "" @@ -18,17 +29,25 @@ import Foundation var location: Int var length: Int + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case type case location case length } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.type = try typeContainer.decode(String.self, forKey: .type) - self.location = try typeContainer.decode(Int.self, forKey: .location) - self.length = try typeContainer.decode(Int.self, forKey: .length) + type = try typeContainer.decode(String.self, forKey: .type) + location = try typeContainer.decode(Int.self, forKey: .location) + length = try typeContainer.decode(Int.self, forKey: .length) } public func encode(to encoder: Encoder) throws { @@ -37,5 +56,4 @@ import Foundation try container.encode(location, forKey: .location) try container.encode(length, forKey: .length) } - } diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 6cedf93c..1c58c574 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -9,41 +9,35 @@ import Foundation extension MFViewController: MoleculeDelegateProtocol { - public func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? { - guard let name = name else { - return nil - } + + public func getModuleWithName(_ name: String?) -> [AnyHashable: Any]? { + guard let name = name else { return nil } + return loadObject?.modulesJSON?.optionalDictionaryForKey(name) } public func getModuleWithName(_ moduleName: String) -> MoleculeModelProtocol? { guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moduleName), let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), - let modelType = ModelRegistry.getType(for: moleculeName) as? MoleculeModelProtocol.Type else { - return nil - } + let modelType = ModelRegistry.getType(for: moleculeName, with: MoleculeModelProtocol.self) + else { return nil } + do { - return try modelType.decode(jsonDict: moduleJSON) + return try modelType.decode(jsonDict: moduleJSON) as? MoleculeModelProtocol } catch { MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") } + return nil } - @objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { - - } + @objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { } - @objc public func addMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - // Do nothing - } + @objc public func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { } - @objc public func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - // Do nothing - } + @objc public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { } } public extension MFViewController { - @objc func parsePageJSON() throws { - } + @objc func parsePageJSON() throws { } } diff --git a/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift b/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift index 599851bb..87460640 100644 --- a/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift @@ -8,7 +8,9 @@ import Foundation -extension KeyedDecodingContainer where Key : CodingKey { + +extension KeyedDecodingContainer where Key: CodingKey { + private enum TypeCodingKey: String, CodingKey { case moleculeName } diff --git a/MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift index 53a6cc10..093c9337 100644 --- a/MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift @@ -8,7 +8,8 @@ import Foundation + public protocol CarouselItemModelProtocol: ContainerModelProtocol, MoleculeModelProtocol { - var peakingUI: Bool? {get} - var peakingArrowColor: Color? {get} + var peakingUI: Bool? { get } + var peakingArrowColor: Color? { get } } diff --git a/MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift index 5f593d3b..94b1277a 100644 --- a/MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift @@ -8,6 +8,7 @@ import Foundation + public protocol CarouselPagingModelProtocol: MoleculeModelProtocol { - var position: Float? {get} + var position: Float? { get } } diff --git a/MVMCoreUI/Models/ModelProtocols/ContainerModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ContainerModelProtocol.swift index 304a4811..bc230731 100644 --- a/MVMCoreUI/Models/ModelProtocols/ContainerModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ContainerModelProtocol.swift @@ -8,6 +8,7 @@ import Foundation + public protocol ContainerModelProtocol { var horizontalAlignment: UIStackView.Alignment? { get set } var verticalAlignment: UIStackView.Alignment? { get set } diff --git a/MVMCoreUI/Models/ModelProtocols/DisableableModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/DisableableModelProtocol.swift index 1e49bd8c..db0cfd77 100644 --- a/MVMCoreUI/Models/ModelProtocols/DisableableModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/DisableableModelProtocol.swift @@ -8,6 +8,7 @@ import Foundation + public protocol EnableableModelProtocol { var enabled: Bool { get set } } diff --git a/MVMCoreUI/Models/ModelProtocols/FormModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/FormModelProtocol.swift index aa298716..1224d5a9 100644 --- a/MVMCoreUI/Models/ModelProtocols/FormModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/FormModelProtocol.swift @@ -8,6 +8,7 @@ import Foundation + public protocol FormModelProtocol: Model { var required: Bool? { get } var fieldKey: String? { get } diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index c6be0488..cd19a23c 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -8,6 +8,7 @@ import Foundation + public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeModelProtocol { var line: LineModel? { get set } var action: ActionModelProtocol? { get set } @@ -16,15 +17,27 @@ public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeModelProt } // Not a strict requirement. -extension ListItemModelProtocol { +public extension ListItemModelProtocol { - public var action: ActionModelProtocol? { + var action: ActionModelProtocol? { get { return nil } set { } } - public var style: String? { + var style: String? { get { return nil } set { } } + + var moleculeName: String? { + get { return Self.identifier } + } + + var categoryName: String { + return "\(ListItemModelProtocol.self)" + } + +// var categoryCodingKey: String { +// return "style" +// } } diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift index 85a91bcd..9f099331 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift @@ -1,12 +1,25 @@ import Foundation + public protocol MoleculeModelProtocol: Model { var moleculeName: String? { get } var backgroundColor: Color? { get set} + + static var categoryName: String { get } + static var categoryCodingKey: String { get } } -extension MoleculeModelProtocol { - public var moleculeName: String? { +public extension MoleculeModelProtocol { + + var moleculeName: String? { get { return Self.identifier } } + + static var categoryName: String { + return "\(MoleculeModelProtocol.self)" + } + + static var categoryCodingKey: String { + return "moleculeName" + } } diff --git a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift index 8c6d1557..2ad9b8a2 100644 --- a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift @@ -8,8 +8,26 @@ import Foundation + public protocol PageModelProtocol: Model { var pageType: String { get set } var screenHeading: String? { get set } var isAtomicTabs: Bool? { get set } + + static var categoryName: String { get } + static var categoryCodingKey: String { get } +} + +extension PageModelProtocol { + //TODO: Scott implement + + public static var categoryCodingKey: String { + return "moleculeName" + } + + public static var categoryName: String { + return "\(PageModelProtocol.self)" + } +// public static var categoryName: String { return "template" } +// public static var categoryCodingKey: String { return "\(PageModelProtocol.self)" } } diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift index 66472da6..90a8ec2a 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift @@ -8,12 +8,14 @@ import Foundation + public protocol TemplateModelProtocol: PageModelProtocol { var template: String { get } } -extension TemplateModelProtocol { - public var template: String { +public extension TemplateModelProtocol { + + var template: String { get { return Self.identifier } } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 4796b2a2..6249e61e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -11,7 +11,7 @@ import Foundation public extension MVMCoreUIMoleculeMappingObject { func register(viewClass: V.Type, viewModelClass: M.Type) { - ModelRegistry.register(viewModelClass) + try? ModelRegistry.register(viewModelClass) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(viewClass, forKey: viewModelClass.identifier as NSString) } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 8c1a36e3..b139f33b 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -18,13 +18,13 @@ import Foundation // Label MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) - //need to move labelattributemodel to different method - ModelRegistry.register(LabelAttributeFontModel.self) - ModelRegistry.register(LabelAttributeColorModel.self) - //ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... - ModelRegistry.register(LabelAttributeUnderlineModel.self) - ModelRegistry.register(LabelAttributeStrikeThroughModel.self) - ModelRegistry.register(LabelAttributeActionModel.self) + // need to move labelattributemodel to different method + try? ModelRegistry.register(LabelAttributeFontModel.self) + try? ModelRegistry.register(LabelAttributeColorModel.self) + try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... + try? ModelRegistry.register(LabelAttributeUnderlineModel.self) + try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) + try? ModelRegistry.register(LabelAttributeActionModel.self) // Buttons MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) @@ -40,7 +40,6 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) // Other Atoms - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ProgressBar.self, viewModelClass: ProgressBarModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MultiProgress.self, viewModelClass: MultiProgressBarModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretView.self, viewModelClass: CaretViewModel.self) @@ -104,6 +103,6 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) // TODO: Need View - ModelRegistry.register(TabsModel.self) + try? ModelRegistry.register(TabsModel.self) } } diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index fe9c12c5..ff899319 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -9,7 +9,10 @@ import Foundation @objcMembers public class ListPageTemplateModel: TemplateModelProtocol { - + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "list" public var pageType: String @@ -21,12 +24,20 @@ import Foundation public var footer: MoleculeModelProtocol? public var line: LineModel? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol]) { self.pageType = pageType self.screenHeading = screenHeading self.molecules = molecules } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case pageType @@ -38,6 +49,10 @@ import Foundation case isAtomicTabs } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) pageType = try typeContainer.decode(String.self, forKey: .pageType) diff --git a/MVMCoreUI/Templates/TemplateProtocol.swift b/MVMCoreUI/Templates/TemplateProtocol.swift index 0498ec5d..63c66263 100644 --- a/MVMCoreUI/Templates/TemplateProtocol.swift +++ b/MVMCoreUI/Templates/TemplateProtocol.swift @@ -14,6 +14,7 @@ public protocol TemplateProtocol: class { } public extension TemplateProtocol where Self: MFViewController { + func parseTemplateJSON() throws { guard let pageJSON = self.loadObject?.pageJSON else { return } let data = try JSONSerialization.data(withJSONObject: pageJSON) From c30a0012394b1b1f855243e62817872532aa643d Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Wed, 12 Feb 2020 23:01:02 +0530 Subject: [PATCH 15/26] 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 16/26] 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 17/26] 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 18/26] 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 19/26] 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) } } From 5b898b1b215d629a2c2bd3ebcb66f5fc18de9eb1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 12 Feb 2020 20:56:05 -0500 Subject: [PATCH 20/26] small clean and reorg --- MVMCoreUI.xcodeproj/project.pbxproj | 48 ++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c5ec4836..b1e42d4b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -888,8 +888,6 @@ D224798E2316A995003FCCF9 /* HorizontalCombinationViews */ = { isa = PBXGroup; children = ( - 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, - 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, D2E2A99B23D8D975000B42E6 /* ImageHeadlineBodyModel.swift */, D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */, D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */, @@ -902,8 +900,6 @@ D224798F2316A99F003FCCF9 /* LeftRightViews */ = { isa = PBXGroup; children = ( - 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, - 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */, 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, @@ -950,6 +946,49 @@ path = Items; sourceTree = ""; }; + D22B38E923F4E07800490EF6 /* DesignedComponents */ = { + isa = PBXGroup; + children = ( + D22B38EC23F4E10700490EF6 /* SectionDividers */, + D22B38EA23F4E08B00490EF6 /* List */, + ); + path = DesignedComponents; + sourceTree = ""; + }; + D22B38EA23F4E08B00490EF6 /* List */ = { + isa = PBXGroup; + children = ( + D22B38EB23F4E0AE00490EF6 /* LeftVariable */, + ); + path = List; + sourceTree = ""; + }; + D22B38EB23F4E0AE00490EF6 /* LeftVariable */ = { + isa = PBXGroup; + children = ( + 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, + 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, + ); + path = LeftVariable; + sourceTree = ""; + }; + D22B38EC23F4E10700490EF6 /* SectionDividers */ = { + isa = PBXGroup; + children = ( + D22B38ED23F4E11100490EF6 /* ThreeColumn */, + ); + path = SectionDividers; + sourceTree = ""; + }; + D22B38ED23F4E11100490EF6 /* ThreeColumn */ = { + isa = PBXGroup; + children = ( + 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, + 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, + ); + path = ThreeColumn; + sourceTree = ""; + }; D22D1F582204D2590077CEC0 /* Legacy */ = { isa = PBXGroup; children = ( @@ -1052,6 +1091,7 @@ D29DF10E21E67A77003B2FB9 /* Molecules */ = { isa = PBXGroup; children = ( + D22B38E923F4E07800490EF6 /* DesignedComponents */, D22479912316A9EF003FCCF9 /* Items */, D224798F2316A99F003FCCF9 /* LeftRightViews */, D224798E2316A995003FCCF9 /* HorizontalCombinationViews */, From 54e012d69908b0968a691ff064305a3814f9961c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 12 Feb 2020 21:55:27 -0500 Subject: [PATCH 21/26] name fix --- MVMCoreUI/BaseControllers/MFViewController+Model.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 1c58c574..1ddbd4ab 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -16,8 +16,8 @@ extension MFViewController: MoleculeDelegateProtocol { return loadObject?.modulesJSON?.optionalDictionaryForKey(name) } - public func getModuleWithName(_ moduleName: String) -> MoleculeModelProtocol? { - guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moduleName), + public func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? { + guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moleculeName), let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), let modelType = ModelRegistry.getType(for: moleculeName, with: MoleculeModelProtocol.self) else { return nil } From 24f44e58292df1efef48ff2654468380cc24a0b6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 12 Feb 2020 22:03:46 -0500 Subject: [PATCH 22/26] Small cleaning --- .../ListItemModelProtocol.swift | 12 ------------ .../MoleculeModelProtocol.swift | 3 --- .../ModelProtocols/PageModelProtocol.swift | 19 +------------------ .../TemplateModelProtocol.swift | 10 +++++++++- 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index cd19a23c..020c3cbe 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -28,16 +28,4 @@ public extension ListItemModelProtocol { get { return nil } set { } } - - var moleculeName: String? { - get { return Self.identifier } - } - - var categoryName: String { - return "\(ListItemModelProtocol.self)" - } - -// var categoryCodingKey: String { -// return "style" -// } } diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift index 9f099331..1ec0d13c 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift @@ -4,9 +4,6 @@ import Foundation public protocol MoleculeModelProtocol: Model { var moleculeName: String? { get } var backgroundColor: Color? { get set} - - static var categoryName: String { get } - static var categoryCodingKey: String { get } } public extension MoleculeModelProtocol { diff --git a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift index 2ad9b8a2..34b58818 100644 --- a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift @@ -9,25 +9,8 @@ import Foundation -public protocol PageModelProtocol: Model { +public protocol PageModelProtocol { var pageType: String { get set } var screenHeading: String? { get set } var isAtomicTabs: Bool? { get set } - - static var categoryName: String { get } - static var categoryCodingKey: String { get } -} - -extension PageModelProtocol { - //TODO: Scott implement - - public static var categoryCodingKey: String { - return "moleculeName" - } - - public static var categoryName: String { - return "\(PageModelProtocol.self)" - } -// public static var categoryName: String { return "template" } -// public static var categoryCodingKey: String { return "\(PageModelProtocol.self)" } } diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift index 90a8ec2a..793baa0a 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift @@ -9,7 +9,7 @@ import Foundation -public protocol TemplateModelProtocol: PageModelProtocol { +public protocol TemplateModelProtocol: PageModelProtocol, Model { var template: String { get } } @@ -18,4 +18,12 @@ public extension TemplateModelProtocol { var template: String { get { return Self.identifier } } + + static var categoryCodingKey: String { + return "template" + } + + static var categoryName: String { + return "\(TemplateModelProtocol.self)" + } } From 66a06d98159e1e64251b5b682c007c8d212f79f6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 13 Feb 2020 10:19:22 -0500 Subject: [PATCH 23/26] Clean up and list item convenience --- MVMCoreUI.xcodeproj/project.pbxproj | 14 ++++--- .../ListLeftVariableIconWithRightCaret.swift | 3 -- ...tLeftVariableIconWithRightCaretModel.swift | 25 ++--------- .../ListThreeColumnPlanDataDivider.swift | 4 +- .../ListThreeColumnPlanDataDividerModel.swift | 20 ++------- .../Items/AccordionListItemModel.swift | 26 ++++++------ .../AccordionMoleculeTableViewCell.swift | 10 ++++- .../Items/DropDownFilterTableViewCell.swift | 4 +- .../Items/DropDownListItemModel.swift | 41 ++++--------------- MVMCoreUI/Molecules/Items/ListItemModel.swift | 33 ++++++--------- .../Items/MoleculeListItemModel.swift | 41 +++++++++++++++++++ .../Items/MoleculeTableViewCell.swift | 4 +- .../Molecules/Items/TabsListItemModel.swift | 31 ++++++-------- .../Molecules/Items/TabsTableViewCell.swift | 22 ++++++---- .../ModelMoleculeDelegateProtocol.swift | 8 ++-- .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- .../Templates/ListPageTemplateModel.swift | 6 +-- .../Templates/MoleculeListTemplate.swift | 21 +++++----- 18 files changed, 149 insertions(+), 166 deletions(-) create mode 100644 MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ad2719bb..d114d2ae 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -54,7 +54,7 @@ 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; - 01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.swift */; }; + 01EB369023609801006832FA /* MoleculeListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* MoleculeListItemModel.swift */; }; 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368B23609801006832FA /* MoleculeStackModel.swift */; }; 01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; }; 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; }; @@ -169,6 +169,7 @@ D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; + D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */; }; D274CA332236A78900B01B62 /* FooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* FooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; @@ -384,7 +385,7 @@ 01C851D223CF9E740021F976 /* LabelToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggleModel.swift; sourceTree = ""; }; 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeModelProtocol.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; - 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; + 01EB368923609801006832FA /* MoleculeListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeListItemModel.swift; sourceTree = ""; }; 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackItemModel.swift; sourceTree = ""; }; 01EB368B23609801006832FA /* MoleculeStackModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackModel.swift; sourceTree = ""; }; 01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = ""; }; @@ -489,6 +490,7 @@ D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = ""; }; D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = ""; }; D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; + D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; D2755D7A23689C7500485468 /* TableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; }; D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsTableViewCell.swift; sourceTree = ""; }; @@ -927,8 +929,8 @@ D22479912316A9EF003FCCF9 /* Items */ = { isa = PBXGroup; children = ( - D2755D7A23689C7500485468 /* TableViewCell.swift */, - 01EB368923609801006832FA /* ListItemModel.swift */, + D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */, + 01EB368923609801006832FA /* MoleculeListItemModel.swift */, 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */, 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, @@ -1430,6 +1432,7 @@ D2B18B7E2360913400A9AEDC /* Control.swift */, D2B18B802360945C00A9AEDC /* View.swift */, 0AE14F63238315D2005417F8 /* TextField.swift */, + D2755D7A23689C7500485468 /* TableViewCell.swift */, 0A5D59C323AD488600EFD9E9 /* Protocols */, ); path = BaseClasses; @@ -1682,7 +1685,7 @@ 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, D2A514672213885800345BFB /* HeaderView.swift in Sources */, D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */, - 01EB369023609801006832FA /* ListItemModel.swift in Sources */, + 01EB369023609801006832FA /* MoleculeListItemModel.swift in Sources */, D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, @@ -1792,6 +1795,7 @@ D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, 0A21DB94235E24ED00C160A2 /* DigitEntryField.swift in Sources */, + D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, 0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */, 94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */, 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift index 62a19d01..9f0e2deb 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift @@ -29,9 +29,6 @@ import UIKit override open func setupView() { super.setupView() - guard leftImage.superview == nil else { - return - } stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: leftImage),StackItem(andContain: leftLabel),StackItem(andContain: rightLabel)] contentView.addSubview(stack) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift index cac928d3..bccf5320 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift @@ -8,25 +8,14 @@ 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? +public class ListLeftVariableIconWithRightCaretModel: ListItemModel, MoleculeModelProtocol { 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 - } + override public func setDefaults() { + super.setDefaults() if image.height == nil { image.height = 30.0 } @@ -37,7 +26,6 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo self.leftLabel = leftLabel self.rightLabel = rightLabel super.init() - setDefaults() } private enum CodingKeys: String, CodingKey { @@ -45,8 +33,6 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo case leftLabel case rightLabel case image - case action - case backgroundColor } required public init(from decoder: Decoder) throws { @@ -54,10 +40,7 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo 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) - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) - setDefaults() } public override func encode(to encoder: Encoder) throws { @@ -67,8 +50,6 @@ public class ListLeftVariableIconWithRightCaretModel: ContainerModel, ListItemMo 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) } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift index e685ce6b..19774110 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift @@ -23,9 +23,7 @@ import Foundation open override func setupView() { super.setupView() - guard leftHeadlineBody.superview == nil else { - return - } + //using stackItems to align the three headlineBody stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: leftHeadlineBody),StackItem(andContain: centerHeadLineBody),StackItem(andContain: rightHeadLineBody)] diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift index 47e97a5a..fd946eb0 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift @@ -8,11 +8,7 @@ import UIKit -public class ListThreeColumnPlanDataDividerModel: ContainerModel, ListItemModelProtocol { - public var hideArrow: Bool? - public var style: String? = "tallDivider" - public var line: LineModel? - public var backgroundColor: Color? +public class ListThreeColumnPlanDataDividerModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "list3CHBDiv" public var leftHeadlineBody: HeadlineBodyModel public var centerHeadlineBody: HeadlineBodyModel @@ -27,13 +23,9 @@ public class ListThreeColumnPlanDataDividerModel: ContainerModel, ListItemModelP } /// Defaults to set - func setDefaults() { - if useHorizontalMargins == nil { - useHorizontalMargins = true - } - if useVerticalMargins == nil { - useVerticalMargins = true - } + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" } private enum CodingKeys: String, CodingKey { @@ -41,7 +33,6 @@ public class ListThreeColumnPlanDataDividerModel: ContainerModel, ListItemModelP case leftHeadlineBody case centerHeadlineBody case rightHeadlineBody - case backgroundColor } required public init(from decoder: Decoder) throws { @@ -49,9 +40,7 @@ public class ListThreeColumnPlanDataDividerModel: ContainerModel, ListItemModelP leftHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .leftHeadlineBody) centerHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .centerHeadlineBody) rightHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .rightHeadlineBody) - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) - setDefaults() } public override func encode(to encoder: Encoder) throws { @@ -61,7 +50,6 @@ public class ListThreeColumnPlanDataDividerModel: ContainerModel, ListItemModelP try container.encode(leftHeadlineBody, forKey: .leftHeadlineBody) try container.encode(centerHeadlineBody, forKey: .centerHeadlineBody) try container.encode(rightHeadlineBody, forKey: .rightHeadlineBody) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift index 0e2fa531..788ef919 100644 --- a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift @@ -8,28 +8,28 @@ import UIKit -class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { - public static var identifier: String = "accordionListItem" - public var molecules: [ListItemModelProtocol] - public var backgroundColor: Color? +class AccordionListItemModel: MoleculeListItemModel { + override public class var identifier: String { + return "accordionListItem" + } + public var molecules: [ListItemModelProtocol & MoleculeModelProtocol] public var hideLineWhenExpanded: Bool = false - public var hideArrow: Bool? = true - public var line: LineModel? private enum CodingKeys: String, CodingKey { case moleculeName case molecules - case backgroundColor + case molecule case hideLineWhenExpanded - case hideArrow - case line + } + + public override func setDefaults() { + super.setDefaults() + hideArrow = true } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [ListItemModelProtocol] - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) + molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [ListItemModelProtocol & MoleculeModelProtocol] if let hideLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideLineWhenExpanded) { hideLineWhenExpanded = hideLine } @@ -41,8 +41,6 @@ class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeModels(molecules, forKey: .molecules) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(hideLineWhenExpanded, forKey: .hideLineWhenExpanded) - try container.encodeIfPresent(line, forKey: .line) } } diff --git a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift index db4e322e..714c7dd9 100644 --- a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -9,7 +9,9 @@ import UIKit @objcMembers public class AccordionMoleculeTableViewCell: MoleculeTableViewCell { - var accordionListItemModel: AccordionListItemModel? + var accordionListItemModel: AccordionListItemModel? { + return listItemModel as? AccordionListItemModel + } let accordionButton = createAccordionButton() static func createAccordionButton() -> MFCustomButton { @@ -30,10 +32,14 @@ import UIKit override public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { accordionButton.isSelected = !accordionButton.isSelected accordionButton.setTitle(accordionButton.isSelected ? "-" : "+", for: .normal) - guard let molecules = accordionListItemModel?.molecules else { + guard let model = accordionListItemModel else { return } + guard let json = model.toJSON(), + let molecules = json.optionalArrayForKey("molecules") as? [[AnyHashable: Any]] + else { return } + if accordionButton.isSelected { delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: .automatic) } else { diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 081da875..164bd2c3 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -24,9 +24,7 @@ import UIKit override public func setupView() { super.setupView() - - guard dropDown.superview == nil else { return } - + addMolecule(dropDown) dropDown.observeDropdownChange = { [weak self] oldValue, newValue in diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 35f69b51..b623f20e 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -8,43 +8,31 @@ import Foundation -@objcMembers public class DropDownListItemModel: ContainerModel, ListItemModelProtocol { +@objcMembers public class DropDownListItemModel: ListItemModel, MoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- public static var identifier: String = "dropDownListItem" - public var molecules: [[ListItemModelProtocol]] + public var molecules: [[ListItemModelProtocol & MoleculeModelProtocol]] public var dropDown: ItemDropdownEntryFieldModel - public var backgroundColor: Color? - public var line: LineModel? = LineModel(type: .none) - public var hideArrow: Bool? = true /// Defaults to set - func setDefaults() { - if useHorizontalMargins == nil { - useHorizontalMargins = true - } - if useVerticalMargins == nil { - useVerticalMargins = true - } - if topMarginPadding == nil { - topMarginPadding = 24 - } - if bottomMarginPadding == nil { - bottomMarginPadding = 0 - } + public override func setDefaults() { + super.setDefaults() + hideArrow = true + line = LineModel(type: .none) + style = "sectionFooter" } //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(molecules: [[ListItemModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { + public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { self.molecules = molecules self.dropDown = dropDown super.init() - setDefaults() } //-------------------------------------------------- @@ -55,8 +43,6 @@ import Foundation case moleculeName case molecules case dropDown - case line - case backgroundColor } //-------------------------------------------------- @@ -65,16 +51,9 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as? [[ListItemModelProtocol]] ?? [[]] + molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as? [[ListItemModelProtocol & MoleculeModelProtocol]] ?? [[]] dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) - - if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { - line = lineModel - } - - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) - setDefaults() } public override func encode(to encoder: Encoder) throws { @@ -83,7 +62,5 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeModels2D(molecules, forKey: .molecules) try container.encode(dropDown, forKey: .dropDown) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(line, forKey: .line) } } diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index ffb0eb35..973a487a 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -1,25 +1,22 @@ // -// ListItem.swift +// BaseListItemModel.swift // MVMCoreUI // -// Created by Suresh, Kamlesh on 10/3/19. -// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// Created by Scott Pfeil on 2/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. // +// A base class that has common list item boilerplate model stuffs. import Foundation -import MVMCore -@objcMembers public class ListItemModel: MoleculeContainerModel, ListItemModelProtocol { - - public static var identifier: String = "listItem" +@objcMembers public class ListItemModel: ContainerModel, ListItemModelProtocol { public var backgroundColor: Color? public var action: ActionModelProtocol? public var hideArrow: Bool? public var line: LineModel? - public var style: String? = "standard" + public var style: String? private enum CodingKeys: String, CodingKey { - case moleculeName case backgroundColor case action case hideArrow @@ -28,23 +25,20 @@ import MVMCore } /// Defaults to set - func setDefaults() { + public func setDefaults() { if useHorizontalMargins == nil { useHorizontalMargins = true } if useVerticalMargins == nil { useVerticalMargins = true } - if topMarginPadding == nil { - topMarginPadding = 24 - } - if bottomMarginPadding == nil { - bottomMarginPadding = 24 + if style == nil { + style = "standard" } } - public override init(with moleculeModel: MoleculeModelProtocol) { - super.init(with: moleculeModel) + public override init() { + super.init() setDefaults() } @@ -54,9 +48,7 @@ import MVMCore action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) { - self.style = style - } + style = try typeContainer.decodeIfPresent(String.self, forKey: .style) try super.init(from: decoder) setDefaults() } @@ -64,7 +56,6 @@ import MVMCore public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeIfPresent(hideArrow, forKey: .hideArrow) diff --git a/MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift new file mode 100644 index 00000000..499669c6 --- /dev/null +++ b/MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift @@ -0,0 +1,41 @@ +// +// ListItem.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation +import MVMCore + +@objcMembers public class MoleculeListItemModel: ListItemModel, MoleculeModelProtocol { + public class var identifier: String { + return "listItem" + } + public var molecule: MoleculeModelProtocol + + private enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + } + + public init(with moleculeModel: MoleculeModelProtocol) { + molecule = moleculeModel + super.init() + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeModel(molecule, forKey: .molecule) + } +} + diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 9f27a918..0416ce8e 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -16,7 +16,7 @@ import UIKit public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let model = model as? ListItemModel else { return } + guard let model = model as? MoleculeListItemModel else { return } if molecule != nil { (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model.molecule, delegateObject, additionalData) @@ -29,7 +29,7 @@ import UIKit } public override class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let moleculeModel = (model as? ListItemModel)?.molecule else { return "\(self)<>" } + guard let moleculeModel = (model as? MoleculeListItemModel)?.molecule else { return "\(self)<>" } let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type let moleculeName = className?.nameForReuse(moleculeModel, delegateObject) ?? moleculeModel.moleculeName ?? "" diff --git a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift index 0158774a..c89ee1a0 100644 --- a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift @@ -8,39 +8,36 @@ import UIKit -public class TabsListItemModel: ContainerModel, ListItemModelProtocol { +public class TabsListItemModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "tabsListItem" var tabs: TabsModel - var molecules: [[ListItemModelProtocol]] - - public var backgroundColor: Color? - public var hideArrow: Bool? = true - public var line: LineModel? = LineModel(type: .standard) + var molecules: [[ListItemModelProtocol & MoleculeModelProtocol]] private enum CodingKeys: String, CodingKey { case moleculeName case tabs case molecules - case backgroundColor - case line } - public init(with tabs: TabsModel, molecules: [[ListItemModelProtocol]]) { + public override func setDefaults() { + super.setDefaults() + hideArrow = true + action = nil + style = nil + topMarginPadding = 8 + bottomMarginPadding = 0 + } + + public init(with tabs: TabsModel, molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]) { self.tabs = tabs self.molecules = molecules super.init() - self.topMarginPadding = 8 - self.bottomMarginPadding = 0 } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) tabs = try typeContainer.decode(TabsModel.self, forKey: .tabs) - molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { - line = lineModel - } + molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol & MoleculeModelProtocol]] try super.init(from: decoder) } @@ -50,7 +47,5 @@ public class TabsListItemModel: ContainerModel, ListItemModelProtocol { try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) try container.encodeModels2D(molecules, forKey: .molecules) - try container.encode(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(line, forKey: .line) } } diff --git a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift index cf09eb51..8a971221 100644 --- a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift @@ -9,7 +9,9 @@ import UIKit @objcMembers public class TabsTableViewCell: TableViewCell { - var tabsListItemModel: TabsListItemModel? + var tabsListItemModel: TabsListItemModel? { + return listItemModel as? TabsListItemModel + } let tabs = TopTabbar(frame: .zero) var delegateObject: MVMCoreUIDelegateObject? var previousTabIndex = 0 @@ -17,11 +19,7 @@ import UIKit // MARK: - MFViewProtocol override public func setupView() { super.setupView() - guard tabs.superview == nil else { - return - } tabs.paddingBeforeFirstTab = false - tabs.translatesAutoresizingMaskIntoConstraints = false tabs.delegate = self tabs.datasource = self @@ -48,11 +46,18 @@ import UIKit super.reset() tabs.reset() } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 46 + } } extension TabsTableViewCell: TopTabbarDelegate { public func shouldSelectItem(at index: Int, topTabbar: TopTabbar) -> Bool { - if let molecules = tabsListItemModel?.molecules[topTabbar.selectedIndex] { + if let model = tabsListItemModel, + let json = model.toJSON(), + let json2d = json.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]] { + let molecules = json2d[topTabbar.selectedIndex] delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: index < tabs.selectedIndex ? .right : .left) } previousTabIndex = tabs.selectedIndex @@ -60,7 +65,10 @@ extension TabsTableViewCell: TopTabbarDelegate { } public func topTabbar(_ topTabbar: TopTabbar, didSelectItemAt index: Int) { - if let molecules = tabsListItemModel?.molecules[index] { + if let model = tabsListItemModel, + let json = model.toJSON(), + let json2d = json.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]] { + let molecules = json2d[index] delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: index < previousTabIndex ? .left : .right) } } diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index 8fe1caa5..d3a2fe80 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -23,8 +23,8 @@ public protocol MoleculeDelegateProtocol { func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) //optional - func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) - func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) + func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) + func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) } extension MoleculeDelegateProtocol { @@ -40,11 +40,11 @@ extension MoleculeDelegateProtocol { // Do nothing } - public func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // Do nothing } - public func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // Do nothing } } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 3dfc935a..a04f964a 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -74,7 +74,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) // List items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: ListItemModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DropDownFilterTableViewCell.self, viewModelClass: DropDownListItemModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: AccordionMoleculeTableViewCell.self, viewModelClass: AccordionListItemModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TabsTableViewCell.self, viewModelClass: TabsListItemModel.self) diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index ff899319..4ce4c6f5 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -20,7 +20,7 @@ import Foundation public var isAtomicTabs: Bool? public var header: MoleculeModelProtocol? - public var molecules: [ListItemModelProtocol]? + public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]? public var footer: MoleculeModelProtocol? public var line: LineModel? @@ -28,7 +28,7 @@ import Foundation // MARK: - Initializer //-------------------------------------------------- - public init(pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol]) { + public init(pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol & MoleculeModelProtocol]) { self.pageType = pageType self.screenHeading = screenHeading self.molecules = molecules @@ -57,7 +57,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) pageType = try typeContainer.decode(String.self, forKey: .pageType) screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) - molecules = try typeContainer.decodeMoleculesIfPresent(codingKey: .molecules) as? [ListItemModelProtocol] + molecules = try typeContainer.decodeMoleculesIfPresent(codingKey: .molecules) as? [ListItemModelProtocol & MoleculeModelProtocol] isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header) footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer) diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index a088d34a..01d0a5e6 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -13,7 +13,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol // MARK: - Stored Properties //-------------------------------------------------- - public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? + public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (ListItemModelProtocol & MoleculeModelProtocol))]? var observer: NSKeyValueObservation? @@ -176,10 +176,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol public override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - var tmpMolecules = [ListItemModelProtocol]() + var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() molecules.forEach { molecule in - if let data = try? JSONSerialization.data(withJSONObject: molecule), let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data) { + if let data = try? JSONSerialization.data(withJSONObject: molecule), let listItemModel = try? JSONDecoder().decode(MoleculeListItemModel.self, from: data) { tmpMolecules.append(listItemModel) } } @@ -205,10 +205,11 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol public override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - var tmpMolecules = [ListItemModelProtocol]() + var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() molecules.forEach { molecule in - if let data = try? JSONSerialization.data(withJSONObject: molecule), let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data) { + if let data = try? JSONSerialization.data(withJSONObject: molecule), + let listItemModel = try? JSONDecoder().decode(MoleculeListItemModel.self, from: data) { tmpMolecules.append(listItemModel) } } @@ -230,7 +231,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol view.layoutIfNeeded() } - public func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // This dispatch is needed to fix a race condition that can occur if this function is called during the table setup. DispatchQueue.main.async { @@ -252,7 +253,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality @@ -274,7 +275,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol //-------------------------------------------------- /// Returns the (identifier, class) of the molecule for the given map. - func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? { + func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? { guard let listItem = listItem, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), @@ -285,9 +286,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } /// Sets up the molecule list and ensures no errors loading all content. - func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? { + func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: (ListItemModelProtocol & MoleculeModelProtocol))]? { - var moleculeList: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)] = [] + var moleculeList: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)] = [] if let molecules = templateModel?.molecules { for molecule in molecules { From adaa9ca1f3c5fbf6e255c9ecfc489143bd9cede2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 13 Feb 2020 10:45:00 -0500 Subject: [PATCH 24/26] Bug fixes --- .../Items => BaseClasses}/TableViewCell.swift | 23 +++++++++++++------ .../ThreeLayerTableViewController.swift | 2 ++ .../Views/Container/ContainerModel.swift | 5 ++-- .../ListItemModelProtocol.swift | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) rename MVMCoreUI/{Molecules/Items => BaseClasses}/TableViewCell.swift (96%) diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift similarity index 96% rename from MVMCoreUI/Molecules/Items/TableViewCell.swift rename to MVMCoreUI/BaseClasses/TableViewCell.swift index cd8a3cdf..fe06a05a 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -28,6 +28,8 @@ import UIKit private var heroAccessoryCenter: CGPoint? + private var initialSetupPerformed = false + // MARK: - Styling open func style(with styleString: String?) { guard let styleString = styleString else { @@ -102,12 +104,19 @@ import UIKit // MARK: - Inits public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) - setupView() + initialSetup() } public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - setupView() + initialSetup() + } + + public func initialSetup() { + if !initialSetupPerformed { + initialSetupPerformed = true + setupView() + } } // MARK: - MFViewProtocol @@ -151,10 +160,6 @@ import UIKit self.listItemModel = model style(with: model.style) - if let backgroundColor = model.backgroundColor { - self.backgroundColor = backgroundColor.uiColor - } - // Add the caret if there is an action and it's not declared hidden. if !customAccessoryView { if let _ = model.action, !(model.hideArrow ?? false) { @@ -169,11 +174,15 @@ import UIKit addSeparatorsIfNeeded() bottomSeparatorView?.setWithModel(separator, nil, nil) } + + if let moleculeModel = model as? MoleculeModelProtocol, + let backgroundColor = moleculeModel.backgroundColor { + self.backgroundColor = backgroundColor.uiColor + } } open func reset() { molecule?.reset?() - styleStandard() backgroundColor = .white } diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index 3176df92..ae3d2fac 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -166,6 +166,8 @@ open class ThreeLayerTableViewController: MFProgrammaticTableViewController { } // This extra view is needed because of the wonkiness of apple's table header. Things breaks if using autolayout. + headerView.setNeedsLayout() + headerView.layoutIfNeeded() MVMCoreUIUtility.sizeView(toFit: headerView) let tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: MVMCoreUIUtility.getWidth(), height: headerView.frame.height)) tableHeaderView.addSubview(headerView) diff --git a/MVMCoreUI/Containers/Views/Container/ContainerModel.swift b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift index 1b721183..cdc6d743 100644 --- a/MVMCoreUI/Containers/Views/Container/ContainerModel.swift +++ b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift @@ -48,7 +48,8 @@ public class ContainerModel: ContainerModelProtocol, Codable { try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment) try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins) try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins) - try container.encodeIfPresent(topMarginPadding, forKey: .topMarginPadding) - try container.encodeIfPresent(bottomMarginPadding, forKey: .bottomMarginPadding) + // TODO: can add this back once we have type erasures. + //try container.encodeIfPresent(topMarginPadding, forKey: .topMarginPadding) + //try container.encodeIfPresent(bottomMarginPadding, forKey: .bottomMarginPadding) } } diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index 020c3cbe..5d0fee08 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -9,7 +9,7 @@ import Foundation -public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeModelProtocol { +public protocol ListItemModelProtocol: ContainerModelProtocol { var line: LineModel? { get set } var action: ActionModelProtocol? { get set } var hideArrow: Bool? { get set } From c6e9c84809438d9acc558f61e6cd6b777d9e0eb3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 13 Feb 2020 10:55:46 -0500 Subject: [PATCH 25/26] Comments update --- MVMCoreUI/BaseControllers/ViewController.swift | 3 +-- MVMCoreUI/Molecules/Items/AccordionListItemModel.swift | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 8202378b..96909c82 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -60,8 +60,7 @@ import UIKit open func setNavigationItem() { navigationItem.title = pageModel?.screenHeading - navigationItem.accessibilityLabel = pageModel?.screenHeading - + navigationItem.accessibilityLabel = pageModel?.screenHeading } open func newDataBuildScreen() { diff --git a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift index 788ef919..60192c2d 100644 --- a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift @@ -29,7 +29,10 @@ class AccordionListItemModel: MoleculeListItemModel { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [ListItemModelProtocol & MoleculeModelProtocol] + guard let molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as? [ListItemModelProtocol & MoleculeModelProtocol] else { + throw DecodingError.typeMismatch([ListItemModelProtocol & MoleculeModelProtocol].self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Casting failed")) + } + self.molecules = molecules if let hideLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideLineWhenExpanded) { hideLineWhenExpanded = hideLine } From 5d578b0eea0a75418945b95349af80028caa6123 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 13 Feb 2020 11:00:18 -0500 Subject: [PATCH 26/26] remove unneeded check --- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 96909c82..1bb06324 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -44,7 +44,7 @@ import UIKit for case let key as String in Array(loadedModules.keys) { guard modulesRequired.count > 0 else { break } - if let index = modulesRequired.firstIndex(where: {($0 as? String) == key}), index != NSNotFound { + if let index = modulesRequired.firstIndex(where: {($0 as? String) == key}) { modulesRequired.remove(at: index) } }