From b49579d05965983403a2baf96e4436dc70f791ae Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 14 May 2020 10:52:17 -0400 Subject: [PATCH] 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) } }