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
@@ -14,17 +14,15 @@ Apple's diffable API requerid models for each object type. If you want use it in
14
14
- [Swift Package Manager](#swift-package-manager)
15
15
- [CocoaPods](#cocoapods)
16
16
- [Manually](#manually)
17
+
- [Ready Use](#ready-use)
18
+
- [Example](#ready-use)
19
+
- [Available Classes](#available-classes)
17
20
- [Usage](#usage)
18
21
- [How it work](#usage)
19
22
- [Set Content](#set-content)
20
23
- [Get Content](#get-content)
21
-
- [Mediator](#mediator)
22
-
- [Diffable Delegate](#diffable-delegate)
23
-
- [Sidebar](#sidebar)
24
-
- [Ready Use](#ready-use)
25
-
- [Example](#ready-use)
26
-
- [List classes](#ready-use-classes)
27
24
- [Wrapper](#wrapper)
25
+
- [Sidebar](#sidebar)
28
26
- [Russian Community](#russian-community)
29
27
30
28
## Installation
@@ -55,6 +53,72 @@ pod 'SPDiffable'
55
53
56
54
If you prefer not to use any of dependency managers, you can integrate manually. Put `Sources/SPDiffable` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.
57
55
56
+
## Ready Use
57
+
58
+
For example you need simple table with native cells. You need create content with `SPDiffableTableRow`:
You init cell model and pass action, choose selection style and other. As you see, model describe native table cell. Next, you need set cell provider, but it also already available, for get it call `SPDiffableTableController.default`.
Now project's models automatically converting to cell. No need any additional work. That all code.
85
+
If you use custom table view or table controller, don't forget register cells classes. For `SPDiffableTableController` all cells already registered.
86
+
87
+
## Available Classes
88
+
89
+
It list models which you can use now, it shoud close your task without code. Of couse you can create your models.
90
+
Now in project you can find this ready-use models:
91
+
92
+
- `SPDiffableItem` it basic class. All item models shoud be extend from it model. Header and footer also.
93
+
- `SPDiffableSection` section class. Included footer and header properties, also items (cells).
94
+
- `SPDiffableTextHeaderFooter` header or footer class with text.
95
+
96
+
#### For Table:
97
+
98
+
Here provided models:
99
+
100
+
- `SPDiffableTableRow` it native item for table cell. Support all basic styles and action for tap event.
101
+
- `SPDiffableTableRowSubtitle` it native item for table cell with subtitle. Support all as before.
102
+
- `SPDiffableTableRowButton` item for table in style as button. Support table styles and action for tap.
103
+
- `SPDiffableTableRowStepper` item for table cell with stepper. Has maximum value and minimum, also incuded action with passed value.
104
+
- `SPDiffableTableRowSwitch` item for table with switch, included default state and action for change event.
105
+
106
+
Here provided cells:
107
+
108
+
- `SPDiffableTableViewCell` basic table cell with detail text right side.
109
+
- `SPDiffableSubtitleTableViewCell` basic table cell with two lines of texts.
110
+
- `SPDiffableStepper` cell with stepper control. Using with `SPDiffableTableRowStepper` model.
111
+
- `SPDiffableSwitch` cell with switch. Using with `SPDiffableTableRowSwitch` model.
112
+
- `SPDiffableSlider` cell with slider.
113
+
114
+
#### For Collection:
115
+
116
+
Provided only models, becouse for most items using list registration and no need specific cell class.
117
+
118
+
- `SPDiffableSideBarItem` menu item in side bar. Support accessories and actions.
119
+
- `SPDiffableSideBarButton` button item in side bar. Color of title similar to tint.
120
+
- `SPDiffableSideBarHeader` header model for side bar item.
121
+
58
122
## Usage
59
123
60
124
Before read it, highly recomded check `Example` target in project. It examle show all features, like use stepper and switch, like process actions, create custom models and many other. Also you can skip full undestand logic and read [Ready-use section](https://github.com/ivanvorobei/SPDiffable#ready-use) with minimum of code for start.
Some methods in diffable data source can't ovveride without custom data source. It solved with mediator delegate. It simple. Next example for table. Set delegate `SPTableDiffableMediator`, all method optional:
171
-
172
-
```swift
173
-
class DiffableTableController: SPDiffableTableController, SPTableDiffableMediator {
In protocol you can find more methods, like `canEdit` and other.
192
-
193
-
### Diffable Delegate
194
-
195
-
For handle some useful extensions, you can use delegates `SPDiffableTableDelegate`, `SPDiffableCollectionDelegate`. For example, when you need get which model did select, use this:
233
+
In project you can find class `SPDiffableWrapperItem`. Using it, when you don't want create custom item model for you diffable struct. You can pass any your model and uwrap it later in cell provider.
196
234
197
235
```swift
198
-
class DiffableTableController: SPDiffableTableController, SPDiffableTableDelegate {
let item = SPDiffableWrapperItem(id: "uniq-identifier", model: LocationRowModel(city: "Minsk"))
213
237
```
214
238
215
239
### Sidebar
@@ -245,80 +269,6 @@ SPDiffableSection(
245
269
)
246
270
```
247
271
248
-
## Ready Use
249
-
250
-
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`:
You init cell model and pass action, choose selection style and other. As you see, model describe native table cell. Next, you need set cell provider, but it also already available, for get it call `SPDiffableTableController.defaultCellProvider`.
Now project's models automatically converting to cell. No need any additional work. That all code.
277
-
If you use custom table view or table controller, don't forget register cells classes. For `SPDiffableTableController` all cells already registered.
278
-
279
-
## Ready-use classes
280
-
281
-
It list models which you can use now, it shoud close your task without code. Of couse you can create your models.
282
-
Now in project you can find this ready-use models:
283
-
284
-
- `SPDiffableItem` it basic class. All item models shoud be extend from it model. Header and footer also.
285
-
- `SPDiffableSection` section class. Included footer and header properties, also items (cells).
286
-
- `SPDiffableTextHeaderFooter` header or footer class with text.
287
-
288
-
#### For Table:
289
-
290
-
Here provided models:
291
-
292
-
- `SPDiffableTableRow` it native item for table cell. Support all basic styles and action for tap event.
293
-
- `SPDiffableTableRowSubtitle` it native item for table cell with subtitle. Support all as before.
294
-
- `SPDiffableTableRowButton` item for table in style as button. Support table styles and action for tap.
295
-
- `SPDiffableTableRowStepper` item for table cell with stepper. Has maximum value and minimum, also incuded action with passed value.
296
-
- `SPDiffableTableRowSwitch` item for table with switch, included default state and action for change event.
297
-
298
-
Here provided cells:
299
-
300
-
- `SPDiffableTableViewCell` basic table cell with detail text right side.
301
-
- `SPDiffableSubtitleTableViewCell` basic table cell with two lines of texts.
302
-
- `SPDiffableStepper` cell with stepper control. Using with `SPDiffableTableRowStepper` model.
303
-
- `SPDiffableSwitch` cell with switch. Using with `SPDiffableTableRowSwitch` model.
304
-
- `SPDiffableSlider` cell with slider.
305
-
306
-
#### For Collection:
307
-
308
-
Provided only models, becouse for most items using list registration and no need specific cell class.
309
-
310
-
- `SPDiffableSideBarItem` menu item in side bar. Support accessories and actions.
311
-
- `SPDiffableSideBarButton` button item in side bar. Color of title similar to tint.
312
-
- `SPDiffableSideBarHeader` header model for side bar item.
313
-
314
-
## Wrapper
315
-
316
-
In project you can find class `SPDiffableWrapperItem`. Using it, when you don't want create custom item model for you diffable struct. You can pass any your model and uwrap it later in cell provider.
317
-
318
-
```swift
319
-
let item = SPDiffableWrapperItem(id: "uniq-identifier", model: LocationRowModel(city: "Minsk"))
320
-
```
321
-
322
272
## Russian Community
323
273
324
274
Я веду [телеграм-канал](https://sparrowcode.by/telegram), там публикую новости и туториалы.<br>
0 commit comments