From b00e9bcf0351a16e009b22d67627f2066f3f75a1 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Jul 2020 13:24:37 -0400 Subject: [PATCH] laets state --- .../Order Tracker/OrderTrackerModel.swift | 6 ++--- .../Order Tracker/Step.swift | 19 ++++++++++++++++ MVMCoreUI/BaseClasses/ImageView.swift | 22 +++++++++---------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/OrderTrackerModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/OrderTrackerModel.swift index 14582f81..fee4ce97 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/OrderTrackerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/OrderTrackerModel.swift @@ -17,7 +17,7 @@ open class OrderTrackerModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "orderTracker" - public var steps: [StepModel]? + public var steps: [StepModel] //-------------------------------------------------- // MARK: - Keys @@ -36,13 +36,13 @@ open class OrderTrackerModel: MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - steps = try typeContainer.decodeIfPresent([StepModel].self, forKey: .steps) + steps = try typeContainer.decode([StepModel].self, forKey: .steps) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(steps, forKey: .steps) + try container.encode(steps, forKey: .steps) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/Step.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/Step.swift index 6d111bfb..06a8a94a 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/Step.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/Step.swift @@ -42,9 +42,28 @@ open class Step: View { open override func setupView() { super.setupView() + addSubview(stateImage) + addSubview(headline) + addSubview(bodyTop) + addSubview(bodyBottom) + stateImage.topAnchor.constraint(equalTo: topAnchor).isActive = true stateImage.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true + stateImage.heightAnchor.constraint(equalToConstant: 18).isActive = true + stateImage.widthAnchor.constraint(equalToConstant: 18).isActive = true + headline.topAnchor.constraint(equalTo: topAnchor).isActive = true + headline.leadingAnchor.constraint(equalTo: stateImage.trailingAnchor, constant: Padding.Four).isActive = true + trailingAnchor.constraint(equalTo: headline.trailingAnchor).isActive = true + + bodyTop.topAnchor.constraint(equalTo: headline.bottomAnchor).isActive = true + bodyTop.leadingAnchor.constraint(equalTo: stateImage.trailingAnchor, constant: Padding.Four).isActive = true + trailingAnchor.constraint(equalTo: bodyTop.trailingAnchor).isActive = true + + bodyBottom.topAnchor.constraint(equalTo: bodyTop.bottomAnchor).isActive = true + bodyBottom.leadingAnchor.constraint(equalTo: stateImage.trailingAnchor, constant: Padding.Four).isActive = true + trailingAnchor.constraint(equalTo: bodyBottom.trailingAnchor).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: bodyBottom.bottomAnchor).isActive = true } public override func reset() { diff --git a/MVMCoreUI/BaseClasses/ImageView.swift b/MVMCoreUI/BaseClasses/ImageView.swift index 079f67cf..66e5aacb 100644 --- a/MVMCoreUI/BaseClasses/ImageView.swift +++ b/MVMCoreUI/BaseClasses/ImageView.swift @@ -51,6 +51,17 @@ open class ImageView: UIImageView, MoleculeViewProtocol { } } + /// Will be called only once. + open func setupView() { + translatesAutoresizingMaskIntoConstraints = false + insetsLayoutMarginsFromSafeArea = false + MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0) + } + + open func reset() { + backgroundColor = .clear + } + //-------------------------------------------------- // MARK: - MoleculeViewProtocol //-------------------------------------------------- @@ -76,16 +87,5 @@ open class ImageView: UIImageView, MoleculeViewProtocol { open func updateView(_ size: CGFloat) { } - /// Will be called only once. - open func setupView() { - translatesAutoresizingMaskIntoConstraints = false - insetsLayoutMarginsFromSafeArea = false - MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0) - } - - open func reset() { - backgroundColor = .clear - } - open func setAsMolecule() { } }