From f58b57e145900ee68dec07dae007f9356cd96f27 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 18 Mar 2020 10:04:37 +0530 Subject: [PATCH] Folder structure changes and conforming to headerView and headermodel --- MVMCoreUI.xcodeproj/project.pbxproj | 12 ++++++------ .../{ => Headers}/HeadersH1Button.swift | 16 +++++----------- .../{ => Headers}/HeadersH1ButtonModel.swift | 14 ++++++-------- .../OtherHandlers/MoleculeObjectMapping.swift | 3 +-- 4 files changed, 18 insertions(+), 27 deletions(-) rename MVMCoreUI/Molecules/DesignedComponents/{ => Headers}/HeadersH1Button.swift (79%) rename MVMCoreUI/Molecules/DesignedComponents/{ => Headers}/HeadersH1ButtonModel.swift (82%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 44bed63f..5b69472d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -175,10 +175,10 @@ AA119DEA240FB430005F98FD /* HeadersH1ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA119DE9240FB430005F98FD /* HeadersH1ButtonModel.swift */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; - BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; - BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; + BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; + BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; @@ -554,10 +554,10 @@ AA119DE9240FB430005F98FD /* HeadersH1ButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1ButtonModel.swift; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; - BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; - BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; + BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; + BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; @@ -898,6 +898,8 @@ children = ( AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */, AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */, + AA119DE7240FB41C005F98FD /* HeadersH1Button.swift */, + AA119DE9240FB430005F98FD /* HeadersH1ButtonModel.swift */, ); path = Headers; sourceTree = ""; @@ -1159,8 +1161,6 @@ 525239C32407FFCC00454969 /* LockUps */, D22B38EC23F4E10700490EF6 /* SectionDividers */, D22B38EA23F4E08B00490EF6 /* List */, - AA119DE7240FB41C005F98FD /* HeadersH1Button.swift */, - AA119DE9240FB430005F98FD /* HeadersH1ButtonModel.swift */, ); path = DesignedComponents; sourceTree = ""; diff --git a/MVMCoreUI/Molecules/DesignedComponents/HeadersH1Button.swift b/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH1Button.swift similarity index 79% rename from MVMCoreUI/Molecules/DesignedComponents/HeadersH1Button.swift rename to MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH1Button.swift index 0600cf1e..0abf9673 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/HeadersH1Button.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH1Button.swift @@ -8,14 +8,13 @@ import Foundation -@objcMembers open class HeadersH1Button: View { +@objcMembers open class HeadersH1Button: HeaderView { //-------------------------------------------------- // MARK: - Outlets //-------------------------------------------------- let headlineBody = HeadlineBody(frame: .zero) let button = PrimaryButton.button() var stack = Stack(frame: .zero) - var spacingBetwenHeadlineBodyAndButton: CGFloat = 72.0 //------------------------------------------------------- // MARK: - View Lifecycle @@ -23,14 +22,10 @@ import Foundation open override func setupView() { super.setupView() stack = Stack.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .leading)), - (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], axis: .vertical) - addSubview(stack) - NSLayoutConstraint.constraintPinSubview(toSuperview: stack) - } - - open override func updateView(_ size: CGFloat) { - super.updateView(size) - stack.updateView(size) + (view: button, model: StackItemModel(spacing: 72, horizontalAlignment: .leading))], axis: .vertical) + headlineBody.styleLandingPageHeader() + addMolecule(stack) + stack.restack() } //---------------------------------------------------- @@ -41,7 +36,6 @@ import Foundation guard let model = model as? HeadersH1ButtonModel else { return } headlineBody.set(with: model.headlineBody, delegateObject, additionalData) button.set(with: model.button, delegateObject, additionalData) - stack.restack() } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Molecules/DesignedComponents/HeadersH1ButtonModel.swift b/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH1ButtonModel.swift similarity index 82% rename from MVMCoreUI/Molecules/DesignedComponents/HeadersH1ButtonModel.swift rename to MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH1ButtonModel.swift index 48e639a4..d008bab2 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/HeadersH1ButtonModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH1ButtonModel.swift @@ -8,22 +8,21 @@ import Foundation -public class HeadersH1ButtonModel: MoleculeModelProtocol { +public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public static var identifier: String = "headerH1Btn" - public var backgroundColor: Color? public var headlineBody: HeadlineBodyModel public var button: ButtonModel - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(headlineBody: HeadlineBodyModel, button: ButtonModel) { self.headlineBody = headlineBody self.button = button + super.init() } //-------------------------------------------------- @@ -31,7 +30,6 @@ public class HeadersH1ButtonModel: MoleculeModelProtocol { //-------------------------------------------------- private enum CodingKeys: String, CodingKey { case moleculeName - case backgroundColor case headlineBody case button } @@ -41,15 +39,15 @@ public class HeadersH1ButtonModel: MoleculeModelProtocol { //-------------------------------------------------- required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) button = try typeContainer.decode(ButtonModel.self, forKey: .button) + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(headlineBody, forKey: .headlineBody) try container.encode(button, forKey: .button) } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 2c89d4b5..26abaccc 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -111,8 +111,6 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH1Button.self, viewModelClass: HeadersH1ButtonModel.self) - // Designed Section Dividers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) @@ -120,6 +118,7 @@ import Foundation // Designed Headers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH1Button.self, viewModelClass: HeadersH1ButtonModel.self) // TODO: Need model MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString)