From 63201a8fa69c909c3fa4e6523577825388beea21 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 12 Feb 2020 15:11:41 +0530 Subject: [PATCH] 19042 - List - Left Variable - Checkbox - With Right Caret - All Text & Links story commit. Added Molecule class, Model class --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ ...heckboxWithRightCaretAllTextAndLinks.swift | 87 +++++++++++++++++++ ...oxWithRightCaretAllTextAndLinksModel.swift | 66 ++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 162 insertions(+) create mode 100644 MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift create mode 100644 MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f97e81aa..b9fad525 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -123,6 +123,8 @@ 94F217B723E0BF6100A47C06 /* PrimaryButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */; }; 94FB966223D797DA003D482B /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94FB966023D797DA003D482B /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; + AA29DC9B23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift */; }; + AA29DC9D23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; @@ -439,6 +441,8 @@ 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PrimaryButtonView.m; sourceTree = ""; }; 94FB966023D797DA003D482B /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = ""; }; 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; + AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift; sourceTree = ""; }; + AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; @@ -897,6 +901,8 @@ D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, 01509D902327ECE600EF99AA /* CornerLabels.swift */, D224798823142BF2003FCCF9 /* ToggleMolecules */, + AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift */, + AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift */, ); path = LeftRightViews; sourceTree = ""; @@ -1582,6 +1588,7 @@ 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, + AA29DC9D23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, @@ -1724,6 +1731,7 @@ D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, + AA29DC9B23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift in Sources */, 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift new file mode 100644 index 00000000..2b47e704 --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift @@ -0,0 +1,87 @@ +// +// ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Lekshmi S on 11/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinks: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + + let checkbox = Checkbox(frame: .zero) + let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + let containerView = Container() + + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------ + + let cellHeight: CGFloat = 125.0 + let leftPadding: CGFloat = 35.0 + let rightPadding: CGFloat = 35.0 + let spaceBetweenCheckBoxAndEyebrowHedline: CGFloat = 16.0 + let checkBoxSize: CGFloat = 18.0 + + //----------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + containerView.updateView(size) + checkbox.updateView(size) + eyebrowHeadlineBodyLink.updateView(size) + } + + override open func setupView() { + super.setupView() + guard checkbox.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(checkbox) + containerView.addSubview(eyebrowHeadlineBodyLink) + + //checkBox constraints + checkbox.centerYAnchor.constraint(equalTo: eyebrowHeadlineBodyLink.centerYAnchor).isActive = true + checkbox.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: leftPadding).isActive = true + + //eyebrowHeadlineBodyLink constraints + eyebrowHeadlineBodyLink.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true + eyebrowHeadlineBodyLink.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true + eyebrowHeadlineBodyLink.leadingAnchor.constraint(equalTo: checkbox.trailingAnchor, constant: spaceBetweenCheckBoxAndEyebrowHedline).isActive = true + eyebrowHeadlineBodyLink.trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + + override open func reset() { + super.reset() + checkbox.reset() + eyebrowHeadlineBodyLink.reset() + } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel else { return} + checkbox.setWithModel(model.checkbox, delegateObject, additionalData) + eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + } +} diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift new file mode 100644 index 00000000..86925752 --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift @@ -0,0 +1,66 @@ +// +// ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 11/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: ContainerModel, ListItemModelProtocol { + + public var line: LineModel? + public var hideArrow: Bool? + public var backgroundColor: Color? + public static var identifier: String = "listLVCB" + public var checkbox: CheckboxModel + var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + func setDefaults() { + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } + if topMarginPadding == nil { + topMarginPadding = 24 + } + if bottomMarginPadding == nil { + bottomMarginPadding = 0 + } + } + + init(checkbox: CheckboxModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.checkbox = checkbox + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case eyebrowHeadlineBodyLink + case checkbox + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + checkbox = try typeContainer.decode(CheckboxModel.self, forKey: .checkbox) + try super.init(from: decoder) + setDefaults() + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(EyebrowHeadlineBodyLinkModel.identifier, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + try container.encode(checkbox, forKey: .checkbox) + } + +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 8c1a36e3..caffd59f 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: ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.self) // List items MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: ListItemModel.self)