You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+71-51Lines changed: 71 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ If you like the project, don't forget to `put star ★` and follow me on GitHub:
17
17
-[How it work](#usage)
18
18
-[Apply content](#apply-content)
19
19
-[Mediator](#mediator)
20
+
-[Diffable Delegate](#diffable-delegate)
20
21
-[Sidebar](#sidebar)
21
22
-[Ready Use](#ready-use)
22
23
-[Example](#ready-use)
@@ -62,15 +63,10 @@ For work with diffable need create model (inside project you found some ready-us
62
63
63
64
New model shoud extend from basic class `SPDiffableItem`:
64
65
65
-
```swift
66
-
classLocationRowModel: SPDiffableItem {}
67
-
```
68
-
69
-
After it add properties, which you want use. For example:
70
-
71
66
```swift
72
67
classLocationRowModel: SPDiffableItem {
73
68
69
+
// Add properties, which you need
74
70
publicvar city: String
75
71
publicvar adress: String?
76
72
}
@@ -79,59 +75,67 @@ class LocationRowModel: SPDiffableItem {
79
75
Last step, create table controller class and extend of `SPDiffableTableController`. Create custom cell provider, it doing convert it data to table cell:
In project available models for like `SPDiffableTableRow` and other with ready-use properties. Also you can use default cell provider if using project's models. For get it call `SPDiffableTableCellProviders.default`.
108
105
109
-
### Apply Content
106
+
Now ready model and convert it to views. Time to add content. Read next section.
107
+
108
+
#### Apply Content
110
109
111
-
Now table support models and custom cell provider. We can apply diffable content with animation (or not).
112
-
Create section class:
110
+
Now table support models and custom cell provider. You can apply diffable content with animation (or not).
In protocol you can find more methods, like `canEdit` and other.
161
165
166
+
### Diffable Delegate
167
+
168
+
For handle some useful extensions, you can use delegates `SPDiffableTableDelegate`, `SPDiffableCollectionDelegate`. For example, when you need get which model did select, use this:
Create new controller and extend from `SPDiffableSideBarController`. Remember, it available only from iOS 14.
@@ -194,7 +220,7 @@ SPDiffableSection(
194
220
195
221
## Ready Use
196
222
197
-
You can save time and count of code using ready-use classes. In project available models and views. For example you need simple table with native cells. You need create content with `SPDiffableTableRow`:
223
+
You can save time and count lines of code using ready-use classes. In project available models and views. For example you need simple table with native cells. You need create content with `SPDiffableTableRow`:
0 commit comments