[Question] Dropdown cell
astrokin opened this issue · comments
@maxsokolov could you please advice any best practices from your perspective with TableKit? Or some code sample?
Hi @maxsokolov yes, something like this.
So I can see at least two approaches to implement this, but I can't say that TableKit has best practices for this.
so, anyway a solution depends on your UI:
- You could make a few collapsable/expandable sections with custom header with arrow button like this:
let myHeader = MyHeaderView(title: "title", icon: UIImage())
myHeader.onClick = {
}
let section1 = TableSection(headerView: myHeader, footerView: nil)
tableDirector += [section1, section2, section3]
so once you clicked at arrow button you could just add rows to that section with animation:
let row1 = TableRow<StringTableCell>(item: "title")
section1 += row1
tableView.beginUpdates()
tableView.insertRows(at: [IndexPath], with: .automatic)
tableView.endUpdates()
Same to collapse section: simply remove rows from that section and perform changes on your tableView.
- Or you could have only one section with different cells. And insert rows below the clicked row. But you should be careful with index paths.
So I guess the first approach is the easiest one.
I thought in some similar way. Thank you for your advice.
@astrokin glad to help. Can we close the issue now?
for sure. thanks!