From 35e7052abbc806d8541ba20b8349fe203183380c Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Tue, 4 Feb 2020 14:10:01 +0530 Subject: [PATCH 01/40] WIP: LabelsWithCircleProgressBar --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ .../LabelsWithCircleProgressBar.swift | 91 +++++++++++++++++++ .../LabelsWithCircleProgressBarModel.swift | 50 ++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 2 + 4 files changed, 151 insertions(+) create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index a35514cb..4edba1af 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -130,6 +130,8 @@ C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */; }; C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5123C77A4900A3614A /* NumberedList.swift */; }; C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; }; + C7F8012123E8303200396FBD /* LabelsWithCircleProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012023E8303200396FBD /* LabelsWithCircleProgressBar.swift */; }; + C7F8012323E846C300396FBD /* LabelsWithCircleProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012223E846C300396FBD /* LabelsWithCircleProgressBarModel.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; @@ -442,6 +444,8 @@ C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeStack.swift; sourceTree = ""; }; C6FA7D5123C77A4900A3614A /* NumberedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedList.swift; sourceTree = ""; }; C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = ""; }; + C7F8012023E8303200396FBD /* LabelsWithCircleProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelsWithCircleProgressBar.swift; sourceTree = ""; }; + C7F8012223E846C300396FBD /* LabelsWithCircleProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelsWithCircleProgressBarModel.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; @@ -859,6 +863,8 @@ C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */, D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */, 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, + C7F8012023E8303200396FBD /* LabelsWithCircleProgressBar.swift */, + C7F8012223E846C300396FBD /* LabelsWithCircleProgressBarModel.swift */, ); path = VerticalCombinationViews; sourceTree = ""; @@ -1586,6 +1592,7 @@ D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */, D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, + C7F8012323E846C300396FBD /* LabelsWithCircleProgressBarModel.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */, 014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */, @@ -1680,6 +1687,7 @@ D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, + C7F8012123E8303200396FBD /* LabelsWithCircleProgressBar.swift in Sources */, D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift new file mode 100644 index 00000000..016403c8 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift @@ -0,0 +1,91 @@ +// +// LabelsWithCircleProgressBar.swift +// MVMCoreUI +// +// Created by Arora, Prateek on 20/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers public class LabelsWithCircleProgressBar: Container { + + let progressBar = GraphView(frame: .zero) + let leftLabel = Label(frame: .zero) + let rightLabel = Label(frame: .zero) + let leftLabelWidthConstant : CGFloat = 151.0 + let rightLabelWidthConstant : CGFloat = 84.0 + let progressBarTrailingConstant : CGFloat = -92.0 + let progressBarLeadingConstant : CGFloat = 195.0 + // MARK: - MVMCoreViewProtocol + open override func updateView(_ size: CGFloat) { + super.updateView(size) + progressBar.updateView(size) + leftLabel.updateView(size) + rightLabel.updateView(size) + } + + open override func setupView() { + super.setupView() + guard leftLabel.superview == nil else { + return + } + let container = MVMCoreUICommonViewsUtility.commonView() + addAndContain(container) + container.addSubview(progressBar) + container.addSubview(leftLabel) + container.addSubview(rightLabel) + + self.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + leftLabel.leadingAnchor.constraint(equalTo: container.leadingAnchor), + leftLabel.topAnchor.constraint(equalTo: container.topAnchor), + leftLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), + leftLabel.widthAnchor.constraint(lessThanOrEqualToConstant: leftLabelWidthConstant) + ]) + + let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:-PaddingHorizontalBetweenRelatedItems) + NSLayoutConstraint.activate([ + rightLabelTrailing, + rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : progressBar.trailingAnchor), + rightLabel.topAnchor.constraint(equalTo: container.topAnchor), + rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), + rightLabel.widthAnchor.constraint(lessThanOrEqualToConstant: rightLabelWidthConstant) + ]) + rightLabelTrailing.priority = .defaultHigh + + NSLayoutConstraint.activate([ + progressBar.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:progressBarTrailingConstant), + progressBar.topAnchor.constraint(equalTo: container.topAnchor), + progressBar.bottomAnchor.constraint(equalTo: container.bottomAnchor), + ]) + } + + // MARK: - MVMCoreUIMoleculeViewProtocol + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + leftLabel.setWithJSON(json?.optionalDictionaryForKey("leftLabel"), delegateObject: delegateObject, additionalData: additionalData) + rightLabel.setWithJSON(json?.optionalDictionaryForKey("rightLabel"), delegateObject: delegateObject, additionalData: additionalData) + progressBar.setWithJSON(json?.optionalDictionaryForKey("progressBar"), delegateObject: delegateObject, additionalData: additionalData) + } + + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? LabelsWithCircleProgressBarModel else { return } + leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) + rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) + progressBar.setWithModel(model.progressBar, delegateObject, additionalData) + } + // MARK:- ModelMoleculeViewProtocol + + open override func reset() { + super.reset() + leftLabel.reset() + rightLabel.reset() + progressBar.reset() + } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 43 + } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift new file mode 100644 index 00000000..9d4af2b6 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift @@ -0,0 +1,50 @@ +// +// LabelsWithCircleProgressBarModel.swift +// MVMCoreUI +// +// Created by Arora, Prateek on 03/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { + + public var backgroundColor: Color? + + public static var identifier: String = "labelsWithCircleProgressBar" + public var leftLabel: LabelModel + public var rightLabel: LabelModel + public var progressBar : CircleProgressModel + + init(leftLabel: LabelModel, rightLabel: LabelModel, progressBar: CircleProgressModel) { + self.leftLabel = leftLabel + self.rightLabel = rightLabel + self.progressBar = progressBar + } + + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case rightLabel + case progressBar + } + + 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) + progressBar = try typeContainer.decode(CircleProgressModel.self, forKey: .progressBar) + } + + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(LabelsWithCircleProgressBarModel.identifier, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(rightLabel, forKey: .rightLabel) + try container.encodeIfPresent(progressBar, forKey: .progressBar) + } + +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index d3523ccf..76be5d23 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -62,6 +62,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: EyebrowHeadlineBodyLink.self, viewModelClass: EyebrowHeadlineBodyLinkModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLink.self, viewModelClass: HeadlineBodyLinkModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyButton.self, viewModelClass: HeadlineBodyButtonModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass:LabelsWithCircleProgressBar.self, viewModelClass: LabelsWithCircleProgressBarModel.self) // Left Right Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CornerLabels.self, viewModelClass: CornerLabelsModel.self) @@ -102,6 +103,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButton.self, forKey: "radioButton" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButtonLabel.self, forKey: "radioButtonLabel" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) + // TODO: Need View ModelRegistry.register(TabsModel.self) From d56335d1036c3aa33ba8a7050303aeaa5ff94e3c Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Thu, 6 Feb 2020 16:59:42 +0530 Subject: [PATCH 02/40] Progress bar molecule changes --- .../LabelsWithCircleProgressBar.swift | 5 ++--- .../LabelsWithCircleProgressBarModel.swift | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift index 016403c8..f1913627 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift @@ -14,8 +14,7 @@ import Foundation let rightLabel = Label(frame: .zero) let leftLabelWidthConstant : CGFloat = 151.0 let rightLabelWidthConstant : CGFloat = 84.0 - let progressBarTrailingConstant : CGFloat = -92.0 - let progressBarLeadingConstant : CGFloat = 195.0 + let progressBarTrailingConstant : CGFloat = -100.0 // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) @@ -43,7 +42,7 @@ import Foundation leftLabel.widthAnchor.constraint(lessThanOrEqualToConstant: leftLabelWidthConstant) ]) - let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:-PaddingHorizontalBetweenRelatedItems) + let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:0) NSLayoutConstraint.activate([ rightLabelTrailing, rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : progressBar.trailingAnchor), diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift index 9d4af2b6..9d7e6c02 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift @@ -36,6 +36,8 @@ public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) progressBar = try typeContainer.decode(CircleProgressModel.self, forKey: .progressBar) + progressBar.size = .small; + progressBar.style = .unlimited; } From 07d8ef5d13daecd05b598344c56065b1f09e129a Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Thu, 6 Feb 2020 17:30:29 +0530 Subject: [PATCH 03/40] Progress bar molecule changes --- .../LabelsWithCircleProgressBar.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift index f1913627..d109cbe8 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift @@ -14,7 +14,7 @@ import Foundation let rightLabel = Label(frame: .zero) let leftLabelWidthConstant : CGFloat = 151.0 let rightLabelWidthConstant : CGFloat = 84.0 - let progressBarTrailingConstant : CGFloat = -100.0 + let progressBarTrailingConstant : CGFloat = -72.0 // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) @@ -42,10 +42,10 @@ import Foundation leftLabel.widthAnchor.constraint(lessThanOrEqualToConstant: leftLabelWidthConstant) ]) - let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:0) + let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: container.trailingAnchor) NSLayoutConstraint.activate([ rightLabelTrailing, - rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : progressBar.trailingAnchor), + rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : progressBar.trailingAnchor, constant: 8.0), rightLabel.topAnchor.constraint(equalTo: container.topAnchor), rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), rightLabel.widthAnchor.constraint(lessThanOrEqualToConstant: rightLabelWidthConstant) From 8f225dda70d44296e4b65a8dc07922d3e704f202 Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Thu, 6 Feb 2020 18:19:15 +0530 Subject: [PATCH 04/40] Code clean --- .../LabelsWithCircleProgressBar.swift | 70 ++++++++++--------- .../LabelsWithCircleProgressBarModel.swift | 7 -- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift index d109cbe8..a636aa05 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift @@ -8,66 +8,70 @@ import Foundation @objcMembers public class LabelsWithCircleProgressBar: Container { - + let progressBar = GraphView(frame: .zero) let leftLabel = Label(frame: .zero) let rightLabel = Label(frame: .zero) let leftLabelWidthConstant : CGFloat = 151.0 let rightLabelWidthConstant : CGFloat = 84.0 let progressBarTrailingConstant : CGFloat = -72.0 - // MARK: - MVMCoreViewProtocol + let rightLabelLeadingAnchorConstant : CGFloat = 8.0 + + //------------------------------------------------- + // MARK: - View Cycle + //------------------------------------------------- open override func updateView(_ size: CGFloat) { super.updateView(size) progressBar.updateView(size) leftLabel.updateView(size) rightLabel.updateView(size) } - + + //------------------------------------------------- + // MARK: - Setup + //------------------------------------------------- open override func setupView() { super.setupView() guard leftLabel.superview == nil else { - return + return } let container = MVMCoreUICommonViewsUtility.commonView() addAndContain(container) container.addSubview(progressBar) container.addSubview(leftLabel) container.addSubview(rightLabel) - + + //------------------------------------------------- + // MARK: - Constraining + //------------------------------------------------- self.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ - leftLabel.leadingAnchor.constraint(equalTo: container.leadingAnchor), - leftLabel.topAnchor.constraint(equalTo: container.topAnchor), - leftLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), - leftLabel.widthAnchor.constraint(lessThanOrEqualToConstant: leftLabelWidthConstant) + leftLabel.leadingAnchor.constraint(equalTo: container.leadingAnchor), + leftLabel.topAnchor.constraint(equalTo: container.topAnchor), + leftLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), + leftLabel.widthAnchor.constraint(lessThanOrEqualToConstant: leftLabelWidthConstant) ]) let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: container.trailingAnchor) NSLayoutConstraint.activate([ - rightLabelTrailing, - rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : progressBar.trailingAnchor, constant: 8.0), - rightLabel.topAnchor.constraint(equalTo: container.topAnchor), - rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), - rightLabel.widthAnchor.constraint(lessThanOrEqualToConstant: rightLabelWidthConstant) - ]) + rightLabelTrailing, + rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : progressBar.trailingAnchor, constant: rightLabelLeadingAnchorConstant), + rightLabel.topAnchor.constraint(equalTo: container.topAnchor), + rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), + rightLabel.widthAnchor.constraint(lessThanOrEqualToConstant: rightLabelWidthConstant) + ]) rightLabelTrailing.priority = .defaultHigh NSLayoutConstraint.activate([ - progressBar.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:progressBarTrailingConstant), - progressBar.topAnchor.constraint(equalTo: container.topAnchor), - progressBar.bottomAnchor.constraint(equalTo: container.bottomAnchor), + progressBar.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:progressBarTrailingConstant), + progressBar.topAnchor.constraint(equalTo: container.topAnchor), + progressBar.bottomAnchor.constraint(equalTo: container.bottomAnchor), ]) } - - // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - leftLabel.setWithJSON(json?.optionalDictionaryForKey("leftLabel"), delegateObject: delegateObject, additionalData: additionalData) - rightLabel.setWithJSON(json?.optionalDictionaryForKey("rightLabel"), delegateObject: delegateObject, additionalData: additionalData) - progressBar.setWithJSON(json?.optionalDictionaryForKey("progressBar"), delegateObject: delegateObject, additionalData: additionalData) - } - + //------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //------------------------------------------------- public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? LabelsWithCircleProgressBarModel else { return } @@ -75,8 +79,10 @@ import Foundation rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) progressBar.setWithModel(model.progressBar, delegateObject, additionalData) } - // MARK:- ModelMoleculeViewProtocol - + + //------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //------------------------------------------------- open override func reset() { super.reset() leftLabel.reset() @@ -84,7 +90,7 @@ import Foundation progressBar.reset() } - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 43 - } + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 43 + } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift index 9d7e6c02..557a5364 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift @@ -11,7 +11,6 @@ import Foundation public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { public var backgroundColor: Color? - public static var identifier: String = "labelsWithCircleProgressBar" public var leftLabel: LabelModel public var rightLabel: LabelModel @@ -22,15 +21,12 @@ public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { self.rightLabel = rightLabel self.progressBar = progressBar } - - private enum CodingKeys: String, CodingKey { case moleculeName case leftLabel case rightLabel case progressBar } - required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) @@ -39,8 +35,6 @@ public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { progressBar.size = .small; progressBar.style = .unlimited; } - - public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(LabelsWithCircleProgressBarModel.identifier, forKey: .moleculeName) @@ -48,5 +42,4 @@ public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { try container.encode(rightLabel, forKey: .rightLabel) try container.encodeIfPresent(progressBar, forKey: .progressBar) } - } From b6762fc45516ac59da77d31cf983e6b82475ef12 Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Thu, 6 Feb 2020 18:21:28 +0530 Subject: [PATCH 05/40] Extra space removal --- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 76be5d23..5c9cf5d5 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -103,7 +103,6 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButton.self, forKey: "radioButton" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButtonLabel.self, forKey: "radioButtonLabel" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) - // TODO: Need View ModelRegistry.register(TabsModel.self) From 21c749489c673d9086ba8819ec8c3cabef39114a Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Thu, 6 Feb 2020 20:20:04 +0530 Subject: [PATCH 06/40] Review Comments --- .../LabelsWithCircleProgressBar.swift | 5 ++--- .../LabelsWithCircleProgressBarModel.swift | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift index a636aa05..9dba7558 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift @@ -51,8 +51,9 @@ import Foundation leftLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), leftLabel.widthAnchor.constraint(lessThanOrEqualToConstant: leftLabelWidthConstant) ]) - + let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: container.trailingAnchor) + rightLabelTrailing.priority = .defaultHigh NSLayoutConstraint.activate([ rightLabelTrailing, rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : progressBar.trailingAnchor, constant: rightLabelLeadingAnchorConstant), @@ -60,8 +61,6 @@ import Foundation rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), rightLabel.widthAnchor.constraint(lessThanOrEqualToConstant: rightLabelWidthConstant) ]) - rightLabelTrailing.priority = .defaultHigh - NSLayoutConstraint.activate([ progressBar.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:progressBarTrailingConstant), progressBar.topAnchor.constraint(equalTo: container.topAnchor), diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift index 557a5364..759b47e2 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift @@ -12,9 +12,9 @@ public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "labelsWithCircleProgressBar" - public var leftLabel: LabelModel - public var rightLabel: LabelModel - public var progressBar : CircleProgressModel + public var leftLabel: LabelModel? + public var rightLabel: LabelModel? + public var progressBar : CircleProgressModel? init(leftLabel: LabelModel, rightLabel: LabelModel, progressBar: CircleProgressModel) { self.leftLabel = leftLabel @@ -32,8 +32,8 @@ public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) progressBar = try typeContainer.decode(CircleProgressModel.self, forKey: .progressBar) - progressBar.size = .small; - progressBar.style = .unlimited; + progressBar?.size = .small; + progressBar?.style = .unlimited; } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) From 7572bf0214535f8972665b40efc074c26b942cb6 Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Fri, 7 Feb 2020 13:48:35 +0530 Subject: [PATCH 07/40] Fixes as per Review comments --- MVMCoreUI/Atoms/Views/CircleProgressModel.swift | 2 ++ .../LabelsWithCircleProgressBarModel.swift | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift index feb69083..e7224ca8 100644 --- a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -73,6 +73,8 @@ public class CircleProgressModel: MoleculeModelProtocol { self.colors = colors } backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + updateSize() + updateStyle() } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift index 759b47e2..e55d5199 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift @@ -7,21 +7,18 @@ // import Foundation - public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { - public var backgroundColor: Color? public static var identifier: String = "labelsWithCircleProgressBar" public var leftLabel: LabelModel? public var rightLabel: LabelModel? public var progressBar : CircleProgressModel? - init(leftLabel: LabelModel, rightLabel: LabelModel, progressBar: CircleProgressModel) { self.leftLabel = leftLabel self.rightLabel = rightLabel self.progressBar = progressBar } - private enum CodingKeys: String, CodingKey { + private enum CodingKeys: String,CodingKey { case moleculeName case leftLabel case rightLabel @@ -32,8 +29,6 @@ public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) progressBar = try typeContainer.decode(CircleProgressModel.self, forKey: .progressBar) - progressBar?.size = .small; - progressBar?.style = .unlimited; } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) From 5ae5cfd2d8b5eeb9a2a2d872fec77add009766c5 Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Fri, 7 Feb 2020 17:03:33 +0530 Subject: [PATCH 08/40] WIP: New molecule changes --- MVMCoreUI.xcodeproj/project.pbxproj | 16 +++---- ...cleProgressBar.swift => ListRVWheel.swift} | 46 +++++++++---------- ...sBarModel.swift => ListRVWheelModel.swift} | 29 ++++++++---- .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- 4 files changed, 51 insertions(+), 42 deletions(-) rename MVMCoreUI/Molecules/VerticalCombinationViews/{LabelsWithCircleProgressBar.swift => ListRVWheel.swift} (65%) rename MVMCoreUI/Molecules/VerticalCombinationViews/{LabelsWithCircleProgressBarModel.swift => ListRVWheelModel.swift} (53%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2d33a957..b2be14ab 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -134,8 +134,8 @@ C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */; }; C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5123C77A4900A3614A /* NumberedList.swift */; }; C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; }; - C7F8012123E8303200396FBD /* LabelsWithCircleProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012023E8303200396FBD /* LabelsWithCircleProgressBar.swift */; }; - C7F8012323E846C300396FBD /* LabelsWithCircleProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012223E846C300396FBD /* LabelsWithCircleProgressBarModel.swift */; }; + C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012023E8303200396FBD /* ListRVWheel.swift */; }; + C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012223E846C300396FBD /* ListRVWheelModel.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; @@ -452,8 +452,8 @@ C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeStack.swift; sourceTree = ""; }; C6FA7D5123C77A4900A3614A /* NumberedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedList.swift; sourceTree = ""; }; C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = ""; }; - C7F8012023E8303200396FBD /* LabelsWithCircleProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelsWithCircleProgressBar.swift; sourceTree = ""; }; - C7F8012223E846C300396FBD /* LabelsWithCircleProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelsWithCircleProgressBarModel.swift; sourceTree = ""; }; + C7F8012023E8303200396FBD /* ListRVWheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRVWheel.swift; sourceTree = ""; }; + C7F8012223E846C300396FBD /* ListRVWheelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRVWheelModel.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; @@ -875,8 +875,8 @@ C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */, D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */, 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, - C7F8012023E8303200396FBD /* LabelsWithCircleProgressBar.swift */, - C7F8012223E846C300396FBD /* LabelsWithCircleProgressBarModel.swift */, + C7F8012023E8303200396FBD /* ListRVWheel.swift */, + C7F8012223E846C300396FBD /* ListRVWheelModel.swift */, ); path = VerticalCombinationViews; sourceTree = ""; @@ -1606,7 +1606,7 @@ D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */, D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, - C7F8012323E846C300396FBD /* LabelsWithCircleProgressBarModel.swift in Sources */, + C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */, 014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */, @@ -1702,7 +1702,7 @@ D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, - C7F8012123E8303200396FBD /* LabelsWithCircleProgressBar.swift in Sources */, + C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift similarity index 65% rename from MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift rename to MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift index 9dba7558..a4f18df6 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBar.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift @@ -1,5 +1,5 @@ // -// LabelsWithCircleProgressBar.swift +// ListRVWheel.swift // MVMCoreUI // // Created by Arora, Prateek on 20/01/20. @@ -7,14 +7,14 @@ // import Foundation -@objcMembers public class LabelsWithCircleProgressBar: Container { +@objcMembers public class ListRVWheel: TableViewCell { - let progressBar = GraphView(frame: .zero) + let wheel = GraphView(frame: .zero) let leftLabel = Label(frame: .zero) let rightLabel = Label(frame: .zero) let leftLabelWidthConstant : CGFloat = 151.0 let rightLabelWidthConstant : CGFloat = 84.0 - let progressBarTrailingConstant : CGFloat = -72.0 + let wheelTrailingConstant : CGFloat = -72.0 let rightLabelLeadingAnchorConstant : CGFloat = 8.0 //------------------------------------------------- @@ -22,7 +22,7 @@ import Foundation //------------------------------------------------- open override func updateView(_ size: CGFloat) { super.updateView(size) - progressBar.updateView(size) + wheel.updateView(size) leftLabel.updateView(size) rightLabel.updateView(size) } @@ -35,36 +35,36 @@ import Foundation guard leftLabel.superview == nil else { return } - let container = MVMCoreUICommonViewsUtility.commonView() - addAndContain(container) - container.addSubview(progressBar) - container.addSubview(leftLabel) - container.addSubview(rightLabel) + contentView.addSubview(wheel) + contentView.addSubview(leftLabel) + contentView.addSubview(rightLabel) + NSLayoutConstraint.constraintPinSubview(toSuperview: contentView) + contentView.translatesAutoresizingMaskIntoConstraints = false //------------------------------------------------- // MARK: - Constraining //------------------------------------------------- self.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ - leftLabel.leadingAnchor.constraint(equalTo: container.leadingAnchor), - leftLabel.topAnchor.constraint(equalTo: container.topAnchor), - leftLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), + leftLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), + leftLabel.topAnchor.constraint(equalTo: contentView.topAnchor), + leftLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), leftLabel.widthAnchor.constraint(lessThanOrEqualToConstant: leftLabelWidthConstant) ]) - let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: container.trailingAnchor) + let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor) rightLabelTrailing.priority = .defaultHigh NSLayoutConstraint.activate([ rightLabelTrailing, - rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : progressBar.trailingAnchor, constant: rightLabelLeadingAnchorConstant), - rightLabel.topAnchor.constraint(equalTo: container.topAnchor), - rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor), + rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : wheel.trailingAnchor, constant: rightLabelLeadingAnchorConstant), + rightLabel.topAnchor.constraint(equalTo: contentView.topAnchor), + rightLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), rightLabel.widthAnchor.constraint(lessThanOrEqualToConstant: rightLabelWidthConstant) ]) NSLayoutConstraint.activate([ - progressBar.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant:progressBarTrailingConstant), - progressBar.topAnchor.constraint(equalTo: container.topAnchor), - progressBar.bottomAnchor.constraint(equalTo: container.bottomAnchor), + wheel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant:wheelTrailingConstant), + wheel.topAnchor.constraint(equalTo: contentView.topAnchor), + wheel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), ]) } @@ -73,10 +73,10 @@ import Foundation //------------------------------------------------- public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let model = model as? LabelsWithCircleProgressBarModel else { return } + guard let model = model as? ListRVWheelModel else { return } leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) - progressBar.setWithModel(model.progressBar, delegateObject, additionalData) + wheel.setWithModel(model.wheel, delegateObject, additionalData) } //------------------------------------------------- @@ -86,7 +86,7 @@ import Foundation super.reset() leftLabel.reset() rightLabel.reset() - progressBar.reset() + wheel.reset() } public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift similarity index 53% rename from MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift rename to MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift index e55d5199..5d8a041a 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/LabelsWithCircleProgressBarModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift @@ -1,5 +1,5 @@ // -// LabelsWithCircleProgressBarModel.swift +// ListRVWheelModel.swift // MVMCoreUI // // Created by Arora, Prateek on 03/02/20. @@ -7,34 +7,43 @@ // import Foundation -public class LabelsWithCircleProgressBarModel:MoleculeModelProtocol { +public class ListRVWheelModel:ListItemModelProtocol { public var backgroundColor: Color? - public static var identifier: String = "labelsWithCircleProgressBar" + public var line: LineModel? + public var hideArrow: Bool? + 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 static var identifier: String = "listRVWheel" public var leftLabel: LabelModel? public var rightLabel: LabelModel? - public var progressBar : CircleProgressModel? - init(leftLabel: LabelModel, rightLabel: LabelModel, progressBar: CircleProgressModel) { + public var wheel : CircleProgressModel? + init(leftLabel: LabelModel, rightLabel: LabelModel, wheel: CircleProgressModel) { self.leftLabel = leftLabel self.rightLabel = rightLabel - self.progressBar = progressBar + self.wheel = wheel } private enum CodingKeys: String,CodingKey { case moleculeName case leftLabel case rightLabel - case progressBar + case wheel } 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) - progressBar = try typeContainer.decode(CircleProgressModel.self, forKey: .progressBar) + wheel = try typeContainer.decode(CircleProgressModel.self, forKey: .wheel) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(LabelsWithCircleProgressBarModel.identifier, forKey: .moleculeName) + try container.encode(ListRVWheelModel.identifier, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(rightLabel, forKey: .rightLabel) - try container.encodeIfPresent(progressBar, forKey: .progressBar) + try container.encodeIfPresent(wheel, forKey: .wheel) } } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 5c9cf5d5..6037ba35 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -62,7 +62,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: EyebrowHeadlineBodyLink.self, viewModelClass: EyebrowHeadlineBodyLinkModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLink.self, viewModelClass: HeadlineBodyLinkModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyButton.self, viewModelClass: HeadlineBodyButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass:LabelsWithCircleProgressBar.self, viewModelClass: LabelsWithCircleProgressBarModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) // Left Right Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CornerLabels.self, viewModelClass: CornerLabelsModel.self) From 63201a8fa69c909c3fa4e6523577825388beea21 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 12 Feb 2020 15:11:41 +0530 Subject: [PATCH 09/40] 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) From 3dbbc1a876d4f604e9bab61b64e18867069fe0f2 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 12 Feb 2020 16:50:46 +0530 Subject: [PATCH 10/40] Code fix --- ...LeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift index 86925752..07efdf1e 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift @@ -57,7 +57,7 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: Contain 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.encode(ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.identifier, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) try container.encode(checkbox, forKey: .checkbox) From 5b1b29c10d723d55b56602474828715fc31de44c Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 14 Feb 2020 10:17:54 +0530 Subject: [PATCH 11/40] Removed container and added stackmodel code changes. --- ...heckboxWithRightCaretAllTextAndLinks.swift | 56 ++++++------------- ...oxWithRightCaretAllTextAndLinksModel.swift | 15 ++++- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift index 2b47e704..c1f68e94 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift @@ -16,17 +16,7 @@ import Foundation 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 + let stack = Stack(frame: .zero) //----------------------------------------------------- // MARK: - View Lifecycle @@ -34,9 +24,7 @@ import Foundation open override func updateView(_ size: CGFloat) { super.updateView(size) - containerView.updateView(size) - checkbox.updateView(size) - eyebrowHeadlineBodyLink.updateView(size) + stack.updateView(size) } override open func setupView() { @@ -44,28 +32,10 @@ import Foundation 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 + stack.translatesAutoresizingMaskIntoConstraints = false + stack.stackItems = [StackItem(andContain: checkbox),StackItem(andContain: eyebrowHeadlineBodyLink)] + contentView.addSubview(stack) + containerHelper.constrainView(stack) } //---------------------------------------------------- @@ -74,8 +44,7 @@ import Foundation override open func reset() { super.reset() - checkbox.reset() - eyebrowHeadlineBodyLink.reset() + stack.reset() } public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { @@ -83,5 +52,16 @@ import Foundation guard let model = model as? ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel else { return} checkbox.setWithModel(model.checkbox, delegateObject, additionalData) eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + + // Create a stack model to use for the internal stack and set the alignment of labels + let checkbox = StackItemModel() + checkbox.horizontalAlignment = .leading + let eyebrowHeadlineBodyLink = StackItemModel() + eyebrowHeadlineBodyLink.horizontalAlignment = .leading + eyebrowHeadlineBodyLink.spacing = 20 + let stackModel = StackModel(molecules: [checkbox,eyebrowHeadlineBodyLink]) + stackModel.axis = .horizontal + stack.model = stackModel + stack.restack() } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift index 07efdf1e..24979f78 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift @@ -11,10 +11,13 @@ import Foundation public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: ContainerModel, ListItemModelProtocol { public var line: LineModel? - public var hideArrow: Bool? + public var style: String? = "standard" + public var hideArrow: Bool? = false public var backgroundColor: Color? + public var action: ActionModelProtocol? public static var identifier: String = "listLVCB" public var checkbox: CheckboxModel + public var spacing: CGFloat = 16.0 var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel func setDefaults() { @@ -43,6 +46,8 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: Contain case backgroundColor case eyebrowHeadlineBodyLink case checkbox + case action + case spacing } required public init(from decoder: Decoder) throws { @@ -50,6 +55,10 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: Contain backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) checkbox = try typeContainer.decode(CheckboxModel.self, forKey: .checkbox) + action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + if let spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) { + self.spacing = spacing + } try super.init(from: decoder) setDefaults() } @@ -57,10 +66,12 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: Contain public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.identifier, forKey: .moleculeName) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) try container.encode(checkbox, forKey: .checkbox) + try container.encodeModelIfPresent(action, forKey: .action) + try container.encodeIfPresent(spacing, forKey: .spacing) } } From 69919f5beb90ecb056a0414713512c1914c63392 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 14 Feb 2020 14:05:54 +0530 Subject: [PATCH 12/40] Added percent for stack items. Removed conformance to ContainerModel and ListItemModelProtocol. --- ...heckboxWithRightCaretAllTextAndLinks.swift | 7 ++-- ...oxWithRightCaretAllTextAndLinksModel.swift | 35 +------------------ 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift index c1f68e94..c194cc50 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift @@ -54,11 +54,10 @@ import Foundation eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData) // Create a stack model to use for the internal stack and set the alignment of labels - let checkbox = StackItemModel() + let checkbox = StackItemModel(percent: 10) checkbox.horizontalAlignment = .leading - let eyebrowHeadlineBodyLink = StackItemModel() - eyebrowHeadlineBodyLink.horizontalAlignment = .leading - eyebrowHeadlineBodyLink.spacing = 20 + let eyebrowHeadlineBodyLink = StackItemModel(percent: 90) + eyebrowHeadlineBodyLink.horizontalAlignment = .fill let stackModel = StackModel(molecules: [checkbox,eyebrowHeadlineBodyLink]) stackModel.axis = .horizontal stack.model = stackModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift index 24979f78..790e8598 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift @@ -8,33 +8,12 @@ import Foundation -public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: ContainerModel, ListItemModelProtocol { +public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { - public var line: LineModel? - public var style: String? = "standard" - public var hideArrow: Bool? = false - public var backgroundColor: Color? - public var action: ActionModelProtocol? public static var identifier: String = "listLVCB" public var checkbox: CheckboxModel - public var spacing: CGFloat = 16.0 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 @@ -43,35 +22,23 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: Contain private enum CodingKeys: String, CodingKey { case moleculeName - case backgroundColor case eyebrowHeadlineBodyLink case checkbox - case action - case spacing } 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) - action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) - if let spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) { - self.spacing = spacing - } 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(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) try container.encode(checkbox, forKey: .checkbox) - try container.encodeModelIfPresent(action, forKey: .action) - try container.encodeIfPresent(spacing, forKey: .spacing) } } From 6cbf4a53bc42073a56f141c94b42dde190963bc8 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 14 Feb 2020 14:09:03 +0530 Subject: [PATCH 13/40] Restructured file group. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- ...istLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift | 0 ...ftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename MVMCoreUI/Molecules/{LeftRightViews => DesignedComponents/List/LeftVariable}/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift (100%) rename MVMCoreUI/Molecules/{LeftRightViews => DesignedComponents/List/LeftVariable}/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 455cb573..f31234f2 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -912,8 +912,6 @@ D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, 01509D902327ECE600EF99AA /* CornerLabels.swift */, D224798823142BF2003FCCF9 /* ToggleMolecules */, - AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift */, - AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift */, ); path = LeftRightViews; sourceTree = ""; @@ -977,6 +975,8 @@ children = ( 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, + AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift */, + AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift */, ); path = LeftVariable; sourceTree = ""; diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift similarity index 100% rename from MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift rename to MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift diff --git a/MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift similarity index 100% rename from MVMCoreUI/Molecules/LeftRightViews/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift rename to MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift From 5da415d0fc21accdc4c40738ed98dca4639029cb Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Fri, 14 Feb 2020 18:17:10 +0530 Subject: [PATCH 14/40] removed line break. --- ...tLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift index 790e8598..330901a6 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift @@ -40,5 +40,4 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: ListIte try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) try container.encode(checkbox, forKey: .checkbox) } - } From a7ebc798d2227bcc328265734dc4d9af871fd35c Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Tue, 18 Feb 2020 19:01:08 +0530 Subject: [PATCH 15/40] Removing hardcoded constraints replacing with multiplier --- .../ListRVWheel.swift | 36 ++++++++----------- .../ListRVWheelModel.swift | 3 +- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift index a4f18df6..485a5464 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift @@ -12,11 +12,6 @@ import Foundation let wheel = GraphView(frame: .zero) let leftLabel = Label(frame: .zero) let rightLabel = Label(frame: .zero) - let leftLabelWidthConstant : CGFloat = 151.0 - let rightLabelWidthConstant : CGFloat = 84.0 - let wheelTrailingConstant : CGFloat = -72.0 - let rightLabelLeadingAnchorConstant : CGFloat = 8.0 - //------------------------------------------------- // MARK: - View Cycle //------------------------------------------------- @@ -41,33 +36,31 @@ import Foundation NSLayoutConstraint.constraintPinSubview(toSuperview: contentView) contentView.translatesAutoresizingMaskIntoConstraints = false - //------------------------------------------------- - // MARK: - Constraining - //------------------------------------------------- + //------------------------------------------------- + // MARK: - Constraining + //------------------------------------------------- self.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ leftLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), leftLabel.topAnchor.constraint(equalTo: contentView.topAnchor), leftLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - leftLabel.widthAnchor.constraint(lessThanOrEqualToConstant: leftLabelWidthConstant) - ]) - - let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor) - rightLabelTrailing.priority = .defaultHigh - NSLayoutConstraint.activate([ - rightLabelTrailing, - rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo : wheel.trailingAnchor, constant: rightLabelLeadingAnchorConstant), - rightLabel.topAnchor.constraint(equalTo: contentView.topAnchor), - rightLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - rightLabel.widthAnchor.constraint(lessThanOrEqualToConstant: rightLabelWidthConstant) + leftLabel.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.3) ]) NSLayoutConstraint.activate([ - wheel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant:wheelTrailingConstant), wheel.topAnchor.constraint(equalTo: contentView.topAnchor), wheel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), ]) + + let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor) + rightLabelTrailing.priority = UILayoutPriority(900) + NSLayoutConstraint.activate([ + rightLabelTrailing, + rightLabel.leadingAnchor.constraint(equalTo: wheel.trailingAnchor), + rightLabel.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.30), + rightLabel.topAnchor.constraint(equalTo: contentView.topAnchor), + rightLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), + ]) } - //------------------------------------------------- // MARK: - MVMCoreUIMoleculeViewProtocol //------------------------------------------------- @@ -88,7 +81,6 @@ import Foundation rightLabel.reset() wheel.reset() } - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 43 } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift index 5d8a041a..9b8a95f4 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift @@ -7,7 +7,8 @@ // import Foundation -public class ListRVWheelModel:ListItemModelProtocol { +public class ListRVWheelModel:ListItemModelProtocol,MoleculeModelProtocol { + public var backgroundColor: Color? public var line: LineModel? public var hideArrow: Bool? From c97c3fe7341ff3aa25acb3dbf5d2524711d83d6f Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Tue, 18 Feb 2020 19:22:17 +0530 Subject: [PATCH 16/40] Code changes and cleaning --- .../VerticalCombinationViews/ListRVWheel.swift | 4 ++-- .../VerticalCombinationViews/ListRVWheelModel.swift | 12 +----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift index 485a5464..47c77ed8 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift @@ -51,12 +51,12 @@ import Foundation wheel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), ]) - let rightLabelTrailing = rightLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor) + let rightLabelTrailing = rightLabel.trailingAnchor.constraint(greaterThanOrEqualTo: contentView.trailingAnchor) rightLabelTrailing.priority = UILayoutPriority(900) NSLayoutConstraint.activate([ rightLabelTrailing, rightLabel.leadingAnchor.constraint(equalTo: wheel.trailingAnchor), - rightLabel.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.30), + rightLabel.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.32), rightLabel.topAnchor.constraint(equalTo: contentView.topAnchor), rightLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), ]) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift index 9b8a95f4..a4c5f028 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift @@ -7,18 +7,8 @@ // import Foundation -public class ListRVWheelModel:ListItemModelProtocol,MoleculeModelProtocol { - +public class ListRVWheelModel:MoleculeModelProtocol { public var backgroundColor: Color? - public var line: LineModel? - public var hideArrow: Bool? - 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 static var identifier: String = "listRVWheel" public var leftLabel: LabelModel? public var rightLabel: LabelModel? From 80935685595cb33427332a173782e7158c82930f Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Thu, 20 Feb 2020 13:42:17 +0530 Subject: [PATCH 17/40] Review comment fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- MVMCoreUI/Atoms/Views/CircleProgressModel.swift | 4 ++-- .../Molecules/VerticalCombinationViews/ListRVWheelModel.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 4aefcfd3..4c449f92 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -890,8 +890,8 @@ C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */, D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */, 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, - C7F8012023E8303200396FBD /* ListRVWheel.swift */, C7F8012223E846C300396FBD /* ListRVWheelModel.swift */, + C7F8012023E8303200396FBD /* ListRVWheel.swift */, ); path = VerticalCombinationViews; sourceTree = ""; diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift index f159f1e3..fd57a04c 100644 --- a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -55,9 +55,11 @@ public class CircleProgressModel: MoleculeModelProtocol { if let style = try typeContainer.decodeIfPresent(GraphStyle.self, forKey: .style) { self.style = style } + updateStyle() if let size = try typeContainer.decodeIfPresent(GraphSize.self, forKey: .size) { self.size = size } + updateSize() if let diameter = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .diameter) { self.diameter = diameter } @@ -74,8 +76,6 @@ public class CircleProgressModel: MoleculeModelProtocol { self.colors = colors } backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - updateSize() - updateStyle() } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift index a4c5f028..ec856bb1 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift @@ -35,6 +35,6 @@ public class ListRVWheelModel:MoleculeModelProtocol { try container.encode(ListRVWheelModel.identifier, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(rightLabel, forKey: .rightLabel) - try container.encodeIfPresent(wheel, forKey: .wheel) + try container.encode(wheel, forKey: .wheel) } } From dc3178815c1cb7886fdc07281275f301e0338750 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Thu, 20 Feb 2020 14:08:47 +0530 Subject: [PATCH 18/40] Renaming of molecule file, class and model --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++++++++-------- ...istLeftVariableCheckboxAllTextAndLinks.swift} | 4 ++-- ...ftVariableCheckboxAllTextAndLinksModel.swift} | 4 ++-- .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) rename MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/{ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift => ListLeftVariableCheckboxAllTextAndLinks.swift} (93%) rename MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/{ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift => ListLeftVariableCheckboxAllTextAndLinksModel.swift} (89%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f31234f2..47d783ce 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -127,8 +127,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 */; }; + AA29DC9B23F2AA3800A52198 /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; + AA29DC9D23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.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 */; }; @@ -451,8 +451,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 = ""; }; + AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; + AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.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 = ""; }; @@ -975,8 +975,8 @@ children = ( 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, - AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift */, - AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift */, + AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxAllTextAndLinks.swift */, + AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */, ); path = LeftVariable; sourceTree = ""; @@ -1645,7 +1645,7 @@ 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, - AA29DC9D23F2ACAC00A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift in Sources */, + AA29DC9D23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, @@ -1792,7 +1792,7 @@ D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, - AA29DC9B23F2AA3800A52198 /* ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift in Sources */, + AA29DC9B23F2AA3800A52198 /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */, 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift similarity index 93% rename from MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift rename to MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index c194cc50..d68c9d1f 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -1,5 +1,5 @@ // -// ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.swift +// ListLeftVariableCheckboxAllTextAndLinks.swift // MVMCoreUI // // Created by Lekshmi S on 11/02/20. @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinks: TableViewCell { +@objcMembers public class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell { //----------------------------------------------------- // MARK: - Outlets diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift similarity index 89% rename from MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift rename to MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift index 330901a6..80ab9506 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift @@ -1,5 +1,5 @@ // -// ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.swift +// ListLeftVariableCheckboxAllTextAndLinksModel.swift // MVMCoreUI // // Created by Lekshmi S on 11/02/20. @@ -8,7 +8,7 @@ import Foundation -public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { +public class ListLeftVariableCheckboxAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "listLVCB" public var checkbox: CheckboxModel diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 049183a4..4b4ee536 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -72,7 +72,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxWithRightCaretAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) // List items MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) From 576ce2ff56150d710da0844f37de8eace8e1fd0a Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Thu, 20 Feb 2020 14:41:01 +0530 Subject: [PATCH 19/40] renamed model --- ...stLeftVariableCheckboxAllTextAndLinks.swift | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index d68c9d1f..d83e8389 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -10,18 +10,10 @@ import Foundation @objcMembers public class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell { - //----------------------------------------------------- - // MARK: - Outlets - //------------------------------------------------------- - let checkbox = Checkbox(frame: .zero) let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) let stack = Stack(frame: .zero) - - //----------------------------------------------------- - // MARK: - View Lifecycle - //------------------------------------------------------- - + open override func updateView(_ size: CGFloat) { super.updateView(size) stack.updateView(size) @@ -38,10 +30,6 @@ import Foundation containerHelper.constrainView(stack) } - //---------------------------------------------------- - // MARK: - Molecule - //------------------------------------------------------ - override open func reset() { super.reset() stack.reset() @@ -49,10 +37,10 @@ import Foundation public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let model = model as? ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel else { return} + guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return} checkbox.setWithModel(model.checkbox, delegateObject, additionalData) eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData) - + // Create a stack model to use for the internal stack and set the alignment of labels let checkbox = StackItemModel(percent: 10) checkbox.horizontalAlignment = .leading From 4803e20363d118392c263937ac8e8497d885ddf3 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Thu, 20 Feb 2020 14:52:57 +0530 Subject: [PATCH 20/40] Merge branch 'develop' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/ListLeftVar_Checkbox-_Right_Caret # Conflicts: # MVMCoreUI.xcodeproj/project.pbxproj # MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift --- MVMCoreUI.xcodeproj/project.pbxproj | 28 ++- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 8 +- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 2 + MVMCoreUI/Atoms/Buttons/Link.swift | 4 + MVMCoreUI/Atoms/Buttons/LinkModel.swift | 20 ++ .../BaseDropdownEntryFieldModel.swift | 2 +- .../Atoms/TextFields/EntryFieldModel.swift | 4 +- .../Atoms/TextFields/TextFieldModel.swift | 2 +- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 2 + MVMCoreUI/Atoms/Views/CheckboxModel.swift | 2 + .../Atoms/Views/CircleProgressModel.swift | 2 + MVMCoreUI/Atoms/Views/DashLineModel.swift | 2 + MVMCoreUI/Atoms/Views/ImageViewModel.swift | 20 +- .../Label/LabelAttributeActionModel.swift | 15 +- .../Views/Label/LabelAttributeModel.swift | 13 +- MVMCoreUI/Atoms/Views/Label/LabelModel.swift | 9 +- .../Atoms/Views/LeftRightLabelModel.swift | 5 + MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 25 ++- .../Atoms/Views/MultiProgressModel.swift | 2 + MVMCoreUI/Atoms/Views/ToggleModel.swift | 1 - MVMCoreUI/BaseClasses/Button.swift | 11 +- .../MFViewController+Model.swift | 4 - MVMCoreUI/BaseControllers/MFViewController.h | 3 + MVMCoreUI/BaseControllers/MFViewController.m | 8 +- MVMCoreUI/Categories/UIColor+Extension.swift | 177 +++++++++++++++--- MVMCoreUI/Categories/UIColor+MFConvenience.h | 1 + MVMCoreUI/Categories/UIColor+MFConvenience.m | 5 +- .../Categories/UIContentMode+Extension.swift | 98 ++++++++++ MVMCoreUI/CustomPrimitives/Color.swift | 2 +- .../MoleculeModelProtocol.swift | 2 +- .../ListRightVariablePayments.swift | 69 +++++++ .../ListRightVariablePaymentsModel.swift | 52 +++++ .../Doughnut/DoughnutChartModel.swift | 2 + .../ImageHeadlineBodyModel.swift | 1 + .../TabsModel.swift | 2 + .../TwoButtonViewModel.swift | 5 + .../Molecules/Items/CarouselItemModel.swift | 2 - .../Items/MoleculeStackItemModel.swift | 2 +- .../Molecules/Items/StackItemModel.swift | 1 + .../ActionDetailWithImageModel.swift | 1 + .../LeftRightViews/CornerLabelsModel.swift | 2 + .../HeadlineBodyLinkToggleModel.swift | 1 + .../HeadlineBodyToggleModel.swift | 1 + .../ToggleMolecules/LabelToggleModel.swift | 6 + MVMCoreUI/Molecules/ScrollerModel.swift | 1 + .../EyebrowHeadlineBodyLinkModel.swift | 2 +- .../HeadlineBodyButtonModel.swift | 1 + .../HeadlineBodyLinkModel.swift | 1 + .../HeadlineBodyModel.swift | 2 +- .../StringAndMoleculeModel.swift | 1 + MVMCoreUI/Organisms/CarouselModel.swift | 2 +- MVMCoreUI/Organisms/StackModel.swift | 1 + .../MVMCoreUIViewControllerMappingObject.m | 3 +- .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- .../Contents.json | 23 +++ .../paypal_horiz_logo.jpeg | Bin 0 -> 1826 bytes .../paypal_horiz_logo@2x.jpeg | Bin 0 -> 3418 bytes .../paypal_horiz_logo@3x.jpeg | Bin 0 -> 4606 bytes .../Templates/MoleculeListTemplate.swift | 8 +- .../Templates/MoleculeStackTemplate.swift | 8 +- MVMCoreUI/Templates/ThreeLayerTemplate.swift | 9 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 2 +- 62 files changed, 609 insertions(+), 83 deletions(-) create mode 100644 MVMCoreUI/Categories/UIContentMode+Extension.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift create mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/Contents.json create mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo.jpeg create mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@2x.jpeg create mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@3x.jpeg diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 47d783ce..281a0672 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 012A88F123985E0100FE3DA1 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88F023985E0100FE3DA1 /* Color.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; + 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */; }; 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */; }; 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72223C501E2006F3E93 /* ContainerModel.swift */; }; 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */; }; @@ -127,8 +128,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 /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; - AA29DC9D23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; }; + AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; + AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; @@ -361,6 +362,7 @@ 012A88F023985E0100FE3DA1 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; + 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIContentMode+Extension.swift"; sourceTree = ""; }; 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeContainerModel.swift; sourceTree = ""; }; 014AA72223C501E2006F3E93 /* ContainerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerModel.swift; sourceTree = ""; }; 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerModelProtocol.swift; sourceTree = ""; }; @@ -451,8 +453,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 /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; - AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = ""; }; + AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; + AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; @@ -784,6 +786,15 @@ name = "Recovered References"; sourceTree = ""; }; + AA4FC2A323F4F69600E251DB /* RightVariable */ = { + isa = PBXGroup; + children = ( + AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, + AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, + ); + path = RightVariable; + sourceTree = ""; + }; D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( @@ -965,6 +976,7 @@ D22B38EA23F4E08B00490EF6 /* List */ = { isa = PBXGroup; children = ( + AA4FC2A323F4F69600E251DB /* RightVariable */, D22B38EB23F4E0AE00490EF6 /* LeftVariable */, ); path = List; @@ -975,8 +987,6 @@ children = ( 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, - AA29DC9A23F2AA3800A52198 /* ListLeftVariableCheckboxAllTextAndLinks.swift */, - AA29DC9C23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */, ); path = LeftVariable; sourceTree = ""; @@ -1148,6 +1158,7 @@ D29DF11021E6805F003B2FB9 /* Categories */ = { isa = PBXGroup; children = ( + 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */, D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */, D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */, D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */, @@ -1619,6 +1630,7 @@ DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */, + AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */, 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, @@ -1645,7 +1657,6 @@ 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, - AA29DC9D23F2ACAC00A52198 /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, @@ -1681,6 +1692,7 @@ D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, + AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, @@ -1792,7 +1804,6 @@ D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, - AA29DC9B23F2AA3800A52198 /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */, 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, @@ -1809,6 +1820,7 @@ 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, + 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D2E2A9A323E096B1000B42E6 /* DisableableModelProtocol.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index cfe8bb2f..f02eaf5c 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -20,7 +20,6 @@ public enum ButtonSize: String, Codable { public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { public static var identifier: String = "button" - public var moleculeName: String? public var backgroundColor: Color? public var title: String public var action: ActionModelProtocol @@ -46,6 +45,12 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { self.action = action style = .secondary } + + init(primaryButtonWith title: String, action: ActionModelProtocol) { + self.title = title + self.action = action + style = .primary + } private enum CodingKeys: String, CodingKey { case moleculeName @@ -67,7 +72,6 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index defe6816..4b28fc8c 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -30,6 +30,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol { case enabledColor case disabledColor case enabled + case moleculeName } required public init(from decoder: Decoder) throws { @@ -50,6 +51,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(title, forKey: .title) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index b4c00c94..5dbbed16 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -36,6 +36,10 @@ import UIKit context?.strokePath() } + //-------------------------------------------------- + // MARK: - ModelMoleculeViewProtocol + //-------------------------------------------------- + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? LinkModel else { return } diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index f4fab34c..7094a038 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -9,7 +9,12 @@ import UIKit public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "link" + public var backgroundColor: Color? public var title: String public var action: ActionModelProtocol @@ -17,12 +22,21 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { public var textColor = Color(uiColor: .mvmBlack) public var disabledColor = Color(uiColor: .mvmCoolGray6) + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(title: String, action: ActionModelProtocol) { self.title = title self.action = action } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case title case action @@ -31,11 +45,16 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { case disabledColor } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { self.enabled = enabled } @@ -51,6 +70,7 @@ public class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(title, forKey: .title) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) try container.encode(enabled, forKey: .enabled) diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift index e6e7cb24..496625dc 100644 --- a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift @@ -37,9 +37,9 @@ } public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(caretView, forKey: .caretView) } } diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift index 5f60081e..e4a794bc 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -19,7 +19,6 @@ import Foundation } public var backgroundColor: Color? - public var moleculeName: String? public var title: String? public var feedback: String? public var errorMessage: String = "" @@ -37,7 +36,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor - case title + case title = "label" case isEnabled case feedback case errorMessage = "errorMsg" @@ -54,7 +53,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decodeIfPresent(String.self, forKey: .title) feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback) diff --git a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift index 6caa70b0..e26995d6 100644 --- a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift @@ -12,7 +12,7 @@ import UIKit public static var identifier: String = "textField" public var backgroundColor: Color? - public var moleculeName: String + public var moleculeName: String? = TextFieldModel.identifier public var editable: Bool? public var disabled: Bool? public var errorMsg: String? diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index 58291984..cf90496f 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -18,6 +18,7 @@ import Foundation public var lineWidth: CGFloat? private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case strokeColor case isHidden @@ -38,6 +39,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(strokeColor, forKey: .strokeColor) try container.encodeIfPresent(isHidden, forKey: .isHidden) try container.encodeIfPresent(isOpaque, forKey: .isOpaque) diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index aa5dedb4..de79c6c6 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -39,6 +39,7 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case groupName case value case fieldKey @@ -85,6 +86,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(groupName, forKey: .groupName) try container.encodeIfPresent(value, forKey: .value) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift index c4f55bef..9a1908f8 100644 --- a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -48,6 +48,7 @@ public class CircleProgressModel: MoleculeModelProtocol { case duration case colors case backgroundColor + case moleculeName } required public init(from decoder: Decoder) throws { @@ -78,6 +79,7 @@ public class CircleProgressModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(style, forKey: .style) try container.encode(size, forKey: .size) try container.encode(diameter, forKey: .diameter) diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 1346b5c2..7f5ac992 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -20,6 +20,7 @@ import Foundation } private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case dashColor case isHidden @@ -36,6 +37,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(dashColor, forKey: .dashColor) try container.encodeIfPresent(isHidden, forKey: .isHidden) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index ce46a930..0f585119 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,11 +11,29 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeModelProtocol { public static var identifier: String = "image" public var backgroundColor: Color? - + public var moleculeName: String? = ImageViewModel.identifier public var image: String public var accessibilityText: String? public var fallbackImage: String? public var imageFormat: String? public var width: CGFloat? public var height: CGFloat? + public var contentMode: UIView.ContentMode? + public var localBundle: Bundle? + + public init(image: String) { + self.image = image + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case image + case accessibilityText + case fallbackImage + case imageFormat + case width + case height + case contentMode + } } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift index 2ebcb4b4..503f00d8 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift @@ -8,12 +8,21 @@ import UIKit -class LabelAttributeActionModel: LabelAttributeModel { +open class LabelAttributeActionModel: LabelAttributeModel { override public class var identifier: String { return "action" } var action: ActionModelProtocol + public init(_ location: Int, _ length: Int, action: ActionModelProtocol) { + self.action = action + super.init(location, length) + } + + private enum CodingKeys: String, CodingKey { + case action + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) @@ -25,8 +34,4 @@ class LabelAttributeActionModel: LabelAttributeModel { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModel(action, forKey: .action) } - - private enum CodingKeys: String, CodingKey { - case action - } } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift index 22bb10d8..437ec0cc 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift @@ -25,10 +25,18 @@ import Foundation return "" } - var type: String + var type: String { + get { return Self.identifier } + } + var location: Int var length: Int - + + init(_ location: Int, _ length: Int) { + self.location = location + self.length = length + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -45,7 +53,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - type = try typeContainer.decode(String.self, forKey: .type) location = try typeContainer.decode(Int.self, forKey: .location) length = try typeContainer.decode(Int.self, forKey: .length) } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index 731b23da..d7fb4fa3 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -11,9 +11,7 @@ import Foundation @objcMembers public class LabelModel: MoleculeModelProtocol { public static var identifier: String = "label" - public var moleculeName: String? public var backgroundColor: Color? - public var text: String public var accessibilityText: String? public var textColor: String? @@ -45,10 +43,13 @@ import Foundation enum AttributeTypeKey: String, CodingKey { case type } - + + public init(text: String) { + self.text = text + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) text = try typeContainer.decode(String.self, forKey: .text) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index 325611ec..d7ee1553 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -10,7 +10,12 @@ import UIKit @objcMembers public class LeftRightLabelModel: MoleculeModelProtocol { public static var identifier: String = "leftRightLabelView" + public var moleculeName: String? = LeftRightLabelModel.identifier public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel? + + init(_ leftText: LabelModel) { + self.leftText = leftText + } } diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 1c54b891..0079d1a6 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -210,6 +210,9 @@ import UIKit } public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + self.delegateObject = delegateObject + // TODO: Temporary, should be moved to init once we have type erasure ready. + setAsMolecule() guard let imageModel = model as? ImageViewModel else { return } @@ -230,7 +233,11 @@ import UIKit if shouldLoadImage(withName: imageModel.image, width: width, height: height) { imageView.image = nil imageView.animatedImage = nil - loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage) + loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage, localBundle: imageModel.localBundle) + } + + if let contentMode = imageModel.contentMode { + imageView.contentMode = contentMode } } @@ -269,7 +276,9 @@ import UIKit } // MARK: - load functions - public func loadImage(withName imageName: String?, format: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?, completionHandler: @escaping MVMCoreGetImageBlock) { + public func loadImage(withName imageName: String?, format: String? = nil, width: NSNumber? = nil, height: NSNumber? = nil, customFallbackImage: String? = nil, allowServerParameters: Bool = false, localBundle: Bundle? = nil, completionHandler: MVMCoreGetImageBlock? = nil) { + + let completionBlock = completionHandler ?? defaultCompletionBlock() MVMCoreDispatchUtility.performBlock(onMainThread: { [unowned self] in self.currentImageName = imageName self.currentImageWidth = width?.cgfloat() @@ -291,15 +300,15 @@ import UIKit if layoutWillChange { self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self!) } - completionHandler(image,data,isFallbackImage) + completionBlock(image,data,isFallbackImage) })} let fallbackImageName = customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback") if let format = format, format.lowercased().contains("gif") { // Gifs aren't supported by default and need special handling - MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, completionHandler: finishedLoadingBlock) + MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, completionHandler: finishedLoadingBlock) } else { - MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, completionHandler: finishedLoadingBlock) + MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock) } }) } @@ -329,6 +338,8 @@ import UIKit }) } + // Note: Exposed for objective-c interfaces. + public func loadImage(withName imageName: String?) { loadImage(withName: imageName, format: nil, width: nil, height: nil, customFallbackImage: nil, completionHandler: defaultCompletionBlock()) } @@ -364,4 +375,8 @@ import UIKit 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()) } + + public func loadImage(withName imageName: String?, format: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?, completionHandler: @escaping MVMCoreGetImageBlock) { + loadImage(withName: imageName, format: format, width: width, height: height, customFallbackImage: customFallbackImage, allowServerParameters: false, completionHandler: completionHandler) + } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 6dd05b0b..4033fd28 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -26,6 +26,7 @@ import Foundation public var roundedRect: Bool? private enum CodingKeys: String, CodingKey { + case moleculeName case progressList case thickness case roundedRect @@ -46,6 +47,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(progressList, forKey: .progressList) try container.encodeIfPresent(thickness, forKey: .thickness) try container.encodeIfPresent(roundedRect, forKey: .roundedRect) diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 9cd96f45..aafacec8 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -10,7 +10,6 @@ import UIKit public class ToggleModel: MoleculeModelProtocol { public static var identifier: String = "toggle" - public var moleculeName: String? public var backgroundColor: Color? public var state: Bool = true public var action: ActionModelProtocol? diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index a780151a..c0ff0e81 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -12,6 +12,7 @@ public typealias ButtonAction = (Button) -> () //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var model: MoleculeModelProtocol? open var actionModel: ActionModelProtocol? @@ -67,7 +68,7 @@ public typealias ButtonAction = (Button) -> () addTarget(self, action: #selector(callActionBlock(_:)), for: event) } - @objc private func callActionBlock(_ sender: Button) { + @objc func callActionBlock(_ sender: Button) { buttonAction?(self) } @@ -88,11 +89,13 @@ public typealias ButtonAction = (Button) -> () // MARK:- ModelMoleculeViewProtocol open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model + if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor } - + guard let model = model as? ButtonModelProtocol else { return } + isEnabled = model.enabled set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } @@ -113,7 +116,7 @@ public typealias ButtonAction = (Button) -> () // MARK: - MVMCoreViewProtocol extension Button: MVMCoreViewProtocol { - open func updateView(_ size: CGFloat) {} + open func updateView(_ size: CGFloat) { } /// Will be called only once. open func setupView() { @@ -126,6 +129,7 @@ extension Button: MVMCoreViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol extension Button: MVMCoreUIMoleculeViewProtocol { + open func reset() { backgroundColor = .clear } @@ -133,6 +137,7 @@ extension Button: MVMCoreUIMoleculeViewProtocol { // MARK: AppleGuidelinesProtocol extension Button: AppleGuidelinesProtocol { + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { return Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 1ddbd4ab..e70e68f6 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -37,7 +37,3 @@ extension MFViewController: MoleculeDelegateProtocol { @objc public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { } } - -public extension MFViewController { - @objc func parsePageJSON() throws { } -} diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/BaseControllers/MFViewController.h index cd96a07f..38ced354 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.h +++ b/MVMCoreUI/BaseControllers/MFViewController.h @@ -96,6 +96,9 @@ // This view controller should subclass this function and check the load to make sure it has all the needed data. Fills the error object if there are any errors. Returns if we should finish the load or not. - (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error; +/// Called in newDataBuildScreen. Can override to parse the json into a model object. +- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error; + // Sets the screen to use the screen heading. // it is required in device flow, where we are showing greeting name as screen heading, // device details screen heading needs to be updated/refreshed again, if user has changed device nick name diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 09700268..f663193f 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -98,7 +98,7 @@ self.loadObject = loadObject; NSError *parseError = nil; - [self parsePageJSONAndReturnError:&parseError]; + [self parsePageJSON:&parseError]; if (parseError) { if (error) { MVMCoreErrorObject *errorObject = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]; @@ -112,6 +112,10 @@ return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error]; } +- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error { + +} + // Sets the screen to use the screen heading. // it is required in device flow, where we are showing greeting name as screen heading, // device details screen heading needs to be updated/refreshed again, if user has changed device nick name @@ -261,7 +265,7 @@ - (BOOL)newPageLoaded:(nonnull NSDictionary *)page { self.loadObject.pageJSON = page; NSError *parseError = nil; - [self parsePageJSONAndReturnError:&parseError]; + [self parsePageJSON:&parseError]; return YES; } diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 55a10c03..94bf780d 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -12,24 +12,52 @@ public typealias ColorHexTuple = (uiColor: UIColor, hex: String) extension UIColor { + //-------------------------------------------------- + // MARK: - Convenience Dictionary + //-------------------------------------------------- /// Dictionary to access brand approved colors by name. public static let names: [String: ColorHexTuple] = ["black": (.mvmBlack, "#000000"), "white": (.mvmWhite, "#FFFFFF"), "red": (.mvmRed, "#D52B1E"), - "orange": (.mvmOrange, "#CC4D0F"), - "green": (.mvmGreen, "#008631"), - "blue": (.mvmBlue, "#007AB8"), - "blueGradient": (.mvmBlueGradient, "#007AB8"), + "pink": (.mvmPink, "#D90368"), + "pink33": (.mvmPink33, "#F2ABCD"), + "pink66": (.mvmPink66, "#E6589B"), + "pinkShade1": (.mvmPinkShade1, "#B31C63"), + "pinkShade2": (.mvmPinkShade2, "#830842"), + "purple": (.mvmPurple, "#8C00AC"), + "purple33": (.mvmPurple33, "#D9ABE4"), + "purple66": (.mvmPurple66, "#B356C8"), + "purpleShade1": (.mvmPurpleShade1, "#6C177F"), + "purpleShade2": (.mvmPurpleShade2, "#4A0E58"), + "green": (.mvmGreen, "#008330"), + "green33": (.mvmGreen33, "#ABE4BF"), + "green66": (.mvmGreen66, "#57C880"), + "greenShade1": (.mvmGreenShade1, "#178437"), + "greenShade2": (.mvmGreenShade2, "#0F5B25"), + "orange": (.mvmOrange, "#ED7000"), + "orange66": (.mvmOrange66, "#F3A157"), + "orange33": (.mvmOrange33, "#F9D0AB"), + "orangeShade1": (.mvmOrangeShade1, "#CB5F00"), + "orangeShade2": (.mvmOrangeShade2, "#984700"), + "orangeAA": (.mvmOrangeAA, "#CC4D0F"), + "blue": (.mvmBlue, "#0077B4"), + "blue33": (.mvmBlue33, "#57B1DF"), + "blue66": (.mvmBlue66, "#57B1DF"), + "blueShade1": (.mvmBlueShade1, "#136598"), + "blueShade2": (.mvmBlueShade2, "#0B4467"), "yellow": (.mvmYellow, "#FFBC3D"), + "yellow33": (.mvmYellow33, "#FFE9BF"), + "yellow66": (.mvmYellow66, "#FFD37F"), + "yellowShade1": (.mvmYellowShade1, "#CC9630"), + "yellowShade2": (.mvmYellowShade2, "#997126"), "coolGray1": (.mvmCoolGray1, "#F6F6F6"), "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), "coolGray10": (.mvmCoolGray10, "#333333"), - "vzupGold": (.vzupGold, "#B89B56"), - "vzupYellow1": (.vzupYellow1, "#F9D542"), - "vzupYellow2": (.vzupYellow2, "#F4CA53"), - "vzupYellow3": (.vzupYellow3, "#CC9B2D")] + "upGold1": (.vzupGold1, "#F9D542"), + "upGold2": (.vzupGold2, "#F4CA53"), + "upGold3": (.vzupGold3, "#CC9B2D")] //-------------------------------------------------- // MARK: - Brand @@ -41,24 +69,134 @@ extension UIColor { /// HEX: #FFFFFF public static let mvmWhite = UIColor.white + //-------------------------------------------------- + // MARK: - Red + //-------------------------------------------------- + /// HEX: #D52B1E public static let mvmRed = UIColor.color8Bits(red: 213, green: 43, blue: 30) + //-------------------------------------------------- + // MARK: - Pink + //-------------------------------------------------- + + /// HEX: #D90368 + public static let mvmPink = UIColor.color8Bits(red: 217, green: 3, blue: 104) + + /// HEX: #F2ABCD + public static let mvmPink33 = UIColor.color8Bits(red: 242, green: 171, blue: 205) + + /// HEX: #E6589B + public static let mvmPink66 = UIColor.color8Bits(red: 230, green: 88, blue: 155) + + /// HEX: #B31C63 + public static let mvmPinkShade1 = UIColor.color8Bits(red: 179, green: 28, blue: 99) + + /// HEX: #830842 + public static let mvmPinkShade2 = UIColor.color8Bits(red: 131, green: 8, blue: 66) + + //-------------------------------------------------- + // MARK: - Purple + //-------------------------------------------------- + + /// HEX: #8C00AC + public static let mvmPurple = UIColor.color8Bits(red: 140, green: 0, blue: 172) + + /// HEX: #D9ABE4 + public static let mvmPurple33 = UIColor.color8Bits(red: 217, green: 171, blue: 228) + + /// HEX: #B356C8 + public static let mvmPurple66 = UIColor.color8Bits(red: 179, green: 86, blue: 200) + + /// HEX: #6C177F + public static let mvmPurpleShade1 = UIColor.color8Bits(red: 108, green: 23, blue: 127) + + /// HEX: #4A0E58 + public static let mvmPurpleShade2 = UIColor.color8Bits(red: 74, green: 14, blue: 88) + + //-------------------------------------------------- + // MARK: - Orange + //-------------------------------------------------- + + /// HEX: #ED7000 + public static let mvmOrange = UIColor.color8Bits(red: 237, green: 112, blue: 0) + /// HEX: #CC4D0F - public static let mvmOrange = UIColor.color8Bits(red: 204, green: 77, blue: 15) + public static let mvmOrangeAA = UIColor.color8Bits(red: 204, green: 77, blue: 15) - /// HEX: #008631 - public static let mvmGreen = UIColor.color8Bits(red: 0, green: 134, blue: 49) + /// HEX: #F9D0AB + public static let mvmOrange33 = UIColor.color8Bits(red: 249, green: 208, blue: 171) - /// HEX: #007AB8 - public static let mvmBlue = UIColor.color8Bits(red: 0, green: 122, blue: 184) + /// HEX: #F3A157 + public static let mvmOrange66 = UIColor.color8Bits(red: 243, green: 161, blue: 87) - /// HEX: #007AB8 - public static let mvmBlueGradient = UIColor.color8Bits(red: 0, green: 122, blue: 184) + /// HEX: #CB5F00 + public static let mvmOrangeShade1 = UIColor.color8Bits(red: 203, green: 95, blue: 0) + + /// HEX: #984700 + public static let mvmOrangeShade2 = UIColor.color8Bits(red: 152, green: 71, blue: 0) + + //-------------------------------------------------- + // MARK: - Green + //-------------------------------------------------- + + /// HEX: #008330 + public static let mvmGreen = UIColor.color8Bits(red: 0, green: 134, blue: 48) + + /// HEX: #ABE4BF + public static let mvmGreen33 = UIColor.color8Bits(red: 171, green: 228, blue: 191) + + /// HEX: #57C880 + public static let mvmGreen66 = UIColor.color8Bits(red: 87, green: 200, blue: 128) + + /// HEX: #178437 + public static let mvmGreenShade1 = UIColor.color8Bits(red: 23, green: 132, blue: 55) + + /// HEX: #0F5B25 + public static let mvmGreenShade2 = UIColor.color8Bits(red: 15, green: 91, blue: 37) + + //-------------------------------------------------- + // MARK: - Blue + //-------------------------------------------------- + + /// HEX: #0077B4 + public static let mvmBlue = UIColor.color8Bits(red: 0, green: 119, blue: 180) + + /// HEX: #57B1DF + public static let mvmBlue33 = UIColor.color8Bits(red: 87, green: 177, blue: 223) + + /// HEX: #57B1DF + public static let mvmBlue66 = UIColor.color8Bits(red: 87, green: 177, blue: 223) + + /// HEX: #136598 + public static let mvmBlueShade1 = UIColor.color8Bits(red: 19, green: 101, blue: 152) + + /// HEX: #0B4467 + public static let mvmBlueShade2 = UIColor.color8Bits(red: 11, green: 68, blue: 103) + + //-------------------------------------------------- + // MARK: - Yellow + //-------------------------------------------------- /// HEX: #FFBC3D public static let mvmYellow = UIColor.color8Bits(red: 255, green: 188, blue: 61) + /// HEX: #FFE9BF + public static let mvmYellow33 = UIColor.color8Bits(red: 255, green: 233, blue: 191) + + /// HEX: #FFD37F + public static let mvmYellow66 = UIColor.color8Bits(red: 255, green: 211, blue: 127) + + /// HEX: #CC9630 + public static let mvmYellowShade1 = UIColor.color8Bits(red: 204, green: 150, blue: 48) + + /// HEX: #997126 + public static let mvmYellowShade2 = UIColor.color8Bits(red: 153, green: 113, blue: 38) + + //-------------------------------------------------- + // MARK: - Gray + //-------------------------------------------------- + /// HEX: #F6F6F6 public static let mvmCoolGray1 = UIColor.grayscale(rgb: 246) @@ -75,17 +213,14 @@ extension UIColor { // MARK: - VZ UP Brand //-------------------------------------------------- - /// HEX: #B89B56 - public static let vzupGold = UIColor.color8Bits(red: 184, green: 155, blue: 68) - /// HEX: #F9D542 - public static let vzupYellow1 = UIColor.color8Bits(red: 249, green: 213, blue: 66) + public static let vzupGold1 = UIColor.color8Bits(red: 249, green: 213, blue: 66) /// HEX: #F4CA53 - public static let vzupYellow2 = UIColor.color8Bits(red: 244, green: 202, blue: 83) + public static let vzupGold2 = UIColor.color8Bits(red: 244, green: 202, blue: 83) /// HEX: #CC9B2D - public static let vzupYellow3 = UIColor.color8Bits(red: 204, green: 155, blue: 45) + public static let vzupGold3 = UIColor.color8Bits(red: 204, green: 155, blue: 45) //-------------------------------------------------- // MARK: - Functions diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index 4a51a13b..c3c78c7a 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -21,6 +21,7 @@ + (nonnull UIColor *)mfLightSilver; + (nonnull UIColor *)mfDarkSilver; + (nonnull UIColor *)mfTomatoRed; ++ (nonnull UIColor *)mvmOrange; + (nonnull UIColor *)mfPumpkinColor; + (nonnull UIColor *)mfShamrock; + (nonnull UIColor *)mfCerulean; diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index e56d89bc..6ff8f70f 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -37,7 +37,6 @@ return [UIColor mfColor8bitsWithRed:198 green:197 blue:197 alpha:1.0]; } - + (nonnull UIColor *)mfPrimaryButtonHighlightBlackColor { return [UIColor mfColor8bitsWithRed:51 green:51 blue:51 alpha:1.0]; } @@ -54,6 +53,10 @@ return [UIColor mfColor8bitsWithRed:204 green:77 blue:15 alpha:1.0]; } ++ (nonnull UIColor *)mvmOrange { + return [UIColor mfColor8bitsWithRed:237 green:112 blue:0 alpha:1.0]; +} + + (nonnull UIColor *)mfShamrock { return [UIColor mfColor8bitsWithRed:0 green:134 blue:49 alpha:1.0]; } diff --git a/MVMCoreUI/Categories/UIContentMode+Extension.swift b/MVMCoreUI/Categories/UIContentMode+Extension.swift new file mode 100644 index 00000000..19cf523b --- /dev/null +++ b/MVMCoreUI/Categories/UIContentMode+Extension.swift @@ -0,0 +1,98 @@ +// +// UIContentMode+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 2/17/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +enum ContentModeError: Error { + case notAContentMode +} + +extension UIView.ContentMode: RawRepresentable { + + init?(rawValue: String) { + switch rawValue { + case "scaleToFill": + self = .scaleToFill + case "scaleAspectFit": + self = .scaleAspectFit + case "scaleAspectFill": + self = .scaleAspectFill + case "redraw": + self = .redraw + case "center": + self = .center + case "top": + self = .top + case "bottom": + self = .bottom + case "left": + self = .left + case "right": + self = .right + case "topLeft": + self = .topLeft + case "topRight": + self = .topRight + case "bottomLeft": + self = .bottomLeft + case "bottomRight": + self = .bottomRight + default: + return nil + } + } + + var rawValueString: String { + switch self { + case .scaleToFill: + return "scaleToFill" + case .scaleAspectFit: + return "scaleAspectFit" + case .scaleAspectFill: + return "scaleAspectFill" + case .redraw: + return "redraw" + case .center: + return "center" + case .top: + return "top" + case .bottom: + return "bottom" + case .left: + return "left" + case .right: + return "right" + case .topLeft: + return "topLeft" + case .topRight: + return "topRight" + case .bottomLeft: + return "bottomLeft" + case .bottomRight: + return "bottomRight" + @unknown default: + return "" + } + } +} + +extension UIView.ContentMode: Codable { + public init(from decoder: Decoder) throws { + let typeContainer = try decoder.singleValueContainer() + let string = try typeContainer.decode(String.self) + guard let mode = UIView.ContentMode(rawValue: string) else { + throw ContentModeError.notAContentMode + } + self = mode + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(rawValueString) + } +} diff --git a/MVMCoreUI/CustomPrimitives/Color.swift b/MVMCoreUI/CustomPrimitives/Color.swift index a34fbd45..165fa8ad 100644 --- a/MVMCoreUI/CustomPrimitives/Color.swift +++ b/MVMCoreUI/CustomPrimitives/Color.swift @@ -49,7 +49,7 @@ public final class Color: Codable { // MARK: - Class Initializers //-------------------------------------------------- - init(uiColor: UIColor) { + public init(uiColor: UIColor) { self.uiColor = uiColor hex = UIColor.hexString(for: uiColor) ?? "" determineRGBA() diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift index 1ec0d13c..cec7b90a 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift @@ -3,7 +3,7 @@ import Foundation public protocol MoleculeModelProtocol: Model { var moleculeName: String? { get } - var backgroundColor: Color? { get set} + var backgroundColor: Color? { get set } } public extension MoleculeModelProtocol { diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift new file mode 100644 index 00000000..2bfbc321 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift @@ -0,0 +1,69 @@ +// +// ListRightVariablePayments.swift +// MVMCoreUI +// +// Created by Lekshmi S on 10/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ListRightVariablePayments: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + + let leftLabel = Label.commonLabelB1(true) + let rightImage = MFLoadImageView(pinnedEdges: .all) + let stack = Stack(frame: .zero) + + //----------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + stack.updateView(size) + } + + override open func setupView() { + super.setupView() + guard leftLabel.superview == nil else { + return + } + stack.translatesAutoresizingMaskIntoConstraints = false + stack.stackItems = [StackItem(andContain: leftLabel),StackItem(andContain: rightImage)] + contentView.addSubview(stack) + containerHelper.constrainView(stack) + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + override open func reset() { + super.reset() + stack.reset() + } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? ListRightVariablePaymentsModel else { return } + leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) + rightImage.setWithModel(model.image, delegateObject, additionalData) + + // Create a stack model to use for the internal stack and set the alignment of label and image + let leftLabel = StackItemModel() + leftLabel.horizontalAlignment = .leading + let rightImage = StackItemModel() + rightImage.horizontalAlignment = .fill + let stackModel = StackModel(molecules: [leftLabel,rightImage]) + stackModel.axis = .horizontal + stack.model = stackModel + stack.restack() + } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 65 + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift new file mode 100644 index 00000000..a8c6ff80 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift @@ -0,0 +1,52 @@ +// +// ListRightVariablePaymentsModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 10/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListRightVariablePaymentsModel: ListItemModel, MoleculeModelProtocol { + + public static var identifier: String = "listRVImg" + public var image: ImageViewModel + public var leftLabel: LabelModel + + public init(image: ImageViewModel, leftLabel: LabelModel) { + self.leftLabel = leftLabel + self.image = image + super.init() + } + + static func createPayPalImage() -> ImageViewModel { + let image = ImageViewModel(image: "imageName_PayPal_logo") + image.localBundle = MVMCoreUIUtility.bundleForMVMCoreUI() + image.width = 70.0 + image.height = 18.0 + image.contentMode = .scaleAspectFit + return image + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + 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) + image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image) ?? ListRightVariablePaymentsModel.createPayPalImage() + 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(leftLabel, forKey: .leftLabel) + try container.encode(image, forKey: .image) + } +} diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift index 42acd2f0..1e5c7dce 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift @@ -11,6 +11,7 @@ import Foundation @objcMembers public class DoughnutChartModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChart" + public var moleculeName: String? = DoughnutChartModel.identifier public var title: LabelModel? public var subtitle: LabelModel? public var sections: [DoughnutChartItemModel] @@ -24,6 +25,7 @@ import Foundation @objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChartItem" + public var moleculeName: String? = DoughnutChartItemModel.identifier public var label: LabelModel @Percent public var percent: CGFloat public var color: Color diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift index 4966ce58..7f3d52dc 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift @@ -10,6 +10,7 @@ import Foundation public struct ImageHeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "imageHeadlineBody" + public var moleculeName: String? = ImageHeadlineBodyModel.identifier public var backgroundColor: Color? public var image: ImageViewModel public var headlineBody: HeadlineBodyModel diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift index f45c771d..8b69c590 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -22,6 +22,7 @@ public class TabsModel: MoleculeModelProtocol { case backgroundColor case selectedColor case selectedIndex + case moleculeName } public init(with tabs: [LabelModel]) { @@ -42,6 +43,7 @@ public class TabsModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) try container.encode(backgroundColor, forKey: .backgroundColor) try container.encode(selectedColor, forKey: .selectedColor) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 5938692b..057203e9 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -21,6 +21,11 @@ public class TwoButtonViewModel: MoleculeModelProtocol { case secondaryButton } + public init(_ primaryButton: ButtonModel?, _ secondaryButton: ButtonModel?) { + self.primaryButton = primaryButton + self.secondaryButton = secondaryButton + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) diff --git a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift index f2c88e9b..9fc218a7 100644 --- a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift @@ -14,7 +14,6 @@ import Foundation public var backgroundColor: Color? public var peakingUI: Bool? public var peakingArrowColor: Color? - public var moleculeName: String? private enum CodingKeys: String, CodingKey { case moleculeName @@ -25,7 +24,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI) peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor) diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift index 4731ef34..dc01fd11 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift @@ -25,7 +25,7 @@ import Foundation public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) } - + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index 2058353c..b7d1a269 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -10,6 +10,7 @@ import Foundation @objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol { public static var identifier: String = "simpleStackItem" + public var moleculeName: String? = StackItemModel.identifier public var backgroundColor: Color? public var spacing: CGFloat? public var percent: Int? diff --git a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift index a397c1a1..9dbf53c0 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift @@ -10,6 +10,7 @@ import Foundation public struct ActionDetailWithImageModel: MoleculeModelProtocol { public static var identifier: String = "actionDetailWithImage" + public var moleculeName: String? = ActionDetailWithImageModel.identifier public var backgroundColor: Color? public var headlineBodyButton: HeadlineBodyButtonModel public var image: ImageViewModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift index f4b67216..bb3e6f17 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -28,6 +28,7 @@ public class CornerLabelsModel: MoleculeModelProtocol { case bottomLeftLabel case bottomRightLabel case molecule + case moleculeName } required public init(from decoder: Decoder) throws { @@ -48,5 +49,6 @@ public class CornerLabelsModel: MoleculeModelProtocol { try container.encodeIfPresent(topRightLabel, forKey: .topRightLabel) try container.encodeIfPresent(bottomLeftLabel, forKey: .bottomLeftLabel) try container.encodeIfPresent(bottomRightLabel, forKey: .bottomRightLabel) + try container.encode(moleculeName, forKey: .moleculeName) } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift index 5ce04f9c..aad8ec06 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift @@ -9,6 +9,7 @@ import Foundation public struct HeadlineBodyLinkToggleModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyLinkToggle" + public var moleculeName: String? = HeadlineBodyLinkToggleModel.identifier public var backgroundColor: Color? public var headlineBodyLink: HeadlineBodyLinkModel public var toggle: ToggleModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift index dd7c2b1c..bb3391a6 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift @@ -11,6 +11,7 @@ import Foundation open class HeadlineBodyToggleModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyToggle" + public var moleculeName: String? = HeadlineBodyToggleModel.identifier open var backgroundColor: Color? open var headlineBody: HeadlineBodyModel open var toggle: ToggleModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift index 7ed5857e..526ac6b9 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift @@ -10,7 +10,13 @@ import Foundation public class LabelToggleModel: MoleculeModelProtocol { public static var identifier: String = "labelToggle" + public var moleculeName: String? = LabelToggleModel.identifier public var backgroundColor: Color? public var label: LabelModel public var toggle: ToggleModel + + init(_ label: LabelModel, _ toggle: ToggleModel) { + self.label = label + self.toggle = toggle + } } diff --git a/MVMCoreUI/Molecules/ScrollerModel.swift b/MVMCoreUI/Molecules/ScrollerModel.swift index f92fe13b..91dc2e1c 100644 --- a/MVMCoreUI/Molecules/ScrollerModel.swift +++ b/MVMCoreUI/Molecules/ScrollerModel.swift @@ -10,5 +10,6 @@ import UIKit public class ScrollerModel: MoleculeContainerModel, MoleculeModelProtocol { public static var identifier: String = "scroller" + public var moleculeName: String? = ScrollerModel.identifier public var backgroundColor: Color? } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index e9341535..81a38111 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -11,7 +11,7 @@ import Foundation struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { static var identifier: String = "eyebrowHeadlineBodyLink" var backgroundColor: Color? - + var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier public var eyeBrow: LabelModel? public var headline: LabelModel? public var body: LabelModel? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift index 74e85ea9..ec97fda0 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift @@ -10,6 +10,7 @@ import Foundation public struct HeadlineBodyButtonModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyButton" + public var moleculeName: String? = HeadlineBodyButtonModel.identifier public var backgroundColor: Color? public var headlineBody: HeadlineBodyModel diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift index 9eae8e03..27f0d670 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift @@ -10,6 +10,7 @@ import Foundation public struct HeadlineBodyLinkModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyLink" + public var moleculeName: String? = HeadlineBodyLinkModel.identifier public var headlineBody: HeadlineBodyModel public var link: LinkModel public var backgroundColor: Color? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 1fbe98e7..d7a08091 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "headlineBody" - public var moleculeName: String? + public var moleculeName: String? = HeadlineBodyModel.identifier public var headline: LabelModel? public var body: LabelModel? public var style: String? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index caa00021..c66f27b8 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -38,5 +38,6 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(string, forKey: .string) try container.encodeModel(molecule, forKey: .molecule) + try container.encode(moleculeName, forKey: .moleculeName) } } diff --git a/MVMCoreUI/Organisms/CarouselModel.swift b/MVMCoreUI/Organisms/CarouselModel.swift index e43e6caa..79693135 100644 --- a/MVMCoreUI/Organisms/CarouselModel.swift +++ b/MVMCoreUI/Organisms/CarouselModel.swift @@ -53,7 +53,7 @@ import UIKit public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(molecules, forKey: .molecules) try container.encode(spacing, forKey: .spacing) diff --git a/MVMCoreUI/Organisms/StackModel.swift b/MVMCoreUI/Organisms/StackModel.swift index 741946c5..8d670efb 100644 --- a/MVMCoreUI/Organisms/StackModel.swift +++ b/MVMCoreUI/Organisms/StackModel.swift @@ -45,5 +45,6 @@ import Foundation try container.encodeIfPresent(molecules, forKey: .molecules) try container.encodeIfPresent(axis.rawValueString, forKey: .axis) try container.encodeIfPresent(spacing, forKey: .spacing) + try container.encode(moleculeName, forKey: .moleculeName) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index 7bdccc8e..5b9592cc 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -22,8 +22,7 @@ @"stack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], @"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]], @"list" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], - @"threeLayer" : - [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]] + @"threeLayer" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]] } mutableCopy]; }); return viewControllerMapping; diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 4b4ee536..ac7375d7 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -72,7 +72,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) // List items MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/Contents.json b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/Contents.json new file mode 100644 index 00000000..b4c381b8 --- /dev/null +++ b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "paypal_horiz_logo.jpeg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "paypal_horiz_logo@2x.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "paypal_horiz_logo@3x.jpeg", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo.jpeg b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..95113ebf4001cf2eed20fbe23530dea3d1e475a9 GIT binary patch literal 1826 zcmbV~c~H|=5XavyccK+YASOX2fIxx}6+uL;C=@WEP`QK#QSkr*#0U}&Emf#omFRG4 z5#^|uR)->#OF#vQ9HJruLZDa@5DX9vAc#jN{e?Pqrhm2Foq7A6dAs}GXWvuztA~L$ z$C>R6AP9h+umiOWq&vm(f&g%H1Lgn#96&=vfP@tUJAh~ay{G};K>DAwC&c)eg8(3f z2T&h#xNy`M+*wooF(M10zdIHpK4m)>B0p)OrcA8_n|6f=q6Ei61V`x`SnI$h2eunZ z(;c=&ZL%n}dse1P&w&b*;uQYE)Plpe>PDc014Q7AgmeHx2SVyVY6&oaZ-IsuZLthq zAOsSH#$a)H!V);4N*f>`Bocu_qS2aTpm=y6pmfkg!}U8bB#%I>QG~8lLPinJ*rB{h z&$COldc%RpL_C4KoI<6Un3^$|=GHbFZ8zC%cKpK0*<~l2!8qv>oLR~9@xMLl95#cPS+u$sJsbpyunkYcObHhKwfPvGnv+)Et35^ zu*CmG_6h87u0h}kF!1A`Q5X#TL|6=tpiLm)@dVvvT1&N;>ryDob;)GfN)rQ`zVQk& znQlQhHZ^0KGpPoa>ns`TOc+dt8g2q%u~-6*Kq3%G3>uln_|K*ug1;qRJph&>A^0;P zb$~q>-?lN#*VmrZ;Bc_+reEPD%Zvk;9)ohzSgb*8Rs1sY`XpSvKrxgr6kZI zZ*J>8p*SF5pW8tp&WRnw^R!E_(0br*Rg|(ys`MM-o#41fup`x=nKYNgxx(yFzPQa% z1C>_XLYDlw$~W16_j~HCV_SDCKvrOM%#uFrRkmWFq2Y4_!8X^ylZ{jPH+{O&WNTC3 zY!;_qRkhraOOHHp(KiDn zL-hzeiX%?wyAwM4JYK}w*|*Dry~d4_rqb(3U-7!B_`x#bd--P%>nAdsi`pZ^ygtmc zu$)?t#AVwQ)G|+M_~Euot{jfSPc;!tJoB>&yLN}PzN}4YDO}@!CM>R@=Uk`guy-_6 zopCv5?0$anKy_<5p*-8W?Do}dV)-$?99LQI>Qfh7W$PrV1xE;2$NcfqsP4P7p29=Q z(zDzP&$tt(eTK>w`qhue>0KWz1@3VNmfBgqNZVlUe-QE|9TT92XuK&2+Jy#>&3Q+n4;yFHviiq7xqVHxq80? zE{1IL^v0DJ6JE7iPx^+Ym{pGDd{Bd39u2Sf7C|4Vs=4trU-tm6&n;EW=_A2s+$i^- zJ*wE)9#8d%NZeArh1S5|`Q#2OGtYM>;C8rSOxYJPdv#TYJyGqZ(@XQRF>=LNZu3K_ z{s$@g)M!D=b<&0Rb|nsv+SkmzU1dsQ%s-Bl*s+2JMN>7Cf?2DzueY>R_Q~p0_j>0` zEgtY+0nfBmM=#>-hNF>_{@s!toQopw!rbfrzn4A=t>tEl{2qOmJs5qQJ7ihr-um^h zk|^(#^bz+AG(q%KD!0(YmTco)Nue#+g#oww2UfSgPpBH#Q+Z3APEfo^ZFy_X-Ou6rk2B==(k2-#Nd(e!t&y&$-Y0oclb_y{~)k9}oR2eFESxGcq*-Kp+4x zVGMvi2_zbZ;5`7q!UB*60DuL6g17)MLxC6r00{xm-x>hSK*IlM8xZF27$yL?g$E#i z$KV+Lz!;Sevj6trJkY-@<}v*fotOvyM@t^0(N_R9D^K4*-vCcvKQSda1wc*T)BbK+=5J?uP7s(AL~jF-j8i~CzwLJ# zV*)XOAy8%*3mn192q1F+Odv3r2?B;f54HhCGS&eICzR``q8>B1^#z!?KhKHlsgGDB z^q;lz+VoN+mD~t1a0DN}fS?fS7#brbt*mlVRZU&P;IyHUv5Bdf?O8i}hjV}6+%I18 zxa^7d3J44ez8Vr5cH?Gj+^yU332EsWnOXPlKgiB6C@d;2DJ^?kT~kYbUiYHD;q{xg z_Kvsj-gox(4}AVI_;qM_a%y^Jc5Z%Qaf!OVvAMOqL)+au;9}h8Us#O!FS7sOVq5}< z2?7B_US$OnQA3bY@ODNe;c-;uS2tG;WNfh+} z?Kjzf2Nv^xk^KYqZ>|x*0AOZ34iv)7%y=RgGYf(Pfq=siJcrrYIQV%41o(OQ_=H4I zNFiZ~BYb>fvSJd)&{EP;g2>|v$1w^hj1-2>C<21PUGeKd#P=7H(8tTt|6!L5B-aCfZJe<(d81Y@cBD zXNStqQFK=<%=cp&O7>yhbfDd#%5&S5KnEm9M8jX`_9(GFxwL8QV30|XL2C2LtnHRD z%H*ds+9>yP5$_IamwnhYNT;3VJ0%!lJ&}Yy*AVYkUw?b|F)2_Zts=!uPrNyR+tj)o zb3Anf9$=_c{KQ;nT{?0OyySn1Mbe-*gXDh7DMUSw=^6sS0C~(0c#d$v20qCYG8v-d zU<;nCkB0ItoMLIiyk9)UB7!wSKIC(2(4~J$*}mVbs>@|FqHeCqk`b;{Q^Wqw*k#*M z*t#Xye+v21{jD5!Eh?r#T08KVFlQ+$1A~eOKm#PbKMHN}UOnZym+y>p`KZ^*l(Dw^ zUa1k&UGKgl@+zFmo22~4h$G3eQRzb`b-m3^T7Q3aVf)6bDxRI5EM2_!uDp&U?wnEE zuk21qD>zcC`lRu`2I*mVeV|SL?C8ELWnNTb$_U%$8Ye`$R@-G^u~k}Gkag)6NBL`N zy$#{;H1Xk6V_cKY34wUE(h=$}_(QaX%lz}7FsjH{5v5yRWx4+-`9(H6*+~a(cturl z>C`kjJq5R+IFR8@X!Uh3&ZrWxY_XtL#RaKmDz935T8Md~=#%5! zd{r~JT$c}Iv)@FbN*Bi_R&5%x8P$4maSyX^uqs zX>vM_mZ_a9XQ0)KlR~flEI?DO3J8I8Xv2IC&sCmstu1T$p$l3x?-Bc$I1Oad(Knhsy!$kq%yA^&W;uS zHB@FyjGhE~IdQOOYJo6?vP@fw^Z;|s-;DL@DXz%o+ZXSXb4xRiwCpsQ{_(v=igoMB zrML>d^gDy^#?(G&_4}7*yLi5)-6?l$xwfS)yDI+RA}io|U!h9@axvVap?dGcxze%< z@{eTMFHNF|D~EUb*Mb$JxbfoCZ@8S)kuMtvO5b^-w{eTzGK4R)-&-bf>ru>G!A@ zax9C1qi8T%sVc!KE!g?qR&XSYa_7xe4ZGOxUz-*@JK=T`{&DBts!KeR+}v!B*!NCI z!eb21wkR!BYw;}DX5tb)+SldN0i|ByqEOkLl;mbqcVuOR=Vx29q>>g#+GOo%AS)zQ z(4VL#jn(q=UZ8X;Q+f%#j;=XsUd}zE8rs-aSKf$#ARlBrZ<;_3W-zTS^|VRr`P7;8 znCL7cZ-FU=4E|L*z`9>VI7@1Cr>$Y{?Q=N`Pd?8iMAv*TOc+hfmEEySy8mV~h&m~*4b2YZimIlqjaNC^L-9E9ZA=kRplr5tG>XFUoT{E{Tp==4tTimHM> z(=;MfZ6tB0J7ChkzrrE4=<>*;AkX&GITI~6rm3*jHGW)^=ixFx>gylIhj_d=rUy*m zMTu=1A-8q9T!}4rZA-c>iUXpdQDO!YNy61r|X}SKeF8u6Bs_axMPd{`i1sQ zzAi)dXVvUWI>3b=usSnB6PaX95ug>%cZ{L!>XT(|NS;}4+Ywv;y8k@{V7Jn3ICMF= zEnLVeR$HDXH?F%(C^LAl@s22{qHW%BRTU@HR5v&G$J8)Lj9Eg9`YD;bq+&)C)PJ5@ zeTJ5?Y~S7)68Noh_-Dhe2zQ70^{B#$0MBd2U$Aw_I(Bb&;^-65j1%;Xw{oNfX_gZ}yxkMsN1>hn|*8*ID_=o%*)UGLz_> zQWjr2sWM+;@aMQpL2QX&f7saYGNG~{2OBG-C4unub#c=^dqraRxU+7wh) zeY0d;P)Oghb#v1TN=KQ{Hz#v{iKi*7FT0+p1-yD+RhWD%!A#mae|hoiWEos?W>3T= z-m@-@Nb&?p$@Usw|JC;j*{`zr`Cd&4dPw&jO+#^;>_)P0;fqwfT!4RWXi*gV1QjMQ zWo5kRDy*?39bw};7j+AJ$mm`x~uU&x&^wEQvgK_k+(A)~)> zm7Xmmtn-hoX9&Cs7$=9lNc2(f-S&IA>FVDjWP!cE^Dw`uAdga&h=gw?U2ZpSbK%JX z`^#tb8%P!(Gqt@gev(~{^{s$}*kIYsj@LZD9y+&F9QLYpDhj!uJ^#ivK@`n*?&B^!>}?Wnkc{u4Cr|MX4g{y# zAI7U<=(+Tz?iZ!H<461q!_&&Qyx;?$i*}mFgZFQ#%GVNekdA-g?=EVv;XG2f99w;0 z>AnIJa{ORAFzBka6wpHq`?i!8QE_^5Ux+4S^C_sTN(Eap@yZ=5Z8MXmCrQzk`TW6u zlgcw7H6HM~lkoV3S!I!K=o56j)@6k6NXPxCQIs259th9;>4+3M`Av(p#G70JuOn)1ksB6XQ5)AGSqq6wNGlWVO&4{_4)r@r>Gk z4I0XQPdT@dWMHXv*ZO-jy?-xZZ%nh%)MpOTe&YTJ3J1lnk(7ymlAp%DL literal 0 HcmV?d00001 diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@3x.jpeg b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@3x.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..cbd78652ce3bdb9fb3e62b4b4522b2f40b1556a2 GIT binary patch literal 4606 zcmb7HXE+-Uw@>V?cI^={gCf;Xp`KAdx&b1tVY7XVlE?jr93fIuKX_b&jKGk_=n z4HY#FH5CmFH4QB-4IRT31_pY122K`MrYk(0SFiGLa&z+uf`$3`K?2;|A`lUfgru~L zG_SDSH94tkU@2)SAT2E|104eg0|SQ?A2*-W|JyEG0c>;t6~G83kPSe=2Bc&IUUmQo z000H$zm)#lXsBuFD5-!~06 zCDeyuZgW2@?n@g;+;NcytPIsg6n-2TT>}0GH}zjW3Lq^T07wO-prWLv`&<0Kx&LOe zQBkvVh$@|ag;nEvKcuu-xBGy(s>T7n<1U@~>*wga907@Nlij=P!L~(PJ34|65AAn*jMtA`RZk{k=!Ptk{Eowj<>iqi+eVve zMKWK>SdZC@kI;bvnfZn2<&>dYkJqdGdwpCvtmnkT?escK*@HgWAC}y|L-&7$Ic@Rb z?q0rQC-QXUT|V0yu0&50UfXWq{nh9}evifgq{hhn`nr;8w&c1AhUW=1IPb@k?LmdY z;~0E^_*&7nKGVxy#KR$naVe%nX^i-JwBLcV!vldKa9?aJMj({MD-eP0n5sm^Z`nGG z?P`zs(N!!@t-x6})t1bb)4PEag5GKNC;Hv&ii)XA% zSNn6!x&df3xE4mNF03HOU)O^@zDvw~>>%7Nd=WVR`@_jU!shF7hX$uSuj>tvey+1> zvh`(2rJ_~Ct;_l*8#%wPO16W9K38i{F7ZdaFLqw+im%&>%;XgPHzc+Pd~)O@AOYHY zhU$?u89`JD3n2pQd2MeNAB5!F*qY%yt*ayat@)i#M=UM@`n%yJM*EuQ<9k0|{5;nv zb30GI1WfLqDwwyt`j8zeo#z#p-n&+x!{S7`b?$j%ql$9s>7TKZS3CUlWxR-Q^M@6s z93YZtjXZx@(9JSZG`@f{haBJ|=Ud1fBaN1&oO;ML*N75}5{r^qHr-d=K$D4K7GFdm zQsRyFGpWywLQG*W|>vdln)(9$Z zi7tnMMJEF~(zC_u`>||!02EfITXJ46Fec&}s9*ZekUCLt01mVels1}_#8DPO`@R+%MP%OFVM!v|dOJ=Ds1{x%XN+b_=7B z(ZJk`R5e!r(3h)-bQ%LI01hn$DZQ|LJt%B#8C5i8vW~IG^t*=ax5a3KoU-6g3AeS4 zbBDVpuH;Ouss27Khg`MWdQkhdl^fNkZZXWNOExJ5QLpo&eZZPcDB8hyF#m`!O96{u zRD;~3cXA)uJGOV4Gt8nI+3_!-rOrZjRQ^@`NwU!~X`5j>D5Bo@=WsAVZqQ(k-xtiD zE^PY3E6NR~0cQ>oO>V4Zad>R^O@0#1^6sN2wfbAR5%KX_AO_ONiDK2h6Y@Jxc$xG0 z!fv#l`u0Pm20LrCM{Sy%CybslQ~Wo>0^Tr>1{BNEe$R4yshGVhmi;%w$7j@Og%9Nt+SX(~V~@B1LQ zY}^B^Lf143k;e2(%okeo`r^nY5d3B3spEMG?rh9glVR%CoPZo{5A{znp7*2B;+oMx zZU0>kK3NEeTpN`i2IzDW+8LDB@Y?8q;Dpe@ehtU^6X)4UPO4XyY6sOnGF$?xayOoxo0vdjV~_Z%Qc#GOVM`tQv=MDr?Qkw6uAD|HFkBG zZ@|Jxgm_{~=bnn*@Dt@)`Jv(>l~X<8Cz&kbN7PoW8qEdQQ^#C640ShD<>pcnF#Fbm zV?Q-phOe7*4#@1If`>_}V<_bpq=|1Dcbp!a5b&Kon^|y6c0LcQ`tOQC+c;!J0i&OC zPpGu7i+FJ)P{^iScWsv%KcGPK8b52&1vf9PRG7*06So>FE*R!2Op}u&AjOke%egEd zSBruc`^#*Vv!(qOB@)8VLhej2jAV}1kIuR1TKlF&J@tMu1Y1vhp;2*`27689|DAMa zeNGuy^!LR(K@>vnU(RS#9>NMBsUaS|ktW2-Zm3DWI$V3`z}T+X0b)Hxnh zHNHJ|w~AVotz8cVJdk($fh4$@x^6MAl>AuxOt4$!yT^MVI-r*-p&akfA+_#__0?&N zcODS{3VD9wbgz^w56B2R45{x%Je#ZhHl3T2_+W>$a51j1APqIOxUX@0q<+mtkFY?! zw-GM>#oKeb*KXw^2?o~v+fev{O=G*GiqI~H5BPqXh{Q{xjA z>+X`QZH5Nh^ok#Ko30x7y=#ZY=**@$GP{9lkcif9_g;l4VIy;aip_0aa!b{z+cMJhTQ3d?RJ#NKm2;T zE2R2bz;_(TR5 z(ZT&te??`fX7nNTMRu=Ia0e znV)O57*yczv(H>{GOoE;~*QNU1fn3^*Sb6@8Dk}3TTvmR-A z!4+ocJ@7O##{Zt#OA07i4q2U*6p)a4Z7Ol)C7=Cwi)$%)kE4|b(}p{}q2?jh0=r%Y zitV!^?GfIaeRhleK8a~hUV~MYg@4J+GdHJnxW}u*#@M`fsMvttVrC3!C=72=j^~;= z5%;oeXIX`MfzF0Pc1|8UUhba~pTlQ)uefd2-#;w&!*m6GpZohQ)7QvFKpJK)tY#NVCqA ztfu8QB1zF%ZY!|VrplktCX44VhkLCJ z?G3f)2(H*3IBL`Za4th!c@i_{ZIgI)iHrZ%1$Xe|PUA!kv1B2bm%(^wR(DMR=zi=G-N4z zwKzSg77MW4DE9$xxn37stzZ52?>#un5#2qX+=u4Fw0N4l+_$@K2W1DZ zHk=aX2p5ej!6iD{N#R!T2u+2o7Fn4FSy2)UQC)0=Jtdb}&tmjt?sZ)&H1tzynuz%H z9ze4fVRld9pI0k_(m^AMM4=1LJGdWuBlGSrHSpJ1P`cZ>b_9nwSr-p~=IG2xB&!pv zvBLZ%prfzI@p!<}!;P0lkKtvhKwk3oIrOhv$B#K1{`chm&)qGy@1*sq+B?}%Y)yo2 zhzAMz6%lHv@uN%i+;c+S=%x7hbfWHYe4SuhI5%F4vQ!Vildcb67P%_ z=zKK&h#rX)j2eaYq~iHeaO0yw9mh9sgK^3E%1sN-tPBUX`eBTS$EO92hd$%qHJrnq z@T?gGLb@ENy9G>Ea1mG!CuJ=|;?)CNB zynah9(N}D$_FZ1ghKxItbyrQ;Az_u11Y8T^&V+<5?}S31Sdm&izX%9(|!<&pa4cz>K5B@U}Wyq$hka!Z{uEeU*`_W9N z1wZ&k)7m>sZY@ojyu3H_OyO2@h7h|Fxvq+Nh}hkxjYi+>X$4?|nO0T~_e+;2biLvA z&+H4+?Q359SKat_p|F-Ip9R$)#z49Trqu?IglRVp zw#Ldp%N%(%4g|BD%Ds|-Jwvs5=W7$KDcN}(xsk+yF?CY}!ZU-N&zQ9Aq|G#g0ZYy+qUNJ0Dp> iR+f_wddt=apA39AYjhTk880w1>-mo|bOnr;-~S7Sc4Ha< literal 0 HcmV?d00001 diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 01d0a5e6..9741f110 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -23,8 +23,12 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol // MARK: - Computed Properties //-------------------------------------------------- - @objc public override func parsePageJSON() throws { - try parseTemplateJSON() + open override func parsePageJSON(_ error: NSErrorPointer) { + do { + try parseTemplateJSON() + } catch let parseError { + error?.pointee = parseError as NSError + } } open override var loadObject: MVMCoreLoadObject? { diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 03d21c6b..ef7a470d 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -12,8 +12,12 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { var observer: NSKeyValueObservation? public var templateModel: StackPageTemplateModel? - public override func parsePageJSON() throws { - try parseTemplateJSON() + open override func parsePageJSON(_ error: NSErrorPointer) { + do { + try parseTemplateJSON() + } catch let parseError { + error?.pointee = parseError as NSError + } } open override var loadObject: MVMCoreLoadObject? { diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 785d1055..eb822279 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -11,8 +11,13 @@ import UIKit @objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol { public var templateModel: ThreeLayerPageTemplateModel? - @objc public override func parsePageJSON() throws { - try parseTemplateJSON() + + open override func parsePageJSON(_ error: NSErrorPointer) { + do { + try parseTemplateJSON() + } catch let parseError { + error?.pointee = parseError as NSError + } } override open func viewDidLoad() { diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 947e6ffc..d0a027b3 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -108,7 +108,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; - (nonnull UIColor *)getBackgroundColorForType:(nullable NSString *)type { if ([type isEqualToString:ValueTypeError]) { - return [UIColor mfPumpkinColor]; + return [UIColor mvmOrange]; } else { return [UIColor mfShamrock]; } From d7a13704f2aadc4329b45fc523c8aefeb6399303 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Thu, 20 Feb 2020 15:56:02 +0530 Subject: [PATCH 21/40] Reference files --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++++++ MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 1 + 2 files changed, 9 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 281a0672..6fed15b6 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -96,6 +96,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 */; }; + 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; + 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; }; 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */; }; 5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */; }; 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; @@ -422,6 +424,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 = ""; }; + 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; + 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.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 = ""; }; 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; @@ -985,6 +989,8 @@ D22B38EB23F4E0AE00490EF6 /* LeftVariable */ = { isa = PBXGroup; children = ( + 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */, + 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */, 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, ); @@ -1652,6 +1658,7 @@ DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodyToggle.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, + 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */, 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, @@ -1777,6 +1784,7 @@ D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, + 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */, 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index ac7375d7..b3bfd241 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -72,6 +72,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) // List items From eacaff5a104fe372871694ad196902fbd55a2243 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Thu, 20 Feb 2020 17:58:50 +0530 Subject: [PATCH 22/40] changing eybrow variable as per contract --- .../VerticalCombinationViews/EyebrowHeadlineBodyLink.swift | 2 +- .../VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index ff8e6cfa..76eb447f 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -47,7 +47,7 @@ import UIKit // MARK:- ModelMoleculeViewProtocol open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) - eyebrow.setWithModel(casteModel?.eyeBrow, delegateObject, additionalData) + eyebrow.setWithModel(casteModel?.eyebrow, delegateObject, additionalData) headline.setWithModel(casteModel?.headline, delegateObject, additionalData) body.setWithModel(casteModel?.body, delegateObject, additionalData) link.setWithModel(casteModel?.link, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index 81a38111..e63d69e2 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -12,7 +12,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { static var identifier: String = "eyebrowHeadlineBodyLink" var backgroundColor: Color? var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier - public var eyeBrow: LabelModel? + public var eyebrow: LabelModel? public var headline: LabelModel? public var body: LabelModel? public var link: LinkModel? From 3f1e37c8783e571336ac179f8c95f388373faf19 Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Thu, 20 Feb 2020 20:45:20 +0530 Subject: [PATCH 23/40] Using stack as per review comments --- .../ListRVWheel.swift | 59 +++++++------------ .../ListRVWheelModel.swift | 11 +++- 2 files changed, 28 insertions(+), 42 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift index 47c77ed8..51f1133f 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift @@ -12,14 +12,13 @@ import Foundation let wheel = GraphView(frame: .zero) let leftLabel = Label(frame: .zero) let rightLabel = Label(frame: .zero) + let stack = Stack(frame: .zero) //------------------------------------------------- // MARK: - View Cycle //------------------------------------------------- open override func updateView(_ size: CGFloat) { super.updateView(size) - wheel.updateView(size) - leftLabel.updateView(size) - rightLabel.updateView(size) + stack.updateView(size) } //------------------------------------------------- @@ -27,39 +26,10 @@ import Foundation //------------------------------------------------- open override func setupView() { super.setupView() - guard leftLabel.superview == nil else { - return - } - contentView.addSubview(wheel) - contentView.addSubview(leftLabel) - contentView.addSubview(rightLabel) - NSLayoutConstraint.constraintPinSubview(toSuperview: contentView) - contentView.translatesAutoresizingMaskIntoConstraints = false - - //------------------------------------------------- - // MARK: - Constraining - //------------------------------------------------- - self.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([ - leftLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - leftLabel.topAnchor.constraint(equalTo: contentView.topAnchor), - leftLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - leftLabel.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.3) - ]) - NSLayoutConstraint.activate([ - wheel.topAnchor.constraint(equalTo: contentView.topAnchor), - wheel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - ]) - - let rightLabelTrailing = rightLabel.trailingAnchor.constraint(greaterThanOrEqualTo: contentView.trailingAnchor) - rightLabelTrailing.priority = UILayoutPriority(900) - NSLayoutConstraint.activate([ - rightLabelTrailing, - rightLabel.leadingAnchor.constraint(equalTo: wheel.trailingAnchor), - rightLabel.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.32), - rightLabel.topAnchor.constraint(equalTo: contentView.topAnchor), - rightLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - ]) + stack.translatesAutoresizingMaskIntoConstraints = false + stack.stackItems = [StackItem(andContain: leftLabel),StackItem(andContain: wheel),StackItem(andContain: rightLabel)] + contentView.addSubview(stack) + containerHelper.constrainView(stack) } //------------------------------------------------- // MARK: - MVMCoreUIMoleculeViewProtocol @@ -70,6 +40,19 @@ import Foundation leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) wheel.setWithModel(model.wheel, delegateObject, additionalData) + + // Create a stack model to use for the internal stack and set the alignment of models + let leftHeadlineBodyAlignment = StackItemModel(percent: 55) + leftHeadlineBodyAlignment.horizontalAlignment = .leading + + let centerHeadLineBodyAlignment = StackItemModel(percent: 20) + centerHeadLineBodyAlignment.horizontalAlignment = .trailing + let rightHeadLineBodyAlignment = StackItemModel(percent: 25) + rightHeadLineBodyAlignment.horizontalAlignment = .trailing + let stackModel = StackModel(molecules: [leftHeadlineBodyAlignment,centerHeadLineBodyAlignment,rightHeadLineBodyAlignment]) + stackModel.axis = .horizontal + stack.model = stackModel + stack.restack() } //------------------------------------------------- @@ -77,9 +60,7 @@ import Foundation //------------------------------------------------- open override func reset() { super.reset() - leftLabel.reset() - rightLabel.reset() - wheel.reset() + stack.reset() } public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 43 diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift index ec856bb1..ab5f3c2a 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift @@ -7,8 +7,7 @@ // import Foundation -public class ListRVWheelModel:MoleculeModelProtocol { - public var backgroundColor: Color? +public class ListRVWheelModel:ListItemModel,MoleculeModelProtocol { public static var identifier: String = "listRVWheel" public var leftLabel: LabelModel? public var rightLabel: LabelModel? @@ -17,20 +16,26 @@ public class ListRVWheelModel:MoleculeModelProtocol { self.leftLabel = leftLabel self.rightLabel = rightLabel self.wheel = wheel + super.init() } + private enum CodingKeys: String,CodingKey { case moleculeName case leftLabel case rightLabel case wheel } + 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) wheel = try typeContainer.decode(CircleProgressModel.self, forKey: .wheel) + try super.init(from: decoder) } - 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(ListRVWheelModel.identifier, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) From ae62d161fd5804edc69e9495d0ac91b2622e28d0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 20 Feb 2020 18:33:03 -0500 Subject: [PATCH 24/40] code improvements --- MVMCoreUI.xcodeproj/project.pbxproj | 4 +-- .../List/RightVariable}/ListRVWheel.swift | 33 +++++++++++-------- .../RightVariable}/ListRVWheelModel.swift | 15 +++++---- 3 files changed, 29 insertions(+), 23 deletions(-) rename MVMCoreUI/Molecules/{VerticalCombinationViews => DesignedComponents/List/RightVariable}/ListRVWheel.swift (72%) rename MVMCoreUI/Molecules/{VerticalCombinationViews => DesignedComponents/List/RightVariable}/ListRVWheelModel.swift (75%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8c9bb884..6e224df7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -795,6 +795,8 @@ children = ( AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, + C7F8012223E846C300396FBD /* ListRVWheelModel.swift */, + C7F8012023E8303200396FBD /* ListRVWheel.swift */, ); path = RightVariable; sourceTree = ""; @@ -903,8 +905,6 @@ C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */, D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */, 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, - C7F8012223E846C300396FBD /* ListRVWheelModel.swift */, - C7F8012023E8303200396FBD /* ListRVWheel.swift */, ); path = VerticalCombinationViews; sourceTree = ""; diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift similarity index 72% rename from MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift rename to MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift index 51f1133f..e9e09639 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift @@ -7,12 +7,12 @@ // import Foundation -@objcMembers public class ListRVWheel: TableViewCell { - +@objcMembers open class ListRVWheel: TableViewCell { let wheel = GraphView(frame: .zero) - let leftLabel = Label(frame: .zero) - let rightLabel = Label(frame: .zero) + let leftLabel = Label.commonLabelB1(true) + let rightLabel = Label.commonLabelB2(true) let stack = Stack(frame: .zero) + //------------------------------------------------- // MARK: - View Cycle //------------------------------------------------- @@ -26,13 +26,15 @@ import Foundation //------------------------------------------------- open override func setupView() { super.setupView() + rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: leftLabel),StackItem(andContain: wheel),StackItem(andContain: rightLabel)] contentView.addSubview(stack) containerHelper.constrainView(stack) } + //------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - ModelMoleculeViewProtocol //------------------------------------------------- public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) @@ -42,14 +44,14 @@ import Foundation wheel.setWithModel(model.wheel, delegateObject, additionalData) // Create a stack model to use for the internal stack and set the alignment of models - let leftHeadlineBodyAlignment = StackItemModel(percent: 55) - leftHeadlineBodyAlignment.horizontalAlignment = .leading - - let centerHeadLineBodyAlignment = StackItemModel(percent: 20) - centerHeadLineBodyAlignment.horizontalAlignment = .trailing - let rightHeadLineBodyAlignment = StackItemModel(percent: 25) - rightHeadLineBodyAlignment.horizontalAlignment = .trailing - let stackModel = StackModel(molecules: [leftHeadlineBodyAlignment,centerHeadLineBodyAlignment,rightHeadLineBodyAlignment]) + let leftLabelStackItem = StackItemModel() + leftLabelStackItem.horizontalAlignment = .leading + let wheelStackItem = StackItemModel() + wheelStackItem.horizontalAlignment = .fill + let rightLabelStackItem = StackItemModel() + rightLabelStackItem.horizontalAlignment = .fill + rightLabelStackItem.spacing = 4 + let stackModel = StackModel(molecules: [leftLabelStackItem,wheelStackItem,rightLabelStackItem]) stackModel.axis = .horizontal stack.model = stackModel stack.restack() @@ -61,8 +63,11 @@ import Foundation open override func reset() { super.reset() stack.reset() + leftLabel.styleB1(true) + rightLabel.styleB2(true) } + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 43 + return 70 } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift similarity index 75% rename from MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift rename to MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift index ab5f3c2a..3831f5c7 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/ListRVWheelModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift @@ -7,19 +7,20 @@ // import Foundation -public class ListRVWheelModel:ListItemModel,MoleculeModelProtocol { +public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "listRVWheel" - public var leftLabel: LabelModel? - public var rightLabel: LabelModel? - public var wheel : CircleProgressModel? - init(leftLabel: LabelModel, rightLabel: LabelModel, wheel: CircleProgressModel) { + public var leftLabel: LabelModel + public var rightLabel: LabelModel + public var wheel : CircleProgressModel + + public init(leftLabel: LabelModel, rightLabel: LabelModel, wheel: CircleProgressModel) { self.leftLabel = leftLabel self.rightLabel = rightLabel self.wheel = wheel super.init() } - private enum CodingKeys: String,CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case leftLabel case rightLabel @@ -37,7 +38,7 @@ public class ListRVWheelModel:ListItemModel,MoleculeModelProtocol { public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(ListRVWheelModel.identifier, forKey: .moleculeName) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(rightLabel, forKey: .rightLabel) try container.encode(wheel, forKey: .wheel) From cc5536a8d1c9f255b5912d0e1dba6d670774de40 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 20 Feb 2020 19:07:54 -0500 Subject: [PATCH 25/40] Minor fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- ...tLeftVariableCheckboxAllTextAndLinks.swift | 26 ++++++++++--------- ...VariableCheckboxAllTextAndLinksModel.swift | 5 ++-- .../EyebrowHeadlineBodyLink.swift | 3 --- .../EyebrowHeadlineBodyLinkModel.swift | 8 +++--- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 7ed0a2e3..4afd3a24 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -995,8 +995,8 @@ D22B38EB23F4E0AE00490EF6 /* LeftVariable */ = { isa = PBXGroup; children = ( - 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */, 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */, + 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */, 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, ); diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index d83e8389..553e6359 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -9,11 +9,11 @@ import Foundation @objcMembers public class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell { - - let checkbox = Checkbox(frame: .zero) - let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) - let stack = Stack(frame: .zero) + public let checkbox = Checkbox(frame: .zero) + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + public let stack = Stack(frame: .zero) + // MARK: - View Lifecycle open override func updateView(_ size: CGFloat) { super.updateView(size) stack.updateView(size) @@ -21,20 +21,18 @@ import Foundation override open func setupView() { super.setupView() - guard checkbox.superview == nil else { - return - } - stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: checkbox),StackItem(andContain: eyebrowHeadlineBodyLink)] contentView.addSubview(stack) containerHelper.constrainView(stack) } + // MARK:- ModelMoleculeViewProtocol override open func reset() { super.reset() stack.reset() } + // MARK:- MVMCoreUIMoleculeViewProtocol public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return} @@ -42,13 +40,17 @@ import Foundation eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData) // Create a stack model to use for the internal stack and set the alignment of labels - let checkbox = StackItemModel(percent: 10) - checkbox.horizontalAlignment = .leading - let eyebrowHeadlineBodyLink = StackItemModel(percent: 90) - eyebrowHeadlineBodyLink.horizontalAlignment = .fill + let checkbox = StackItemModel() + checkbox.horizontalAlignment = .fill + let eyebrowHeadlineBodyLink = StackItemModel() + eyebrowHeadlineBodyLink.horizontalAlignment = .leading let stackModel = StackModel(molecules: [checkbox,eyebrowHeadlineBodyLink]) stackModel.axis = .horizontal stack.model = stackModel stack.restack() } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 140 + } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift index 80ab9506..2fb89b1e 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift @@ -9,12 +9,11 @@ import Foundation public class ListLeftVariableCheckboxAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "listLVCB" public var checkbox: CheckboxModel - var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel - init(checkbox: CheckboxModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + public init(checkbox: CheckboxModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { self.checkbox = checkbox self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink super.init() diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 76eb447f..8f206e35 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -21,9 +21,6 @@ import UIKit // MARK: - MFViewProtocol open override func setupView() { super.setupView() - guard stack.superview == nil else { - return - } stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)] addSubview(stack) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index e63d69e2..913933d9 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -8,10 +8,10 @@ import Foundation -struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { - static var identifier: String = "eyebrowHeadlineBodyLink" - var backgroundColor: Color? - var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier +public struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { + public static var identifier: String = "eyebrowHeadlineBodyLink" + public var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier + public var backgroundColor: Color? public var eyebrow: LabelModel? public var headline: LabelModel? public var body: LabelModel? From 47603e7a599ba67c0bf5640cbcb16a40d926c45f Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Fri, 21 Feb 2020 16:58:16 +0530 Subject: [PATCH 26/40] Added ListOneColumnFullWidthTextAllTextAndLinks molecule class and model files. --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++++ ...neColumnFullWidthTextAllTextAndLinks.swift | 74 +++++++++++++++++++ ...umnFullWidthTextAllTextAndLinksModel.swift | 57 ++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 2 + 4 files changed, 149 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 4afd3a24..4f81feab 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -98,6 +98,8 @@ 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; }; + 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; }; + 52267A0923FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0823FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */; }; 5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */; }; 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; @@ -428,6 +430,8 @@ 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = ""; }; + 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = ""; }; + 52267A0823FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.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 = ""; }; 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; @@ -763,6 +767,15 @@ path = Views; sourceTree = ""; }; + 52267A0523FFE0A900906CBA /* OneColumn */ = { + isa = PBXGroup; + children = ( + 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, + 52267A0823FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */, + ); + path = OneColumn; + sourceTree = ""; + }; 946EE1B5237B663A0036751F /* Extensions */ = { isa = PBXGroup; children = ( @@ -1006,6 +1019,7 @@ D22B38EC23F4E10700490EF6 /* SectionDividers */ = { isa = PBXGroup; children = ( + 52267A0523FFE0A900906CBA /* OneColumn */, D22B38ED23F4E11100490EF6 /* ThreeColumn */, ); path = SectionDividers; @@ -1672,6 +1686,7 @@ D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, + 52267A0923FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, @@ -1847,6 +1862,7 @@ 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, + 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */, C003506123AA94CD00B6AC29 /* Button.swift in Sources */, DBC4391B224421A0001AB423 /* CaretLink.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift new file mode 100644 index 00000000..9827fed4 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift @@ -0,0 +1,74 @@ +// +// ListOneColumnFullWidthTextAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Kruthika KP on 14/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ListOneColumnFullWidthTextAllTextAndLinks: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + + let stack = Stack(frame: .zero) + let eyebrow = Label.commonLabelB3(true) + let headline = Label.commonLabelH3(true) + let subHeadline = Label.commonLabelB1(true) + let body = Label.commonLabelB2(true) + let link = Link() + + //----------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + stack.updateView(size) + } + + override open func setupView() { + super.setupView() + guard stack.superview == nil else { + return + } + stack.translatesAutoresizingMaskIntoConstraints = false + stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: subHeadline),StackItem(andContain: body),StackItem(andContain: link)] + contentView.addSubview(stack) + containerHelper.constrainView(stack) + } + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + + override open func reset() { + super.reset() + stack.reset() + eyebrow.styleB3(true) + headline.styleH3(true) + subHeadline.styleB1(true) + body.styleB2(true) + } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? ListOneColumnFullWidthTextAllTextAndLinksModel else { return} + eyebrow.setWithModel(model.eyebrow, delegateObject, additionalData) + headline.setWithModel(model.headline, delegateObject, additionalData) + subHeadline.setWithModel(model.subHeadline, delegateObject, additionalData) + body.setWithModel(model.body, delegateObject, additionalData) + link.setWithModel(model.link, delegateObject, additionalData) + + let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText),StackItemModel(gone: !headline.hasText),StackItemModel(gone: !subHeadline.hasText),StackItemModel(gone: !body.hasText),StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)]) + stack.model = stackModel + stackModel.spacing = 2 + stack.restack() + } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift new file mode 100644 index 00000000..ebc87aa4 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift @@ -0,0 +1,57 @@ +// +// ListOneColumnFullWidthTextAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 14/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListOneColumnFullWidthTextAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list1CTxt" + public var eyebrow: LabelModel? + public var headline : LabelModel? + public var subHeadline: LabelModel? + public var body: LabelModel? + public var link : LinkModel? + + public init(eyebrow:LabelModel, headline: LabelModel, subHeadline: LabelModel, body: LabelModel, link: LinkModel) { + self.eyebrow = eyebrow + self.headline = headline + self.subHeadline = subHeadline + self.body = body + self.link = link + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case eyebrow + case headline + case subHeadline + case body + case link + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + eyebrow = try typeContainer.decode(LabelModel.self, forKey: .eyebrow) + headline = try typeContainer.decode(LabelModel.self, forKey: .headline) + subHeadline = try typeContainer.decode(LabelModel.self, forKey: .subHeadline) + body = try typeContainer.decode(LabelModel.self, forKey: .body) + link = try typeContainer.decode(LinkModel.self, forKey: .link) + 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(eyebrow, forKey: .eyebrow) + try container.encode(headline, forKey: .headline) + try container.encode(subHeadline, forKey: .subHeadline) + try container.encode(body, forKey: .body) + try container.encode(link, forKey: .link) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 7ae80d49..0c82b7fe 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -55,6 +55,8 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ImageHeadlineBody.self, viewModelClass: ImageHeadlineBodyModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) + // Vertical Combination Molecules From ee66dbe8d59bf0b06bfd486bbf83de095e675748 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 21 Feb 2020 09:27:30 -0500 Subject: [PATCH 27/40] Caret fix in table view cell code condensing extra init functions --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 2 +- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 2 +- MVMCoreUI/Atoms/Views/Checkbox.swift | 2 +- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 2 + .../Atoms/Views/CircleProgressModel.swift | 5 +- MVMCoreUI/BaseClasses/TableViewCell.swift | 14 ++--- .../Views/Container/ContainerModel.swift | 6 +++ ...tLeftVariableCheckboxAllTextAndLinks.swift | 30 +++-------- ...VariableCheckboxAllTextAndLinksModel.swift | 2 +- .../ListLeftVariableIconWithRightCaret.swift | 38 +++++-------- ...tLeftVariableIconWithRightCaretModel.swift | 3 +- .../List/RightVariable/ListRVWheel.swift | 29 +++------- .../List/RightVariable/ListRVWheelModel.swift | 8 ++- .../ListRightVariablePayments.swift | 40 +++++--------- .../ListRightVariablePaymentsModel.swift | 6 +++ .../ListThreeColumnPlanDataDivider.swift | 30 +++-------- .../ListThreeColumnPlanDataDividerModel.swift | 3 ++ .../Molecules/Items/StackItemModel.swift | 13 ++--- .../EyebrowHeadlineBodyLinkModel.swift | 54 ++++++++++++++++++- MVMCoreUI/Organisms/StackModel.swift | 3 +- 20 files changed, 149 insertions(+), 143 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index f02eaf5c..917f573d 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -24,7 +24,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { public var title: String public var action: ActionModelProtocol public var enabled: Bool = true - public var style: ButtonStyle? + public var style: ButtonStyle? = .primary public var size: ButtonSize? = .standard public var fillColor: Color? public var textColor: Color? diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 4b28fc8c..4ea79ef8 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -15,7 +15,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol { public var title: String public var action: ActionModelProtocol public var enabledColor: Color = Color(uiColor: .black) - public var disabledColor: Color? = Color(uiColor: .mfSilver()) + public var disabledColor: Color? = Color(uiColor: .mvmCoolGray6) public var enabled = true public init(title: String, action: ActionModelProtocol) { diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 27bed31e..2980b879 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -395,7 +395,7 @@ import MVMCore heightConstraint?.constant = dimension } - layoutIfNeeded() + //layoutIfNeeded() } public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index de79c6c6..706597ff 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -58,6 +58,8 @@ import Foundation case isEnabled case action } + + init(isChecked: Bool = false) {} //-------------------------------------------------- // MARK: - Codec diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift index 3cafb1bb..2fc67b44 100644 --- a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -37,7 +37,10 @@ public class CircleProgressModel: MoleculeModelProtocol { public var colors = [Color]() public var backgroundColor: Color? - public init() {} + public init() { + updateStyle() + updateSize() + } private enum CodingKeys: String, CodingKey { case style diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index fe06a05a..ac91f292 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -198,16 +198,16 @@ import UIKit /// Adds the standard mvm style caret to the accessory view @objc public func addCaretViewAccessory() { guard accessoryView == nil else { return } - caretView = CaretView(lineWidth: 1) - caretView?.translatesAutoresizingMaskIntoConstraints = true - caretView?.size = .small(.vertical) - caretView?.setConstraints() - - if let size = caretView?.size?.dimensions() { + let caret = CaretView(lineWidth: 1) + caret.translatesAutoresizingMaskIntoConstraints = true + caret.size = .small(.vertical) + if let size = caret.size?.dimensions() { + caret.frame = CGRect(origin: CGPoint.zero, size: size) caretViewWidthSizeObject = MFSizeObject(standardSize: size.width, standardiPadPortraitSize: 9) caretViewHeightSizeObject = MFSizeObject(standardSize: size.height, standardiPadPortraitSize: 16) } - accessoryView = caretView + caretView = caret + accessoryView = caret } /// NOTE: Should only be called when displayed or about to be displayed. diff --git a/MVMCoreUI/Containers/Views/Container/ContainerModel.swift b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift index cdc6d743..a5e89adb 100644 --- a/MVMCoreUI/Containers/Views/Container/ContainerModel.swift +++ b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift @@ -27,6 +27,12 @@ public class ContainerModel: ContainerModelProtocol, Codable { } public init() {} + + public convenience init(horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil) { + self.init() + self.horizontalAlignment = horizontalAlignment + self.verticalAlignment = verticalAlignment + } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index 553e6359..0dad7228 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -8,49 +8,33 @@ import Foundation -@objcMembers public class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell { +@objcMembers open class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell { public let checkbox = Checkbox(frame: .zero) public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) public let stack = Stack(frame: .zero) // MARK: - View Lifecycle - open override func updateView(_ size: CGFloat) { - super.updateView(size) - stack.updateView(size) - } - override open func setupView() { super.setupView() stack.stackItems = [StackItem(andContain: checkbox),StackItem(andContain: eyebrowHeadlineBodyLink)] - contentView.addSubview(stack) - containerHelper.constrainView(stack) - } - - // MARK:- ModelMoleculeViewProtocol - override open func reset() { - super.reset() - stack.reset() + addMolecule(stack) } // MARK:- MVMCoreUIMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return} checkbox.setWithModel(model.checkbox, delegateObject, additionalData) eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData) - // Create a stack model to use for the internal stack and set the alignment of labels - let checkbox = StackItemModel() - checkbox.horizontalAlignment = .fill - let eyebrowHeadlineBodyLink = StackItemModel() - eyebrowHeadlineBodyLink.horizontalAlignment = .leading - let stackModel = StackModel(molecules: [checkbox,eyebrowHeadlineBodyLink]) - stackModel.axis = .horizontal + let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .leading)], + axis: .horizontal) stack.model = stackModel stack.restack() } - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 140 } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift index 2fb89b1e..fec71c0b 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift @@ -28,7 +28,7 @@ public class ListLeftVariableCheckboxAllTextAndLinksModel: ListItemModel, Molecu required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) - checkbox = try typeContainer.decode(CheckboxModel.self, forKey: .checkbox) + checkbox = try typeContainer.decodeIfPresent(CheckboxModel.self, forKey: .checkbox) ?? CheckboxModel() try super.init(from: decoder) } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift index 9f0e2deb..058d0da3 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift @@ -9,7 +9,7 @@ import Foundation import UIKit -@objcMembers public class ListLeftVariableIconWithRightCaret: TableViewCell { +@objcMembers open class ListLeftVariableIconWithRightCaret: TableViewCell { //----------------------------------------------------- // MARK: - Outlets @@ -22,17 +22,11 @@ import UIKit //----------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- - open override func updateView(_ size: CGFloat) { - super.updateView(size) - stack.updateView(size) - } override open func setupView() { super.setupView() - stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: leftImage),StackItem(andContain: leftLabel),StackItem(andContain: rightLabel)] - contentView.addSubview(stack) - containerHelper.constrainView(stack) + addMolecule(stack) leftLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 901), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 902), for: .horizontal) } @@ -40,32 +34,28 @@ import UIKit //---------------------------------------------------- // MARK: - Molecule //------------------------------------------------------ - override open func reset() { - super.reset() - stack.reset() - } - - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) 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) - // 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 + let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .trailing)], + axis: .horizontal) stack.model = stackModel stack.restack() } - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 90 } + + open override func reset() { + super.reset() + leftLabel.styleB2(true) + rightLabel.styleB2(true) + } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift index bccf5320..4b426909 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift @@ -19,6 +19,7 @@ public class ListLeftVariableIconWithRightCaretModel: ListItemModel, MoleculeMod if image.height == nil { image.height = 30.0 } + rightLabel.hero = 0 } public init(image: ImageViewModel, leftLabel: LabelModel, rightLabel: LabelModel) { @@ -43,7 +44,7 @@ public class ListLeftVariableIconWithRightCaretModel: ListItemModel, MoleculeMod try super.init(from: decoder) } - public override 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(moleculeName, forKey: .moleculeName) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift index e9e09639..46d4b955 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift @@ -13,46 +13,30 @@ import Foundation let rightLabel = Label.commonLabelB2(true) let stack = Stack(frame: .zero) - //------------------------------------------------- - // MARK: - View Cycle - //------------------------------------------------- - open override func updateView(_ size: CGFloat) { - super.updateView(size) - stack.updateView(size) - } - //------------------------------------------------- // MARK: - Setup //------------------------------------------------- open override func setupView() { super.setupView() rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) - stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: leftLabel),StackItem(andContain: wheel),StackItem(andContain: rightLabel)] - contentView.addSubview(stack) - containerHelper.constrainView(stack) + addMolecule(stack) } //------------------------------------------------- // MARK: - ModelMoleculeViewProtocol //------------------------------------------------- - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? ListRVWheelModel else { return } leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) rightLabel.setWithModel(model.rightLabel, delegateObject, additionalData) wheel.setWithModel(model.wheel, delegateObject, additionalData) - // Create a stack model to use for the internal stack and set the alignment of models - let leftLabelStackItem = StackItemModel() - leftLabelStackItem.horizontalAlignment = .leading - let wheelStackItem = StackItemModel() - wheelStackItem.horizontalAlignment = .fill - let rightLabelStackItem = StackItemModel() - rightLabelStackItem.horizontalAlignment = .fill - rightLabelStackItem.spacing = 4 - let stackModel = StackModel(molecules: [leftLabelStackItem,wheelStackItem,rightLabelStackItem]) - stackModel.axis = .horizontal + let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading), + StackItemModel(horizontalAlignment: .fill), + StackItemModel(spacing: 4, horizontalAlignment: .fill)], + axis: .horizontal) stack.model = stackModel stack.restack() } @@ -62,7 +46,6 @@ import Foundation //------------------------------------------------- open override func reset() { super.reset() - stack.reset() leftLabel.styleB1(true) rightLabel.styleB2(true) } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift index 3831f5c7..89b70b0f 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift @@ -20,6 +20,12 @@ public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol { super.init() } + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + rightLabel.hero = 0 + } + private enum CodingKeys: String, CodingKey { case moleculeName case leftLabel @@ -31,7 +37,7 @@ public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - wheel = try typeContainer.decode(CircleProgressModel.self, forKey: .wheel) + wheel = try typeContainer.decodeIfPresent(CircleProgressModel.self, forKey: .wheel) ?? CircleProgressModel() try super.init(from: decoder) } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift index 2bfbc321..66f88371 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift @@ -8,12 +8,11 @@ import Foundation -@objcMembers public class ListRightVariablePayments: TableViewCell { +@objcMembers open class ListRightVariablePayments: TableViewCell { //----------------------------------------------------- // MARK: - Outlets //------------------------------------------------------- - let leftLabel = Label.commonLabelB1(true) let rightImage = MFLoadImageView(pinnedEdges: .all) let stack = Stack(frame: .zero) @@ -21,49 +20,34 @@ import Foundation //----------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- - - open override func updateView(_ size: CGFloat) { - super.updateView(size) - stack.updateView(size) - } - override open func setupView() { super.setupView() - guard leftLabel.superview == nil else { - return - } - stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: leftLabel),StackItem(andContain: rightImage)] - contentView.addSubview(stack) - containerHelper.constrainView(stack) + addMolecule(stack) } //---------------------------------------------------- // MARK: - Molecule //------------------------------------------------------ - override open func reset() { - super.reset() - stack.reset() - } - - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? ListRightVariablePaymentsModel else { return } leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) rightImage.setWithModel(model.image, delegateObject, additionalData) - // Create a stack model to use for the internal stack and set the alignment of label and image - let leftLabel = StackItemModel() - leftLabel.horizontalAlignment = .leading - let rightImage = StackItemModel() - rightImage.horizontalAlignment = .fill - let stackModel = StackModel(molecules: [leftLabel,rightImage]) - stackModel.axis = .horizontal + let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading), + StackItemModel(horizontalAlignment: .fill)], + axis: .horizontal) stack.model = stackModel stack.restack() } - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 65 } + + open override func reset() { + super.reset() + leftLabel.styleB1(true) + } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift index a8c6ff80..4842b60a 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift @@ -20,6 +20,12 @@ public class ListRightVariablePaymentsModel: ListItemModel, MoleculeModelProtoco super.init() } + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + leftLabel.hero = 0 + } + static func createPayPalImage() -> ImageViewModel { let image = ImageViewModel(image: "imageName_PayPal_logo") image.localBundle = MVMCoreUIUtility.bundleForMVMCoreUI() diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift index 19774110..565ed737 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift @@ -16,23 +16,16 @@ import Foundation let stack = Stack(frame: .zero) // MARK: - MFViewProtocol - open override func updateView(_ size: CGFloat) { - super.updateView(size) - stack.updateView(size) - } - open override func setupView() { super.setupView() //using stackItems to align the three headlineBody - stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: leftHeadlineBody),StackItem(andContain: centerHeadLineBody),StackItem(andContain: rightHeadLineBody)] - contentView.addSubview(stack) - containerHelper.constrainView(stack) + addMolecule(stack) } // MARK: - MVMCoreUIMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open 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) @@ -40,24 +33,15 @@ import Foundation rightHeadLineBody.setWithModel(model.rightHeadlineBody, delegateObject, additionalData) // 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 + let stackModel = StackModel(molecules: [StackItemModel(percent: 33, horizontalAlignment: .leading), + StackItemModel(percent: 34, horizontalAlignment: .center), + StackItemModel(percent: 33, horizontalAlignment: .trailing)], + axis: .horizontal) stack.model = stackModel stack.restack() } - open override func reset() { - super.reset() - stack.reset() - } - - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + open override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return 121 } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift index fd946eb0..3ddfe64b 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift @@ -26,6 +26,9 @@ public class ListThreeColumnPlanDataDividerModel: ListItemModel, MoleculeModelPr override public func setDefaults() { super.setDefaults() style = "tallDivider" + leftHeadlineBody.style = "itemHeader" + centerHeadlineBody.style = "itemHeader" + rightHeadlineBody.style = "itemHeader" } private enum CodingKeys: String, CodingKey { diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index b7d1a269..795b2983 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -16,13 +16,14 @@ import Foundation public var percent: Int? public var gone: Bool = false - public convenience init(gone: Bool) { - self.init() - self.gone = gone - } - - public convenience init(percent: Int) { + public convenience init(spacing: CGFloat? = nil, percent: Int? = nil, horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil, gone: Bool? = nil) { self.init() + self.horizontalAlignment = horizontalAlignment + self.verticalAlignment = verticalAlignment + self.spacing = spacing self.percent = percent + if let gone = gone { + self.gone = gone + } } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index 913933d9..2ff3ca57 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -8,7 +8,7 @@ import Foundation -public struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { +public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { public static var identifier: String = "eyebrowHeadlineBodyLink" public var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier public var backgroundColor: Color? @@ -16,4 +16,56 @@ public struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { public var headline: LabelModel? public var body: LabelModel? public var link: LinkModel? + + public init(eyebrow: LabelModel? = nil, headline: LabelModel? = nil, body: LabelModel? = nil, link: LinkModel? = nil) throws { + // TODO: This class initializers should ensure that atleast one item is set. + /*guard eyebrow != nil || headline != nil || body != nil || link != nil else { + throw + }*/ + self.eyebrow = eyebrow + self.headline = headline + self.body = body + self.link = link + setDefaults() + } + + /// Defaults to set + public func setDefaults() { + if let headline = headline { + headline.hero = 0 + } + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case eyebrow + case headline + case body + case link + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) + headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline) + body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) + link = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .link) + setDefaults() + // TODO: This class initializers should ensure that atleast one item is set. + /*guard eyebrow != nil || headline != nil || body != nil || link != nil else { + throw + }*/ + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(eyebrow, forKey: .eyebrow) + try container.encodeIfPresent(headline, forKey: .headline) + try container.encodeIfPresent(body, forKey: .body) + try container.encodeIfPresent(link, forKey: .link) + } } diff --git a/MVMCoreUI/Organisms/StackModel.swift b/MVMCoreUI/Organisms/StackModel.swift index 8d670efb..b762a03c 100644 --- a/MVMCoreUI/Organisms/StackModel.swift +++ b/MVMCoreUI/Organisms/StackModel.swift @@ -16,8 +16,9 @@ import Foundation public var spacing: CGFloat = 16.0 public var useStackSpacingBeforeFirstItem = false - public init(molecules: [StackItemModel]) { + public init(molecules: [StackItemModel], axis: NSLayoutConstraint.Axis = .vertical) { self.molecules = molecules + self.axis = axis } private enum CodingKeys: String, CodingKey { From dedcd9de12a9d02dcaf3da414e6a78bf4bcf3f2b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 21 Feb 2020 10:16:00 -0500 Subject: [PATCH 28/40] undo commented code --- MVMCoreUI/Atoms/Views/Checkbox.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 2980b879..27bed31e 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -395,7 +395,7 @@ import MVMCore heightConstraint?.constant = dimension } - //layoutIfNeeded() + layoutIfNeeded() } public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { From 17583c107ce721dab4a044d76add9fc61eae3e38 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 21 Feb 2020 14:31:46 -0500 Subject: [PATCH 29/40] moved hero is setWithModel. Was not being set. Mild changes. --- MVMCoreUI/Atoms/Views/Label/Label.swift | 3 ++- MVMCoreUI/Atoms/Views/Label/LabelModel.swift | 20 +++++++++++++-- MVMCoreUI/BaseClasses/TableViewCell.swift | 6 ++--- .../EyebrowHeadlineBodyLink.swift | 14 ++++++++--- MVMCoreUI/Organisms/Stack.swift | 25 ++++++++----------- 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index 013f7f11..b300b7bb 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -231,6 +231,7 @@ public typealias ActionBlock = () -> () attributedText = nil originalAttributedString = nil text = labelModel.text + hero = labelModel.hero Label.setLabel(self, withHTML: labelModel.html) let alignment = LabelAlignment(rawValue: labelModel.textAlignment ?? "") @@ -344,7 +345,6 @@ public typealias ActionBlock = () -> () } attributedText = attributedString originalAttributedString = attributedText - hero = labelModel.hero } } @@ -716,6 +716,7 @@ extension Label { public func reset() { text = nil attributedText = nil + hero = nil textAlignment = .left originalAttributedString = nil styleB2(true) diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index d7fb4fa3..cb9cc0a9 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -10,6 +10,10 @@ import Foundation @objcMembers public class LabelModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "label" public var backgroundColor: Color? public var text: String @@ -24,6 +28,10 @@ import Foundation public var hero: Int? public var makeWholeViewClickable: Bool? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case text @@ -43,11 +51,19 @@ import Foundation enum AttributeTypeKey: String, CodingKey { case type } - + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(text: String) { self.text = text } - + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) text = try typeContainer.decode(String.self, forKey: .text) diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index ac91f292..a301926c 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -198,8 +198,8 @@ import UIKit /// Adds the standard mvm style caret to the accessory view @objc public func addCaretViewAccessory() { guard accessoryView == nil else { return } + let caret = CaretView(lineWidth: 1) - caret.translatesAutoresizingMaskIntoConstraints = true caret.size = .small(.vertical) if let size = caret.size?.dimensions() { caret.frame = CGRect(origin: CGPoint.zero, size: size) @@ -217,11 +217,11 @@ import UIKit layoutIfNeeded() guard let heroLabel = findHeroLabel(views: contentView.subviews), let hero = heroLabel.hero else { return } let rect = Label.boundingRect(forCharacterRange: NSRange(location: hero, length: 1), in: heroLabel) - accessoryView?.center.y = contentView.convert(UIView(frame: rect).center, from: heroLabel).y + accessoryView?.center.y = convert(UIView(frame: rect).center, from: heroLabel).y heroAccessoryCenter = accessoryView?.center } - /// Traverses the view hierarchy for a 🦸‍♂️heroic Label. + /// Traverses the view hierarchy for a 🦸‍♂️ heroic Label. private func findHeroLabel(views: [UIView]) -> Label? { if views.isEmpty { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 8f206e35..c964c6ed 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -9,11 +9,13 @@ import UIKit @objcMembers open class EyebrowHeadlineBodyLink: Container { + let stack = Stack(frame: .zero) let eyebrow = Label.commonLabelB3(true) let headline = Label.commonLabelB1(true) let body = Label.commonLabelB2(true) let link = Link() + var casteModel: EyebrowHeadlineBodyLinkModel? { get { return model as? EyebrowHeadlineBodyLinkModel } } @@ -21,7 +23,10 @@ import UIKit // MARK: - MFViewProtocol open override func setupView() { super.setupView() - stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)] + stack.stackItems = [StackItem(andContain: eyebrow), + StackItem(andContain: headline), + StackItem(andContain: body), + StackItem(andContain: link)] addSubview(stack) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) } @@ -42,7 +47,7 @@ import UIKit } // MARK:- ModelMoleculeViewProtocol - open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) eyebrow.setWithModel(casteModel?.eyebrow, delegateObject, additionalData) headline.setWithModel(casteModel?.headline, delegateObject, additionalData) @@ -50,7 +55,10 @@ import UIKit link.setWithModel(casteModel?.link, delegateObject, additionalData) // Create a stack model to use for the internal stack. - let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText),StackItemModel(gone: !headline.hasText),StackItemModel(gone: !body.hasText),StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)]) + let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText), + StackItemModel(gone: !headline.hasText), + StackItemModel(gone: !body.hasText), + StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)]) stackModel.spacing = 0 stack.model = stackModel stack.restack() diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 4e7a3114..1f2fa288 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -51,7 +51,7 @@ open class Stack: Container where T: StackModelProtocol { super.init(frame: frame) } - public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.init(frame: CGRect.zero) setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } @@ -63,9 +63,7 @@ open class Stack: Container where T: StackModelProtocol { // MARK: - MFViewProtocol public override func setupView() { super.setupView() - guard contentView.superview == nil else { - return - } + guard contentView.superview == nil else { return } MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0) translatesAutoresizingMaskIntoConstraints = false backgroundColor = .clear @@ -91,7 +89,7 @@ open class Stack: Container where T: StackModelProtocol { } } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { let previousModel = self.model super.setWithModel(model, delegateObject, additionalData) removeAllItemViews() @@ -132,6 +130,7 @@ open class Stack: Container where T: StackModelProtocol { guard let model = molecule as? T else { return 0 } let horizontal = model.axis == .horizontal var estimatedHeight: CGFloat = 0 + for case let item in model.molecules { if item.gone { continue } let height = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(forRow: item, delegateObject: delegateObject) ?? 0 @@ -161,11 +160,10 @@ open class Stack: Container where T: StackModelProtocol { // MARK: - Subclassables /// Can be subclassed to create views when we get stack item models and have no views yet - func createStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - } + func createStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { } /// Can be subclassed to set stack items with model when we already have views - func setStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + func setStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let models = stackModel?.molecules else { return } for (index, element) in models.enumerated() { (stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element, delegateObject, additionalData) @@ -178,6 +176,7 @@ open class Stack: Container where T: StackModelProtocol { guard let stackModel = stackModel else { return 0.0 } var totalSpace: CGFloat = 0.0 var firstMoleculeFound = false + for stackItemModel in stackModel.molecules { guard !stackItemModel.gone else { continue } let spacing = stackItemModel.spacing ?? stackModel.spacing @@ -214,9 +213,7 @@ open class Stack: Container where T: StackModelProtocol { if stackModel.axis == .vertical { if first { pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) - } else if let previousView = stackItems.last(where: { item in - return !model.gone - }) { + } else if let previousView = stackItems.last(where: { item in !model.gone }) { view.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true } pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) @@ -233,15 +230,13 @@ open class Stack: Container where T: StackModelProtocol { if first { // First horizontal item has no spacing by default unless told otherwise. pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) - } else if let previousView = stackItems.last(where: { item in - return !model.gone - }) { + } else if let previousView = stackItems.last(where: { item in !model.gone }) { view.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true } pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) if let percent = model.percent { - let multiplier = CGFloat(percent)/100.0 + let multiplier = CGFloat(percent) / 100.0 let constant = multiplier * totalSpacing view.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: multiplier, constant: -constant).isActive = true } From 0c11ded57778570e316f981f16a4ac4f4361d567 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 21 Feb 2020 14:41:53 -0500 Subject: [PATCH 30/40] rolled back change. --- MVMCoreUI/Organisms/Stack.swift | 35 ++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 1f2fa288..67ff0110 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -9,13 +9,20 @@ import Foundation open class Stack: Container where T: StackModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + var contentView: UIView = MVMCoreUICommonViewsUtility.commonView() var stackModel: T? { get { return model as? T } } var stackItems: [UIView] = [] + //-------------------------------------------------- // MARK: - Helpers + //-------------------------------------------------- + public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) { let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant) constraint.priority = priority @@ -45,8 +52,11 @@ open class Stack: Container where T: StackModelProtocol { item.removeFromSuperview() } } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- - // MARK: - Inits public override init(frame: CGRect) { super.init(frame: frame) } @@ -60,7 +70,10 @@ open class Stack: Container where T: StackModelProtocol { fatalError("init(coder:) has not been implemented") } + //-------------------------------------------------- // MARK: - MFViewProtocol + //-------------------------------------------------- + public override func setupView() { super.setupView() guard contentView.superview == nil else { return } @@ -80,7 +93,10 @@ open class Stack: Container where T: StackModelProtocol { } } + //-------------------------------------------------- // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + public override func reset() { super.reset() backgroundColor = .clear @@ -157,8 +173,10 @@ open class Stack: Container where T: StackModelProtocol { return modules.count > 0 ? modules : nil } + //-------------------------------------------------- // MARK: - Subclassables - + //-------------------------------------------------- + /// Can be subclassed to create views when we get stack item models and have no views yet func createStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { } @@ -170,7 +188,10 @@ open class Stack: Container where T: StackModelProtocol { } } + //-------------------------------------------------- // MARK: - Adding to stack + //-------------------------------------------------- + /// Gets the percent modifier. This value is used to help properly calculate percent for stack items when spacing is involved. private func getTotalSpace() -> CGFloat { guard let stackModel = stackModel else { return 0.0 } @@ -213,13 +234,15 @@ open class Stack: Container where T: StackModelProtocol { if stackModel.axis == .vertical { if first { pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) - } else if let previousView = stackItems.last(where: { item in !model.gone }) { + } else if let previousView = stackItems.last(where: { item in + return !model.gone + }) { view.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true } pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: view, attribute: .trailing, relation: .equal, priority: .required, constant: 0) if let percent = model.percent { - let multiplier = CGFloat(percent)/100.0 + let multiplier = CGFloat(percent) / 100.0 let constant = multiplier * totalSpacing view.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: multiplier, constant: -constant).isActive = true } @@ -230,7 +253,9 @@ open class Stack: Container where T: StackModelProtocol { if first { // First horizontal item has no spacing by default unless told otherwise. pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) - } else if let previousView = stackItems.last(where: { item in !model.gone }) { + } else if let previousView = stackItems.last(where: { item in + return !model.gone + }) { view.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true } pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) From f8895157097676ce1ce3e4e41363f2f85544c87b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Sun, 23 Feb 2020 13:34:20 -0500 Subject: [PATCH 31/40] hero is working. commenting done. --- .../EyebrowHeadlineBodyLink.swift | 15 +++++++++- .../EyebrowHeadlineBodyLinkModel.swift | 28 ++++++++++++++++--- MVMCoreUI/Organisms/Stack.swift | 2 ++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index c964c6ed..e9d7d34e 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -9,6 +9,9 @@ import UIKit @objcMembers open class EyebrowHeadlineBodyLink: Container { + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- let stack = Stack(frame: .zero) let eyebrow = Label.commonLabelB3(true) @@ -20,7 +23,10 @@ import UIKit get { return model as? EyebrowHeadlineBodyLinkModel } } + //-------------------------------------------------- // MARK: - MFViewProtocol + //-------------------------------------------------- + open override func setupView() { super.setupView() stack.stackItems = [StackItem(andContain: eyebrow), @@ -36,7 +42,10 @@ import UIKit stack.updateView(size) } + //-------------------------------------------------- // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + open override func reset() { super.reset() stack.reset() @@ -46,9 +55,13 @@ import UIKit body.styleB2(true) } - // MARK:- ModelMoleculeViewProtocol + //-------------------------------------------------- + // MARK: - ModelMoleculeViewProtocol + //-------------------------------------------------- + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) + eyebrow.setWithModel(casteModel?.eyebrow, delegateObject, additionalData) headline.setWithModel(casteModel?.headline, delegateObject, additionalData) body.setWithModel(casteModel?.body, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index 2ff3ca57..e277f5de 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -9,6 +9,10 @@ import Foundation public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "eyebrowHeadlineBodyLink" public var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier public var backgroundColor: Color? @@ -17,11 +21,15 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { public var body: LabelModel? public var link: LinkModel? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(eyebrow: LabelModel? = nil, headline: LabelModel? = nil, body: LabelModel? = nil, link: LinkModel? = nil) throws { // TODO: This class initializers should ensure that atleast one item is set. /*guard eyebrow != nil || headline != nil || body != nil || link != nil else { - throw - }*/ + throw + }*/ self.eyebrow = eyebrow self.headline = headline self.body = body @@ -29,6 +37,10 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { setDefaults() } + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + /// Defaults to set public func setDefaults() { if let headline = headline { @@ -36,6 +48,10 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { } } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor @@ -45,6 +61,10 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { case link } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) @@ -55,8 +75,8 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { setDefaults() // TODO: This class initializers should ensure that atleast one item is set. /*guard eyebrow != nil || headline != nil || body != nil || link != nil else { - throw - }*/ + throw + }*/ } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 67ff0110..602ab0f1 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -8,6 +8,7 @@ import Foundation + open class Stack: Container where T: StackModelProtocol { //-------------------------------------------------- // MARK: - Properties @@ -24,6 +25,7 @@ open class Stack: Container where T: StackModelProtocol { //-------------------------------------------------- public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) { + let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant) constraint.priority = priority constraint.isActive = true From e33fe346c69bd3e0a748a4d2f51d6e5917fe96fd Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 24 Feb 2020 09:58:47 -0500 Subject: [PATCH 32/40] mild updates --- MVMCoreUI/Atoms/Views/Label/Label.swift | 3 --- MVMCoreUI/BaseClasses/TableViewCell.swift | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index b300b7bb..f08d532d 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -808,9 +808,6 @@ extension Label { - Attention: This method expects text to be set first. Otherwise, it will do nothing. - parameter range: The range of text to be tapped. - - parameter actionMap: - - parameter delegate: - - parameter additionalData: */ @objc public func addTappableLinkAttribute(range: NSRange, actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index a301926c..8547457e 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -139,7 +139,6 @@ import UIKit topSeparatorView?.updateView(size) bottomSeparatorView?.updateView(size) - molecule?.updateView(size) } @@ -153,9 +152,7 @@ import UIKit //TODO: Model, Change to model public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let model = model as? ListItemModelProtocol else { - return - } + guard let model = model as? ListItemModelProtocol else { return } self.listItemModel = model style(with: model.style) @@ -194,7 +191,7 @@ import UIKit return nil } - // MARK: - Arrow + // MARK: - Caret View /// Adds the standard mvm style caret to the accessory view @objc public func addCaretViewAccessory() { guard accessoryView == nil else { return } From 9b5379626607dab86fbca95d8b8d4fab72ab7ff9 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 24 Feb 2020 10:13:45 -0500 Subject: [PATCH 33/40] undoing removal --- MVMCoreUI/BaseClasses/TableViewCell.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index 8547457e..d96a4587 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -197,6 +197,7 @@ import UIKit guard accessoryView == nil else { return } let caret = CaretView(lineWidth: 1) + caret.translatesAutoresizingMaskIntoConstraints = true caret.size = .small(.vertical) if let size = caret.size?.dimensions() { caret.frame = CGRect(origin: CGPoint.zero, size: size) From 2f94f3435ab3049471f8786e08d1851505331854 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Mon, 24 Feb 2020 22:04:28 +0530 Subject: [PATCH 34/40] Code changes as per condensed code feature branch. --- ...neColumnFullWidthTextAllTextAndLinks.swift | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift index 9827fed4..8d588374 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift @@ -36,24 +36,15 @@ import Foundation return } stack.translatesAutoresizingMaskIntoConstraints = false - stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: subHeadline),StackItem(andContain: body),StackItem(andContain: link)] + stack.stackItems = [StackItem(andContain: eyebrow), + StackItem(andContain: headline), + StackItem(andContain: body), + StackItem(andContain: link)] contentView.addSubview(stack) - containerHelper.constrainView(stack) - } - //---------------------------------------------------- - // MARK: - Molecule - //------------------------------------------------------ - - override open func reset() { - super.reset() - stack.reset() - eyebrow.styleB3(true) - headline.styleH3(true) - subHeadline.styleB1(true) - body.styleB2(true) + addMolecule(stack) } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ super.setWithModel(model, delegateObject, additionalData) guard let model = model as? ListOneColumnFullWidthTextAllTextAndLinksModel else { return} eyebrow.setWithModel(model.eyebrow, delegateObject, additionalData) @@ -61,14 +52,25 @@ import Foundation subHeadline.setWithModel(model.subHeadline, delegateObject, additionalData) body.setWithModel(model.body, delegateObject, additionalData) link.setWithModel(model.link, delegateObject, additionalData) - - let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText),StackItemModel(gone: !headline.hasText),StackItemModel(gone: !subHeadline.hasText),StackItemModel(gone: !body.hasText),StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)]) + let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText), + StackItemModel(gone: !headline.hasText), + StackItemModel(gone: !body.hasText), + StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)]) stack.model = stackModel stackModel.spacing = 2 stack.restack() } - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat?{ return 90 } + + open override func reset() { + super.reset() + stack.reset() + eyebrow.styleB3(true) + headline.styleH3(true) + subHeadline.styleB1(true) + body.styleB2(true) + } } From 9a8c510b7fc0a4c97e5268f6583a0912bc4782a4 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Mon, 24 Feb 2020 22:06:31 +0530 Subject: [PATCH 35/40] minor change --- .../OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift index 8d588374..b10a9d65 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift @@ -40,7 +40,6 @@ import Foundation StackItem(andContain: headline), StackItem(andContain: body), StackItem(andContain: link)] - contentView.addSubview(stack) addMolecule(stack) } From b255b1acac35b5c41b41bbb6ba2699335c7a74b7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 24 Feb 2020 16:53:42 -0500 Subject: [PATCH 36/40] header updates --- MVMCoreUI.xcodeproj/project.pbxproj | 16 +++++-- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 2 +- .../Containers/Views/MoleculeContainer.swift | 8 ++-- .../Views/MoleculeContainerModel.swift | 2 +- .../Views/MoleculeContainerProtocol.swift | 13 ++++++ MVMCoreUI/Molecules/HeaderModel.swift | 20 ++++---- MVMCoreUI/Molecules/MoleculeHeaderModel.swift | 37 +++++++++++++++ ...derView.swift => MoleculeHeaderView.swift} | 46 +++++++------------ .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- 9 files changed, 95 insertions(+), 51 deletions(-) create mode 100644 MVMCoreUI/Containers/Views/MoleculeContainerProtocol.swift create mode 100644 MVMCoreUI/Molecules/MoleculeHeaderModel.swift rename MVMCoreUI/Molecules/{HeaderView.swift => MoleculeHeaderView.swift} (60%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 4afd3a24..3e9138f7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -307,7 +307,7 @@ D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */; }; D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */; }; D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */; }; - D2A514672213885800345BFB /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* HeaderView.swift */; }; + D2A514672213885800345BFB /* MoleculeHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* MoleculeHeaderView.swift */; }; D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; }; D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A638FC22CA98280052ED1F /* HeadlineBody.swift */; }; D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390022CBB1820052ED1F /* Carousel.swift */; }; @@ -322,6 +322,8 @@ D2C521A923EDE79E00CA2634 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2C521A823EDE79E00CA2634 /* ViewController.swift */; }; D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */; }; D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */; }; + D2D90B42240463E100DD6EC9 /* MoleculeHeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D90B41240463E100DD6EC9 /* MoleculeHeaderModel.swift */; }; + D2D90B442404789000DD6EC9 /* MoleculeContainerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D90B432404789000DD6EC9 /* MoleculeContainerProtocol.swift */; }; D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; }; @@ -650,7 +652,7 @@ D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackView.swift; sourceTree = ""; }; D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackTemplate.swift; sourceTree = ""; }; D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackCenteredTemplate.swift; sourceTree = ""; }; - D2A514662213885800345BFB /* HeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = ""; }; + D2A514662213885800345BFB /* MoleculeHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeHeaderView.swift; sourceTree = ""; }; D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; D2A638FC22CA98280052ED1F /* HeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBody.swift; sourceTree = ""; }; D2A6390022CBB1820052ED1F /* Carousel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Carousel.swift; sourceTree = ""; }; @@ -665,6 +667,8 @@ D2C521A823EDE79E00CA2634 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Scroller.swift; sourceTree = ""; }; D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTemplate.swift; sourceTree = ""; }; + D2D90B41240463E100DD6EC9 /* MoleculeHeaderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeHeaderModel.swift; sourceTree = ""; }; + D2D90B432404789000DD6EC9 /* MoleculeContainerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainerProtocol.swift; sourceTree = ""; }; D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = ""; }; D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = ""; }; D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = ""; }; @@ -757,6 +761,7 @@ children = ( 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */, D29E28DE23D740FC00ACEA85 /* Container */, + D2D90B432404789000DD6EC9 /* MoleculeContainerProtocol.swift */, 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */, D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, ); @@ -1128,7 +1133,8 @@ D224798E2316A995003FCCF9 /* HorizontalCombinationViews */, D224798D2316A988003FCCF9 /* VerticalCombinationViews */, 01EB368C23609801006832FA /* HeaderModel.swift */, - D2A514662213885800345BFB /* HeaderView.swift */, + D2D90B41240463E100DD6EC9 /* MoleculeHeaderModel.swift */, + D2A514662213885800345BFB /* MoleculeHeaderView.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, D274CA322236A78900B01B62 /* FooterView.swift */, 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */, @@ -1716,7 +1722,7 @@ D2E2A99C23D8D975000B42E6 /* ImageHeadlineBodyModel.swift in Sources */, D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */, 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, - D2A514672213885800345BFB /* HeaderView.swift in Sources */, + D2A514672213885800345BFB /* MoleculeHeaderView.swift in Sources */, D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */, 01EB369023609801006832FA /* MoleculeListItemModel.swift in Sources */, D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, @@ -1781,6 +1787,7 @@ D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, + D2D90B42240463E100DD6EC9 /* MoleculeHeaderModel.swift in Sources */, 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */, @@ -1802,6 +1809,7 @@ D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */, + D2D90B442404789000DD6EC9 /* MoleculeContainerProtocol.swift in Sources */, 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 917f573d..f02eaf5c 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -24,7 +24,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { public var title: String public var action: ActionModelProtocol public var enabled: Bool = true - public var style: ButtonStyle? = .primary + public var style: ButtonStyle? public var size: ButtonSize? = .standard public var fillColor: Color? public var textColor: Color? diff --git a/MVMCoreUI/Containers/Views/MoleculeContainer.swift b/MVMCoreUI/Containers/Views/MoleculeContainer.swift index 9a907222..d179ef72 100644 --- a/MVMCoreUI/Containers/Views/MoleculeContainer.swift +++ b/MVMCoreUI/Containers/Views/MoleculeContainer.swift @@ -31,7 +31,7 @@ open class MoleculeContainer: Container { } public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - if let casteModel = model as? MoleculeContainerModel { + if let casteModel = model as? MoleculeContainerModelProtocol { if view != nil { (view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData) } else { @@ -44,7 +44,7 @@ open class MoleculeContainer: Container { } public override static func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let containerModel = model as? MoleculeContainerModel, + guard let containerModel = model as? MoleculeContainerModelProtocol, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type, let moleculeName = moleculeClass.nameForReuse(containerModel.molecule, delegateObject) else { return "\(model?.moleculeName ?? "moleculeContainer")<>" @@ -53,7 +53,7 @@ open class MoleculeContainer: Container { } public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - guard let containerModel = molecule as? MoleculeContainerModel else { return 0 } + guard let containerModel = molecule as? MoleculeContainerModelProtocol else { return 0 } guard let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type, let moleculeHeight = moleculeClass.estimatedHeight(forRow: containerModel.molecule, delegateObject: delegateObject) else { return (containerModel.topMarginPadding ?? 0) + (containerModel.bottomMarginPadding ?? 0) @@ -62,7 +62,7 @@ open class MoleculeContainer: Container { } public override class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { - guard let containerModel = molecule as? MoleculeContainerModel, + guard let containerModel = molecule as? MoleculeContainerModelProtocol, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type else { return nil } return moleculeClass.requiredModules(containerModel.molecule, delegateObject: delegateObject, error: error) } diff --git a/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift b/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift index 0421b3d1..95683f8f 100644 --- a/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift +++ b/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift @@ -8,7 +8,7 @@ import Foundation -public class MoleculeContainerModel: ContainerModel { +public class MoleculeContainerModel: ContainerModel, MoleculeContainerModelProtocol { public var molecule: MoleculeModelProtocol private enum CodingKeys: String, CodingKey { diff --git a/MVMCoreUI/Containers/Views/MoleculeContainerProtocol.swift b/MVMCoreUI/Containers/Views/MoleculeContainerProtocol.swift new file mode 100644 index 00000000..882cf181 --- /dev/null +++ b/MVMCoreUI/Containers/Views/MoleculeContainerProtocol.swift @@ -0,0 +1,13 @@ +// +// MoleculeContainerProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 2/24/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol MoleculeContainerModelProtocol: ContainerModelProtocol { + var molecule: MoleculeModelProtocol { get set } +} diff --git a/MVMCoreUI/Molecules/HeaderModel.swift b/MVMCoreUI/Molecules/HeaderModel.swift index b6f3629f..6314947c 100644 --- a/MVMCoreUI/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Molecules/HeaderModel.swift @@ -8,19 +8,17 @@ import Foundation -@objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeModelProtocol { - public static var identifier: String = "header" +@objcMembers public class HeaderModel: ContainerModel { public var backgroundColor: Color? public var line: LineModel? private enum CodingKeys: String, CodingKey { - case moleculeName case line case backgroundColor } /// Defaults to set - func setDefaults() { + public func setDefaults() { if useHorizontalMargins == nil { useHorizontalMargins = true } @@ -33,25 +31,27 @@ import Foundation if bottomMarginPadding == nil { bottomMarginPadding = PaddingDefaultVerticalSpacing } - line?.type = .heavy + if line == nil { + line = LineModel(type: .heavy) + } } - public override init(with moleculeModel: MoleculeModelProtocol) { - super.init(with: moleculeModel) + public override init() { + super.init() setDefaults() } required public init(from decoder: Decoder) throws { try super.init(from: decoder) - setDefaults() let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) ?? LineModel(type: .heavy) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + setDefaults() } 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(line, forKey: .line) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } diff --git a/MVMCoreUI/Molecules/MoleculeHeaderModel.swift b/MVMCoreUI/Molecules/MoleculeHeaderModel.swift new file mode 100644 index 00000000..92958ca1 --- /dev/null +++ b/MVMCoreUI/Molecules/MoleculeHeaderModel.swift @@ -0,0 +1,37 @@ +// +// MoleculeHeaderModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation + +@objcMembers public class MoleculeHeaderModel: HeaderModel, MoleculeModelProtocol, MoleculeContainerModelProtocol { + public static var identifier: String = "header" + 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/HeaderView.swift b/MVMCoreUI/Molecules/MoleculeHeaderView.swift similarity index 60% rename from MVMCoreUI/Molecules/HeaderView.swift rename to MVMCoreUI/Molecules/MoleculeHeaderView.swift index c90be96d..5d58c675 100644 --- a/MVMCoreUI/Molecules/HeaderView.swift +++ b/MVMCoreUI/Molecules/MoleculeHeaderView.swift @@ -1,5 +1,5 @@ // -// HeaderView.swift +// MoleculeHeaderView.swift // MVMCoreUI // // Created by Scott Pfeil on 2/12/19. @@ -8,55 +8,41 @@ import UIKit -public class HeaderView: MoleculeContainer { - var line: Line? +public class MoleculeHeaderView: MoleculeContainer { + var line = Line() - var headerModel: HeaderModel? { - get { return model as? HeaderModel } + var headerModel: MoleculeHeaderModel? { + get { return model as? MoleculeHeaderModel } } // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) - line?.updateView(size) + line.updateView(size) } public override func setupView() { super.setupView() - - guard line == nil else { return } - let line = Line() line.setStyle(.heavy) addSubview(line) NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true - self.line = line } // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - if let separatorJSON = json?.optionalDictionaryForKey("line") { - line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) - } - } - - open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.setWithModel(model, delegateObject, additionalData) - - guard let headerModel = model as? HeaderModel else { - return - } - - if let seperatorModel = headerModel.line { - line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) - } - } - open override func reset() { super.reset() - line?.setStyle(.heavy) + line.setStyle(.heavy) + } + + // MARK: - ModelMoleculeViewProtocol + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let headerModel = headerModel else { return } + if let lineModel = headerModel.line { + line.setWithModel(lineModel, delegateObject, additionalData) + } } public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 7ae80d49..fde8f4cb 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -88,7 +88,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeCollectionViewCell.self, viewModelClass: CarouselItemModel.self) // Other Container Molecules - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeaderView.self, viewModelClass: HeaderModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: FooterView.self, viewModelClass: FooterModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Scroller.self, viewModelClass: ScrollerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ModuleMolecule.self, viewModelClass: ModuleMoleculeModel.self) From fea1c2e9972ddbb220d6af95f50bb807638fdfb6 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Tue, 25 Feb 2020 13:33:40 +0530 Subject: [PATCH 37/40] added subHeadline and changed the files order --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++---- .../ListOneColumnFullWidthTextAllTextAndLinks.swift | 12 +++--------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0fb1da3a..95bd45b6 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -99,11 +99,11 @@ 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; }; 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; }; - 52267A0923FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0823FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */; }; 5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */; }; 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; }; + 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.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 */; }; @@ -433,11 +433,11 @@ 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = ""; }; 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = ""; }; - 52267A0823FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.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 = ""; }; 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = ""; }; + 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.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 = ""; }; @@ -775,8 +775,8 @@ 52267A0523FFE0A900906CBA /* OneColumn */ = { isa = PBXGroup; children = ( + 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */, 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, - 52267A0823FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */, ); path = OneColumn; sourceTree = ""; @@ -1692,7 +1692,6 @@ D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, - 52267A0923FFE28200906CBA /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, @@ -1793,6 +1792,7 @@ 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, + 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, D2E2A99623D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift index b10a9d65..e13bdd8b 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift @@ -32,12 +32,9 @@ import Foundation override open func setupView() { super.setupView() - guard stack.superview == nil else { - return - } - stack.translatesAutoresizingMaskIntoConstraints = false stack.stackItems = [StackItem(andContain: eyebrow), StackItem(andContain: headline), + StackItem(andContain: subHeadline), StackItem(andContain: body), StackItem(andContain: link)] addMolecule(stack) @@ -53,6 +50,7 @@ import Foundation link.setWithModel(model.link, delegateObject, additionalData) let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText), StackItemModel(gone: !headline.hasText), + StackItemModel(gone: !subHeadline.hasText), StackItemModel(gone: !body.hasText), StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)]) stack.model = stackModel @@ -66,10 +64,6 @@ import Foundation open override func reset() { super.reset() - stack.reset() - eyebrow.styleB3(true) - headline.styleH3(true) - subHeadline.styleB1(true) - body.styleB2(true) + } } From 54782b187132f158fd9d955b1cc36e2168052500 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Tue, 25 Feb 2020 20:11:22 +0530 Subject: [PATCH 38/40] Changes in init method and spacing --- ...neColumnFullWidthTextAllTextAndLinks.swift | 16 +++++++----- ...umnFullWidthTextAllTextAndLinksModel.swift | 26 +++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift index e13bdd8b..4b0e2e91 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift @@ -48,13 +48,12 @@ import Foundation subHeadline.setWithModel(model.subHeadline, delegateObject, additionalData) body.setWithModel(model.body, delegateObject, additionalData) link.setWithModel(model.link, delegateObject, additionalData) - let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText), - StackItemModel(gone: !headline.hasText), - StackItemModel(gone: !subHeadline.hasText), - StackItemModel(gone: !body.hasText), - StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)]) + let stackModel = StackModel(molecules: [StackItemModel(spacing: 2, gone: !eyebrow.hasText), + StackItemModel(spacing: 2, gone: !headline.hasText), + StackItemModel(spacing: 2, gone: !subHeadline.hasText), + StackItemModel(spacing: 2, gone: !body.hasText), + StackItemModel(spacing: 2, gone: (link.titleLabel?.text?.count ?? 0) == 0)]) stack.model = stackModel - stackModel.spacing = 2 stack.restack() } @@ -64,6 +63,9 @@ import Foundation open override func reset() { super.reset() - + eyebrow.styleB3(true) + headline.styleH3(true) + subHeadline.styleB1(true) + body.styleB2(true) } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift index ebc87aa4..47e482a0 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift @@ -15,8 +15,8 @@ public class ListOneColumnFullWidthTextAllTextAndLinksModel: ListItemModel, Mole public var subHeadline: LabelModel? public var body: LabelModel? public var link : LinkModel? - - public init(eyebrow:LabelModel, headline: LabelModel, subHeadline: LabelModel, body: LabelModel, link: LinkModel) { + + public init(eyebrow: LabelModel? = nil, headline: LabelModel? = nil, subHeadline: LabelModel? = nil, body: LabelModel? = nil, link: LinkModel? = nil) { self.eyebrow = eyebrow self.headline = headline self.subHeadline = subHeadline @@ -36,22 +36,22 @@ public class ListOneColumnFullWidthTextAllTextAndLinksModel: ListItemModel, Mole required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - eyebrow = try typeContainer.decode(LabelModel.self, forKey: .eyebrow) - headline = try typeContainer.decode(LabelModel.self, forKey: .headline) - subHeadline = try typeContainer.decode(LabelModel.self, forKey: .subHeadline) - body = try typeContainer.decode(LabelModel.self, forKey: .body) - link = try typeContainer.decode(LinkModel.self, forKey: .link) + eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) + headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline) + subHeadline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .subHeadline) + body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) + link = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .link) 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(eyebrow, forKey: .eyebrow) - try container.encode(headline, forKey: .headline) - try container.encode(subHeadline, forKey: .subHeadline) - try container.encode(body, forKey: .body) - try container.encode(link, forKey: .link) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(eyebrow, forKey: .eyebrow) + try container.encodeIfPresent(headline, forKey: .headline) + try container.encodeIfPresent(subHeadline, forKey: .subHeadline) + try container.encodeIfPresent(body, forKey: .body) + try container.encodeIfPresent(link, forKey: .link) } } From 2ec429974abd978b90adadb838a064154e99ffa0 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Tue, 25 Feb 2020 21:24:04 +0530 Subject: [PATCH 39/40] removing updateView. --- .../ListOneColumnFullWidthTextAllTextAndLinks.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift index 4b0e2e91..9e930396 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift @@ -24,12 +24,6 @@ import Foundation //----------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- - - open override func updateView(_ size: CGFloat) { - super.updateView(size) - stack.updateView(size) - } - override open func setupView() { super.setupView() stack.stackItems = [StackItem(andContain: eyebrow), From cfcff1aa6ea5a43ee3b613b7692504799de64467 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 26 Feb 2020 11:49:31 -0500 Subject: [PATCH 40/40] Top Alert Fixes for top color and status bar color --- .../TopAlert/MVMCoreUITopAlertExpandableView.m | 5 ++++- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 2 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 14 ++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index f215fa0b..cc25cd9b 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -109,6 +109,7 @@ self.backgroundColor = [[MVMCoreUITopAlertView sharedGlobal] getBackgroundColorForType:topAlertObject.type]; UIColor *contentColor = [[MVMCoreUITopAlertView sharedGlobal] getContentColorForType:topAlertObject.type]; [self setupTopMessage:nil]; + self.shortView.label.textColor = contentColor; MVMCoreUITopAlertMainView *topAlertWithButton = [[MVMCoreUITopAlertMainView alloc] initWithColor:self.backgroundColor contentColor:contentColor message:topAlertObject.message subMessage:nil closeButton:YES animationDelegate:animationDelegate]; [self setupTopAlertWithButton:topAlertWithButton]; [self expand:NO]; @@ -173,6 +174,7 @@ - (void)setupViewWithTopMessage:(nullable NSString *)topMessage message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage contentColor:(nonnull UIColor *)contentColor buttonTitle:(nullable NSString *)buttonTitle { [self setupTopMessage:topMessage]; + self.shortView.label.textColor = contentColor; MVMCoreUITopAlertMainView *topAlertWithButton = [[MVMCoreUITopAlertMainView alloc] initWithColor:[UIColor clearColor] contentColor:contentColor message:message subMessage:subMessage buttonTitle:buttonTitle userActionHandler:nil]; [self setupTopAlertWithButton:topAlertWithButton]; @@ -181,7 +183,8 @@ - (void)setupViewWithTopMessage:(nullable NSString *)topMessage message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage contentColor:(nonnull UIColor *)contentColor actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData { [self setupTopMessage:topMessage]; - + self.shortView.label.textColor = contentColor; + MVMCoreUITopAlertMainView *topAlertWithButton = [[MVMCoreUITopAlertMainView alloc] initWithColor:[UIColor clearColor] contentColor:contentColor message:message subMessage:subMessage actionMap:actionMap additionalData:additionalData]; [self setupTopAlertWithButton:topAlertWithButton]; } diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index ca9520f3..ec11530a 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -45,7 +45,7 @@ - (void)resetDefaultBackgroundColor:(nullable UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style; // Can be subclassed for custom views. -- (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor; +- (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor statusBarStyle:(UIStatusBarStyle *_Nullable)statusBarStyle; /// Get the background color based on the type - (nonnull UIColor *)getBackgroundColorForType:(nullable NSString *)type; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index d0a027b3..930828f6 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -98,10 +98,17 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; } } -- (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor { +- (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor statusBarStyle:(UIStatusBarStyle *_Nullable)statusBarStyle { MVMCoreUITopAlertExpandableView *view = [[MVMCoreUITopAlertExpandableView alloc] initWithTopAlertObject:topAlertObject animationDelegate:animationDelegate viewToLayout:self.superview]; if (statusBarColor && view.shortView.label.text) { *statusBarColor = view.backgroundColor; + + if (statusBarStyle) { + CGFloat greyScale = 0; + if ([view.shortView.label.textColor getWhite:&greyScale alpha:nil]) { + *statusBarStyle = greyScale > 0.5 ? UIStatusBarStyleLightContent : UIStatusBarStyleDefault; + } + } } return view; } @@ -131,12 +138,11 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; self.topAlertClearspotView = nil; UIColor *statusBarColor = nil; - MVMCoreUITopAlertBaseView *view = [self topAlertViewForTopAlertObject:topAlertObject animationDelegate:animationDelegate statusBarColor:&statusBarColor]; + UIStatusBarStyle statusBarStyle = UIStatusBarStyleDefault; + MVMCoreUITopAlertBaseView *view = [self topAlertViewForTopAlertObject:topAlertObject animationDelegate:animationDelegate statusBarColor:&statusBarColor statusBarStyle:&statusBarStyle]; if (!statusBarColor) { statusBarColor = [UIColor whiteColor]; } -#warning This logic is incomplete, it is possible to show the wrong status bar color here if the background is yellow or pumpkin. - UIStatusBarStyle statusBarStyle = statusBarColor == [UIColor whiteColor] ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent; [self setStatusBarColor:statusBarColor statusBarStyle:statusBarStyle]; [self showAlertView:view topAlertObject:topAlertObject completionHandler:completionHandler]; });