Merge branch 'bugfix/Table' into 'develop'
Bugfix/table See merge request BPHV_MIPS/vds_ios_sample!69
This commit is contained in:
commit
1cb7904cf7
@ -10,6 +10,23 @@ import VDS
|
||||
import UIKit
|
||||
import VDSCoreTokens
|
||||
|
||||
enum TableLineStyle: String, CaseIterable {
|
||||
case none
|
||||
case primary
|
||||
case secondary
|
||||
|
||||
func lineStyle() -> Line.Style? {
|
||||
switch self {
|
||||
case .primary:
|
||||
return Line.Style.primary
|
||||
case .secondary:
|
||||
return Line.Style.secondary
|
||||
case .none:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TableViewController: BaseViewController<Table> {
|
||||
|
||||
var striped = Toggle()
|
||||
@ -21,11 +38,11 @@ class TableViewController: BaseViewController<Table> {
|
||||
}
|
||||
|
||||
lazy var headerLineStylePicker = {
|
||||
PickerSelectorView(title: "primary", picker: self.picker, items: Line.Style.allCases)
|
||||
PickerSelectorView(title: "primary", picker: self.picker, items: TableLineStyle.allCases)
|
||||
}()
|
||||
|
||||
lazy var rowLineStylePicker = {
|
||||
PickerSelectorView(title: "secondary", picker: self.picker, items: Line.Style.allCases)
|
||||
PickerSelectorView(title: "secondary", picker: self.picker, items: TableLineStyle.allCases)
|
||||
}()
|
||||
|
||||
lazy var paddingPicker = {
|
||||
@ -55,6 +72,20 @@ class TableViewController: BaseViewController<Table> {
|
||||
|
||||
striped.onChange = { [weak self] sender in
|
||||
self?.component.striped = sender.isOn
|
||||
|
||||
let headerStyle = sender.isOn ? nil : TableLineStyle(rawValue: self?.headerLineStylePicker.text ?? "")
|
||||
let rowStyle = sender.isOn ? nil : TableLineStyle(rawValue: self?.rowLineStylePicker.text ?? "")
|
||||
|
||||
var headers = self?.component.tableHeader ?? [TableRowModel]()
|
||||
self?.updateBottomLineStyle(items:&headers, style: headerStyle?.lineStyle())
|
||||
self?.component.tableHeader = headers
|
||||
|
||||
var rows = self?.component.tableRows ?? [TableRowModel]()
|
||||
self?.updateBottomLineStyle(items:&rows, style: rowStyle?.lineStyle())
|
||||
self?.component.tableRows = rows
|
||||
|
||||
self?.component.padding = .compact
|
||||
self?.paddingPicker.text = Table.Padding.compact.rawValue
|
||||
}
|
||||
|
||||
fillContainer.onChange = { [weak self] sender in
|
||||
@ -82,28 +113,14 @@ class TableViewController: BaseViewController<Table> {
|
||||
|
||||
headerLineStylePicker.onPickerDidSelect = { [weak self] item in
|
||||
var headers = self?.component.tableHeader ?? [TableRowModel]()
|
||||
for currentHeaderIndex in 0..<headers.count {
|
||||
var currentHeader = headers[currentHeaderIndex]
|
||||
for currentHeaderItem in 0..<currentHeader.columnsCount {
|
||||
currentHeader.columns[currentHeaderItem].bottomLine = item
|
||||
}
|
||||
headers[currentHeaderIndex] = currentHeader
|
||||
}
|
||||
self?.updateBottomLineStyle(items:&headers, style: item.lineStyle())
|
||||
self?.component.tableHeader = headers
|
||||
}
|
||||
|
||||
rowLineStylePicker.onPickerDidSelect = { [weak self] item in
|
||||
|
||||
var rows = self?.component.tableRows ?? [TableRowModel]()
|
||||
|
||||
for currentRowIndex in 0..<rows.count {
|
||||
var currentRow = rows[currentRowIndex]
|
||||
for currentRowItem in 0..<currentRow.columnsCount {
|
||||
currentRow.columns[currentRowItem].bottomLine = item
|
||||
}
|
||||
rows[currentRowIndex] = currentRow
|
||||
}
|
||||
|
||||
self?.updateBottomLineStyle(items:&rows, style: item.lineStyle())
|
||||
self?.component.tableRows = rows
|
||||
}
|
||||
|
||||
@ -117,12 +134,22 @@ class TableViewController: BaseViewController<Table> {
|
||||
customColumnWidthSize.backgroundColor = enable ? UIColor.white : VDSColor.paletteGray85
|
||||
}
|
||||
|
||||
func updateBottomLineStyle(items:inout [TableRowModel], style: Line.Style?) {
|
||||
for currentRowIndex in 0..<items.count {
|
||||
var currentRow = items[currentRowIndex]
|
||||
for currentRowItem in 0..<currentRow.columnsCount {
|
||||
currentRow.columns[currentRowItem].bottomLine = style
|
||||
}
|
||||
items[currentRowIndex] = currentRow
|
||||
}
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
///Header row
|
||||
|
||||
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 })])]
|
||||
TableItemModel(bottomLine: .primary, component: Label().with { $0.text = "Call filter"; $0.textStyle = .boldTitleSmall; $0.lineBreakMode = .byWordWrapping })], isHeader: true)]
|
||||
|
||||
///First row
|
||||
var rows = [TableRowModel(columns: [TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "Cost"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping}),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user