using TableRowModel to populate data for Table component.
This commit is contained in:
parent
7a47221d62
commit
0590309726
@ -60,10 +60,15 @@ class TableViewController: BaseViewController<Table> {
|
||||
fillContainer.onChange = { [weak self] sender in
|
||||
self?.component.fillContainer = sender.isOn
|
||||
self?.updateTextFieldStatus(enable:!sender.isOn)
|
||||
if let count = self?.component.tableHeader.first?.columnsCount,
|
||||
let text = self?.customColumnWidthSize.text,
|
||||
let width = NumberFormatter().number(from: text) {
|
||||
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 {
|
||||
if let count = self?.component.tableHeader.first?.columnsCount, let text, text.intValue > 50 {
|
||||
self?.component.columnWidths = Array(repeating: CGFloat(truncating: text), count: count)
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
@ -76,11 +81,11 @@ class TableViewController: BaseViewController<Table> {
|
||||
}
|
||||
|
||||
headerLineStylePicker.onPickerDidSelect = { [weak self] item in
|
||||
var headers = self?.component.tableHeader ?? [[]]
|
||||
var headers = self?.component.tableHeader ?? [TableRowModel]()
|
||||
for currentHeaderIndex in 0..<headers.count {
|
||||
var currentHeader = headers[currentHeaderIndex]
|
||||
for currentHeaderItem in 0..<currentHeader.count {
|
||||
currentHeader[currentHeaderItem].bottomLine = item
|
||||
for currentHeaderItem in 0..<currentHeader.columnsCount {
|
||||
currentHeader.columns[currentHeaderItem].bottomLine = item
|
||||
}
|
||||
headers[currentHeaderIndex] = currentHeader
|
||||
}
|
||||
@ -89,12 +94,12 @@ class TableViewController: BaseViewController<Table> {
|
||||
|
||||
rowLineStylePicker.onPickerDidSelect = { [weak self] item in
|
||||
|
||||
var rows = self?.component.tableRows ?? [[]]
|
||||
var rows = self?.component.tableRows ?? [TableRowModel]()
|
||||
|
||||
for currentRowIndex in 0..<rows.count {
|
||||
var currentRow = rows[currentRowIndex]
|
||||
for currentRowItem in 0..<currentRow.count {
|
||||
currentRow[currentRowItem].bottomLine = item
|
||||
for currentRowItem in 0..<currentRow.columnsCount {
|
||||
currentRow.columns[currentRowItem].bottomLine = item
|
||||
}
|
||||
rows[currentRowIndex] = currentRow
|
||||
}
|
||||
@ -114,23 +119,24 @@ class TableViewController: BaseViewController<Table> {
|
||||
|
||||
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 })]]
|
||||
|
||||
self.component.tableHeader = [TableRowModel(columns: [TableItemModel(bottomLine: .primary, component: nil),
|
||||
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}),
|
||||
var rows = [TableRowModel(columns: [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})]]
|
||||
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}),
|
||||
rows.append(TableRowModel(columns: [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 })])
|
||||
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}),
|
||||
rows.append(TableRowModel(columns: [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})])
|
||||
TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "Permanently"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping})]))
|
||||
|
||||
if UIDevice.isIPad {
|
||||
|
||||
@ -147,9 +153,9 @@ class TableViewController: BaseViewController<Table> {
|
||||
let button = Button()
|
||||
button.text = "Testing"
|
||||
|
||||
rows.append([TableItemModel(bottomLine: .secondary, component:Toggle()),
|
||||
rows.append(TableRowModel(columns: [TableItemModel(bottomLine: .secondary, component:Toggle()),
|
||||
TableItemModel(bottomLine: .secondary, component:titleLockUp),
|
||||
TableItemModel(bottomLine: .secondary, component: button)])
|
||||
TableItemModel(bottomLine: .secondary, component: button)]))
|
||||
|
||||
|
||||
///Fifth row
|
||||
@ -172,9 +178,9 @@ class TableViewController: BaseViewController<Table> {
|
||||
let image = UIImage(named: "clean-surface")
|
||||
let imageView = UIImageView(image: image)
|
||||
|
||||
rows.append([TableItemModel(bottomLine: .secondary, component:textArea),
|
||||
rows.append(TableRowModel(columns: [TableItemModel(bottomLine: .secondary, component:textArea),
|
||||
TableItemModel(bottomLine: .secondary, component:imageView),
|
||||
TableItemModel(bottomLine: .secondary, component:trailingToolTip)])
|
||||
TableItemModel(bottomLine: .secondary, component:trailingToolTip)]))
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user