latest updates

This commit is contained in:
Kevin G Christiano 2020-07-13 15:45:48 -04:00
parent e714a6ff12
commit db5f51dd92
3 changed files with 25 additions and 12 deletions

View File

@ -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]?) {

View File

@ -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]?) {

View File

@ -51,7 +51,7 @@ open class StepModel: MoleculeModelProtocol {
case .complete:
return .mvmGreen
case .incomplete,.invalid:
case .incomplete, .invalid:
return .mvmCoolGray3
}
}