From e4436b4e29d457079ca9ebb3eb8bd62a3292b861 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 16 Jun 2020 19:42:16 +0530 Subject: [PATCH 1/5] 19223(iOS - Headers - H2 - Pricing - Two Rows) initial commit. Added model and molecule class files. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../Headers/HeadersH2PricingTwoRows.swift | 95 +++++++++++++++++++ .../HeadersH2PricingTwoRowsModel.swift | 90 ++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRows.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRowsModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3af65c10..9e306fad 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -201,6 +201,8 @@ AA56A211243C5EFC00303286 /* ListTwoColumnSubsectionDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA56A210243C5EFC00303286 /* ListTwoColumnSubsectionDivider.swift */; }; AA617AB02453010A00910B8F /* ListDeviceComplexLinkSmall.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA617AAF2453010A00910B8F /* ListDeviceComplexLinkSmall.swift */; }; AA617AB22453012400910B8F /* ListDeviceComplexLinkSmallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA617AB12453012400910B8F /* ListDeviceComplexLinkSmallModel.swift */; }; + AA633B3124989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA633B3024989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift */; }; + AA633B3324989ED500731E80 /* HeadersH2PricingTwoRows.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA633B3224989ED500731E80 /* HeadersH2PricingTwoRows.swift */; }; AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA69AAF52445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift */; }; AA69AAF82445BF6800AF3D3B /* ListLeftVariableCheckboxBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA69AAF72445BF6800AF3D3B /* ListLeftVariableCheckboxBodyTextModel.swift */; }; AA7F32AB246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA7F32AA246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift */; }; @@ -646,6 +648,8 @@ AA56A210243C5EFC00303286 /* ListTwoColumnSubsectionDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTwoColumnSubsectionDivider.swift; sourceTree = ""; }; AA617AAF2453010A00910B8F /* ListDeviceComplexLinkSmall.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexLinkSmall.swift; sourceTree = ""; }; AA617AB12453012400910B8F /* ListDeviceComplexLinkSmallModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexLinkSmallModel.swift; sourceTree = ""; }; + AA633B3024989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2PricingTwoRowsModel.swift; sourceTree = ""; }; + AA633B3224989ED500731E80 /* HeadersH2PricingTwoRows.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2PricingTwoRows.swift; sourceTree = ""; }; AA69AAF52445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxBodyText.swift; sourceTree = ""; }; AA69AAF72445BF6800AF3D3B /* ListLeftVariableCheckboxBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxBodyTextModel.swift; sourceTree = ""; }; AA7F32AA246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonAllTextAndLinksModel.swift; sourceTree = ""; }; @@ -1038,6 +1042,8 @@ AA26850B244840AE00CE34CC /* HeadersH2TinyButton.swift */, AA104B1B24474A76004D2810 /* HeadersH2ButtonsModel.swift */, AA104B1924474A66004D2810 /* HeadersH2Buttons.swift */, + AA633B3024989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift */, + AA633B3224989ED500731E80 /* HeadersH2PricingTwoRows.swift */, ); path = Headers; sourceTree = ""; @@ -2217,6 +2223,7 @@ 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, D264FA8E243BCD9A00D98315 /* CollectionTemplate.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, + AA633B3124989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift in Sources */, 8DEFA95C243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift in Sources */, D2092357244FA1EF0044AD09 /* ThreeLayerModelBase.swift in Sources */, 0A1B4A96233BB18F005B3FB4 /* CheckboxLabel.swift in Sources */, @@ -2433,6 +2440,7 @@ 0A25209824645B76000FA9F6 /* TextViewEntryFieldModel.swift in Sources */, 525019DD2406430800EED91C /* ListProgressBarDataModel.swift in Sources */, C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */, + AA633B3324989ED500731E80 /* HeadersH2PricingTwoRows.swift in Sources */, 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */, 0A6682A22434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift in Sources */, EA5124FD243601600051A3A4 /* BGImageHeadlineBodyButton.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 98b1e6a3..2c5f54e6 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -206,6 +206,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2TinyButton.self, viewModelClass: HeadersH2TinyButtonModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2Buttons.self, viewModelClass: HeadersH2ButtonsModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2PricingTwoRows.self, viewModelClass: HeadersH2PricingTwoRowsModel.self) // Device Items MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexButtonMedium.self, viewModelClass: ListDeviceComplexButtonMediumModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRows.swift new file mode 100644 index 00000000..9d861fe2 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRows.swift @@ -0,0 +1,95 @@ +// +// HeadersH2PricingTwoRows.swift +// MVMCoreUI +// +// Created by Lekshmi S on 16/06/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class HeadersH2PricingTwoRows: HeaderView { + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + public let headline = Label(fontStyle: .H2) + public let body = Label(fontStyle: .B2) + public let subBody = Label(fontStyle: .B3) + public let body2 = Label(fontStyle: .B2) + public let subBody2 = Label(fontStyle: .B3) + public let body3 = Label(fontStyle: .B2) + public let subBody3 = Label(fontStyle: .B3) + 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 + + //------------------------------------------------------- + // 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, horizontalAlignment: .leading, verticalAlignment: .top)), (view: verticalLine1, model: StackItemModel(percent: 2, verticalAlignment: .top)), + (view: verticalStack2, model: StackItemModel(percent: 33, horizontalAlignment: .center, verticalAlignment: .top)), + (view: verticalLine2, model: StackItemModel(percent: 2, verticalAlignment: .top)), + (view: verticalStack3, model: StackItemModel(percent: 34, horizontalAlignment: .center, verticalAlignment: .top))], + axis: .horizontal) + stack = Stack.createStack(with: [headline, horizontalStack], spacing: 8) + super.init(frame: frame) + } + + public required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------- + // MARK: - Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + verticalLine1.widthConstraint?.isActive = true + verticalLine1.backgroundColor = .mvmBlack + verticalLine1.heightConstraint?.constant = 13 + verticalLine2.widthConstraint?.isActive = true + verticalLine2.backgroundColor = .mvmBlack + verticalLine2.heightConstraint?.constant = 13 + addMolecule(stack) + stack.restack() + verticalStack1.restack() + verticalStack2.restack() + verticalStack3.restack() + horizontalStack.restack() + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? HeadersH2PricingTwoRowsModel else { return } + headline.set(with: model.headline, delegateObject, additionalData) + verticalStack1.updateContainedMolecules(with: [model.body, model.subBody], delegateObject, additionalData) + verticalStack2.updateContainedMolecules(with: [model.body2, model.subBody2], delegateObject, additionalData) + verticalStack3.updateContainedMolecules(with: [model.body3, model.subBody3], delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 121 + } + + open override func reset() { + super.reset() + headline.setFontStyle(.H2) + body.setFontStyle(.B2) + subBody.setFontStyle(.B3) + body2.setFontStyle(.B2) + subBody2.setFontStyle(.B3) + body3.setFontStyle(.B2) + subBody3.setFontStyle(.B3) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRowsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRowsModel.swift new file mode 100644 index 00000000..6991bf03 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRowsModel.swift @@ -0,0 +1,90 @@ +// +// HeadersH2PricingTwoRowsModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 16/06/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "headerH2TwoRows" + public var headline: LabelModel + public var body: LabelModel + public var subBody: LabelModel? + public var body2: LabelModel + public var subBody2: LabelModel? + public var body3: LabelModel + public var subBody3: LabelModel? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(headline: LabelModel, body: LabelModel, subBody: LabelModel? = nil, body2: LabelModel, subBody2: LabelModel? = nil, body3: LabelModel, subBody3: LabelModel? = nil) { + self.headline = headline + self.body = body + self.subBody = subBody + self.body2 = body2 + self.subBody2 = subBody2 + self.body3 = body3 + self.subBody3 = subBody3 + super.init() + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + public override func setDefaults() { + super.setDefaults() + body.hero = 0 + subBody?.attributes = [LabelAttributeStrikeThroughModel(0, subBody?.text.count ?? 0)] + subBody2?.attributes = [LabelAttributeStrikeThroughModel(0, subBody2?.text.count ?? 0)] + subBody3?.attributes = [LabelAttributeStrikeThroughModel(0, subBody3?.text.count ?? 0)] + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case moleculeName + case headline + case body + case subBody + case body2 + case subBody2 + case body3 + case subBody3 + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + headline = try typeContainer.decode(LabelModel.self, forKey: .headline) + body = try typeContainer.decode(LabelModel.self, forKey: .body) + subBody = try typeContainer.decode(LabelModel.self, forKey: .subBody) + body2 = try typeContainer.decode(LabelModel.self, forKey: .body2) + subBody2 = try typeContainer.decode(LabelModel.self, forKey: .subBody2) + body3 = try typeContainer.decode(LabelModel.self, forKey: .body3) + subBody3 = try typeContainer.decode(LabelModel.self, forKey: .subBody3) + try super.init(from: decoder) + } + + 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.encode(headline, forKey: .headline) + try container.encode(body, forKey: .body) + try container.encode(subBody, forKey: .subBody) + try container.encode(body2, forKey: .body2) + try container.encode(subBody2, forKey: .subBody2) + try container.encode(body3, forKey: .body3) + try container.encode(subBody3, forKey: .subBody3) + } +} From a5e6941c30d6c99c44164f79d4e5482d5ece641e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 23 Jun 2020 12:12:02 -0400 Subject: [PATCH 2/5] re-arrage code --- .../Headers/H2/HeadersH2PricingTwoRows.swift | 121 ++++++++++++++++++ .../H2/HeadersH2PricingTwoRowsModel.swift | 89 +++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift new file mode 100644 index 00000000..12097880 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -0,0 +1,121 @@ +// +// HeadersH2PricingTwoRows.swift +// MVMCoreUI +// +// Created by Lekshmi S on 16/06/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class HeadersH2PricingTwoRows: HeaderView { + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + public let headline = Label(fontStyle: .RegularTitleLarge) + public let body = Label(fontStyle: .RegularMicro) + public let subBody = Label(fontStyle: .RegularMicro) + public let body2 = Label(fontStyle: .RegularMicro) + public let subBody2 = Label(fontStyle: .RegularMicro) + public let body3 = Label(fontStyle: .RegularMicro) + 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 + + //------------------------------------------------------- + // 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) + } + + public required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------- + // MARK: - Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + setDefaults() + body.numberOfLines = 1 + body.lineBreakMode = .byTruncatingTail + body2.numberOfLines = 1 + body2.lineBreakMode = .byTruncatingTail + body3.numberOfLines = 1 + body3.lineBreakMode = .byTruncatingTail + + verticalLine1.widthConstraint?.isActive = true + verticalLine1.backgroundColor = .mvmBlack + verticalLine2.widthConstraint?.isActive = true + verticalLine2.backgroundColor = .mvmBlack + + addMolecule(stack) + stack.restack() + verticalStack1.restack() + verticalStack2.restack() + verticalStack3.restack() + horizontalStack.restack() + setLineHeight() + } + + open func setDefaults() { + headline.setFontStyle(.BoldTitleLarge) + body.setFontStyle(.RegularMicro) + subBody.setFontStyle(.RegularMicro) + body2.setFontStyle(.RegularMicro) + subBody2.setFontStyle(.RegularMicro) + body3.setFontStyle(.RegularMicro) + subBody3.setFontStyle(.RegularMicro) + subBody.textColor = .mvmCoolGray6 + subBody2.textColor = .mvmCoolGray6 + subBody3.textColor = .mvmCoolGray6 + } + + open func setLineHeight() { + verticalLine1.heightConstraint?.isActive = false + verticalLine1.heightConstraint = verticalLine1.heightAnchor.constraint(equalTo: body2.heightAnchor, multiplier: 1) + verticalLine1.heightConstraint?.isActive = true + + verticalLine2.heightConstraint?.isActive = false + verticalLine2.heightConstraint = verticalLine2.heightAnchor.constraint(equalTo: body3.heightAnchor, multiplier: 1) + verticalLine2.heightConstraint?.isActive = true + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? HeadersH2PricingTwoRowsModel else { return } + headline.set(with: model.headline, delegateObject, additionalData) + verticalStack1.updateContainedMolecules(with: [model.body, model.subBody], delegateObject, additionalData) + verticalStack2.updateContainedMolecules(with: [model.body2, model.subBody2], delegateObject, additionalData) + verticalStack3.updateContainedMolecules(with: [model.body3, model.subBody3], delegateObject, additionalData) + setLineHeight() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 121 + } + + open override func reset() { + super.reset() + setDefaults() + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift new file mode 100644 index 00000000..219f539f --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift @@ -0,0 +1,89 @@ +// +// HeadersH2PricingTwoRowsModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 16/06/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "headerH2TwoRows" + public var headline: LabelModel + public var body: LabelModel + public var subBody: LabelModel? + public var body2: LabelModel + public var subBody2: LabelModel? + public var body3: LabelModel + public var subBody3: LabelModel? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(headline: LabelModel, body: LabelModel, subBody: LabelModel? = nil, body2: LabelModel, subBody2: LabelModel? = nil, body3: LabelModel, subBody3: LabelModel? = nil) { + self.headline = headline + self.body = body + self.subBody = subBody + self.body2 = body2 + self.subBody2 = subBody2 + self.body3 = body3 + self.subBody3 = subBody3 + super.init() + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + public override func setDefaults() { + super.setDefaults() + subBody?.attributes = [LabelAttributeStrikeThroughModel(0, subBody?.text.count ?? 0)] + subBody2?.attributes = [LabelAttributeStrikeThroughModel(0, subBody2?.text.count ?? 0)] + subBody3?.attributes = [LabelAttributeStrikeThroughModel(0, subBody3?.text.count ?? 0)] + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case moleculeName + case headline + case body + case subBody + case body2 + case subBody2 + case body3 + case subBody3 + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + headline = try typeContainer.decode(LabelModel.self, forKey: .headline) + body = try typeContainer.decode(LabelModel.self, forKey: .body) + subBody = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .subBody) + body2 = try typeContainer.decode(LabelModel.self, forKey: .body2) + subBody2 = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .subBody2) + body3 = try typeContainer.decode(LabelModel.self, forKey: .body3) + subBody3 = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .subBody3) + try super.init(from: decoder) + } + + 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.encode(headline, forKey: .headline) + try container.encode(body, forKey: .body) + try container.encodeIfPresent(subBody, forKey: .subBody) + try container.encode(body2, forKey: .body2) + try container.encodeIfPresent(subBody2, forKey: .subBody2) + try container.encode(body3, forKey: .body3) + try container.encodeIfPresent(subBody3, forKey: .subBody3) + } +} From 384158e8556dce41f6a2b635f070044831ceb8c6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 23 Jun 2020 12:13:19 -0400 Subject: [PATCH 3/5] align --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index afac04c7..d483d10c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1511,7 +1511,7 @@ AA26850B244840AE00CE34CC /* HeadersH2TinyButton.swift */, AA104B1B24474A76004D2810 /* HeadersH2ButtonsModel.swift */, AA104B1924474A66004D2810 /* HeadersH2Buttons.swift */, - AA633B3024989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift */, + AA633B3024989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift */, AA633B3224989ED500731E80 /* HeadersH2PricingTwoRows.swift */, ); path = H2; From 3add9702c68505f55b3bb783c5d172954dd464e8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 23 Jun 2020 12:14:10 -0400 Subject: [PATCH 4/5] move files --- .../Headers/HeadersH2PricingTwoRows.swift | 95 ------------------- 1 file changed, 95 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRows.swift diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRows.swift deleted file mode 100644 index 9d861fe2..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRows.swift +++ /dev/null @@ -1,95 +0,0 @@ -// -// HeadersH2PricingTwoRows.swift -// MVMCoreUI -// -// Created by Lekshmi S on 16/06/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -@objcMembers open class HeadersH2PricingTwoRows: HeaderView { - //-------------------------------------------------- - // MARK: - Outlets - //-------------------------------------------------- - public let headline = Label(fontStyle: .H2) - public let body = Label(fontStyle: .B2) - public let subBody = Label(fontStyle: .B3) - public let body2 = Label(fontStyle: .B2) - public let subBody2 = Label(fontStyle: .B3) - public let body3 = Label(fontStyle: .B2) - public let subBody3 = Label(fontStyle: .B3) - 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 - - //------------------------------------------------------- - // 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, horizontalAlignment: .leading, verticalAlignment: .top)), (view: verticalLine1, model: StackItemModel(percent: 2, verticalAlignment: .top)), - (view: verticalStack2, model: StackItemModel(percent: 33, horizontalAlignment: .center, verticalAlignment: .top)), - (view: verticalLine2, model: StackItemModel(percent: 2, verticalAlignment: .top)), - (view: verticalStack3, model: StackItemModel(percent: 34, horizontalAlignment: .center, verticalAlignment: .top))], - axis: .horizontal) - stack = Stack.createStack(with: [headline, horizontalStack], spacing: 8) - super.init(frame: frame) - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - //------------------------------------------------------- - // MARK: - Lifecycle - //------------------------------------------------------- - open override func setupView() { - super.setupView() - verticalLine1.widthConstraint?.isActive = true - verticalLine1.backgroundColor = .mvmBlack - verticalLine1.heightConstraint?.constant = 13 - verticalLine2.widthConstraint?.isActive = true - verticalLine2.backgroundColor = .mvmBlack - verticalLine2.heightConstraint?.constant = 13 - addMolecule(stack) - stack.restack() - verticalStack1.restack() - verticalStack2.restack() - verticalStack3.restack() - horizontalStack.restack() - } - - //---------------------------------------------------- - // MARK: - Molecule - //------------------------------------------------------ - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? HeadersH2PricingTwoRowsModel else { return } - headline.set(with: model.headline, delegateObject, additionalData) - verticalStack1.updateContainedMolecules(with: [model.body, model.subBody], delegateObject, additionalData) - verticalStack2.updateContainedMolecules(with: [model.body2, model.subBody2], delegateObject, additionalData) - verticalStack3.updateContainedMolecules(with: [model.body3, model.subBody3], delegateObject, additionalData) - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 121 - } - - open override func reset() { - super.reset() - headline.setFontStyle(.H2) - body.setFontStyle(.B2) - subBody.setFontStyle(.B3) - body2.setFontStyle(.B2) - subBody2.setFontStyle(.B3) - body3.setFontStyle(.B2) - subBody3.setFontStyle(.B3) - } -} From 17af164cd9a6c2b52e841ed39cb16cefac46854b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 23 Jun 2020 12:14:37 -0400 Subject: [PATCH 5/5] move files --- .../HeadersH2PricingTwoRowsModel.swift | 90 ------------------- 1 file changed, 90 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRowsModel.swift diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRowsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRowsModel.swift deleted file mode 100644 index 6991bf03..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2PricingTwoRowsModel.swift +++ /dev/null @@ -1,90 +0,0 @@ -// -// HeadersH2PricingTwoRowsModel.swift -// MVMCoreUI -// -// Created by Lekshmi S on 16/06/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - public static var identifier: String = "headerH2TwoRows" - public var headline: LabelModel - public var body: LabelModel - public var subBody: LabelModel? - public var body2: LabelModel - public var subBody2: LabelModel? - public var body3: LabelModel - public var subBody3: LabelModel? - - //-------------------------------------------------- - // MARK: - Initializer - //-------------------------------------------------- - public init(headline: LabelModel, body: LabelModel, subBody: LabelModel? = nil, body2: LabelModel, subBody2: LabelModel? = nil, body3: LabelModel, subBody3: LabelModel? = nil) { - self.headline = headline - self.body = body - self.subBody = subBody - self.body2 = body2 - self.subBody2 = subBody2 - self.body3 = body3 - self.subBody3 = subBody3 - super.init() - } - - //-------------------------------------------------- - // MARK: - Methods - //-------------------------------------------------- - public override func setDefaults() { - super.setDefaults() - body.hero = 0 - subBody?.attributes = [LabelAttributeStrikeThroughModel(0, subBody?.text.count ?? 0)] - subBody2?.attributes = [LabelAttributeStrikeThroughModel(0, subBody2?.text.count ?? 0)] - subBody3?.attributes = [LabelAttributeStrikeThroughModel(0, subBody3?.text.count ?? 0)] - } - - //-------------------------------------------------- - // MARK: - Keys - //-------------------------------------------------- - private enum CodingKeys: String, CodingKey { - case moleculeName - case headline - case body - case subBody - case body2 - case subBody2 - case body3 - case subBody3 - } - - //-------------------------------------------------- - // MARK: - Codec - //-------------------------------------------------- - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - headline = try typeContainer.decode(LabelModel.self, forKey: .headline) - body = try typeContainer.decode(LabelModel.self, forKey: .body) - subBody = try typeContainer.decode(LabelModel.self, forKey: .subBody) - body2 = try typeContainer.decode(LabelModel.self, forKey: .body2) - subBody2 = try typeContainer.decode(LabelModel.self, forKey: .subBody2) - body3 = try typeContainer.decode(LabelModel.self, forKey: .body3) - subBody3 = try typeContainer.decode(LabelModel.self, forKey: .subBody3) - try super.init(from: decoder) - } - - 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.encode(headline, forKey: .headline) - try container.encode(body, forKey: .body) - try container.encode(subBody, forKey: .subBody) - try container.encode(body2, forKey: .body2) - try container.encode(subBody2, forKey: .subBody2) - try container.encode(body3, forKey: .body3) - try container.encode(subBody3, forKey: .subBody3) - } -}