Minor refactoring changes.
This commit is contained in:
parent
e51b4dfe37
commit
7a47221d62
@ -8,6 +8,7 @@
|
||||
import Foundation
|
||||
import VDS
|
||||
import UIKit
|
||||
import VDSTokens
|
||||
|
||||
class TableViewController: BaseViewController<Table> {
|
||||
|
||||
@ -15,7 +16,9 @@ class TableViewController: BaseViewController<Table> {
|
||||
|
||||
var fillContainer = Toggle()
|
||||
|
||||
var customColumnWidthSize = NumericField()
|
||||
var customColumnWidthSize = NumericField().with {
|
||||
$0.placeholder = "Minimum 50px"
|
||||
}
|
||||
|
||||
lazy var headerLineStylePicker = {
|
||||
PickerSelectorView(title: "primary", picker: self.picker, items: Line.Style.allCases)
|
||||
@ -46,6 +49,7 @@ class TableViewController: BaseViewController<Table> {
|
||||
addFormRow(label: "Custom column size", view: customColumnWidthSize)
|
||||
|
||||
fillContainer.isOn = component.fillContainer
|
||||
updateTextFieldStatus(enable: !fillContainer.isOn)
|
||||
|
||||
addContentTopView(view: component)
|
||||
|
||||
@ -55,14 +59,13 @@ class TableViewController: BaseViewController<Table> {
|
||||
|
||||
fillContainer.onChange = { [weak self] sender in
|
||||
self?.component.fillContainer = sender.isOn
|
||||
self?.customColumnWidthSize.isEnabled = !sender.isOn
|
||||
self?.updateTextFieldStatus(enable:!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)
|
||||
|
||||
customColumnWidthSize.numberPublisher.sink { [weak self] text in
|
||||
if let count = self?.component.tableHeader.first?.count, let text, text.intValue > 50 {
|
||||
self?.component.columnWidths = Array(repeating: CGFloat(truncating: text), count: count)
|
||||
}
|
||||
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
@ -104,6 +107,11 @@ class TableViewController: BaseViewController<Table> {
|
||||
}
|
||||
}
|
||||
|
||||
func updateTextFieldStatus(enable: Bool) {
|
||||
customColumnWidthSize.isEnabled = enable
|
||||
customColumnWidthSize.backgroundColor = enable ? UIColor.white : VDSColor.paletteGray85
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
///Header row
|
||||
self.component.tableHeader = [[TableItemModel(bottomLine: .primary, component: Label().with { $0.text = ""}),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user