diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/OrderTracker.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/OrderTracker.swift index 716a3968..af66cc8f 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/OrderTracker.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/OrderTracker.swift @@ -62,7 +62,7 @@ open class OrderTracker: View { if i == stepModels.count - 1 { bottomAnchor.constraint(equalTo: step.bottomAnchor).isActive = true - step.imageBottomConstraint?.isActive = false + step.imageBottomConstraint?.constant = 0 } previousStep = step @@ -75,6 +75,7 @@ open class OrderTracker: View { $0.reset() $0.removeFromSuperview() } + steps = [] } @@ -84,27 +85,39 @@ open class OrderTracker: View { open override func draw(_ rect: CGRect) { - guard let context = UIGraphicsGetCurrentContext(), let firstStep = steps.first else { return } + guard let context = UIGraphicsGetCurrentContext(), + let firstStep = steps.first + else { return } context.setLineWidth(1) let firstRect = convert(firstStep.stateImage.frame, from: firstStep.stateImage) let imageDimension = firstStep.stateImage.bounds.height - let startPoint = CGPoint(x: imageDimension / 2, y: firstRect.size.height - imageDimension / 2) + let halfDimension = imageDimension / 2 + let startPoint = CGPoint(x: halfDimension, y: firstRect.size.height - halfDimension) + let defaultGrey: UIColor = .mvmCoolGray3 context.move(to: startPoint) - var lineColor = (firstStep.state?.color() ?? .mvmCoolGray3).cgColor + var lineColor = (firstStep.state?.color() ?? defaultGrey).cgColor - for step in steps.dropFirst() { + for (i, step) in steps.dropFirst().enumerated() { + + if let state = step.state, state == .incomplete { + lineColor = defaultGrey.cgColor + } context.setStrokeColor(lineColor) let relativeOrigin = convert(step.stateImage.frame, from: step.stateImage) - let point = CGPoint(x: imageDimension / 2, y: relativeOrigin.origin.y + imageDimension / 2) + let point = CGPoint(x: halfDimension, y: relativeOrigin.origin.y + halfDimension) context.addLine(to: point) context.strokePath() - let nextPoint = CGPoint(x: imageDimension / 2, y: relativeOrigin.origin.y + imageDimension) - lineColor = (step.state?.color() ?? .mvmCoolGray3).cgColor + if i == steps.count - 2 { + break + } + + let nextPoint = CGPoint(x: halfDimension, y: relativeOrigin.origin.y + imageDimension) + lineColor = (step.state?.color() ?? defaultGrey).cgColor context.move(to: nextPoint) } } @@ -114,7 +127,7 @@ open class OrderTracker: View { //------------------------------------------------------ public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 320 + return 196 } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/Step.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/Step.swift index 0304129d..6414609b 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/Step.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/Step.swift @@ -81,7 +81,7 @@ open class Step: View { bodyTop.text = "" bodyBottom.text = "" stateImage.image = nil - imageBottomConstraint?.isActive = true + imageBottomConstraint?.constant = Padding.Ten } //------------------------------------------------------ @@ -89,7 +89,7 @@ open class Step: View { //------------------------------------------------------ public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 320 + return 64 } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/StepModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/StepModel.swift index 915e860a..3fa25d22 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/StepModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Order Tracker/StepModel.swift @@ -51,7 +51,7 @@ open class StepModel: MoleculeModelProtocol { case .complete: return .mvmGreen - case .incomplete,.invalid: + case .incomplete, .invalid: return .mvmCoolGray3 } }