refactored constants
updated constant references fixed bug in checkbox Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
7256f0971c
commit
7fef4aadb7
@ -22,7 +22,7 @@
|
|||||||
EA3361B6288B2A410071C351 /* VDSControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B5288B2A410071C351 /* VDSControl.swift */; };
|
EA3361B6288B2A410071C351 /* VDSControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B5288B2A410071C351 /* VDSControl.swift */; };
|
||||||
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */; };
|
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */; };
|
||||||
EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BC288B2C760071C351 /* TypeAlias.swift */; };
|
EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BC288B2C760071C351 /* TypeAlias.swift */; };
|
||||||
EA3361BF288B2EA60071C351 /* Modelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BE288B2EA60071C351 /* Modelable.swift */; };
|
EA3361BF288B2EA60071C351 /* ModelHandlerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BE288B2EA60071C351 /* ModelHandlerable.swift */; };
|
||||||
EA3361C328902D960071C351 /* VDSToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C228902D960071C351 /* VDSToggle.swift */; };
|
EA3361C328902D960071C351 /* VDSToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C228902D960071C351 /* VDSToggle.swift */; };
|
||||||
EA3361C5289030FC0071C351 /* Accessable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C4289030FC0071C351 /* Accessable.swift */; };
|
EA3361C5289030FC0071C351 /* Accessable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C4289030FC0071C351 /* Accessable.swift */; };
|
||||||
EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C8289054C50071C351 /* Surfaceable.swift */; };
|
EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C8289054C50071C351 /* Surfaceable.swift */; };
|
||||||
@ -40,10 +40,11 @@
|
|||||||
EA3362432892EFF20071C351 /* VDSLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3362422892EFF20071C351 /* VDSLabelModel.swift */; };
|
EA3362432892EFF20071C351 /* VDSLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3362422892EFF20071C351 /* VDSLabelModel.swift */; };
|
||||||
EA3362452892F9130071C351 /* Labelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3362442892F9130071C351 /* Labelable.swift */; };
|
EA3362452892F9130071C351 /* Labelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3362442892F9130071C351 /* Labelable.swift */; };
|
||||||
EA33624728931B050071C351 /* Initable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33624628931B050071C351 /* Initable.swift */; };
|
EA33624728931B050071C351 /* Initable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33624628931B050071C351 /* Initable.swift */; };
|
||||||
EA3C3B4C2894823E000CA526 /* ProxPropertyWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B4B2894823E000CA526 /* ProxPropertyWrapper.swift */; };
|
EA3C3B4C2894823E000CA526 /* AnyProxy-PropertyWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B4B2894823E000CA526 /* AnyProxy-PropertyWrapper.swift */; };
|
||||||
EAF7F0952899861000B287F5 /* VDSCheckbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0932899861000B287F5 /* VDSCheckbox.swift */; };
|
EAF7F0952899861000B287F5 /* VDSCheckbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0932899861000B287F5 /* VDSCheckbox.swift */; };
|
||||||
EAF7F0962899861000B287F5 /* VDSCheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0942899861000B287F5 /* VDSCheckboxModel.swift */; };
|
EAF7F0962899861000B287F5 /* VDSCheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0942899861000B287F5 /* VDSCheckboxModel.swift */; };
|
||||||
EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0992899B17200B287F5 /* CATransaction.swift */; };
|
EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0992899B17200B287F5 /* CATransaction.swift */; };
|
||||||
|
EAF7F09E289AAEC000B287F5 /* VDSConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09D289AAEC000B287F5 /* VDSConstants.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -73,7 +74,7 @@
|
|||||||
EA3361B5288B2A410071C351 /* VDSControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSControl.swift; sourceTree = "<group>"; };
|
EA3361B5288B2A410071C351 /* VDSControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSControl.swift; sourceTree = "<group>"; };
|
||||||
EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewProtocol.swift; sourceTree = "<group>"; };
|
EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewProtocol.swift; sourceTree = "<group>"; };
|
||||||
EA3361BC288B2C760071C351 /* TypeAlias.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypeAlias.swift; sourceTree = "<group>"; };
|
EA3361BC288B2C760071C351 /* TypeAlias.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypeAlias.swift; sourceTree = "<group>"; };
|
||||||
EA3361BE288B2EA60071C351 /* Modelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modelable.swift; sourceTree = "<group>"; };
|
EA3361BE288B2EA60071C351 /* ModelHandlerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHandlerable.swift; sourceTree = "<group>"; };
|
||||||
EA3361C228902D960071C351 /* VDSToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSToggle.swift; sourceTree = "<group>"; };
|
EA3361C228902D960071C351 /* VDSToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSToggle.swift; sourceTree = "<group>"; };
|
||||||
EA3361C4289030FC0071C351 /* Accessable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Accessable.swift; sourceTree = "<group>"; };
|
EA3361C4289030FC0071C351 /* Accessable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Accessable.swift; sourceTree = "<group>"; };
|
||||||
EA3361C8289054C50071C351 /* Surfaceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Surfaceable.swift; sourceTree = "<group>"; };
|
EA3361C8289054C50071C351 /* Surfaceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Surfaceable.swift; sourceTree = "<group>"; };
|
||||||
@ -91,10 +92,11 @@
|
|||||||
EA3362422892EFF20071C351 /* VDSLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSLabelModel.swift; sourceTree = "<group>"; };
|
EA3362422892EFF20071C351 /* VDSLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSLabelModel.swift; sourceTree = "<group>"; };
|
||||||
EA3362442892F9130071C351 /* Labelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Labelable.swift; sourceTree = "<group>"; };
|
EA3362442892F9130071C351 /* Labelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Labelable.swift; sourceTree = "<group>"; };
|
||||||
EA33624628931B050071C351 /* Initable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Initable.swift; sourceTree = "<group>"; };
|
EA33624628931B050071C351 /* Initable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Initable.swift; sourceTree = "<group>"; };
|
||||||
EA3C3B4B2894823E000CA526 /* ProxPropertyWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxPropertyWrapper.swift; sourceTree = "<group>"; };
|
EA3C3B4B2894823E000CA526 /* AnyProxy-PropertyWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AnyProxy-PropertyWrapper.swift"; sourceTree = "<group>"; };
|
||||||
EAF7F0932899861000B287F5 /* VDSCheckbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VDSCheckbox.swift; sourceTree = "<group>"; };
|
EAF7F0932899861000B287F5 /* VDSCheckbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VDSCheckbox.swift; sourceTree = "<group>"; };
|
||||||
EAF7F0942899861000B287F5 /* VDSCheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VDSCheckboxModel.swift; sourceTree = "<group>"; };
|
EAF7F0942899861000B287F5 /* VDSCheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VDSCheckboxModel.swift; sourceTree = "<group>"; };
|
||||||
EAF7F0992899B17200B287F5 /* CATransaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CATransaction.swift; sourceTree = "<group>"; };
|
EAF7F0992899B17200B287F5 /* CATransaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CATransaction.swift; sourceTree = "<group>"; };
|
||||||
|
EAF7F09D289AAEC000B287F5 /* VDSConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSConstants.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -212,7 +214,7 @@
|
|||||||
EA3361AE288B26310071C351 /* FormFieldable.swift */,
|
EA3361AE288B26310071C351 /* FormFieldable.swift */,
|
||||||
EA33624628931B050071C351 /* Initable.swift */,
|
EA33624628931B050071C351 /* Initable.swift */,
|
||||||
EA3362442892F9130071C351 /* Labelable.swift */,
|
EA3362442892F9130071C351 /* Labelable.swift */,
|
||||||
EA3361BE288B2EA60071C351 /* Modelable.swift */,
|
EA3361BE288B2EA60071C351 /* ModelHandlerable.swift */,
|
||||||
EA3361C8289054C50071C351 /* Surfaceable.swift */,
|
EA3361C8289054C50071C351 /* Surfaceable.swift */,
|
||||||
EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */,
|
EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */,
|
||||||
);
|
);
|
||||||
@ -223,7 +225,8 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
EA3361B5288B2A410071C351 /* VDSControl.swift */,
|
EA3361B5288B2A410071C351 /* VDSControl.swift */,
|
||||||
EA3C3B4B2894823E000CA526 /* ProxPropertyWrapper.swift */,
|
EA3C3B4B2894823E000CA526 /* AnyProxy-PropertyWrapper.swift */,
|
||||||
|
EAF7F09D289AAEC000B287F5 /* VDSConstants.swift */,
|
||||||
);
|
);
|
||||||
path = Classes;
|
path = Classes;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -409,8 +412,9 @@
|
|||||||
EA33624728931B050071C351 /* Initable.swift in Sources */,
|
EA33624728931B050071C351 /* Initable.swift in Sources */,
|
||||||
EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */,
|
EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */,
|
||||||
EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */,
|
EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */,
|
||||||
EA3C3B4C2894823E000CA526 /* ProxPropertyWrapper.swift in Sources */,
|
EA3C3B4C2894823E000CA526 /* AnyProxy-PropertyWrapper.swift in Sources */,
|
||||||
EA3361AF288B26310071C351 /* FormFieldable.swift in Sources */,
|
EA3361AF288B26310071C351 /* FormFieldable.swift in Sources */,
|
||||||
|
EAF7F09E289AAEC000B287F5 /* VDSConstants.swift in Sources */,
|
||||||
EA3361B3288B265D0071C351 /* Changable.swift in Sources */,
|
EA3361B3288B265D0071C351 /* Changable.swift in Sources */,
|
||||||
EA336171288B19200071C351 /* VDS.docc in Sources */,
|
EA336171288B19200071C351 /* VDS.docc in Sources */,
|
||||||
EAF7F0962899861000B287F5 /* VDSCheckboxModel.swift in Sources */,
|
EAF7F0962899861000B287F5 /* VDSCheckboxModel.swift in Sources */,
|
||||||
@ -421,7 +425,7 @@
|
|||||||
EA33623E2892EE950071C351 /* UIDevice.swift in Sources */,
|
EA33623E2892EE950071C351 /* UIDevice.swift in Sources */,
|
||||||
EA3362302891EB4A0071C351 /* VDSFonts.swift in Sources */,
|
EA3362302891EB4A0071C351 /* VDSFonts.swift in Sources */,
|
||||||
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */,
|
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */,
|
||||||
EA3361BF288B2EA60071C351 /* Modelable.swift in Sources */,
|
EA3361BF288B2EA60071C351 /* ModelHandlerable.swift in Sources */,
|
||||||
EA3361A8288B23300071C351 /* UIColor.swift in Sources */,
|
EA3361A8288B23300071C351 /* UIColor.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|||||||
12
VDS/Classes/VDSConstants.swift
Normal file
12
VDS/Classes/VDSConstants.swift
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// VDSConstants.swift
|
||||||
|
// VDS
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 8/3/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public struct VDSConstants {
|
||||||
|
public static let ModelStateDebounce = 0.02
|
||||||
|
}
|
||||||
@ -9,7 +9,8 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
open class VDSControl<ModelType: Initable>: UIControl, Modelable, ViewProtocol {
|
|
||||||
|
open class VDSControl<ModelType: Initable>: UIControl, ModelHandlerable, ViewProtocol {
|
||||||
|
|
||||||
@Published public var model: ModelType
|
@Published public var model: ModelType
|
||||||
private var cancellable: AnyCancellable?
|
private var cancellable: AnyCancellable?
|
||||||
@ -53,7 +54,7 @@ open class VDSControl<ModelType: Initable>: UIControl, Modelable, ViewProtocol {
|
|||||||
initialSetupPerformed = true
|
initialSetupPerformed = true
|
||||||
setupView()
|
setupView()
|
||||||
}
|
}
|
||||||
cancellable = $model.debounce(for: .seconds(ModelStateDebounce), scheduler: RunLoop.main).sink { [weak self] viewModel in
|
cancellable = $model.debounce(for: .seconds(VDSConstants.ModelStateDebounce), scheduler: RunLoop.main).sink { [weak self] viewModel in
|
||||||
self?.onStateChange(viewModel: viewModel)
|
self?.onStateChange(viewModel: viewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -259,7 +259,6 @@ import Combine
|
|||||||
checkboxWidthConstraint = checkboxView.widthAnchor.constraint(equalToConstant: checkboxSize.width)
|
checkboxWidthConstraint = checkboxView.widthAnchor.constraint(equalToConstant: checkboxSize.width)
|
||||||
checkboxWidthConstraint?.isActive = true
|
checkboxWidthConstraint?.isActive = true
|
||||||
|
|
||||||
checkboxView.layer.borderWidth = 1.0
|
|
||||||
setCheckboxColor(viewModel: model)
|
setCheckboxColor(viewModel: model)
|
||||||
|
|
||||||
mainStackView.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
mainStackView.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
||||||
@ -390,12 +389,9 @@ import Combine
|
|||||||
public var checkColor: UIColor = .white
|
public var checkColor: UIColor = .white
|
||||||
public var isSelected: Bool = false {
|
public var isSelected: Bool = false {
|
||||||
didSet {
|
didSet {
|
||||||
if oldValue != isSelected {
|
if let shapeLayer = shapeLayer, let sublayers = layer.sublayers, sublayers.contains(shapeLayer) {
|
||||||
if let shapeLayer = shapeLayer, let sublayers = layer.sublayers, sublayers.contains(shapeLayer) {
|
shapeLayer.removeFromSuperlayer()
|
||||||
shapeLayer.removeFromSuperlayer()
|
self.shapeLayer = nil
|
||||||
self.shapeLayer = nil
|
|
||||||
}
|
|
||||||
drawShapeLayer()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,6 +403,7 @@ import Combine
|
|||||||
private func drawShapeLayer() {
|
private func drawShapeLayer() {
|
||||||
layer.borderColor = borderColor.cgColor
|
layer.borderColor = borderColor.cgColor
|
||||||
layer.cornerRadius = 2.0
|
layer.cornerRadius = 2.0
|
||||||
|
layer.borderWidth = 1.0
|
||||||
shapeLayer?.strokeColor = checkColor.cgColor
|
shapeLayer?.strokeColor = checkColor.cgColor
|
||||||
|
|
||||||
guard let path = try? checkMarkPath(), shapeLayer == nil else { return }
|
guard let path = try? checkMarkPath(), shapeLayer == nil else { return }
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import UIKit
|
|||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
open class VDSLabel: UILabel, Modelable, Initable {
|
open class VDSLabel: UILabel, ModelHandlerable, Initable {
|
||||||
|
|
||||||
@Published public var model: VDSLabelModel = DefaultLabelModel()
|
@Published public var model: VDSLabelModel = DefaultLabelModel()
|
||||||
private var cancellable: AnyCancellable?
|
private var cancellable: AnyCancellable?
|
||||||
@ -52,7 +52,7 @@ open class VDSLabel: UILabel, Modelable, Initable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func setup() {
|
private func setup() {
|
||||||
cancellable = $model.debounce(for: .seconds(ModelStateDebounce), scheduler: RunLoop.main).sink { [weak self] viewModel in
|
cancellable = $model.debounce(for: .seconds(VDSConstants.ModelStateDebounce), scheduler: RunLoop.main).sink { [weak self] viewModel in
|
||||||
self?.onStateChange(viewModel: viewModel)
|
self?.onStateChange(viewModel: viewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ public protocol Accessable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Helpers to set within the UIControl
|
//Helpers to set within the UIControl
|
||||||
extension Modelable where Self: UIView {
|
extension ModelHandlerable where Self: UIView {
|
||||||
private var accessableModel: Accessable? {
|
private var accessableModel: Accessable? {
|
||||||
guard let model = self.model as? Accessable else {
|
guard let model = self.model as? Accessable else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -7,9 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public let ModelStateDebounce = 0.02
|
public protocol ModelHandlerable {
|
||||||
|
|
||||||
public protocol Modelable {
|
|
||||||
associatedtype ModelType
|
associatedtype ModelType
|
||||||
var model: ModelType { get set }
|
var model: ModelType { get set }
|
||||||
init(with model: ModelType)
|
init(with model: ModelType)
|
||||||
Loading…
Reference in New Issue
Block a user