// // TextLink.swift // VDSSample // // Created by Matt Bruce on 11/1/22. // import Foundation import UIKit import VDS import VDSColorTokens class TextLinkViewController: BaseViewController { lazy var buttonSizePickerSelectorView = { PickerSelectorView(title: "", picker: self.picker, items: ButtonSize.allCases) }() var label = Label() var disabledSwitch = Toggle() var textField = TextField() override func viewDidLoad() { super.viewDidLoad() addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0) setupPicker() setupModel() } override func allTextFields() -> [TextField]? { [textField] } override func setupForm(){ super.setupForm() addFormRow(label: "Button Action", view: label) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch)) addFormRow(label: "Label", view: textField) addFormRow(label: "Size", view: buttonSizePickerSelectorView) disabledSwitch.onChange = { [weak self] sender in self?.component.disabled = sender.isOn } textField .textPublisher .sink { [weak self] text in self?.component.text = text }.store(in: &subscribers) } func setupModel() { component.text = "Text Link" component.labelPublisher(label) //setup UI surfacePickerSelectorView.text = component.surface.rawValue disabledSwitch.isOn = component.disabled textField.text = component.text buttonSizePickerSelectorView.text = ButtonSize.large.rawValue } func setupPicker(){ surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.surface = item self?.contentTopView.backgroundColor = item.color } buttonSizePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.size = item } } }