From 73c59a9d5771b576ba7673f8f831ebc38d5d373a Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Thu, 8 Oct 2020 16:49:57 +0530 Subject: [PATCH 01/14] View init model method fix --- .../Atoms/FormFields/TextFields/DigitBox.swift | 6 ++++++ MVMCoreUI/Atomic/Atoms/Views/Arrow.swift | 6 ++++++ MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift | 5 +++++ MVMCoreUI/Atomic/Atoms/Views/DashLine.swift | 6 ++++++ .../Atomic/Atoms/Views/LeftRightLabelView.swift | 6 ++++++ .../Headers/H1/HeadersH1Button.swift | 5 +++++ .../Headers/H2/HeadersH2Buttons.swift | 5 +++++ .../Headers/H2/HeadersH2CaretLink.swift | 5 +++++ .../Headers/H2/HeadersH2Link.swift | 5 +++++ .../Headers/H2/HeadersH2PricingTwoRows.swift | 13 +++++++++++++ .../Headers/H2/HeadersH2TinyButton.swift | 7 +++++++ .../LockUps/LockUpsPlanNames.swift | 7 +++++++ .../LockUps/LockupsPlanSMLXL.swift | 11 +++++++++++ .../Atomic/Molecules/Doughnut/DoughnutChart.swift | 6 ++++++ .../RadioButtonLabel.swift | 6 ++++++ .../HorizontalCombinationViews/TwoButtonView.swift | 6 ++++++ .../HorizontalCombinationViews/TwoLinkView.swift | 6 ++++++ .../LeftRightViews/ActionDetailWithImage.swift | 6 ++++++ .../HeadlineBodyButton.swift | 6 ++++++ .../StringAndMoleculeView.swift | 7 +++++++ .../ThreeHeadlineBodyLink.swift | 6 ++++++ MVMCoreUI/Atomic/Organisms/Stack.swift | 6 ++++++ MVMCoreUI/BaseClasses/View.swift | 6 ++++++ 23 files changed, 148 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift index ba04f482..ec233a44 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift @@ -91,6 +91,12 @@ import UIKit fatalError("DigitBox does not support xibs.") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift index 13c4ff36..b712d55e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift @@ -91,6 +91,12 @@ open class Arrow: View { fatalError("init(coder:) has not been implemented") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift index 281c306d..d157cfc9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift @@ -97,6 +97,11 @@ fatalError("xib file is not implemented for CheckboxLabel") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(model: model, delegateObject, additionalData) + setupView() + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift b/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift index c8a59c6d..db4ebef9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift @@ -40,6 +40,12 @@ open class DashLine: View { super.init(coder: coder) } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //------------------------------------------------------ // MARK: - Lifecycle //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift index aca7113f..8f158a15 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift @@ -62,6 +62,12 @@ super.init(coder: aDecoder) } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + override open func setupView() { super.setupView() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift index d41b9022..7ccd521b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift @@ -28,6 +28,11 @@ import Foundation fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + stack = Stack.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen) + super.init(model: model, delegateObject, additionalData) + } + //------------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift index 5cf8bba1..0980a518 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift @@ -31,6 +31,11 @@ import Foundation fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + stack = Stack.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3) + super.init(model: model, delegateObject, additionalData) + } + //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift index 1aaf092f..e8fcf603 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift @@ -27,6 +27,11 @@ import Foundation fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + stack = Stack.createStack(with: [headlineBody, caretLink]) + super.init(model: model, delegateObject, additionalData) + } + //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift index c5aaefc8..0456ac03 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift @@ -28,6 +28,11 @@ import Foundation fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + stack = Stack.createStack(with: [headlineBody, link]) + super.init(model: model, delegateObject, additionalData) + } + //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift index 12097880..000d2a03 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -47,6 +47,19 @@ import Foundation fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + verticalStack1 = Stack.createStack(with: [body, subBody], spacing: 0) + verticalStack2 = Stack.createStack(with: [body2, subBody2], spacing: 0) + verticalStack3 = Stack.createStack(with: [body3, subBody3], spacing: 0) + horizontalStack = Stack.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 29, verticalAlignment: .top)), (view: verticalLine1, model: StackItemModel(verticalAlignment: .top)), + (view: verticalStack2, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)), + (view: verticalLine2, model: StackItemModel(verticalAlignment: .top)), + (view: verticalStack3, model: StackItemModel(percent: 32, verticalAlignment: .top))], + axis: .horizontal) + stack = Stack.createStack(with: [headline, horizontalStack], spacing: 8) + super.init(model: model, delegateObject, additionalData) + } + //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift index 2ec507b9..f146c2f2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift @@ -33,6 +33,13 @@ import Foundation fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + stack = Stack.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)), + (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], + axis: .vertical) + super.init(model: model, delegateObject, additionalData) + } + //------------------------------------------------------ // MARK: - Constants //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift index e947322f..c393d134 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift @@ -31,6 +31,13 @@ import Foundation fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + stack = Stack.createStack(with: [(view: headline, model: StackItemModel()), + (view: subHeadline, model: StackItemModel(spacing: 16)), + (view: body, model: StackItemModel(spacing: 8))]) + super.init(model: model, delegateObject, additionalData) + } + //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift index 8312e5da..90a6b032 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -37,6 +37,17 @@ import Foundation fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + verticalStack = Stack.createStack(with: [(view: headline, model: StackItemModel()), + (view: subHeadline, model: StackItemModel()), + (view: body, model: StackItemModel(horizontalAlignment: .fill))], + axis: .vertical, spacing: 0) + stack = Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)), + (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))], + axis: .horizontal) + super.init(model: model, delegateObject, additionalData) + } + //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index db57f977..5956aac9 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -65,6 +65,12 @@ open class DoughnutChart: View { fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift index d415971e..31d099cb 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift @@ -27,6 +27,12 @@ import UIKit required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } + + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } public override func updateView(_ size: CGFloat) { super.updateView(size) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 31420e56..d88a49fd 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -39,6 +39,12 @@ import UIKit super.init(frame: frame) } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift index fbc56b0b..78dde228 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift @@ -34,6 +34,12 @@ import Foundation super.init(frame: frame) } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - MVMCoreViewProtocol //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift index ab0924b2..9381e358 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift @@ -45,6 +45,12 @@ import UIKit super.init(coder: aDecoder) } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //------------------------------------------------------ // MARK: - View Lifecycle //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift index 5170d8f2..8b0d03a0 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift @@ -45,6 +45,12 @@ import UIKit super.init(coder: aDecoder) } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //------------------------------------------------------ // MARK: - View Lifecycle //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index 3c97e988..4fb125c4 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -36,6 +36,13 @@ open class StringAndMoleculeView: View { fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + let moleculeModel = model as? StringAndMoleculeModel + label.text = moleculeModel?.string + self.molecule = moleculeModel?.molecule as! MoleculeViewProtocol + super.init(model: model, delegateObject, additionalData) + } + override public func setupView() { super.setupView() guard subviews.count == 0 else { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift index 5926951f..93c07673 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift @@ -36,6 +36,12 @@ open class ThreeHeadlineBodyLink: View { super.init(coder: aDecoder) } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //------------------------------------------------------ // MARK: - Lifecycle //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index ad961586..99766ebc 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -113,6 +113,12 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto fatalError("init(coder:) has not been implemented") } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + /// Returns a Stack created with a StackModel and StackItems containing the passed in views. public static func createStack(with views: [UIView], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) -> Stack { var items: [StackItem] = [] diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 686985eb..cfb6ff1f 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -43,6 +43,12 @@ import UIKit } } + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + initialSetup() + set(with: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - MoleculeViewProtocol //-------------------------------------------------- From e103cd554d5db119feef7618092343a66b83d181 Mon Sep 17 00:00:00 2001 From: gonch26 Date: Fri, 9 Oct 2020 01:53:17 -0500 Subject: [PATCH 02/14] [ COREUI: IMPROV ] Improve symbol with additional data parameter --- .../Containers/SplitViewController/MVMCoreUIPanelProtocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h index 4537e791..9ab2e8ce 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h @@ -17,7 +17,7 @@ - (BOOL)panelAvailable; // Notified when it is appearing and disappearing. Called by the container. -- (void)willOpenWithActionInformation:(nullable NSDictionary *)actionInformation; +- (void)willOpenWithActionInformation: (nullable NSDictionary *)actionInformation additionalData: (nullable NSDictionary *) additionalData; - (void)willAppear:(BOOL)animated; - (void)didAppear:(BOOL)animated; - (void)willDisappear:(BOOL)animated; From 24864bc99db1ea7da95a8441067661c802f7be4d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 9 Oct 2020 10:51:52 -0400 Subject: [PATCH 03/14] Polling top notification --- .../Atomic/Molecules/OtherContainers/MoleculeContainer.swift | 4 ++-- .../Molecules/OtherContainers/MoleculeContainerModel.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/MoleculeContainer.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/MoleculeContainer.swift index 4e2c6279..d6b795ce 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/MoleculeContainer.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/MoleculeContainer.swift @@ -11,11 +11,11 @@ import UIKit open class MoleculeContainer: Container { /// Can be overriden to change how the molecule is added to the hierarchy. - public func addMolecule(_ molecule: UIView) { + open func addMolecule(_ molecule: UIView) { addAndContain(molecule) } - public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let casteModel = model as? MoleculeContainerModelProtocol { if view != nil { (view as? MoleculeViewProtocol)?.set(with: casteModel.molecule, delegateObject, additionalData) diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/MoleculeContainerModel.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/MoleculeContainerModel.swift index aa847f88..77b40716 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/MoleculeContainerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/MoleculeContainerModel.swift @@ -9,7 +9,7 @@ import Foundation open class MoleculeContainerModel: ContainerModel, MoleculeContainerModelProtocol, MoleculeModelProtocol { - public class var identifier: String { + open class var identifier: String { return "container" } public var backgroundColor: Color? @@ -41,7 +41,7 @@ open class MoleculeContainerModel: ContainerModel, MoleculeContainerModelProtoco try super.init(from: decoder) } - public override func encode(to encoder: Encoder) throws { + open 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) From 3b1e3d01c081f914b1b659054b32a06b37dd93cf Mon Sep 17 00:00:00 2001 From: gonch26 Date: Fri, 9 Oct 2020 11:12:30 -0500 Subject: [PATCH 04/14] [ Chatbot: FIX ] Update to remove space between parameter's types --- .../Containers/SplitViewController/MVMCoreUIPanelProtocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h index 9ab2e8ce..8d381b76 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h @@ -17,7 +17,7 @@ - (BOOL)panelAvailable; // Notified when it is appearing and disappearing. Called by the container. -- (void)willOpenWithActionInformation: (nullable NSDictionary *)actionInformation additionalData: (nullable NSDictionary *) additionalData; +- (void)willOpenWithActionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; - (void)willAppear:(BOOL)animated; - (void)didAppear:(BOOL)animated; - (void)willDisappear:(BOOL)animated; From b512b0a20e6e22e7ed2f4f277c536ae5baa9f308 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Sat, 10 Oct 2020 00:16:52 +0530 Subject: [PATCH 05/14] implemented review feedback --- .../FormFields/TextFields/DigitBox.swift | 1 - MVMCoreUI/Atomic/Atoms/Views/Arrow.swift | 1 - MVMCoreUI/Atomic/Atoms/Views/DashLine.swift | 1 - .../Atoms/Views/LeftRightLabelView.swift | 1 - .../Headers/H1/HeadersH1Button.swift | 7 +-- .../Headers/H2/HeadersH2Buttons.swift | 7 +-- .../Headers/H2/HeadersH2CaretLink.swift | 7 +-- .../Headers/H2/HeadersH2Link.swift | 7 +-- .../Headers/H2/HeadersH2PricingTwoRows.swift | 48 ++++++++++--------- .../Headers/H2/HeadersH2TinyButton.swift | 13 +++-- .../LockUps/LockUpsPlanNames.swift | 13 +++-- .../LockUps/LockupsPlanSMLXL.swift | 29 +++++------ .../Molecules/Doughnut/DoughnutChart.swift | 1 - .../RadioButtonLabel.swift | 1 - .../TwoButtonView.swift | 1 - .../TwoLinkView.swift | 1 - .../ActionDetailWithImage.swift | 1 - .../HeadlineBodyButton.swift | 1 - .../ThreeHeadlineBodyLink.swift | 1 - MVMCoreUI/Atomic/Organisms/Stack.swift | 1 - 20 files changed, 66 insertions(+), 77 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift index ec233a44..027550ec 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift @@ -93,7 +93,6 @@ import UIKit required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift index b712d55e..d425214b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift @@ -93,7 +93,6 @@ open class Arrow: View { required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift b/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift index db4ebef9..4239687e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift @@ -42,7 +42,6 @@ open class DashLine: View { required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift index 8f158a15..452a5b7f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift @@ -64,7 +64,6 @@ required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift index 7ccd521b..c3234776 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift @@ -14,13 +14,15 @@ import Foundation //-------------------------------------------------- public let headlineBody = HeadlineBody(frame: .zero) public let buttons = TwoButtonView(frame: .zero) - public let stack: Stack + public lazy var stack: Stack = { + let stack = Stack.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen) + return stack + }() //------------------------------------------------------- // MARK: - Initializers //------------------------------------------------------- public override init(frame: CGRect) { - stack = Stack.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen) super.init(frame: frame) } @@ -29,7 +31,6 @@ import Foundation } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - stack = Stack.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen) super.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift index 0980a518..301d0134 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift @@ -16,14 +16,16 @@ import Foundation public let headlineBody = HeadlineBody() public let buttons = TwoButtonView() - public let stack: Stack + public lazy var stack: Stack = { + let stack = Stack.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3) + return stack + }() //------------------------------------------------------- // MARK: - Initializers //------------------------------------------------------- public override init(frame: CGRect) { - stack = Stack.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3) super.init(frame: frame) } @@ -32,7 +34,6 @@ import Foundation } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - stack = Stack.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3) super.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift index e8fcf603..7161c38a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift @@ -13,13 +13,15 @@ import Foundation //-------------------------------------------------- public let headlineBody = HeadlineBody() public let caretLink = CaretLink() - public let stack: Stack + public lazy var stack: Stack = { + let stack = Stack.createStack(with: [headlineBody, caretLink]) + return stack + }() //------------------------------------------------------- // MARK: - Initializers //------------------------------------------------------- public override init(frame: CGRect) { - stack = Stack.createStack(with: [headlineBody, caretLink]) super.init(frame: frame) } @@ -28,7 +30,6 @@ import Foundation } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - stack = Stack.createStack(with: [headlineBody, caretLink]) super.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift index 0456ac03..e849021f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift @@ -14,13 +14,15 @@ import Foundation //-------------------------------------------------- public let headlineBody = HeadlineBody() public let link = Link() - public let stack: Stack + public lazy var stack: Stack = { + let stack = Stack.createStack(with: [headlineBody, link]) + return stack + }() //------------------------------------------------------- // MARK: - Initializers //------------------------------------------------------- public override init(frame: CGRect) { - stack = Stack.createStack(with: [headlineBody, link]) super.init(frame: frame) } @@ -29,7 +31,6 @@ import Foundation } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - stack = Stack.createStack(with: [headlineBody, link]) super.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift index 000d2a03..5d5413f9 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -21,25 +21,36 @@ import Foundation public let subBody3 = Label(fontStyle: .RegularMicro) public let verticalLine1 = Line() public let verticalLine2 = Line() - public let verticalStack1: Stack - public let verticalStack2: Stack - public let verticalStack3: Stack - public let horizontalStack: Stack - public let stack: Stack + public lazy var verticalStack1: Stack = { + let stack = Stack.createStack(with: [body, subBody], spacing: 0) + return stack + }() + public lazy var verticalStack2: Stack = { + let stack = Stack.createStack(with: [body2, subBody2], spacing: 0) + return stack + }() + public lazy var verticalStack3: Stack = { + let stack = Stack.createStack(with: [body3, subBody3], spacing: 0) + return stack + }() + public lazy var horizontalStack: Stack = { + let stack = Stack.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 29, verticalAlignment: .top)), + (view: verticalLine1, model: StackItemModel(verticalAlignment: .top)), + (view: verticalStack2, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)), + (view: verticalLine2, model: StackItemModel(verticalAlignment: .top)), + (view: verticalStack3, model: StackItemModel(percent: 32, verticalAlignment: .top))], + axis: .horizontal) + return stack + }() + public lazy var stack: Stack = { + let stack = Stack.createStack(with: [headline, horizontalStack], spacing: 8) + return stack + }() //------------------------------------------------------- // MARK: - Initializers //------------------------------------------------------- public override init(frame: CGRect) { - verticalStack1 = Stack.createStack(with: [body, subBody], spacing: 0) - verticalStack2 = Stack.createStack(with: [body2, subBody2], spacing: 0) - verticalStack3 = Stack.createStack(with: [body3, subBody3], spacing: 0) - horizontalStack = Stack.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 29, verticalAlignment: .top)), (view: verticalLine1, model: StackItemModel(verticalAlignment: .top)), - (view: verticalStack2, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)), - (view: verticalLine2, model: StackItemModel(verticalAlignment: .top)), - (view: verticalStack3, model: StackItemModel(percent: 32, verticalAlignment: .top))], - axis: .horizontal) - stack = Stack.createStack(with: [headline, horizontalStack], spacing: 8) super.init(frame: frame) } @@ -48,15 +59,6 @@ import Foundation } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - verticalStack1 = Stack.createStack(with: [body, subBody], spacing: 0) - verticalStack2 = Stack.createStack(with: [body2, subBody2], spacing: 0) - verticalStack3 = Stack.createStack(with: [body3, subBody3], spacing: 0) - horizontalStack = Stack.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 29, verticalAlignment: .top)), (view: verticalLine1, model: StackItemModel(verticalAlignment: .top)), - (view: verticalStack2, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)), - (view: verticalLine2, model: StackItemModel(verticalAlignment: .top)), - (view: verticalStack3, model: StackItemModel(percent: 32, verticalAlignment: .top))], - axis: .horizontal) - stack = Stack.createStack(with: [headline, horizontalStack], spacing: 8) super.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift index f146c2f2..f6042ce5 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift @@ -16,16 +16,18 @@ import Foundation public let headlineBody = HeadlineBody() public let button = PillButton() - public let stack: Stack + public lazy var stack: Stack = { + let stack = Stack.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)), + (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], + axis: .vertical) + return stack + }() //------------------------------------------------------- // MARK: - Initializers //------------------------------------------------------- public override init(frame: CGRect) { - stack = Stack.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)), - (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], - axis: .vertical) super.init(frame: frame) } @@ -34,9 +36,6 @@ import Foundation } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - stack = Stack.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)), - (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], - axis: .vertical) super.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift index c393d134..c97e5d00 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift @@ -15,15 +15,17 @@ import Foundation public let headline = Label(fontStyle: .Title2XLarge) public let subHeadline = Label(fontStyle: .RegularTitleLarge) public let body = Label(fontStyle: .RegularBodySmall) - public let stack: Stack + public lazy var stack: Stack = { + let stack = Stack.createStack(with: [(view: headline, model: StackItemModel()), + (view: subHeadline, model: StackItemModel(spacing: 16)), + (view: body, model: StackItemModel(spacing: 8))]) + return stack + }() //------------------------------------------------------- // MARK: - Initializers //------------------------------------------------------- public override init(frame: CGRect) { - stack = Stack.createStack(with: [(view: headline, model: StackItemModel()), - (view: subHeadline, model: StackItemModel(spacing: 16)), - (view: body, model: StackItemModel(spacing: 8))]) super.init(frame: frame) } @@ -32,9 +34,6 @@ import Foundation } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - stack = Stack.createStack(with: [(view: headline, model: StackItemModel()), - (view: subHeadline, model: StackItemModel(spacing: 16)), - (view: body, model: StackItemModel(spacing: 8))]) super.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift index 90a6b032..8a818f17 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -16,20 +16,24 @@ import Foundation public let headline = Label(fontStyle: .BoldTitleLarge) public let subHeadline = Label(fontStyle: .RegularTitleLarge) public let body = Label(fontStyle: .RegularBodySmall) - public let verticalStack: Stack - public var stack: Stack + public lazy var verticalStack: Stack = { + let stack = Stack.createStack(with: [(view: headline, model: StackItemModel()), + (view: subHeadline, model: StackItemModel()), + (view: body, model: StackItemModel(horizontalAlignment: .fill))], + axis: .vertical, spacing: 0) + return stack + }() + public lazy var stack: Stack = { + let stack = Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)), + (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))], + axis: .horizontal) + return stack + }() //------------------------------------------------------- // MARK: - Initializers //------------------------------------------------------- public override init(frame: CGRect) { - verticalStack = Stack.createStack(with: [(view: headline, model: StackItemModel()), - (view: subHeadline, model: StackItemModel()), - (view: body, model: StackItemModel(horizontalAlignment: .fill))], - axis: .vertical, spacing: 0) - stack = Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)), - (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))], - axis: .horizontal) super.init(frame: frame) } @@ -38,13 +42,6 @@ import Foundation } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - verticalStack = Stack.createStack(with: [(view: headline, model: StackItemModel()), - (view: subHeadline, model: StackItemModel()), - (view: body, model: StackItemModel(horizontalAlignment: .fill))], - axis: .vertical, spacing: 0) - stack = Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)), - (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))], - axis: .horizontal) super.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index 5956aac9..2ee49ceb 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -67,7 +67,6 @@ open class DoughnutChart: View { public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift index 31d099cb..d3e6aa86 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift @@ -30,7 +30,6 @@ import UIKit required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift index d88a49fd..7ea87df8 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -41,7 +41,6 @@ import UIKit required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift index 78dde228..b356274d 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift @@ -36,7 +36,6 @@ import Foundation required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift index 9381e358..8b29bb15 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift @@ -47,7 +47,6 @@ import UIKit required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift index 8b0d03a0..55fd31c0 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift @@ -47,7 +47,6 @@ import UIKit required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift index 93c07673..82029644 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift @@ -38,7 +38,6 @@ open class ThreeHeadlineBodyLink: View { required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index 99766ebc..7b31e45a 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -115,7 +115,6 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) - initialSetup() set(with: model, delegateObject, additionalData) } From b553367dc9d6fd73326c8ad4bc0ed0a53f73e470 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 13 Oct 2020 23:24:21 +0530 Subject: [PATCH 06/14] Removing init from molecules as per Review feedback --- .../Headers/H1/HeadersH1Button.swift | 15 ------------- .../Headers/H2/HeadersH2Buttons.swift | 16 -------------- .../Headers/H2/HeadersH2CaretLink.swift | 15 ------------- .../Headers/H2/HeadersH2Link.swift | 15 ------------- .../Headers/H2/HeadersH2PricingTwoRows.swift | 15 ------------- .../Headers/H2/HeadersH2TinyButton.swift | 16 -------------- .../LockUps/LockUpsPlanNames.swift | 15 ------------- .../LockUps/LockupsPlanSMLXL.swift | 15 ------------- .../Molecules/Doughnut/DoughnutChart.swift | 21 ------------------- .../RadioButtonLabel.swift | 18 ---------------- .../TwoButtonView.swift | 21 ------------------- .../TwoLinkView.swift | 21 ------------------- .../ActionDetailWithImage.swift | 21 ------------------- .../HeadlineBodyButton.swift | 21 ------------------- .../ThreeHeadlineBodyLink.swift | 21 ------------------- 15 files changed, 266 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift index c3234776..74ad3715 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift @@ -19,21 +19,6 @@ import Foundation return stack }() - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) - } - //------------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift index 301d0134..0931fcd9 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift @@ -21,22 +21,6 @@ import Foundation return stack }() - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) - } - //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift index 7161c38a..14d5c61e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift @@ -18,21 +18,6 @@ import Foundation return stack }() - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) - } - //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift index e849021f..e401876a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift @@ -19,21 +19,6 @@ import Foundation return stack }() - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) - } - //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift index 5d5413f9..e8d31ded 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -47,21 +47,6 @@ import Foundation return stack }() - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) - } - //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift index f6042ce5..45b37caf 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift @@ -23,22 +23,6 @@ import Foundation return stack }() - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) - } - //------------------------------------------------------ // MARK: - Constants //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift index c97e5d00..3b6e33c3 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift @@ -22,21 +22,6 @@ import Foundation return stack }() - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) - } - //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift index 8a818f17..53a6288a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -30,21 +30,6 @@ import Foundation return stack }() - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) - } - //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index 2ee49ceb..18de25f1 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -49,27 +49,6 @@ open class DoughnutChart: View { } } - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - public override init(frame: CGRect) { - super.init(frame: .zero) - } - - public convenience init() { - self.init(frame: .zero) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift index d3e6aa86..918871e7 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift @@ -15,24 +15,6 @@ import UIKit var delegateObject: MVMCoreUIDelegateObject? let label = Label() - // MARK: - Inits - public init() { - super.init(frame: .zero) - } - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - public override func updateView(_ size: CGFloat) { super.updateView(size) radioButton.updateView(size) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 7ea87df8..29fb22e8 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -23,27 +23,6 @@ import UIKit private var equalWidthConstraint: NSLayoutConstraint? - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - public init() { - super.init(frame: .zero) - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift index b356274d..09a09dcd 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift @@ -17,27 +17,6 @@ import Foundation open var leftLink = Link() open var rightLink = Link() private var stack = UIStackView() - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - public init() { - super.init(frame: .zero) - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } //-------------------------------------------------- // MARK: - MVMCoreViewProtocol diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift index 8b29bb15..74543d21 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift @@ -29,27 +29,6 @@ import UIKit var imageLeadingConstraint: NSLayoutConstraint? - //------------------------------------------------------ - // MARK: - Initialization - //------------------------------------------------------ - - public init() { - super.init(frame: .zero) - } - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - //------------------------------------------------------ // MARK: - View Lifecycle //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift index 55fd31c0..90d31af0 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift @@ -29,27 +29,6 @@ import UIKit var buttonTopConstraint: NSLayoutConstraint? - //------------------------------------------------------ - // MARK: - Initialization - //------------------------------------------------------ - - public convenience init() { - self.init(frame: .zero) - } - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - //------------------------------------------------------ // MARK: - View Lifecycle //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift index 82029644..ae7d8dab 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLink.swift @@ -20,27 +20,6 @@ open class ThreeHeadlineBodyLink: View { public let body = Label(fontStyle: .RegularBodySmall) public let link = Link() - //------------------------------------------------------ - // MARK: - Initialization - //------------------------------------------------------ - - public convenience init() { - self.init(frame: .zero) - } - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - //------------------------------------------------------ // MARK: - Lifecycle //------------------------------------------------------ From d655cdb3e892c27bec7be85c0d24eed02649b12f Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 13 Oct 2020 23:56:38 +0530 Subject: [PATCH 07/14] Removing init from Atom Views as per Review Feedback. --- .../FormFields/TextFields/DigitBox.swift | 22 -------------- MVMCoreUI/Atomic/Atoms/Views/Arrow.swift | 17 ----------- .../Atomic/Atoms/Views/CheckboxLabel.swift | 29 ------------------- MVMCoreUI/Atomic/Atoms/Views/DashLine.swift | 21 -------------- .../Atoms/Views/LeftRightLabelView.swift | 21 -------------- 5 files changed, 110 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift index 027550ec..7dce16a4 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitBox.swift @@ -74,28 +74,6 @@ import UIKit private weak var widthConstraint: NSLayoutConstraint? private weak var heightConstraint: NSLayoutConstraint? - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - @objc public override init(frame: CGRect) { - super.init(frame: frame) - } - - @objc public convenience init() { - self.init(frame: .zero) - } - - @objc required public init?(coder: NSCoder) { - super.init(coder: coder) - fatalError("DigitBox does not support xibs.") - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift index d425214b..d80c1882 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift @@ -79,23 +79,6 @@ open class Arrow: View { widthConstraint?.isActive = true } - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift index d157cfc9..88ee69be 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift @@ -73,35 +73,6 @@ layoutIfNeeded() } - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - public override init(frame: CGRect) { - super.init(frame: frame) - setupView() - } - - public convenience init() { - self.init(frame: .zero) - } - - public convenience init(position: CheckboxPosition) { - self.init(frame: .zero) - - alignCheckbox(position) - } - - required public init?(coder: NSCoder) { - super.init(coder: coder) - fatalError("xib file is not implemented for CheckboxLabel") - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(model: model, delegateObject, additionalData) - setupView() - } - //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift b/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift index 4239687e..c5a6c09e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift @@ -24,27 +24,6 @@ open class DashLine: View { @objc private var dashLayer: CAShapeLayer? - //------------------------------------------------------ - // MARK: - Initializer - //------------------------------------------------------ - - public override init(frame: CGRect) { - super.init(frame: .zero) - } - - public convenience init() { - self.init(frame: .zero) - } - - required public init?(coder: NSCoder) { - super.init(coder: coder) - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - //------------------------------------------------------ // MARK: - Lifecycle //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift index 452a5b7f..0fa3dc40 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift @@ -46,27 +46,6 @@ rightTextLabelLeading?.isActive = false } - //------------------------------------------------------ - // MARK: - Initialization - //------------------------------------------------------ - - public convenience init() { - self.init(frame: .zero) - } - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.init(frame: .zero) - set(with: model, delegateObject, additionalData) - } - override open func setupView() { super.setupView() From 159798f0d8cbc7134e64b4cb28029e5d0eb88831 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 15 Oct 2020 10:37:36 -0400 Subject: [PATCH 08/14] updates for polling --- .../TopNotification/CollapsableNotificationModel.swift | 8 ++++---- .../Molecules/TopNotification/NotificationModel.swift | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift index 804bfeb6..17b1aef7 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift @@ -8,7 +8,7 @@ import Foundation -public class CollapsableNotificationModel: NotificationModel { +open class CollapsableNotificationModel: NotificationModel { public class override var identifier: String { return "collapsableNotification" } @@ -19,12 +19,12 @@ public class CollapsableNotificationModel: NotificationModel { public var initiallyCollapsed = false public var pages: [String]? - init(with topLabel: LabelModel, headline: LabelModel) { + public init(with topLabel: LabelModel, headline: LabelModel) { self.topLabel = topLabel super.init(with: headline) } - override func setDefault() { + open override func setDefault() { super.setDefault() if topLabel.textColor == nil { topLabel.textColor = Color(uiColor: .white) @@ -61,7 +61,7 @@ public class CollapsableNotificationModel: NotificationModel { try super.init(from: decoder) } - public override func encode(to encoder: Encoder) throws { + open 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/Atomic/Molecules/TopNotification/NotificationModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationModel.swift index e2f94326..70ff00bb 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationModel.swift @@ -8,7 +8,7 @@ import Foundation -public class NotificationModel: MoleculeModelProtocol { +open class NotificationModel: MoleculeModelProtocol { public class var identifier: String { return "notification" } @@ -18,11 +18,11 @@ public class NotificationModel: MoleculeModelProtocol { public var button: ButtonModel? public var closeButton: NotificationXButtonModel? - init(with headline: LabelModel) { + public init(with headline: LabelModel) { self.headline = headline } - func setDefault() { + open func setDefault() { if backgroundColor == nil { backgroundColor = Color(uiColor: .mvmGreen()) } @@ -59,7 +59,7 @@ public class NotificationModel: MoleculeModelProtocol { setDefault() } - public func encode(to encoder: Encoder) throws { + open 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) From b371cf5e8374834ff3dff72ddd6c2f4eb74974bb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 15 Oct 2020 16:36:29 -0400 Subject: [PATCH 09/14] new timers top alert update function --- .../MVMCoreUITopAlertView+Extension.swift | 46 +++++++++++++++---- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 3 ++ MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 6 ++- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index 8bf4860f..5c199c14 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -21,14 +21,17 @@ public extension MVMCoreUITopAlertView { NotificationCenter.default.addObserver(self, selector: #selector(viewControllerChanged(notification:)), name: NSNotification.Name(rawValue: MVMCoreNotificationViewControllerChanged), object: nil) } + @objc func getDelegateObject() -> MVMCoreUIDelegateObject { + // TODO: Top alert view is current delegate. Should move to current view controller eventually? + return MVMCoreUIDelegateObject.create(withDelegateForAll: self) + } + /// Checks for new top alert json @objc func responseJSONUpdated(notification: Notification) { guard let responseJSON = (notification.userInfo?[String(describing: MVMCoreLoadObject.self)] as? MVMCoreLoadObject)?.responseJSON, - let json = responseJSON.optionalDictionaryForKey("TopNotification") else { return } - - // TODO: Top alert view is current delegate. Should move to current view controller eventually? - let delegateObject = MVMCoreUIDelegateObject.create(withDelegateForAll: self) - showTopAlert(with: json, delegateObject: delegateObject) + let json = responseJSON.optionalDictionaryForKey("TopNotification"), + let model = decodeTopNotification(with: json, delegateObject: getDelegateObject()) else { return } + showTopAlert(with: model) } /// When a detail page changes, check top alerts. @@ -37,24 +40,47 @@ public extension MVMCoreUITopAlertView { MVMCoreAlertHandler.shared()?.checkPagesDependency(for: controller.pageType) } - /// Shows the top alert with the json payload. - func showTopAlert(with json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) { + func decodeTopNotification(with json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) -> TopNotificationModel? { do { - let model = try TopNotificationModel.decode(json: json, delegateObject: delegateObject) - showTopAlert(with: model, delegateObject: delegateObject) + return try TopNotificationModel.decode(json: json, delegateObject: delegateObject) } catch { if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "\(self)") { MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) } + return nil } } /// Shows the top alert with the model. - func showTopAlert(with model: TopNotificationModel, delegateObject: MVMCoreUIDelegateObject?) { + func showTopAlert(with model: TopNotificationModel) { let object = model.createTopAlertObject() MVMCoreAlertHandler.shared()?.showTopAlert(with: object) } + @objc func updateMolecule(with topAlertObject: MVMCoreTopAlertObject) { + guard topAlertObject.type == self.topAlertObject?.type else { return } + let delegateObject = getDelegateObject() + guard let newJson = topAlertObject.json, + let newModel = decodeTopNotification(with: newJson, delegateObject: delegateObject), + let newModelName = MoleculeObjectMapping.shared()?.getMoleculeClass(newModel.molecule)?.nameForReuse(with: newModel.molecule, delegateObject), + let currentJson = self.topAlertObject?.json, + let currentModel = decodeTopNotification(with: currentJson, delegateObject: delegateObject), + let currentModelName = MoleculeObjectMapping.shared()?.getMoleculeClass(currentModel.molecule)?.nameForReuse(with: currentModel.molecule, delegateObject), + newModelName == currentModelName, + let molecule = currentAlert as? MoleculeViewProtocol else { return /* Something is not right, revisit */} + // Update molecule + MVMCoreDispatchUtility.performBlock(onMainThread: { + molecule.reset() + molecule.set(with: newModel.molecule, delegateObject, nil) + (molecule as? MVMCoreViewProtocol)?.updateView(self.bounds.width) + + // Update status bar. + guard let statusBarDelegate = molecule as? StatusBarUI else { return } + let statusBarUI = statusBarDelegate.getStatusBarUI() + self.setStatusBarColor(statusBarUI.color, statusBarStyle: statusBarUI.style) + }) + } + /// Returns the top alert molecule to use and status bar color legacy style. @objc func molecule(for topAlertObject: MVMCoreTopAlertObject, statusBarColor: AutoreleasingUnsafeMutablePointer?, statusBarStyle: UnsafeMutablePointer?) -> UIView? { do { diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index 82c0a7e9..1979a850 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -27,6 +27,9 @@ // Current top alert object @property (strong, nullable, nonatomic) MVMCoreTopAlertObject *topAlertObject; +/// Current top alert view. +@property (weak, nullable, nonatomic, readonly) UIView *currentAlert; + // Returns the top alert view + (nullable instancetype)sharedGlobal; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index d54190b0..14f4dee2 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -39,7 +39,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; @property (strong, nonatomic) NSLayoutConstraint *statusBarBottomConstraint; @property (weak, nonatomic) UIView *alertView; -@property (weak, nonatomic) UIView *currentAlert; +@property (weak, nullable, nonatomic, readwrite) UIView *currentAlert; @property (strong, nonatomic) NSLayoutConstraint *height; @property (weak, nonatomic) MVMCoreUITopAlertExpandableView *topAlertClearspotView; @@ -181,6 +181,10 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; }); } +- (void)updateTopAlertWith:(MVMCoreTopAlertObject *)topAlertObject { + [self updateMoleculeWith:topAlertObject]; +} + - (void)setStatusBarColor:(nullable UIColor *)statusBarColor statusBarStyle:(UIStatusBarStyle)style { self.statusBarView.backgroundColor = statusBarColor; self.statusBarStyle = style; From 44c74765425cab5444cef34d26b46235f6ec1331 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 15 Oct 2020 16:51:27 -0400 Subject: [PATCH 10/14] clean --- .../TopAlert/MVMCoreUITopAlertView+Extension.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index 5c199c14..6a3c78de 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -40,6 +40,7 @@ public extension MVMCoreUITopAlertView { MVMCoreAlertHandler.shared()?.checkPagesDependency(for: controller.pageType) } + /// Decodes the json into a TopNotificationModel func decodeTopNotification(with json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) -> TopNotificationModel? { do { return try TopNotificationModel.decode(json: json, delegateObject: delegateObject) @@ -57,6 +58,7 @@ public extension MVMCoreUITopAlertView { MVMCoreAlertHandler.shared()?.showTopAlert(with: object) } + /// Updates the current top alert molecule with the new object @objc func updateMolecule(with topAlertObject: MVMCoreTopAlertObject) { guard topAlertObject.type == self.topAlertObject?.type else { return } let delegateObject = getDelegateObject() @@ -67,9 +69,15 @@ public extension MVMCoreUITopAlertView { let currentModel = decodeTopNotification(with: currentJson, delegateObject: delegateObject), let currentModelName = MoleculeObjectMapping.shared()?.getMoleculeClass(currentModel.molecule)?.nameForReuse(with: currentModel.molecule, delegateObject), newModelName == currentModelName, - let molecule = currentAlert as? MoleculeViewProtocol else { return /* Something is not right, revisit */} - // Update molecule + let molecule = currentAlert as? MoleculeViewProtocol else { + // Log that we couldn't update. + if let errorObject = MVMCoreErrorObject(title: nil, message: nil, messageToLog: nil, code: ErrorCode.parsingJSON.rawValue, domain: ErrorDomainNative, location: "TopNotification update \(String(describing: topAlertObject.type))") { + MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + } + return + } MVMCoreDispatchUtility.performBlock(onMainThread: { + // Update molecule molecule.reset() molecule.set(with: newModel.molecule, delegateObject, nil) (molecule as? MVMCoreViewProtocol)?.updateView(self.bounds.width) From bfa77d70329b4b58e60669322ae27655d7148633 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 20 Oct 2020 00:21:53 +0530 Subject: [PATCH 11/14] implemented review feedback --- .../Headers/H1/HeadersH1Button.swift | 3 +-- .../Headers/H2/HeadersH2Buttons.swift | 3 +-- .../Headers/H2/HeadersH2CaretLink.swift | 3 +-- .../Headers/H2/HeadersH2Link.swift | 3 +-- .../Headers/H2/HeadersH2PricingTwoRows.swift | 25 ++++++++----------- .../Headers/H2/HeadersH2TinyButton.swift | 7 +++--- .../LockUps/LockUpsPlanNames.swift | 7 +++--- .../LockUps/LockupsPlanSMLXL.swift | 16 ++++++------ 8 files changed, 27 insertions(+), 40 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift index 74ad3715..3bd34674 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1Button.swift @@ -15,8 +15,7 @@ import Foundation public let headlineBody = HeadlineBody(frame: .zero) public let buttons = TwoButtonView(frame: .zero) public lazy var stack: Stack = { - let stack = Stack.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen) - return stack + return Stack.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen) }() //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift index 0931fcd9..8604a56b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Buttons.swift @@ -17,8 +17,7 @@ import Foundation public let headlineBody = HeadlineBody() public let buttons = TwoButtonView() public lazy var stack: Stack = { - let stack = Stack.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3) - return stack + return Stack.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3) }() //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift index 14d5c61e..c641ac97 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift @@ -14,8 +14,7 @@ import Foundation public let headlineBody = HeadlineBody() public let caretLink = CaretLink() public lazy var stack: Stack = { - let stack = Stack.createStack(with: [headlineBody, caretLink]) - return stack + return Stack.createStack(with: [headlineBody, caretLink]) }() //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift index e401876a..e90a51f2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2Link.swift @@ -15,8 +15,7 @@ import Foundation public let headlineBody = HeadlineBody() public let link = Link() public lazy var stack: Stack = { - let stack = Stack.createStack(with: [headlineBody, link]) - return stack + return Stack.createStack(with: [headlineBody, link]) }() //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift index e8d31ded..a6d69e24 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -22,29 +22,24 @@ import Foundation public let verticalLine1 = Line() public let verticalLine2 = Line() public lazy var verticalStack1: Stack = { - let stack = Stack.createStack(with: [body, subBody], spacing: 0) - return stack + return Stack.createStack(with: [body, subBody], spacing: 0) }() public lazy var verticalStack2: Stack = { - let stack = Stack.createStack(with: [body2, subBody2], spacing: 0) - return stack + return Stack.createStack(with: [body2, subBody2], spacing: 0) }() public lazy var verticalStack3: Stack = { - let stack = Stack.createStack(with: [body3, subBody3], spacing: 0) - return stack + return Stack.createStack(with: [body3, subBody3], spacing: 0) }() public lazy var horizontalStack: Stack = { - let stack = Stack.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 29, verticalAlignment: .top)), - (view: verticalLine1, model: StackItemModel(verticalAlignment: .top)), - (view: verticalStack2, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)), - (view: verticalLine2, model: StackItemModel(verticalAlignment: .top)), - (view: verticalStack3, model: StackItemModel(percent: 32, verticalAlignment: .top))], - axis: .horizontal) - return stack + return Stack.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 29, verticalAlignment: .top)), + (view: verticalLine1, model: StackItemModel(verticalAlignment: .top)), + (view: verticalStack2, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)), + (view: verticalLine2, model: StackItemModel(verticalAlignment: .top)), + (view: verticalStack3, model: StackItemModel(percent: 32, verticalAlignment: .top))], + axis: .horizontal) }() public lazy var stack: Stack = { - let stack = Stack.createStack(with: [headline, horizontalStack], spacing: 8) - return stack + return Stack.createStack(with: [headline, horizontalStack], spacing: 8) }() //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift index 45b37caf..77a44761 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButton.swift @@ -17,10 +17,9 @@ import Foundation public let headlineBody = HeadlineBody() public let button = PillButton() public lazy var stack: Stack = { - let stack = Stack.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)), - (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], - axis: .vertical) - return stack + return Stack.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)), + (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], + axis: .vertical) }() //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift index 3b6e33c3..fd776ebb 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockUpsPlanNames.swift @@ -16,10 +16,9 @@ import Foundation public let subHeadline = Label(fontStyle: .RegularTitleLarge) public let body = Label(fontStyle: .RegularBodySmall) public lazy var stack: Stack = { - let stack = Stack.createStack(with: [(view: headline, model: StackItemModel()), - (view: subHeadline, model: StackItemModel(spacing: 16)), - (view: body, model: StackItemModel(spacing: 8))]) - return stack + return Stack.createStack(with: [(view: headline, model: StackItemModel()), + (view: subHeadline, model: StackItemModel(spacing: 16)), + (view: body, model: StackItemModel(spacing: 8))]) }() //------------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift index 53a6288a..c0d4c44f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -17,17 +17,15 @@ import Foundation public let subHeadline = Label(fontStyle: .RegularTitleLarge) public let body = Label(fontStyle: .RegularBodySmall) public lazy var verticalStack: Stack = { - let stack = Stack.createStack(with: [(view: headline, model: StackItemModel()), - (view: subHeadline, model: StackItemModel()), - (view: body, model: StackItemModel(horizontalAlignment: .fill))], - axis: .vertical, spacing: 0) - return stack + return Stack.createStack(with: [(view: headline, model: StackItemModel()), + (view: subHeadline, model: StackItemModel()), + (view: body, model: StackItemModel(horizontalAlignment: .fill))], + axis: .vertical, spacing: 0) }() public lazy var stack: Stack = { - let stack = Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)), - (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))], - axis: .horizontal) - return stack + return Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)), + (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))], + axis: .horizontal) }() //------------------------------------------------------- From d9f937c052d17ec8a79b4d6c58dc78b0cc81d11b Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Tue, 20 Oct 2020 18:13:35 +0530 Subject: [PATCH 12/14] Bug fix for CXTDT-129481. When we select the first date from date drop down, the time drop down is not appearing until we select anther date again from the date drop down --- .../Atoms/FormFields/TextFields/ItemDropdownEntryField.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/ItemDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/ItemDropdownEntryField.swift index ddc459c3..47c59dae 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/ItemDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/ItemDropdownEntryField.swift @@ -81,7 +81,9 @@ open class ItemDropdownEntryField: BaseDropdownEntryField { guard !pickerData.isEmpty else { return } if setInitialValueInTextField, let pickerIndex = pickerView?.selectedRow(inComponent: 0) { + observeDropdownChange?(text ?? "", pickerData[pickerIndex]) text = pickerData[pickerIndex] + itemDropdownEntryFieldModel?.selectedIndex = pickerIndex } } From d07dff8a2abefd3ddd77a691b7bc9147b434a557 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 20 Oct 2020 17:04:53 -0400 Subject: [PATCH 13/14] use progressTintColor to prevent progress bar losing color when overlaid. --- .../SplitViewController/MVMCoreUISplitViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index d88641fa..72152c40 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -878,7 +878,7 @@ CGFloat const PanelAnimationDuration = 0.2; // Create bottom progress bar UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; progressView.translatesAutoresizingMaskIntoConstraints = NO; - progressView.tintColor = [UIColor mfTomatoRed]; + progressView.progressTintColor = [UIColor mfTomatoRed]; [self.view addSubview:progressView]; self.bottomProgressBar = progressView; [NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0].active = YES; From 49f376d554ecd2adc2dd5499d0461f32ee602c93 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 21 Oct 2020 11:44:44 -0400 Subject: [PATCH 14/14] Fixes for pages and priority --- .../MVMCoreUITopAlertView+Extension.swift | 61 +++++++++++++++++-- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index 6a3c78de..58a06420 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -21,13 +21,13 @@ public extension MVMCoreUITopAlertView { NotificationCenter.default.addObserver(self, selector: #selector(viewControllerChanged(notification:)), name: NSNotification.Name(rawValue: MVMCoreNotificationViewControllerChanged), object: nil) } - @objc func getDelegateObject() -> MVMCoreUIDelegateObject { + private func getDelegateObject() -> MVMCoreUIDelegateObject { // TODO: Top alert view is current delegate. Should move to current view controller eventually? return MVMCoreUIDelegateObject.create(withDelegateForAll: self) } /// Checks for new top alert json - @objc func responseJSONUpdated(notification: Notification) { + @objc private func responseJSONUpdated(notification: Notification) { guard let responseJSON = (notification.userInfo?[String(describing: MVMCoreLoadObject.self)] as? MVMCoreLoadObject)?.responseJSON, let json = responseJSON.optionalDictionaryForKey("TopNotification"), let model = decodeTopNotification(with: json, delegateObject: getDelegateObject()) else { return } @@ -35,13 +35,43 @@ public extension MVMCoreUITopAlertView { } /// When a detail page changes, check top alerts. - @objc func viewControllerChanged(notification: Notification) { + @objc private func viewControllerChanged(notification: Notification) { guard let controller = MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() as? MVMCoreViewControllerProtocol else { return } - MVMCoreAlertHandler.shared()?.checkPagesDependency(for: controller.pageType) + MVMCoreAlertHandler.shared()?.handleAllPagesDependency(for: controller.pageType) + reevalutePriority() + } + + /// Re-evaluates the queue priority + private func reevalutePriority() { + guard let operations = MVMCoreAlertHandler.shared()?.topAlertQueue.operations else { return } + var highestReadyOperation: Operation? + var executingOperation: Operation? + for operation in operations { + guard !operation.isCancelled, + !operation.isFinished else { + continue + } + if operation.isReady, + highestReadyOperation == nil || operation.queuePriority.rawValue > highestReadyOperation!.queuePriority.rawValue { + highestReadyOperation = operation + } + if operation.isExecuting { + executingOperation = operation + } + } + + // If the highest priority operation is not executing, and the executing operation is persistent, cancel it. + if let newOperation = highestReadyOperation, + let currentOperation = executingOperation as? MVMCoreTopAlertOperation, + currentOperation != newOperation, + currentOperation.topAlertObject.persistent { + currentOperation.reAddAfterCancel = true + currentOperation.cancel() + } } /// Decodes the json into a TopNotificationModel - func decodeTopNotification(with json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) -> TopNotificationModel? { + private func decodeTopNotification(with json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) -> TopNotificationModel? { do { return try TopNotificationModel.decode(json: json, delegateObject: delegateObject) } catch { @@ -55,7 +85,26 @@ public extension MVMCoreUITopAlertView { /// Shows the top alert with the model. func showTopAlert(with model: TopNotificationModel) { let object = model.createTopAlertObject() - MVMCoreAlertHandler.shared()?.showTopAlert(with: object) + guard !checkAndUpdateExisting(with: object), + let operation = MVMCoreTopAlertOperation(topAlertObject: object) else { return } + MVMCoreAlertHandler.shared()?.addPagesDependency(to: operation) + MVMCoreAlertHandler.shared()?.handlePageDependency(for: operation, with: (MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() as? MVMCoreViewControllerProtocol)?.pageType) + MVMCoreAlertHandler.shared()?.add(operation) + } + + /// Checks for existing top alert object of same type and updates it. Only happens for molecular top alerts. Returns true if we updated. + private func checkAndUpdateExisting(with topAlertObject: MVMCoreTopAlertObject) -> Bool { + guard let queue = MVMCoreAlertHandler.shared()?.topAlertQueue.operations else { return false } + for case let operation as MVMCoreTopAlertOperation in queue { + guard topAlertObject.json != nil, + operation.topAlertObject.type == topAlertObject.type else { continue } + operation.update(with: topAlertObject) + MVMCoreAlertHandler.shared()?.updatePages(for: operation, with: topAlertObject) + MVMCoreAlertHandler.shared()?.handlePageDependency(for: operation, with: (MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() as? MVMCoreViewControllerProtocol)?.pageType) + reevalutePriority() + return true + } + return false } /// Updates the current top alert molecule with the new object