From 23bd844e8e53d98eaadf21c865b96dcb7dbadeb9 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Thu, 19 Mar 2020 14:55:33 +0530 Subject: [PATCH] Folder structure changes and conforming to headerView and headermodel. --- MVMCoreUI.xcodeproj/project.pbxproj | 12 ++++----- .../{ => Headers}/HeadersH2TinyButton.swift | 19 ++++++------- .../HeadersH2TinyButtonModel.swift | 27 +++++++++++-------- 3 files changed, 30 insertions(+), 28 deletions(-) rename MVMCoreUI/Molecules/DesignedComponents/{ => Headers}/HeadersH2TinyButton.swift (85%) rename MVMCoreUI/Molecules/DesignedComponents/{ => Headers}/HeadersH2TinyButtonModel.swift (81%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 08213989..11a46857 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -175,6 +175,8 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; + AA573B092418BA2000FFCB65 /* HeadersH2TinyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA573B082418BA2000FFCB65 /* HeadersH2TinyButton.swift */; }; + AA573B0B2418BA2C00FFCB65 /* HeadersH2TinyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA573B0A2418BA2C00FFCB65 /* HeadersH2TinyButtonModel.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 */; }; @@ -183,8 +185,6 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; - AA573B092418BA2000FFCB65 /* HeadersH2TinyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA573B082418BA2000FFCB65 /* HeadersH2TinyButton.swift */; }; - AA573B0B2418BA2C00FFCB65 /* HeadersH2TinyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA573B0A2418BA2C00FFCB65 /* HeadersH2TinyButtonModel.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 */; }; @@ -561,6 +561,8 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; 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 = ""; }; + AA573B082418BA2000FFCB65 /* HeadersH2TinyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2TinyButton.swift; sourceTree = ""; }; + AA573B0A2418BA2C00FFCB65 /* HeadersH2TinyButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2TinyButtonModel.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 = ""; }; @@ -569,8 +571,6 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTall.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = SOURCE_ROOT; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; - AA573B082418BA2000FFCB65 /* HeadersH2TinyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2TinyButton.swift; sourceTree = ""; }; - AA573B0A2418BA2C00FFCB65 /* HeadersH2TinyButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2TinyButtonModel.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 = ""; }; @@ -912,6 +912,8 @@ children = ( AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */, AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */, + AA573B082418BA2000FFCB65 /* HeadersH2TinyButton.swift */, + AA573B0A2418BA2C00FFCB65 /* HeadersH2TinyButtonModel.swift */, ); path = Headers; sourceTree = ""; @@ -1187,8 +1189,6 @@ 525239C32407FFCC00454969 /* LockUps */, D22B38EC23F4E10700490EF6 /* SectionDividers */, D22B38EA23F4E08B00490EF6 /* List */, - AA573B082418BA2000FFCB65 /* HeadersH2TinyButton.swift */, - AA573B0A2418BA2C00FFCB65 /* HeadersH2TinyButtonModel.swift */, ); path = DesignedComponents; sourceTree = ""; diff --git a/MVMCoreUI/Molecules/DesignedComponents/HeadersH2TinyButton.swift b/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2TinyButton.swift similarity index 85% rename from MVMCoreUI/Molecules/DesignedComponents/HeadersH2TinyButton.swift rename to MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2TinyButton.swift index bc6c34e8..bbb52de2 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/HeadersH2TinyButton.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2TinyButton.swift @@ -8,13 +8,17 @@ import Foundation -@objcMembers open class HeadersH2TinyButton: View { +@objcMembers open class HeadersH2TinyButton: HeaderView { //-------------------------------------------------- // MARK: - Outlets //-------------------------------------------------- let headlineBody = HeadlineBody(frame: .zero) - let button = PrimaryButton(frame: .zero) + let button = PrimaryButton.button() var stack = Stack(frame: .zero) + + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------ var spacingBetwenHeadlineBodyAndButton: CGFloat = 16.0 //------------------------------------------------------- @@ -25,14 +29,8 @@ import Foundation stack = Stack.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .leading)), (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], axis: .vertical) headlineBody.stylePageHeader() - addSubview(stack) - NSLayoutConstraint.constraintPinSubview(toSuperview: stack) - } - - open override func updateView(_ size: CGFloat) { - super.updateView(size) - stack.updateView(size) - button.updateView(size) + addMolecule(stack) + stack.restack() } //---------------------------------------------------- @@ -43,7 +41,6 @@ import Foundation guard let model = model as? HeadersH2TinyButtonModel 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/HeadersH2TinyButtonModel.swift b/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2TinyButtonModel.swift similarity index 81% rename from MVMCoreUI/Molecules/DesignedComponents/HeadersH2TinyButtonModel.swift rename to MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2TinyButtonModel.swift index 14a8d891..28048fa1 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/HeadersH2TinyButtonModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2TinyButtonModel.swift @@ -8,13 +8,12 @@ import Foundation -public class HeadersH2TinyButtonModel: MoleculeModelProtocol { +public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- public static var identifier: String = "headerH2BtnTny" - public var backgroundColor: Color? public var headlineBody: HeadlineBodyModel public var button: ButtonModel @@ -24,6 +23,18 @@ public class HeadersH2TinyButtonModel: MoleculeModelProtocol { public init(headlineBody: HeadlineBodyModel, button: ButtonModel) { self.headlineBody = headlineBody self.button = button + super.init() + } + + public override func setDefaults() { + super.setDefaults() + topMarginPadding = PaddingDefaultVerticalSpacing3 + bottomMarginPadding = PaddingDefaultVerticalSpacing3 + //default secondary tiny + if button.style == nil { + button.style = .secondary + } + button.size = .tiny } //-------------------------------------------------- @@ -31,7 +42,6 @@ public class HeadersH2TinyButtonModel: MoleculeModelProtocol { //-------------------------------------------------- private enum CodingKeys: String, CodingKey { case moleculeName - case backgroundColor case headlineBody case button } @@ -41,20 +51,15 @@ public class HeadersH2TinyButtonModel: 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) - //default secondary tiny - if button.style == nil { - button.style = .secondary - } - button.size = .tiny + 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) }