// // PaginationViewController.swift // VDSSample // // Created by Bandaru, Krishna Kishore on 01/03/24. // import UIKit import VDS final class PaginationViewController: BaseViewController { var totalPagesTextField = NumericField() var selectedPageTextField = NumericField() override func viewDidLoad() { super.viewDidLoad() addContentTopView(view: component) totalPagesTextField.text = "10" component.total = 10 } override func setupForm(){ super.setupForm() addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Total pages", view: totalPagesTextField) addFormRow(label: "Selected page", view: selectedPageTextField) setUpPublishers() } func setUpPublishers() { surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.surface = item self?.contentTopView.backgroundColor = item.color } totalPagesTextField .numberPublisher .sink { [weak self] number in self?.component.total = number?.intValue ?? 0 }.store(in: &subscribers) selectedPageTextField .numberPublisher .sink { [weak self] number in self?.component.selectedPage = number?.intValue ?? 0 }.store(in: &subscribers) } } extension PaginationViewController: ComponentSampleable { static func makeSample() -> ComponentSample { let component = Self.makeComponent() component.total = 10 return ComponentSample(component: component) } }