// // ToggleElementViewController.swift // VDSSample // // Created by Matt Bruce on 7/19/23. // import Foundation import UIKit import VDS import VDSColorTokens class ToggleViewController: BaseViewController { var disabledSwitch = Toggle() override func viewDidLoad() { super.viewDidLoad() // let stack = UIStackView() // stack.axis = .vertical // stack.spacing = 10 // stack.distribution = .fill // stack.alignment = .trailing // stack.addArrangedSubview(component) // stack.addArrangedSubview(UISwitch().with { $0.isOn = true }) // addContentTopView(view: stack) addContentTopView(view: component) setupPicker() } override func setupForm() { super.setupForm() addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Disabled", view: disabledSwitch) component.onChange = { [weak self] toggle in let alertController:UIAlertController = UIAlertController(title: "Alert", message: "Toggle Value: \(toggle.isOn)", preferredStyle: UIAlertController.Style.alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil)) self?.present(alertController, animated: true) print("toggle changed: \(toggle.isOn)") } disabledSwitch.onChange = { [weak self] sender in self?.component.disabled = sender.isOn } //setup UI surfacePickerSelectorView.text = component.surface.rawValue } //Picker func setupPicker(){ surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.surface = item self?.contentTopView.backgroundColor = item.color } } }