deleted code
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
9ac7cef6c3
commit
04eab99144
@ -50,10 +50,8 @@
|
||||
EA89204C28B66CE2006B9984 /* ScrollWrapperView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89204528B66CE2006B9984 /* ScrollWrapperView.swift */; };
|
||||
EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */; };
|
||||
EA89205128B68307006B9984 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89205028B68307006B9984 /* TextField.swift */; };
|
||||
EAB1D2C928AAAA1D00DAE764 /* ModelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C828AAAA1D00DAE764 /* ModelViewController.swift */; };
|
||||
EAB1D2CB28AAB9E200DAE764 /* TemplateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CA28AAB9E200DAE764 /* TemplateViewController.swift */; };
|
||||
EAB1D2C928AAAA1D00DAE764 /* ModelScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C828AAAA1D00DAE764 /* ModelScrollViewController.swift */; };
|
||||
EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */; };
|
||||
EAF7F07C2899698800B287F5 /* Components.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07A2899698800B287F5 /* Components.storyboard */; };
|
||||
EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07B2899698800B287F5 /* Assets.xcassets */; };
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */; };
|
||||
EAF7F0CA289DA24F00B287F5 /* ArtifactoryItems.txt in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */; };
|
||||
@ -112,10 +110,8 @@
|
||||
EA89204528B66CE2006B9984 /* ScrollWrapperView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollWrapperView.swift; sourceTree = "<group>"; };
|
||||
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckBoxGroupViewController.swift; sourceTree = "<group>"; };
|
||||
EA89205028B68307006B9984 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; };
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2CA28AAB9E200DAE764 /* TemplateViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelScrollViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelScrollViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F07A2899698800B287F5 /* Components.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Components.storyboard; sourceTree = "<group>"; };
|
||||
EAF7F07B2899698800B287F5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ArtifactoryItems.txt; sourceTree = "<group>"; };
|
||||
@ -225,7 +221,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EAF7F07B2899698800B287F5 /* Assets.xcassets */,
|
||||
EAF7F07A2899698800B287F5 /* Components.storyboard */,
|
||||
EA3C3BA7289966F1000CA526 /* LaunchScreen.storyboard */,
|
||||
EA3C3BA2289966EF000CA526 /* Main.storyboard */,
|
||||
);
|
||||
@ -246,13 +241,12 @@
|
||||
children = (
|
||||
EA89203E28B66CE2006B9984 /* ScrollViewController */,
|
||||
EA3C3BB228996775000CA526 /* MenuViewController.swift */,
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelViewController.swift */,
|
||||
EAB1D2C828AAAA1D00DAE764 /* ModelScrollViewController.swift */,
|
||||
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */,
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */,
|
||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
|
||||
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */,
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */,
|
||||
EAB1D2CA28AAB9E200DAE764 /* TemplateViewController.swift */,
|
||||
EA3C3BB328996775000CA526 /* ToggleViewController.swift */,
|
||||
);
|
||||
path = ViewControllers;
|
||||
@ -345,7 +339,6 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EA3C3BA9289966F1000CA526 /* LaunchScreen.storyboard in Resources */,
|
||||
EAF7F07C2899698800B287F5 /* Components.storyboard in Resources */,
|
||||
EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */,
|
||||
EA3C3BA4289966EF000CA526 /* Main.storyboard in Resources */,
|
||||
EAF7F0CC289DA24F00B287F5 /* DownloadArtifactoryItems.sh in Resources */,
|
||||
@ -406,12 +399,11 @@
|
||||
EA3C3BB628996775000CA526 /* MenuViewController.swift in Sources */,
|
||||
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */,
|
||||
EAF7F11A28A14A0E00B287F5 /* RadioButtonViewController.swift in Sources */,
|
||||
EAB1D2CB28AAB9E200DAE764 /* TemplateViewController.swift in Sources */,
|
||||
EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */,
|
||||
EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */,
|
||||
EA89204A28B66CE2006B9984 /* KeyboardFrameChange.swift in Sources */,
|
||||
EA3C3BB428996775000CA526 /* PickerBase.swift in Sources */,
|
||||
EAB1D2C928AAAA1D00DAE764 /* ModelViewController.swift in Sources */,
|
||||
EAB1D2C928AAAA1D00DAE764 /* ModelScrollViewController.swift in Sources */,
|
||||
EA89204728B66CE2006B9984 /* KeyboardFrameChangeListener.swift in Sources */,
|
||||
EA89204828B66CE2006B9984 /* ScrollViewKeyboardAvoiding.swift in Sources */,
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -10,75 +10,6 @@ import UIKit
|
||||
import Combine
|
||||
import VDS
|
||||
|
||||
public class ModelViewController<ModelType: Modelable>: UIViewController, ModelHandlerable, Initable {
|
||||
deinit {
|
||||
print("\(Self.self) deinit")
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// 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
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//--------------------------------------------------
|
||||
required public init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
public required init(with model: ModelType) {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
initialSetup()
|
||||
set(with: model)
|
||||
}
|
||||
|
||||
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
initialSetup()
|
||||
}
|
||||
|
||||
public required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
initialSetup()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Setup
|
||||
//--------------------------------------------------
|
||||
|
||||
public func initialSetup() {
|
||||
if !initialSetupPerformed {
|
||||
initialSetupPerformed = true
|
||||
setupUpdateView()
|
||||
setup()
|
||||
}
|
||||
}
|
||||
|
||||
open func setup() {}
|
||||
|
||||
open func shouldUpdateView(viewModel: ModelType) -> Bool { true }
|
||||
|
||||
open func updateView(viewModel: ModelType) {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class ModelScrollViewController<ModelType: Modelable>: UIViewController, ModelHandlerable, Initable {
|
||||
deinit {
|
||||
print("\(Self.self) deinit")
|
||||
@ -1,110 +0,0 @@
|
||||
//
|
||||
// TemplateViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 8/15/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
struct TestLayoutModel: Modelable {
|
||||
var surface: VDS.Surface = .light
|
||||
var disabled: Bool = false
|
||||
// var molecules : [any Modelable] = []
|
||||
var checkbox: DefaultCheckboxModel
|
||||
var radioButtonGroup: DefaultRadioButtonGroupModel
|
||||
var subscribers = Set<AnyCancellable>()
|
||||
init(){
|
||||
let labelAction = LabelAttributeActionModel(location: 31, length: 10)
|
||||
labelAction.action.sink {
|
||||
print("clicked on the word 'conditions'")
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//add the checkbox
|
||||
checkbox = DefaultCheckboxModel()
|
||||
checkbox.labelText = "Terms and conditions"
|
||||
checkbox.childText = "I agree to Verizon's terms and conditions click here"
|
||||
checkbox.childTextAttributes = [
|
||||
LabelAttributeUnderline(location: 11, length: 10),
|
||||
LabelAttributeStrikeThrough(location: 22, length: 5),
|
||||
LabelAttributeColor(location: 31, length: 10, color: UIColor.blue.hexString!),
|
||||
LabelAttributeFont(location: 2, length: 5, style: .BoldTitleLarge, color: UIColor.red.hexString!),
|
||||
labelAction
|
||||
|
||||
]
|
||||
checkbox.errorText = "Error Text"
|
||||
|
||||
//add the radio
|
||||
radioButtonGroup = DefaultRadioButtonGroupModel()
|
||||
var radio1 = DefaultRadioButtonModel()
|
||||
radio1.value = "model 1 Value"
|
||||
radio1.labelText = "Terms and conditions"
|
||||
radio1.childText = "I agree to Verizon's terms and conditions click here"
|
||||
radio1.childTextAttributes = [
|
||||
LabelAttributeUnderline(location: 11, length: 10),
|
||||
LabelAttributeStrikeThrough(location: 22, length: 5),
|
||||
LabelAttributeColor(location: 31, length: 10, color: UIColor.blue.hexString!),
|
||||
LabelAttributeFont(location: 2, length: 5, style: .BoldTitleLarge, color: UIColor.red.hexString!),
|
||||
labelAction
|
||||
]
|
||||
|
||||
var radio2 = DefaultRadioButtonModel()
|
||||
radio2.value = "model 2 Value"
|
||||
radio2.childText = "Radio Sample 2"
|
||||
radioButtonGroup.selectors = [radio1, radio2]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class TemplateViewController: ModelViewController<TestLayoutModel> {
|
||||
enum ModelHandlerError: Error {
|
||||
case cantFind
|
||||
}
|
||||
|
||||
var stackView = UIStackView()
|
||||
var radioButtonGroup = RadioButtonGroup()
|
||||
var checkbox = Checkbox()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
view.backgroundColor = .white
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
stackView.spacing = 10
|
||||
stackView.axis = .vertical
|
||||
stackView.alignment = .top
|
||||
|
||||
view.addSubview(stackView)
|
||||
stackView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 10).isActive = true
|
||||
stackView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -20).isActive = true
|
||||
stackView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 20).isActive = true
|
||||
stackView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: 10).isActive = true
|
||||
|
||||
//Publisher way
|
||||
checkbox.handlerPublisher()
|
||||
.sink { [weak self] checkModel in
|
||||
self?.model.checkbox = checkModel
|
||||
}
|
||||
.store(in: &subscribers)
|
||||
stackView.addArrangedSubview(checkbox)
|
||||
|
||||
radioButtonGroup.handlerPublisher()
|
||||
.sink { [weak self] radioGroupModel in
|
||||
self?.model.radioButtonGroup = radioGroupModel
|
||||
}
|
||||
.store(in: &subscribers)
|
||||
stackView.addArrangedSubview(radioButtonGroup)
|
||||
}
|
||||
|
||||
override func updateView(viewModel: ModelType) {
|
||||
print("\(Self.self) updateView(viewModel)")
|
||||
checkbox.set(with: model.checkbox)
|
||||
radioButtonGroup.set(with: model.radioButtonGroup)
|
||||
|
||||
print("radioButtonGroup selected: \(radioButtonGroup.selectedModel?.id)")
|
||||
print("model.value.radioButtonGroup selected: \(model.radioButtonGroup.selectedModel?.id)")
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user