From 35e7052abbc806d8541ba20b8349fe203183380c Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Tue, 4 Feb 2020 14:10:01 +0530 Subject: [PATCH 01/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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 a7ebc798d2227bcc328265734dc4d9af871fd35c Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Tue, 18 Feb 2020 19:01:08 +0530 Subject: [PATCH 09/13] 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 10/13] 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 11/13] 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 3f1e37c8783e571336ac179f8c95f388373faf19 Mon Sep 17 00:00:00 2001 From: Prateek Arora Date: Thu, 20 Feb 2020 20:45:20 +0530 Subject: [PATCH 12/13] 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 13/13] 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)