Skip to content

Commit 69be9b1

Browse files
committed
Update docs
1 parent c4acbd1 commit 69be9b1

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Readme.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TableRowModel: SPDiffableItem {}
7777
After it add properties, which you want use. For example:
7878

7979
```swift
80-
class TableRowMode: SPDiffableItem {
80+
class TableRowModel: SPDiffableItem {
8181

8282
public var text: String
8383
public var detail: String? = nil
@@ -95,13 +95,13 @@ override func viewDidLoad() {
9595
super.viewDidLoad()
9696

9797
// Register cell for usage it in table view
98-
tableView.register(NativeTableViewCell.self, forCellReuseIdentifier: NativeTableViewCell.identifier)
98+
tableView.register(SPDiffableTableViewCell.self, forCellReuseIdentifier: SPDiffableTableViewCell.reuseIdentifier)
9999

100-
// Cell provider for `TableRowMode`
100+
// Cell provider for `TableRowModel`
101101
let cellProvider: SPDiffableTableCellProvider = { (tableView, indexPath, model) -> UITableViewCell? in
102102
switch model {
103-
case let model as TableRowMode:
104-
let cell = tableView.dequeueReusableCell(withIdentifier: NativeTableViewCell.identifier, for: indexPath) as! NativeTableViewCell
103+
case let model as TableRowModel:
104+
let cell = tableView.dequeueReusableCell(withIdentifier: YourTableViewCell.identifier, for: indexPath) as! YourTableViewCell
105105
cell.textLabel?.text = model.text
106106
cell.detailTextLabel?.text = model.detail
107107
cell.accessoryType = model.accessoryType
@@ -117,7 +117,7 @@ override func viewDidLoad() {
117117
setCellProviders([cellProvider], sections: content)
118118
}
119119
```
120-
120+
You can use default cell provider if using project's models. For get it call `SPDiffableTableController.defaultCellProvider`.
121121
All actions similar to collections. For example usage you can find in project in taget `Example`.
122122

123123
### Apply Content
@@ -131,7 +131,7 @@ let section = SPDiffableSection(
131131
header: SPDiffableTextHeaderFooter(text: "Header"),
132132
footer: SPDiffableTextHeaderFooter(text: "Footer"),
133133
items: [
134-
TableRowMode(text: "Basic Table Cell", accessoryType: .disclosureIndicator, action: { [weak self] indexPath in
134+
TableRowModel(text: "Basic Table Cell", accessoryType: .disclosureIndicator, action: { [weak self] indexPath in
135135
guard let self = self else { return }
136136
self.tableView.deselectRow(at: indexPath, animated: true)
137137
print("Tapped")
@@ -221,10 +221,14 @@ Now in project you can find this ready-use models:
221221
#### For Table:
222222

223223
- `SPDiffableTableRow` it native item for table cell. Support all basic styles and action for tap event.
224+
- `SPDiffableTableRowSubtitle` it native item for table cell with subtitle. Support all as before.
224225
- `SPDiffableTableRowStepper` item for table cell with stepper. Has maximum value and minimum, also incuded action with passed value.
225226
- `SPDiffableTableRowSwitch` item for table with switch, included default state and action for change event.
226227
- `SPDiffableTableRowButton` item for table in style as button. Support table styles and action for tap.
227228

229+
- `SPDiffableTableViewCell` basic table cell with detail text right side.
230+
- `SPDiffableSubtitleTableViewCell` basic table cell with two lines of texts.
231+
228232
#### For Collection:
229233

230234
Now in progress development.

Sources/SPDiffable/Table/SPDiffableTableController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ open class SPDiffableTableController: UITableViewController {
5151
diffableDataSource?.apply(sections: sections, animating: false)
5252
}
5353

54+
/**
55+
Return cell provider, which process for all project models cells.
56+
No need additional configure.
57+
58+
For change style of cells requerid register new cell provider.
59+
*/
5460
public static var defaultCellProvider: SPDiffableTableCellProvider {
5561
let cellProvider: SPDiffableTableCellProvider = { (tableView, indexPath, model) -> UITableViewCell? in
5662
switch model {

0 commit comments

Comments
 (0)