Skip to content

Commit 7e3cbe5

Browse files
committed
README fix
1 parent 0663b17 commit 7e3cbe5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ UITableViewController and UICollectionViewController based on a DiffableDataSour
1818

1919
### [Swift Package Manager](https://swift.org/package-manager/)
2020

21-
Add the following to the dependencies of your `Package.swift:
21+
Add the following to the dependencies of your `Package.swift`:
2222

2323
```swift
2424
.package(url: "https://github.com/FelixHerrmann/FHDiffableViewControllers", from: "x.x.x")
@@ -34,6 +34,8 @@ If you are using Swift Package Manager, you have to import FHDiffableViewControl
3434

3535
Now you can inherit your view controller class from `FHDiffableTableViewController` and `FHDiffableCollectionViewController`.
3636

37+
<br>
38+
3739
But first we need a `SectionIdentifier` and `ItemIdentifier` which will be used for the generic types. Both types have to conform to `Hashable`.
3840

3941
```swift
@@ -47,6 +49,8 @@ struct Item: Hashable {
4749
```
4850
>It is recommend to conform the item to `Identifiable` because the app crashes if there are duplicates in the data source!
4951
52+
<br>
53+
5054
These types can be used like that:
5155

5256
```swift
@@ -74,6 +78,8 @@ class ViewController: FHDiffableTableViewController<Section, Item> {
7478
```
7579
>This is the most simple implementation of a FHDiffableTableViewController.
7680
81+
<br>
82+
7783
### Customize Cells
7884

7985
In order to use custom cells, the `cellProvider` property must be overritten. This works exactly the same for table view and collection view.
@@ -94,6 +100,8 @@ Do not forget to register the cell bevor you call `applySnapshot(_:)` the first
94100
tableView.register(CustomCell.self, forCellReuseIdentifier: "customCell")
95101
```
96102

103+
<br>
104+
97105
### Customize Header and Footer Views (only collection view)
98106

99107
In order to use custom header or footer views, the `supplementaryViewProvider` property must be overritten.
@@ -119,6 +127,8 @@ Do not forget to register the cell bevor you call `applySnapshot(_:)` the first
119127
collectionView.register(CustomHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "customHeader")
120128
```
121129

130+
<br>
131+
122132
### Custom Data Source
123133

124134
In case you want to change the behavior of the title creation or you want to use section index titles and other features you have to subclass the appropriate data source. For the table view it could look something like that:
@@ -148,6 +158,8 @@ override var dataSource: UITableViewDiffableDataSource<Section, Item> {
148158
}
149159
```
150160

161+
<br>
162+
151163
### Custom `applySnapshot(_:)`
152164

153165
You are not forced to use `applySnapshot(_:)` in combination with `FHDiffableDataSourceSection` array to apply snapshots to your `dataSource`. You can override the `applySnapshot(_:)` to change its behavior, create your own `applySnapshot()` method or do it manually as follows:
@@ -160,10 +172,14 @@ snapshot.appendItems([Item(title: "Detail Item")], toSection: .detail)
160172
dataSource.apply(snapshot, animatingDifferences: true, completion: nil)
161173
```
162174

175+
<br>
176+
163177
### init(layout:)
164178

165179
I use a custom initializer for the `FHDiffableCollectionViewController` which is based on an enum. This contains a case for `UICollectionViewFlowLayout`, for `UICollectionViewCompositionalLayout`, for a custom `UICollectionViewLayout` or a default case. The default case creates a compositional layout which is only intended to be used for testing.
166180

181+
<br>
182+
167183
## License
168184

169185
FHConstraints is available under the MIT license. See the [LICENSE](https://github.com/FelixHerrmann/FHDiffableViewControllers/blob/master/LICENSE) file for more info.

0 commit comments

Comments
 (0)