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
-225
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,6 @@ 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)
20
-
-[Usage](#usage)
21
-
-[How it work](#usage)
22
-
-[Set Content](#set-content)
23
-
-[Get Content](#get-content)
24
-
-[Wrapper](#wrapper)
25
-
-[Sidebar](#sidebar)
26
17
-[Russian Community](#russian-community)
27
18
28
19
## Installation
@@ -53,222 +44,6 @@ pod 'SPDiffable'
53
44
54
45
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`.
55
46
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
-
122
-
## Usage
123
-
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.
125
-
126
-
For work with diffable need create model (inside project you found some ready-use models) and do cell provider, which convert data-model to `UITableViewCell` or `UICollectionViewCell`. Next example for table, but all methods and class names available for collections.
127
-
128
-
New model shoud extend from basic class `SPDiffableItem`:
129
-
130
-
```swift
131
-
classLocationRowModel: SPDiffableItem {
132
-
133
-
// Add properties, which you need
134
-
publicvar city: String
135
-
publicvar adress: String?
136
-
}
137
-
```
138
-
139
-
Last step, create table controller class and extend of `SPDiffableTableController`. Create custom cell provider, it doing convert it data to table cell:
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.
234
-
235
-
```swift
236
-
let item =SPDiffableWrapperItem(id: "uniq-identifier", model: LocationRowModel(city: "Minsk"))
237
-
```
238
-
239
-
### Sidebar
240
-
241
-
Create new controller and extend from `SPDiffableSideBarController`. Remember, it available only from iOS 14.
Content it array of `SPDiffableSection`. For menu model need use model `SPDiffableSideBarItem` or `SPDiffableSideBarButton`. For header and footer will create `SPDiffableSideBarHeader` model.
0 commit comments