Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
fun committed Oct 10, 2022
1 parent 268fc71 commit ea96f01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Sources/Jenga/Core/Row/BasicRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ open class BasicRow<T: UITableViewCell>: SystemRow, RowConfigurable {

public extension BasicRow {

func selectionStyle(_ value: UITableViewCell.SelectionStyle) -> Self {
reform { $0.selectionStyle = value }
}

func customize(_ value: @escaping ((T) -> Void)) -> Self {
reform { $0.customize = value }
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/Jenga/Core/Row/TableRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public extension TableRow {
reform { $0.isSelectable = value }
}

func selectionStyle(_ value: UITableViewCell.SelectionStyle) -> Self {
reform { $0.selectionStyle = value }
}

func data(_ data: Cell.CellData) -> Self {
reform { $0.item = .constant(data) }
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Jenga/Core/TableDirector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ extension TableDirector: UITableViewDataSource {
let cell =
tableView.dequeueReusableCell(withIdentifier: row.reuseIdentifier) ??
row.cellType.init(style: row.cellStyle, reuseIdentifier: row.reuseIdentifier)
(row as? RowConfigurable)?.configure(cell)
cell.selectionStyle = row.selectionStyle
(row as? RowConfigurable)?.configure(cell)
return cell

} else {
cellRegisterer?.register(cellType: row.cellType, forCellReuseIdentifier: row.reuseIdentifier)

let cell =
tableView.dequeueReusableCell(withIdentifier: row.reuseIdentifier, for: indexPath)
(row as? RowConfigurable)?.configure(cell)
cell.selectionStyle = row.selectionStyle
(row as? RowConfigurable)?.configure(cell)
return cell
}
}
Expand Down

0 comments on commit ea96f01

Please sign in to comment.