From 5ae5cfd2d8b5eeb9a2a2d872fec77add009766c5 Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Fri, 7 Feb 2020 17:03:33 +0530 Subject: [PATCH] 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)