latest order tracker

This commit is contained in:
Kevin G Christiano 2020-07-06 15:40:14 -04:00
parent f5f91684cd
commit 088595305c
19 changed files with 366 additions and 71 deletions

View File

@ -108,6 +108,9 @@
0AB764D324460FA400E7FE72 /* UIPickerView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AB764D224460FA400E7FE72 /* UIPickerView+Extension.swift */; };
0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; };
0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; };
0AC16CEB24B3A1080085EF34 /* Step.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC16CEA24B3A1080085EF34 /* Step.swift */; };
0AC16CED24B3A11C0085EF34 /* StepModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC16CEC24B3A11C0085EF34 /* StepModel.swift */; };
0AC16CEE24B3A39C0085EF34 /* ImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7918F423F5E7EA00772FF4 /* ImageView.swift */; };
0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; };
0AE98BAF23FEF956004C5109 /* ExternalLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BAE23FEF956004C5109 /* ExternalLink.swift */; };
0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */; };
@ -568,6 +571,8 @@
0AB764D224460FA400E7FE72 /* UIPickerView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIPickerView+Extension.swift"; sourceTree = "<group>"; };
0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = "<group>"; };
0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = "<group>"; };
0AC16CEA24B3A1080085EF34 /* Step.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Step.swift; sourceTree = "<group>"; };
0AC16CEC24B3A11C0085EF34 /* StepModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepModel.swift; sourceTree = "<group>"; };
0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; };
0AE98BAE23FEF956004C5109 /* ExternalLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLink.swift; sourceTree = "<group>"; };
0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkModel.swift; sourceTree = "<group>"; };
@ -1031,6 +1036,17 @@
path = Views;
sourceTree = "<group>";
};
0AC16CE924B3A0ED0085EF34 /* Order Tracker */ = {
isa = PBXGroup;
children = (
0A0B147A24ACFDAD00BADD56 /* OrderTrackerModel.swift */,
0A0B147824ACFD8200BADD56 /* OrderTracker.swift */,
0AC16CEC24B3A11C0085EF34 /* StepModel.swift */,
0AC16CEA24B3A1080085EF34 /* Step.swift */,
);
path = "Order Tracker";
sourceTree = "<group>";
};
0AE98BAD23FEF92B004C5109 /* Link */ = {
isa = PBXGroup;
children = (
@ -1261,8 +1277,7 @@
EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */,
0A775F2724893937009EFB58 /* ThreeHeadlineBodyLinkModel.swift */,
0A775F2524893916009EFB58 /* ThreeHeadlineBodyLink.swift */,
0A0B147A24ACFDAD00BADD56 /* OrderTrackerModel.swift */,
0A0B147824ACFD8200BADD56 /* OrderTracker.swift */,
0AC16CE924B3A0ED0085EF34 /* Order Tracker */,
);
path = VerticalCombinationViews;
sourceTree = "<group>";
@ -2353,6 +2368,7 @@
32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */,
011D958524042432000E3791 /* RulesProtocol.swift in Sources */,
AA9972502475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift in Sources */,
0AC16CED24B3A11C0085EF34 /* StepModel.swift in Sources */,
AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */,
D264FAA3243E632F00D98315 /* ProgrammaticCollectionViewController.swift in Sources */,
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
@ -2371,9 +2387,11 @@
011D95A5240455DC000E3791 /* FormGroupRule.swift in Sources */,
D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */,
D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */,
0AC16CEB24B3A1080085EF34 /* Step.swift in Sources */,
C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */,
BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */,
D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */,
0AC16CEE24B3A39C0085EF34 /* ImageView.swift in Sources */,
279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */,
BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */,
8DEFA95E243DAC2F000D27E5 /* ListThreeColumnDataUsageDivider.swift in Sources */,

View File

@ -0,0 +1,107 @@
//
// OrderTracker.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 7/1/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
open class OrderTracker: View {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
var steps = [Step]()
//--------------------------------------------------
// MARK: - Life Cycle
//--------------------------------------------------
open override func setupView() {
super.setupView()
}
open override func reset() {
super.reset()
removeSteps()
}
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
func constrain(stepModels: [StepModel]?) {
guard let stepModels = stepModels else { return }
var previousStep: Step?
for (i, stepModel) in stepModels.enumerated() {
let step = Step()
step.set(with: stepModel, nil, nil)
addSubview(step)
step.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
trailingAnchor.constraint(equalTo: step.trailingAnchor).isActive = true
if i == 0 {
step.topAnchor.constraint(equalTo: topAnchor).isActive = true
} else if let previousStep = previousStep{
step.topAnchor.constraint(equalTo: previousStep.bottomAnchor).isActive = true
}
if i == steps.count - 1 {
bottomAnchor.constraint(equalTo: step.bottomAnchor).isActive = true
}
previousStep = step
}
}
func removeSteps() {
steps.forEach { $0.removeFromSuperview() }
steps = []
}
//--------------------------------------------------
// MARK: - Draw
//--------------------------------------------------
open override func draw(_ rect: CGRect) {
guard let context = UIGraphicsGetCurrentContext() else { return }
context.setLineWidth(1)
context.move(to: steps.first!.imageCenterPoint)
for step in steps.dropLast() {
context.setStrokeColor((step.state?.color() ?? .mvmCoolGray3).cgColor)
context.addLine(to: convert(step.imageCenterPoint, from: step))
}
context.strokePath()
}
//------------------------------------------------------
// MARK: - MoleculeViewProtocol
//------------------------------------------------------
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 320
}
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? OrderTrackerModel else { return }
constrain(stepModels: model.steps)
}
}

View File

@ -17,13 +17,7 @@ open class OrderTrackerModel: MoleculeModelProtocol {
public var backgroundColor: Color?
public static var identifier: String = "orderTracker"
public var state: State?
public enum State: String, Codable {
case complete
case incomplete
case invalid
}
public var steps: [StepModel]?
//--------------------------------------------------
// MARK: - Keys
@ -32,7 +26,7 @@ open class OrderTrackerModel: MoleculeModelProtocol {
private enum CodingKeys: String, CodingKey {
case moleculeName
case backgroundColor
case state
case steps
}
//--------------------------------------------------
@ -42,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)
state = try typeContainer.decodeIfPresent(State.self, forKey: .state)
steps = try typeContainer.decodeIfPresent([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(state, forKey: .state)
try container.encodeIfPresent(steps, forKey: .steps)
}
}

View File

@ -0,0 +1,77 @@
//
// Step.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 7/6/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
open class Step: View {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var headline = Label(fontStyle: .BoldMicro)
public var bodyTop = Label(fontStyle: .RegularMicro)
public var bodyBottom = Label(fontStyle: .RegularMicro)
public var stateImage = ImageView()
//--------------------------------------------------
// MARK: - Computed Properties
//--------------------------------------------------
public var stepModel: StepModel? {
return model as? StepModel
}
public var state: StepModel.State? {
return stepModel?.state
}
public var imageCenterPoint: CGPoint {
return stateImage.center
}
//--------------------------------------------------
// MARK: - Life Cycle
//--------------------------------------------------
open override func setupView() {
super.setupView()
stateImage.topAnchor.constraint(equalTo: topAnchor).isActive = true
stateImage.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
}
public override func reset() {
super.reset()
headline.text = ""
bodyTop.text = ""
bodyBottom.text = ""
stateImage.image = nil
}
//------------------------------------------------------
// MARK: - MoleculeViewProtocol
//------------------------------------------------------
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 320
}
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? StepModel else { return }
headline.text = model.headline
bodyTop.text = model.bodyTop
bodyBottom.text = model.bodyBottom
stateImage.image = model.state?.image()
}
}

View File

@ -0,0 +1,85 @@
//
// StepModel.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 7/6/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
open class StepModel: MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var backgroundColor: Color?
public static var identifier: String = "step"
public var state: State?
public var headline: String = ""
public var bodyTop: String?
public var bodyBottom: String?
public enum State: String, Codable {
case complete
case incomplete
case invalid
func image() -> UIImage? {
switch self {
case .complete:
return UIImage(named: "icon_tracker_complete")
case .incomplete:
return UIImage(named: "icon_tracker_incomplete")
case .invalid:
return UIImage(named: "icon_tracker_invalid")
}
}
func color() -> UIColor {
switch self {
case .complete:
return .mvmGreen
case .incomplete:
return .mvmOrangeAA
case .invalid:
return .mvmCoolGray3
}
}
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case backgroundColor
case state
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
state = try typeContainer.decodeIfPresent(State.self, forKey: .state)
}
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(state, forKey: .state)
}
}

View File

@ -1,47 +0,0 @@
//
// OrderTracker.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 7/1/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
open class OrderTracker: View {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
//--------------------------------------------------
// MARK: - Life Cycle
//--------------------------------------------------
open override func setupView() {
super.setupView()
}
//--------------------------------------------------
// MARK: - Draw
//--------------------------------------------------
open override func draw(_ rect: CGRect) {
}
//------------------------------------------------------
// MARK: - MoleculeViewProtocol
//------------------------------------------------------
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 320
}
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? OrderTrackerModel else { return }
}
}

View File

@ -8,7 +8,7 @@
import UIKit
open class ImageView: UIImageView, ModelMoleculeViewProtocol {
open class ImageView: UIImageView, MoleculeViewProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
@ -52,12 +52,12 @@ open class ImageView: UIImageView, ModelMoleculeViewProtocol {
}
//--------------------------------------------------
// MARK: - ModelMoleculeViewProtocol
// MARK: - MoleculeViewProtocol
//--------------------------------------------------
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
self.model = model
if let backgroundColor = model?.backgroundColor {
if let backgroundColor = model.backgroundColor {
self.backgroundColor = backgroundColor.uiColor
}
}
@ -73,10 +73,6 @@ open class ImageView: UIImageView, ModelMoleculeViewProtocol {
open class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
}
// MARK:- MVMCoreViewProtocol
extension ImageView: MVMCoreViewProtocol {
open func updateView(_ size: CGFloat) { }
@ -86,10 +82,6 @@ extension ImageView: MVMCoreViewProtocol {
insetsLayoutMarginsFromSafeArea = false
MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0)
}
}
// MARK:- MVMCoreUIMoleculeViewProtocol
extension ImageView: MVMCoreUIMoleculeViewProtocol {
open func reset() {
backgroundColor = .clear

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Green.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Green@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Green@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Group.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Group@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Group@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Group 2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Group 2@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Group 2@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB