initial commit
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
8f319e3b11
commit
2a1f3c9e33
@ -7,6 +7,12 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
EA1F265D28B944F00033E859 /* CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F265B28B944F00033E859 /* CollectionView.swift */; };
|
||||
EA1F265E28B944F00033E859 /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F265C28B944F00033E859 /* CollectionViewCell.swift */; };
|
||||
EA1F266428B945070033E859 /* RadioSwatchGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266028B945070033E859 /* RadioSwatchGroupModel.swift */; };
|
||||
EA1F266528B945070033E859 /* RadioSwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266128B945070033E859 /* RadioSwatch.swift */; };
|
||||
EA1F266628B945070033E859 /* RadioSwatchGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266228B945070033E859 /* RadioSwatchGroup.swift */; };
|
||||
EA1F266728B945070033E859 /* RadioSwatchModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266328B945070033E859 /* RadioSwatchModel.swift */; };
|
||||
EA336171288B19200071C351 /* VDS.docc in Sources */ = {isa = PBXBuildFile; fileRef = EA336170288B19200071C351 /* VDS.docc */; };
|
||||
EA336177288B19210071C351 /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA33616C288B19200071C351 /* VDS.framework */; };
|
||||
EA33617C288B19210071C351 /* VDSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33617B288B19210071C351 /* VDSTests.swift */; };
|
||||
@ -93,6 +99,12 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
EA1F265B28B944F00033E859 /* CollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionView.swift; sourceTree = "<group>"; };
|
||||
EA1F265C28B944F00033E859 /* CollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
EA1F266028B945070033E859 /* RadioSwatchGroupModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatchGroupModel.swift; sourceTree = "<group>"; };
|
||||
EA1F266128B945070033E859 /* RadioSwatch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatch.swift; sourceTree = "<group>"; };
|
||||
EA1F266228B945070033E859 /* RadioSwatchGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatchGroup.swift; sourceTree = "<group>"; };
|
||||
EA1F266328B945070033E859 /* RadioSwatchModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatchModel.swift; sourceTree = "<group>"; };
|
||||
EA33616C288B19200071C351 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EA33616F288B19200071C351 /* VDS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VDS.h; sourceTree = "<group>"; };
|
||||
EA336170288B19200071C351 /* VDS.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = VDS.docc; sourceTree = "<group>"; };
|
||||
@ -195,6 +207,17 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
EA1F265F28B945070033E859 /* RadioSwatch */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EA1F266128B945070033E859 /* RadioSwatch.swift */,
|
||||
EA1F266328B945070033E859 /* RadioSwatchModel.swift */,
|
||||
EA1F266228B945070033E859 /* RadioSwatchGroup.swift */,
|
||||
EA1F266028B945070033E859 /* RadioSwatchGroupModel.swift */,
|
||||
);
|
||||
path = RadioSwatch;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EA336162288B19200071C351 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -258,11 +281,12 @@
|
||||
EA33619D288B1E330071C351 /* Components */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EAF7F092289985E200B287F5 /* Checkbox */,
|
||||
EA3362412892EF700071C351 /* Label */,
|
||||
EA89200B28B530F0006B9984 /* RadioBox */,
|
||||
EAF7F11428A1470D00B287F5 /* RadioButton */,
|
||||
EAF7F092289985E200B287F5 /* Checkbox */,
|
||||
EA1F265F28B945070033E859 /* RadioSwatch */,
|
||||
EA3361A0288B1E6F0071C351 /* Toggle */,
|
||||
EA3362412892EF700071C351 /* Label */,
|
||||
);
|
||||
path = Components;
|
||||
sourceTree = "<group>";
|
||||
@ -316,6 +340,8 @@
|
||||
EA3361B4288B2A360071C351 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EA1F265B28B944F00033E859 /* CollectionView.swift */,
|
||||
EA1F265C28B944F00033E859 /* CollectionViewCell.swift */,
|
||||
EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */,
|
||||
EAF7F09D289AAEC000B287F5 /* Constants.swift */,
|
||||
EA3361B5288B2A410071C351 /* Control.swift */,
|
||||
@ -568,6 +594,7 @@
|
||||
EAF7F0A0289AB7EC00B287F5 /* View.swift in Sources */,
|
||||
EAF7F11828A1475A00B287F5 /* RadioButtonModel.swift in Sources */,
|
||||
EA89200D28B530FD006B9984 /* RadioBoxModel.swift in Sources */,
|
||||
EA1F266728B945070033E859 /* RadioSwatchModel.swift in Sources */,
|
||||
EA89201328B568D8006B9984 /* RadioBox.swift in Sources */,
|
||||
EA3362402892EF6C0071C351 /* Label.swift in Sources */,
|
||||
EAF7F0B3289B1ADC00B287F5 /* LabelAttributeAction.swift in Sources */,
|
||||
@ -582,6 +609,7 @@
|
||||
EA89201728B56CFF006B9984 /* RadioBoxGroupModel.swift in Sources */,
|
||||
EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */,
|
||||
EA3361A2288B1E840071C351 /* ToggleModel.swift in Sources */,
|
||||
EA1F265D28B944F00033E859 /* CollectionView.swift in Sources */,
|
||||
EA3362432892EFF20071C351 /* LabelModel.swift in Sources */,
|
||||
EA33624728931B050071C351 /* Initable.swift in Sources */,
|
||||
EAF7F0A4289B017C00B287F5 /* LabelAttributeModel.swift in Sources */,
|
||||
@ -602,6 +630,7 @@
|
||||
EAF7F0BB289D80ED00B287F5 /* Modelable.swift in Sources */,
|
||||
EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */,
|
||||
EAF7F09E289AAEC000B287F5 /* Constants.swift in Sources */,
|
||||
EA1F266528B945070033E859 /* RadioSwatch.swift in Sources */,
|
||||
EA3361B3288B265D0071C351 /* Changable.swift in Sources */,
|
||||
EA89200228AECF2A006B9984 /* UIButton+Publisher.swift in Sources */,
|
||||
EAF7F0AB289B13FD00B287F5 /* LabelAttributeFont.swift in Sources */,
|
||||
@ -619,10 +648,13 @@
|
||||
EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */,
|
||||
EA33623E2892EE950071C351 /* UIDevice.swift in Sources */,
|
||||
EA3362302891EB4A0071C351 /* Fonts.swift in Sources */,
|
||||
EA1F265E28B944F00033E859 /* CollectionViewCell.swift in Sources */,
|
||||
EAF7F0AD289B142900B287F5 /* LabelAttributeStrikeThrough.swift in Sources */,
|
||||
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */,
|
||||
EA3361BF288B2EA60071C351 /* ModelHandlerable.swift in Sources */,
|
||||
EA3361A8288B23300071C351 /* UIColor.swift in Sources */,
|
||||
EA1F266428B945070033E859 /* RadioSwatchGroupModel.swift in Sources */,
|
||||
EA1F266628B945070033E859 /* RadioSwatchGroup.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
114
VDS/Classes/CollectionView.swift
Normal file
114
VDS/Classes/CollectionView.swift
Normal file
@ -0,0 +1,114 @@
|
||||
//
|
||||
// CollectionView.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 8/25/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Combine
|
||||
|
||||
open class CollectionView<ModelType: Modelable>: UICollectionView, ModelHandlerable, ViewProtocol, Resettable {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Combine Properties
|
||||
//--------------------------------------------------
|
||||
@Published public var model: ModelType = ModelType()
|
||||
public var modelPublisher: Published<ModelType>.Publisher { $model }
|
||||
public var subscribers = Set<AnyCancellable>()
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
@Proxy(\.model.surface)
|
||||
open var surface: Surface
|
||||
|
||||
@Proxy(\.model.disabled)
|
||||
open var disabled: Bool {
|
||||
didSet {
|
||||
self.isEnabled = !disabled
|
||||
}
|
||||
}
|
||||
|
||||
open var isEnabled: Bool {
|
||||
get { !model.disabled }
|
||||
set {
|
||||
//create local vars for clear coding
|
||||
let disabled = !newValue
|
||||
if model.disabled != disabled {
|
||||
model.disabled = disabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//--------------------------------------------------
|
||||
required public init() {
|
||||
super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
|
||||
initialSetup()
|
||||
}
|
||||
|
||||
public required init(with model: ModelType) {
|
||||
super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
public required init(with model: ModelType, collectionViewLayout layout: UICollectionViewLayout) {
|
||||
super.init(frame: .zero, collectionViewLayout: layout)
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
|
||||
super.init(frame: frame, collectionViewLayout: layout)
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
public required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
initialSetup()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Setup
|
||||
//--------------------------------------------------
|
||||
|
||||
public func initialSetup() {
|
||||
if !initialSetupPerformed {
|
||||
initialSetupPerformed = true
|
||||
setupUpdateView()
|
||||
setup()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
open func shouldUpdateView(viewModel: ModelType) -> Bool {
|
||||
fatalError("Implement shouldUpdateView")
|
||||
}
|
||||
|
||||
open func updateView(viewModel: ModelType) {
|
||||
fatalError("Implement updateView")
|
||||
}
|
||||
|
||||
open func reset() {
|
||||
backgroundColor = .clear
|
||||
if let model = model as? Resettable {
|
||||
model.reset()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ViewProtocol
|
||||
/// Will be called only once.
|
||||
open func setup() {
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
insetsLayoutMarginsFromSafeArea = false
|
||||
}
|
||||
}
|
||||
108
VDS/Classes/CollectionViewCell.swift
Normal file
108
VDS/Classes/CollectionViewCell.swift
Normal file
@ -0,0 +1,108 @@
|
||||
//
|
||||
// CollectionViewCell.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 8/25/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Combine
|
||||
|
||||
open class CollectionViewCell<ModelType: Modelable>: UICollectionViewCell, ModelHandlerable, ViewProtocol, Resettable {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Combine Properties
|
||||
//--------------------------------------------------
|
||||
@Published public var model: ModelType = ModelType()
|
||||
public var modelPublisher: Published<ModelType>.Publisher { $model }
|
||||
public var subscribers = Set<AnyCancellable>()
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
@Proxy(\.model.surface)
|
||||
open var surface: Surface
|
||||
|
||||
@Proxy(\.model.disabled)
|
||||
open var disabled: Bool {
|
||||
didSet {
|
||||
self.isEnabled = !disabled
|
||||
}
|
||||
}
|
||||
|
||||
open var isEnabled: Bool {
|
||||
get { !model.disabled }
|
||||
set {
|
||||
//create local vars for clear coding
|
||||
let disabled = !newValue
|
||||
if model.disabled != disabled {
|
||||
model.disabled = disabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//--------------------------------------------------
|
||||
required public init() {
|
||||
super.init(frame: .zero)
|
||||
initialSetup()
|
||||
}
|
||||
|
||||
public required init(with model: ModelType) {
|
||||
super.init(frame: .zero)
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
public required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
initialSetup()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Setup
|
||||
//--------------------------------------------------
|
||||
|
||||
public func initialSetup() {
|
||||
if !initialSetupPerformed {
|
||||
initialSetupPerformed = true
|
||||
setupUpdateView()
|
||||
setup()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
open func shouldUpdateView(viewModel: ModelType) -> Bool {
|
||||
fatalError("Implement shouldUpdateView")
|
||||
}
|
||||
|
||||
open func updateView(viewModel: ModelType) {
|
||||
fatalError("Implement updateView")
|
||||
}
|
||||
|
||||
open func reset() {
|
||||
backgroundColor = .clear
|
||||
if let model = model as? Resettable {
|
||||
model.reset()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ViewProtocol
|
||||
/// Will be called only once.
|
||||
open func setup() {
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
insetsLayoutMarginsFromSafeArea = false
|
||||
}
|
||||
}
|
||||
8
VDS/Components/RadioSwatch/RadioSwatch.swift
Normal file
8
VDS/Components/RadioSwatch/RadioSwatch.swift
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// RadioSwatch.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 8/25/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
8
VDS/Components/RadioSwatch/RadioSwatchGroup.swift
Normal file
8
VDS/Components/RadioSwatch/RadioSwatchGroup.swift
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// RadioSwatchGroup.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 8/25/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
8
VDS/Components/RadioSwatch/RadioSwatchGroupModel.swift
Normal file
8
VDS/Components/RadioSwatch/RadioSwatchGroupModel.swift
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// RadioSwatchGroupModel.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 8/25/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
8
VDS/Components/RadioSwatch/RadioSwatchModel.swift
Normal file
8
VDS/Components/RadioSwatch/RadioSwatchModel.swift
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// RadioSwatchModel.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 8/25/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
Loading…
Reference in New Issue
Block a user