// // FootnoteGroupViewController.swift // VDSSample // // Created by Kanamarlapudi, Vasavi on 29/08/24. // import Foundation import UIKit import VDS class FootnoteGroupViewController: BaseViewController { var widthTextField = NumericField() var percentageTextField = NumericField() var footnotes: [FootnoteItem] = [] override func viewDidLoad() { super.viewDidLoad() addContentTopView(view: component) setupPicker() setupModel() } override func setupForm() { super.setupForm() addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Width", view: widthTextField) addFormRow(label: "Percentage (1-100)", view: percentageTextField) widthTextField .numberPublisher .sink { [weak self] number in self?.updateComponentConstraint(pinTrailing: number == nil) 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 self?.updateComponentConstraint(pinTrailing: number == nil) if let number, number.intValue > 9 { self?.component.width = .percentage(number.cgFloatValue) self?.widthTextField.text = "" } else { self?.component.width = nil } }.store(in: &subscribers) } func setupModel() { let toolTipModel = Tooltip.TooltipModel.init(title: "Check your item.", content:"Here is the content for your item.") footnotes.append(.init().with { $0.text = "Offer you best deals on phones, tablets, home, internet and more. Pre order the new version mobiles and get off *T&C apply."; $0.symbolType = "*"; $0.kind = .primary; $0.tooltipModel = toolTipModel}) footnotes.append(.init().with { $0.text = "The display has rounded corners. When measured as a standard rectangular shape, the screen is 6.68 inches diagonally. Actual viewable area is less."; $0.symbolType = "**"; $0.kind = .primary}) footnotes.append(.init().with { $0.text = "Some features may not be available for all countries or all areas."; $0.symbolType = "1."; $0.kind = .primary}) component.footnoteItems = footnotes } func setupPicker() { surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.surface = item self?.contentTopView.backgroundColor = item.color } } } extension FootnoteGroupViewController: ComponentSampleable { static func makeSample() -> ComponentSample { let c = Self() c.setupModel() return ComponentSample(component: c.component) } }