// // FootnoteViewController.swift // VDSSample // // Created by Kanamarlapudi, Vasavi on 21/08/24. // import Foundation import UIKit import VDS class FootnoteViewController: BaseViewController { lazy var kindPickerSelectorView = { PickerSelectorView(title: "secondary", picker: self.picker, items: Footnote.Kind.allCases) }() lazy var symbolTypePickerSelectorView = { PickerSelectorView(title: "asterisk", picker: self.picker, items: Footnote.SymbolType.allCases) }() lazy var sizePickerSelectorView = { PickerSelectorView(title: "micro", picker: self.picker, items: Footnote.Size.allCases) }() var hideSymbolSwitch = Toggle() var widthTextField = NumericField() var percentageTextField = NumericField() override func viewDidLoad() { super.viewDidLoad() addContentTopView(view: component) setupPicker() setupModel() } override func setupForm() { super.setupForm() addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Kind", view: kindPickerSelectorView) addFormRow(label: "Size", view: sizePickerSelectorView) addFormRow(label: "Symbol Type", view: symbolTypePickerSelectorView) addFormRow(label: "Hide Symbol", view: hideSymbolSwitch) addFormRow(label: "Width", view: widthTextField) addFormRow(label: "Percentage (1-100)", view: percentageTextField) hideSymbolSwitch.publisher(for: .valueChanged).sink { [weak self] control in self?.component.hideSymbol = control.isOn }.store(in: &subscribers) widthTextField .numberPublisher .sink { [weak self] number in if let number { self?.component.width = .value(number.cgFloatValue) self?.percentageTextField.text = "" } else { self?.component.width = nil } }.store(in: &subscribers) percentageTextField .numberPublisher .sink { [weak self] number in if let number { self?.component.width = .percentage(number.cgFloatValue) self?.widthTextField.text = "" } else { self?.component.width = nil } }.store(in: &subscribers) } func setupModel() { component.text = "Service is included for free for two years with activation of any iPhone15 model. Connection and response times vary based on location, site conditions, and other factors. See support.apple.com/en-us/HT213885 for more information." component.tooltipModel = .init(title: "Check your item.", content:"Here is the content for your item.") sizePickerSelectorView.text = component.size.rawValue kindPickerSelectorView.text = component.kind.rawValue symbolTypePickerSelectorView.text = component.symbolType.rawValue } func setupPicker() { surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.surface = item self?.contentTopView.backgroundColor = item.color } kindPickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.kind = item } sizePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.size = item } symbolTypePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.symbolType = item } } }