104 lines
4.8 KiB
Swift
104 lines
4.8 KiB
Swift
//
|
|
// TableViewController.swift
|
|
// VDSSample
|
|
//
|
|
// Created by Nadigadda, Sumanth on 24/04/24.
|
|
//
|
|
|
|
import Foundation
|
|
import VDS
|
|
import UIKit
|
|
|
|
class TableViewController: BaseViewController<Table> {
|
|
|
|
var striped = Toggle()
|
|
|
|
lazy var headerLineStylePicker = {
|
|
PickerSelectorView(title: "primary", picker: self.picker, items: Line.Style.allCases)
|
|
}()
|
|
|
|
lazy var rowLineStylePicker = {
|
|
PickerSelectorView(title: "secondary", picker: self.picker, items: Line.Style.allCases)
|
|
}()
|
|
|
|
lazy var paddingPicker = {
|
|
PickerSelectorView(title: "standard", picker: self.picker, items: Table.Padding.allCases)
|
|
}()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
self.setupPicker()
|
|
self.setupModel()
|
|
}
|
|
|
|
override func setupForm() {
|
|
super.setupForm()
|
|
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
|
addFormRow(label: "Padding", view: paddingPicker)
|
|
addFormRow(label: "Striped", view: striped)
|
|
addFormRow(label: "Header line style", view: headerLineStylePicker)
|
|
addFormRow(label: "Row line style", view: rowLineStylePicker)
|
|
|
|
addContentTopView(view: component)
|
|
|
|
striped.onChange = { [weak self] sender in
|
|
self?.component.striped = sender.isOn
|
|
}
|
|
}
|
|
|
|
func setupPicker() {
|
|
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
|
self?.component.surface = item
|
|
self?.contentTopView.backgroundColor = item.color
|
|
}
|
|
|
|
headerLineStylePicker.onPickerDidSelect = { [weak self] item in
|
|
let headers = self?.component.tableHeader ?? [[]]
|
|
for currentRow in headers {
|
|
for var currentItem in currentRow {
|
|
currentItem.bottomLine = item
|
|
}
|
|
}
|
|
self?.component.tableHeader = headers
|
|
}
|
|
|
|
rowLineStylePicker.onPickerDidSelect = { [weak self] item in
|
|
|
|
let rows = self?.component.tableRows ?? [[]]
|
|
for currentRow in rows {
|
|
for var currentItem in currentRow {
|
|
currentItem.bottomLine = item
|
|
}
|
|
}
|
|
self?.component.tableRows = rows
|
|
}
|
|
|
|
paddingPicker.onPickerDidSelect = { [weak self] item in
|
|
self?.component.padding = item
|
|
}
|
|
}
|
|
|
|
func setupModel() {
|
|
///Header row
|
|
self.component.tableHeader = [[TableItemModel(bottomLine: .primary, component: Label().with { $0.text = ""}),
|
|
TableItemModel(bottomLine: .primary, component: Label().with { $0.text = "Verizon smart family"; $0.textStyle = .boldTitleSmall; $0.lineBreakMode = .byWordWrapping}),
|
|
TableItemModel(bottomLine: .primary, component: Label().with { $0.text = "Call filter"; $0.textStyle = .boldTitleSmall; $0.lineBreakMode = .byWordWrapping })]]
|
|
|
|
///First row
|
|
var rows = [[TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "Cost"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping}),
|
|
TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "$5/month for up to 10 lines"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping}),
|
|
TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "$2.99/month per device"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping})]]
|
|
///second row
|
|
rows.append([TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "Block web domains"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping}),
|
|
TableItemModel(bottomLine: .secondary, component: Icon().with { $0.name = Icon.Name.checkmark }),
|
|
TableItemModel(bottomLine: .secondary, component: Icon().with { $0.name = Icon.Name.checkmark })])
|
|
|
|
///Third row
|
|
rows.append([TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "Block calls and messages from specific numbers"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping}),
|
|
TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "Permanently"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping}),
|
|
TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "Permanently"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping})])
|
|
|
|
self.component.tableRows = rows
|
|
}
|
|
}
|