Adding fillContainer and column width elements to controller.

This commit is contained in:
Sumanth Nadigadda 2024-05-24 20:48:48 +05:30
parent 1af6fbb220
commit e51b4dfe37

View File

@ -13,6 +13,10 @@ class TableViewController: BaseViewController<Table> {
var striped = Toggle()
var fillContainer = Toggle()
var customColumnWidthSize = NumericField()
lazy var headerLineStylePicker = {
PickerSelectorView(title: "primary", picker: self.picker, items: Line.Style.allCases)
}()
@ -38,12 +42,28 @@ class TableViewController: BaseViewController<Table> {
addFormRow(label: "Striped", view: striped)
addFormRow(label: "Header line style", view: headerLineStylePicker)
addFormRow(label: "Row line style", view: rowLineStylePicker)
addFormRow(label: "Fill container", view: fillContainer)
addFormRow(label: "Custom column size", view: customColumnWidthSize)
fillContainer.isOn = component.fillContainer
addContentTopView(view: component)
striped.onChange = { [weak self] sender in
self?.component.striped = sender.isOn
}
fillContainer.onChange = { [weak self] sender in
self?.component.fillContainer = sender.isOn
self?.customColumnWidthSize.isEnabled = !sender.isOn
}
customColumnWidthSize.textPublisher.sink { [weak self] text in
if let width = NumberFormatter().number(from: text), let count = self?.component.tableHeader.first?.count {
self?.component.columnWidths = Array(repeating: CGFloat(truncating: width), count: count)
}
}.store(in: &subscribers)
}
func setupPicker() {
@ -104,6 +124,55 @@ class TableViewController: BaseViewController<Table> {
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})])
if UIDevice.isIPad {
///Fourth row
let titleLockUp = TitleLockup()
let eyebrowModel = TitleLockup.EyebrowModel(text: "Today only.")
let titleModel = TitleLockup.TitleModel(text: "Get more of our best")
let subTitleModel = TitleLockup.SubTitleModel(text: "Get both of our best and pay less. Pair 5G Home Internet with Verizon mobile to save every month.")
titleLockUp.eyebrowModel = eyebrowModel
titleLockUp.titleModel = titleModel
titleLockUp.subTitleModel = subTitleModel
let button = Button()
button.text = "Testing"
rows.append([TableItemModel(bottomLine: .secondary, component:Toggle()),
TableItemModel(bottomLine: .secondary, component:titleLockUp),
TableItemModel(bottomLine: .secondary, component: button)])
///Fifth row
let tilelet = Tilelet()
let ftitleModel = Tilelet.TitleModel(text: "Save $XX on your monthly bill.")
let fsubTitleModel = Tilelet.SubTitleModel(text: "Enroll in Auto Pay & paper-free billing to save on your monthly bill.")
tilelet.titleModel = ftitleModel
tilelet.subTitleModel = fsubTitleModel
let textArea = TextArea()
textArea.labelText = "Street Address"
textArea.helperText = "For example: 123 Verizon St"
textArea.errorText = "Enter a valid address."
textArea.tooltipModel = .init(title: "Check the formatting of your address", content:"House/Building number then street name")
let trailingToolTip = TrailingTooltipLabel()
trailingToolTip.labelText = "5G Ultra Wideband is available in your area"
trailingToolTip.tooltipModel = .init(title: "Check the formatting of your address",
content:"House/Building number then street name")
let image = UIImage(named: "clean-surface")
let imageView = UIImageView(image: image)
rows.append([TableItemModel(bottomLine: .secondary, component:textArea),
TableItemModel(bottomLine: .secondary, component:imageView),
TableItemModel(bottomLine: .secondary, component:trailingToolTip)])
}
component.fillContainer = true
component.columnWidths = [400.0, 400.0, 400.0]
self.component.tableRows = rows
}
}