From 3cbd9b53a8646c38720573fd0a893652a9c60b99 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 12 May 2020 18:56:10 +0530 Subject: [PATCH 1/5] 18972(iOS - List - ProgressBar - Thin) story initial commit. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../List/ListProgressBarThin.swift | 89 +++++++++++++++++++ .../List/ListProgressBarThinModel.swift | 69 ++++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ec7e68b0..35697500 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -196,6 +196,8 @@ AA85236C244435A20059CC1E /* RadioSwatchCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA85236B244435A20059CC1E /* RadioSwatchCollectionViewCell.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; + AAB7EDEF246ADA1600E54929 /* ListProgressBarThinModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB7EDEE246ADA1600E54929 /* ListProgressBarThinModel.swift */; }; + AAB7EDF1246ADA2A00E54929 /* ListProgressBarThin.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB7EDF0246ADA2A00E54929 /* ListProgressBarThin.swift */; }; AAB9C10824346F4B00151545 /* RadioSwatches.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB9C10724346F4B00151545 /* RadioSwatches.swift */; }; AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB9C109243496DD00151545 /* RadioSwatch.swift */; }; AAC6F167243332E400F295C1 /* RadioSwatchesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC6F166243332E400F295C1 /* RadioSwatchesModel.swift */; }; @@ -607,6 +609,8 @@ AA85236B244435A20059CC1E /* RadioSwatchCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatchCollectionViewCell.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 = ""; }; + AAB7EDEE246ADA1600E54929 /* ListProgressBarThinModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListProgressBarThinModel.swift; sourceTree = ""; }; + AAB7EDF0246ADA2A00E54929 /* ListProgressBarThin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListProgressBarThin.swift; sourceTree = ""; }; AAB9C10724346F4B00151545 /* RadioSwatches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatches.swift; sourceTree = ""; }; AAB9C109243496DD00151545 /* RadioSwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatch.swift; sourceTree = ""; }; AAC6F166243332E400F295C1 /* RadioSwatchesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatchesModel.swift; sourceTree = ""; }; @@ -1240,6 +1244,8 @@ D20492F12434CB5F00A5EED6 /* FourColumn */, AA4FC2A323F4F69600E251DB /* RightVariable */, D22B38EB23F4E0AE00490EF6 /* LeftVariable */, + AAB7EDEE246ADA1600E54929 /* ListProgressBarThinModel.swift */, + AAB7EDF0246ADA2A00E54929 /* ListProgressBarThin.swift */, ); path = List; sourceTree = ""; @@ -2180,6 +2186,7 @@ C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, + AAB7EDF1246ADA2A00E54929 /* ListProgressBarThin.swift in Sources */, 8D070BB2241B56AD0099AC56 /* ListRightVariableTotalData.swift in Sources */, D264FAA5243F66A500D98315 /* CollectionTemplateItemProtocol.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, @@ -2264,6 +2271,7 @@ EA5124FD243601600051A3A4 /* BGImageHeadlineBodyButton.swift in Sources */, 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, + AAB7EDEF246ADA1600E54929 /* ListProgressBarThinModel.swift in Sources */, D21B7F75243BAC8900051ABF /* CarouselItem.swift in Sources */, C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */, 8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index a9e86d50..cb108207 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -162,6 +162,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsage.self, viewModelClass: ListThreeColumnDataUsageModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListProgressBarThin.self, viewModelClass: ListProgressBarThinModel.self) // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift new file mode 100644 index 00000000..69e26ea2 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -0,0 +1,89 @@ +// +// ListProgressBarThin.swift +// MVMCoreUI +// +// Created by Lekshmi S on 12/05/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListProgressBarThin: TableViewCell { + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + let progressBar = ProgressBar() + let leftHeadline = Label.commonLabelB1(true) + let leftBody = Label.commonLabelB2(true) + let leftBody2 = Label.commonLabelB2(true) + let bar = Line() + let rightLabel = Label.commonLabelB2(true) + public var horizontalStack: Stack + public var verticalStack: Stack + public var stack: Stack + + //------------------------------------------------------ + // MARK: - Initializers + //------------------------------------------------------ + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + verticalStack = Stack.createStack(with: [(view: leftHeadline, model: StackItemModel(horizontalAlignment: .leading)), + (view: leftBody, model: StackItemModel(horizontalAlignment: .leading)), + (view: leftBody2, model: StackItemModel(horizontalAlignment: .leading))], + axis: .vertical, spacing: 0) + horizontalStack = Stack.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading)), + (view: bar, model: StackItemModel(horizontalAlignment: .fill)), (view: rightLabel, model: StackItemModel(spacing: 5, horizontalAlignment: .fill))], + axis: .horizontal) + stack = Stack.createStack(with: [(view: horizontalStack, model: StackItemModel(horizontalAlignment: .fill)), (view: progressBar, model: StackItemModel(spacing: 20, horizontalAlignment: .fill))], axis: .vertical) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + open override func alignAccessoryToHero() -> CGPoint? { + let heroCenter = super.alignAccessoryToHero() + return heroCenter + } + + //------------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + bar.widthAnchor.constraint(equalToConstant: 20).isActive = true + rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.numberOfLines = 1 + addMolecule(stack) + stack.restack() + horizontalStack.restack() + verticalStack.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? ListProgressBarThinModel else { return } + verticalStack.updateContainedMolecules(with: [model.leftHeadline, + model.leftBody, + model.leftBody2],delegateObject, additionalData) + progressBar.set(with: model.progressBar, delegateObject, additionalData) + bar.set(with: model.bar, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 120 + } + + open override func reset() { + super.reset() + leftHeadline.styleB1(true) + leftBody.styleB2(true) + leftBody2.styleB2(true) + rightLabel.styleB2(true) + bar.setStyle(.medium) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift new file mode 100644 index 00000000..2e0b7cdb --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -0,0 +1,69 @@ +// +// ListProgressBarThinModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 12/05/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { + public static var identifier = "listPrgBarThin" + public var progressBar: ProgressBarModel + public var leftHeadline: LabelModel? + public var leftBody: LabelModel? + public var leftBody2: LabelModel? + public var bar: LineModel + public var rightLabel: LabelModel + + public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel, leftBody2: LabelModel, bar: LineModel, rightLabel: LabelModel) { + self.progressBar = progressBar + self.leftHeadline = leftHeadline + self.leftBody = leftBody + self.leftBody2 = leftBody2 + self.bar = bar + self.rightLabel = rightLabel + super.init() + } + + override public func setDefaults() { + super.setDefaults() + bar.type = .medium + if bar.backgroundColor == nil { + bar.backgroundColor = Color(uiColor: .gray) + } + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case progressBar + case leftHeadline + case leftBody + case leftBody2 + case line + case rightLabel + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + progressBar = try typeContainer.decode(ProgressBarModel.self, forKey:.progressBar) + leftHeadline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftHeadline) + leftBody = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody) + leftBody2 = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody2) + bar = try typeContainer.decode(LineModel.self, forKey: .line) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + 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(progressBar, forKey: .progressBar) + try container.encodeIfPresent(leftHeadline, forKey: .leftHeadline) + try container.encodeIfPresent(leftBody, forKey: .leftBody) + try container.encodeIfPresent(leftBody2, forKey: .leftBody2) + try container.encode(bar, forKey: .line) + try container.encode(rightLabel, forKey: .rightLabel) + } +} From 3fce526c90c556d72a6c8e391894e1ac899d7d8b Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 13 May 2020 15:52:50 +0530 Subject: [PATCH 2/5] Code changes for aligning rightlabel with leftheadline. --- .../List/ListProgressBarThin.swift | 30 +++++++++++++++---- .../List/ListProgressBarThinModel.swift | 3 ++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index 69e26ea2..73561ec1 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -17,6 +17,8 @@ import Foundation let leftBody2 = Label.commonLabelB2(true) let bar = Line() let rightLabel = Label.commonLabelB2(true) + private let barStackItem: StackItem + private let rightLabelStackItem: StackItem public var horizontalStack: Stack public var verticalStack: Stack public var stack: Stack @@ -25,14 +27,25 @@ import Foundation // MARK: - Initializers //------------------------------------------------------ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - verticalStack = Stack.createStack(with: [(view: leftHeadline, model: StackItemModel(horizontalAlignment: .leading)), - (view: leftBody, model: StackItemModel(horizontalAlignment: .leading)), - (view: leftBody2, model: StackItemModel(horizontalAlignment: .leading))], + //vertical stack with leftHeadline, leftBody, leftBody2 + let verticalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading), StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .leading)], axis: .vertical, spacing: 0) - horizontalStack = Stack.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading)), - (view: bar, model: StackItemModel(horizontalAlignment: .fill)), (view: rightLabel, model: StackItemModel(spacing: 5, horizontalAlignment: .fill))], + let verticalStackItems = [StackItem(andContain: leftHeadline), StackItem(andContain: leftBody), StackItem(andContain: leftBody2)] + verticalStack = Stack(with: verticalStackModel, stackItems: verticalStackItems) + + //horizontal stack with leftHeadline, leftBody, leftBody2, bar, rightLabel + let horizontalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .fill), StackItemModel(spacing: 5, horizontalAlignment: .fill)], axis: .horizontal) - stack = Stack.createStack(with: [(view: horizontalStack, model: StackItemModel(horizontalAlignment: .fill)), (view: progressBar, model: StackItemModel(spacing: 20, horizontalAlignment: .fill))], axis: .vertical) + barStackItem = StackItem(andContain: bar) + rightLabelStackItem = StackItem(andContain: rightLabel) + let horizontalStackItems = [StackItem(andContain: verticalStack), barStackItem, rightLabelStackItem] + horizontalStack = Stack(with: horizontalStackModel, stackItems: horizontalStackItems) + + //stack with all components + let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), + StackItemModel(spacing: 20, horizontalAlignment: .fill)], axis: .vertical) + let stackItems = [StackItem(andContain: horizontalStack), StackItem(andContain: progressBar)] + stack = Stack(with: stackModel, stackItems: stackItems) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -42,6 +55,11 @@ import Foundation open override func alignAccessoryToHero() -> CGPoint? { let heroCenter = super.alignAccessoryToHero() + if let heroCenter = heroCenter { + let convertedPoint = horizontalStack.convert(heroCenter, from: self) + barStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - horizontalStack.bounds.midY + rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - horizontalStack.bounds.midY + } return heroCenter } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index 2e0b7cdb..7bed74b1 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -32,6 +32,9 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { if bar.backgroundColor == nil { bar.backgroundColor = Color(uiColor: .gray) } + if let leftHeadline = leftHeadline { + leftHeadline.hero = 0 + } } private enum CodingKeys: String, CodingKey { From e217970a0417c992676c342256c913094bfe0408 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 13 May 2020 19:41:17 +0530 Subject: [PATCH 3/5] Updated code as per confluence changes. --- .../List/ListProgressBarThin.swift | 21 ++++++------------- .../List/ListProgressBarThinModel.swift | 7 +------ 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index 73561ec1..901e5b2d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -14,7 +14,6 @@ import Foundation let progressBar = ProgressBar() let leftHeadline = Label.commonLabelB1(true) let leftBody = Label.commonLabelB2(true) - let leftBody2 = Label.commonLabelB2(true) let bar = Line() let rightLabel = Label.commonLabelB2(true) private let barStackItem: StackItem @@ -27,25 +26,19 @@ import Foundation // MARK: - Initializers //------------------------------------------------------ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - //vertical stack with leftHeadline, leftBody, leftBody2 - let verticalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading), StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .leading)], - axis: .vertical, spacing: 0) - let verticalStackItems = [StackItem(andContain: leftHeadline), StackItem(andContain: leftBody), StackItem(andContain: leftBody2)] - verticalStack = Stack(with: verticalStackModel, stackItems: verticalStackItems) + //vertical stack with leftHeadline, leftBody + verticalStack = Stack.createStack(with: [leftHeadline, leftBody], axis: .vertical, spacing: 2) - //horizontal stack with leftHeadline, leftBody, leftBody2, bar, rightLabel + //horizontal stack with leftHeadline, leftBody, bar, rightLabel let horizontalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .fill), StackItemModel(spacing: 5, horizontalAlignment: .fill)], axis: .horizontal) barStackItem = StackItem(andContain: bar) rightLabelStackItem = StackItem(andContain: rightLabel) let horizontalStackItems = [StackItem(andContain: verticalStack), barStackItem, rightLabelStackItem] horizontalStack = Stack(with: horizontalStackModel, stackItems: horizontalStackItems) - + //stack with all components - let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), - StackItemModel(spacing: 20, horizontalAlignment: .fill)], axis: .vertical) - let stackItems = [StackItem(andContain: horizontalStack), StackItem(andContain: progressBar)] - stack = Stack(with: stackModel, stackItems: stackItems) + stack = Stack.createStack(with: [horizontalStack, progressBar], axis: .vertical, spacing: PaddingDefaultVerticalSpacing3) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -85,8 +78,7 @@ import Foundation super.set(with: model, delegateObject, additionalData) guard let model = model as? ListProgressBarThinModel else { return } verticalStack.updateContainedMolecules(with: [model.leftHeadline, - model.leftBody, - model.leftBody2],delegateObject, additionalData) + model.leftBody], delegateObject, additionalData) progressBar.set(with: model.progressBar, delegateObject, additionalData) bar.set(with: model.bar, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) @@ -100,7 +92,6 @@ import Foundation super.reset() leftHeadline.styleB1(true) leftBody.styleB2(true) - leftBody2.styleB2(true) rightLabel.styleB2(true) bar.setStyle(.medium) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index 7bed74b1..5c9c507b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -12,15 +12,13 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { public var progressBar: ProgressBarModel public var leftHeadline: LabelModel? public var leftBody: LabelModel? - public var leftBody2: LabelModel? public var bar: LineModel public var rightLabel: LabelModel - public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel, leftBody2: LabelModel, bar: LineModel, rightLabel: LabelModel) { + public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel, bar: LineModel, rightLabel: LabelModel) { self.progressBar = progressBar self.leftHeadline = leftHeadline self.leftBody = leftBody - self.leftBody2 = leftBody2 self.bar = bar self.rightLabel = rightLabel super.init() @@ -42,7 +40,6 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { case progressBar case leftHeadline case leftBody - case leftBody2 case line case rightLabel } @@ -52,7 +49,6 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { progressBar = try typeContainer.decode(ProgressBarModel.self, forKey:.progressBar) leftHeadline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftHeadline) leftBody = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody) - leftBody2 = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody2) bar = try typeContainer.decode(LineModel.self, forKey: .line) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) try super.init(from: decoder) @@ -65,7 +61,6 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { try container.encode(progressBar, forKey: .progressBar) try container.encodeIfPresent(leftHeadline, forKey: .leftHeadline) try container.encodeIfPresent(leftBody, forKey: .leftBody) - try container.encodeIfPresent(leftBody2, forKey: .leftBody2) try container.encode(bar, forKey: .line) try container.encode(rightLabel, forKey: .rightLabel) } From 77a99e99c9cff8f4eab6b3700c7e1d048bd1d7bb Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Thu, 14 May 2020 15:43:19 +0530 Subject: [PATCH 4/5] Code changes: made headline as required key and body as optional. --- .../List/ListProgressBarThinModel.swift | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index 5c9c507b..44d11479 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -10,12 +10,12 @@ import Foundation public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { public static var identifier = "listPrgBarThin" public var progressBar: ProgressBarModel - public var leftHeadline: LabelModel? + public var leftHeadline: LabelModel public var leftBody: LabelModel? public var bar: LineModel public var rightLabel: LabelModel - public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel, bar: LineModel, rightLabel: LabelModel) { + public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, bar: LineModel, rightLabel: LabelModel) { self.progressBar = progressBar self.leftHeadline = leftHeadline self.leftBody = leftBody @@ -30,9 +30,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { if bar.backgroundColor == nil { bar.backgroundColor = Color(uiColor: .gray) } - if let leftHeadline = leftHeadline { - leftHeadline.hero = 0 - } + leftHeadline.hero = 0 } private enum CodingKeys: String, CodingKey { @@ -47,7 +45,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) progressBar = try typeContainer.decode(ProgressBarModel.self, forKey:.progressBar) - leftHeadline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftHeadline) + leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) leftBody = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody) bar = try typeContainer.decode(LineModel.self, forKey: .line) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) @@ -59,7 +57,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(progressBar, forKey: .progressBar) - try container.encodeIfPresent(leftHeadline, forKey: .leftHeadline) + try container.encode(leftHeadline, forKey: .leftHeadline) try container.encodeIfPresent(leftBody, forKey: .leftBody) try container.encode(bar, forKey: .line) try container.encode(rightLabel, forKey: .rightLabel) From b49579d05965983403a2baf96e4436dc70f791ae Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 14 May 2020 10:52:17 -0400 Subject: [PATCH 5/5] line fix, small clean --- .../List/ListProgressBarThin.swift | 31 ++++++++++--------- .../List/ListProgressBarThinModel.swift | 18 +++++------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index 901e5b2d..072be6bb 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -11,15 +11,15 @@ import Foundation //-------------------------------------------------- // MARK: - Outlets //-------------------------------------------------- - let progressBar = ProgressBar() - let leftHeadline = Label.commonLabelB1(true) - let leftBody = Label.commonLabelB2(true) - let bar = Line() - let rightLabel = Label.commonLabelB2(true) + public let progressBar = ProgressBar() + public let leftHeadline = Label.commonLabelB1(true) + public let leftBody = Label.commonLabelB2(true) + public let rightBar = Line() + public let rightLabel = Label.commonLabelB2(true) private let barStackItem: StackItem private let rightLabelStackItem: StackItem + public var labelStack: Stack public var horizontalStack: Stack - public var verticalStack: Stack public var stack: Stack //------------------------------------------------------ @@ -27,14 +27,14 @@ import Foundation //------------------------------------------------------ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { //vertical stack with leftHeadline, leftBody - verticalStack = Stack.createStack(with: [leftHeadline, leftBody], axis: .vertical, spacing: 2) + labelStack = Stack.createStack(with: [leftHeadline, leftBody], axis: .vertical, spacing: 2) //horizontal stack with leftHeadline, leftBody, bar, rightLabel + barStackItem = StackItem(andContain: rightBar) + rightLabelStackItem = StackItem(andContain: rightLabel) + let horizontalStackItems = [StackItem(andContain: labelStack), barStackItem, rightLabelStackItem] let horizontalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .fill), StackItemModel(spacing: 5, horizontalAlignment: .fill)], axis: .horizontal) - barStackItem = StackItem(andContain: bar) - rightLabelStackItem = StackItem(andContain: rightLabel) - let horizontalStackItems = [StackItem(andContain: verticalStack), barStackItem, rightLabelStackItem] horizontalStack = Stack(with: horizontalStackModel, stackItems: horizontalStackItems) //stack with all components @@ -47,6 +47,7 @@ import Foundation } open override func alignAccessoryToHero() -> CGPoint? { + // Ensures that the right items are centered with the arrow. let heroCenter = super.alignAccessoryToHero() if let heroCenter = heroCenter { let convertedPoint = horizontalStack.convert(heroCenter, from: self) @@ -61,14 +62,14 @@ import Foundation //------------------------------------------------------- open override func setupView() { super.setupView() - bar.widthAnchor.constraint(equalToConstant: 20).isActive = true + rightBar.widthAnchor.constraint(equalToConstant: 20).isActive = true rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() horizontalStack.restack() - verticalStack.restack() + labelStack.restack() } //------------------------------------------------------ @@ -77,10 +78,10 @@ import Foundation open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListProgressBarThinModel else { return } - verticalStack.updateContainedMolecules(with: [model.leftHeadline, + labelStack.updateContainedMolecules(with: [model.leftHeadline, model.leftBody], delegateObject, additionalData) progressBar.set(with: model.progressBar, delegateObject, additionalData) - bar.set(with: model.bar, delegateObject, additionalData) + rightBar.set(with: model.rightBar, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) } @@ -93,6 +94,6 @@ import Foundation leftHeadline.styleB1(true) leftBody.styleB2(true) rightLabel.styleB2(true) - bar.setStyle(.medium) + rightBar.setStyle(.medium) } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index 44d11479..acd8e013 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -12,23 +12,23 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { public var progressBar: ProgressBarModel public var leftHeadline: LabelModel public var leftBody: LabelModel? - public var bar: LineModel + public var rightBar: LineModel public var rightLabel: LabelModel - public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, bar: LineModel, rightLabel: LabelModel) { + public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, rightBar: LineModel, rightLabel: LabelModel) { self.progressBar = progressBar self.leftHeadline = leftHeadline self.leftBody = leftBody - self.bar = bar + self.rightBar = rightBar self.rightLabel = rightLabel super.init() } override public func setDefaults() { super.setDefaults() - bar.type = .medium - if bar.backgroundColor == nil { - bar.backgroundColor = Color(uiColor: .gray) + rightBar.type = .medium + if rightBar.backgroundColor == nil { + rightBar.backgroundColor = Color(uiColor: .gray) } leftHeadline.hero = 0 } @@ -38,7 +38,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { case progressBar case leftHeadline case leftBody - case line + case rightBar case rightLabel } @@ -47,7 +47,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { progressBar = try typeContainer.decode(ProgressBarModel.self, forKey:.progressBar) leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) leftBody = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody) - bar = try typeContainer.decode(LineModel.self, forKey: .line) + rightBar = try typeContainer.decode(LineModel.self, forKey: .rightBar) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) try super.init(from: decoder) } @@ -59,7 +59,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { try container.encode(progressBar, forKey: .progressBar) try container.encode(leftHeadline, forKey: .leftHeadline) try container.encodeIfPresent(leftBody, forKey: .leftBody) - try container.encode(bar, forKey: .line) + try container.encode(rightBar, forKey: .rightBar) try container.encode(rightLabel, forKey: .rightLabel) } }