Skip to content

Commit a006d02

Browse files
committed
Fixed sidebar.
1 parent 30b40b3 commit a006d02

File tree

8 files changed

+14
-25
lines changed

8 files changed

+14
-25
lines changed

Example Apps/iOS Example/Controllers/DiffableTableController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DiffableTableController: SPDiffableTableController, SPDiffableTableMediato
3636
override func viewDidLoad() {
3737
super.viewDidLoad()
3838
diffableDataSource?.mediator = self
39-
setCellProviders([.default], sections: content)
39+
setCellProviders(SPDiffableTableCellProvider.default, sections: content)
4040
}
4141

4242
var content: [SPDiffableSection] {

Example Apps/iOS Example/Controllers/SideBarController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SidebarController: SPDiffableSideBarController {
2727

2828
override func viewDidLoad() {
2929
super.viewDidLoad()
30-
setCellProviders([.sideBar], sections: content)
30+
setCellProviders(SPDiffableCollectionCellProvider.sideBar, sections: content)
3131
}
3232

3333
enum Section: String {

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ In class available ready-use cell providers for menu item and header section. Fo
225225
```swift
226226
override func viewDidLoad() {
227227
super.viewDidLoad()
228-
setCellProviders(SPDiffableCollectionCellProviders.sideBar, sections: content)
228+
setCellProviders(SPDiffableCollectionCellProvider.sideBar, sections: content)
229229
}
230230
```
231231

@@ -270,7 +270,7 @@ let section = SPDiffableSection(
270270
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`.
271271

272272
```swift
273-
setCellProviders([.default], sections: [section])
273+
setCellProviders(SPDiffableTableCellProvider.default, sections: [section])
274274
```
275275

276276
Now project's models automatically converting to cell. No need any additional work. That all code.

SPDiffable.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPDiffable'
4-
s.version = '2.1.1'
4+
s.version = '2.1.2'
55
s.summary = 'Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.'
66
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }

Sources/SPDiffable/Collection/SPDiffableCollectionCellProvider.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,13 @@ open class SPDiffableCollectionCellProvider {
4040
/**
4141
SPDiffable: Defaults cell provider, which can help you doing side bar faster.
4242
You can do your providers and ise its with more flexible.
43+
44+
- warning:
45+
Don't make shared clouser becouse cell registrantion handle inside with error.
4346
*/
4447
@available(iOS 14, *)
45-
public static var sideBar: SPDiffableCollectionCellProvider {
46-
return SPDiffableCollectionCellProvider() { (collectionView, indexPath, item) -> UICollectionViewCell? in
47-
let providers = [sideBarItem, sideBarButton, sideBarHeader]
48-
for provider in providers {
49-
if let cell = provider.clouser(collectionView, indexPath, item) {
50-
return cell
51-
}
52-
}
53-
return nil
54-
}
48+
public static var sideBar: [SPDiffableCollectionCellProvider] {
49+
[sideBarItem, sideBarButton, sideBarHeader]
5550
}
5651

5752
@available(iOS 14, *)

Sources/SPDiffable/Table/SPDiffableTableCellProvider.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,8 @@ open class SPDiffableTableCellProvider {
3535

3636
// MARK: - Ready Use
3737

38-
public static var `default`: SPDiffableTableCellProvider {
39-
return SPDiffableTableCellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
40-
let providers = [rowDetail, rowSubtitle, `switch`, stepper]
41-
for provider in providers {
42-
if let cell = provider.clouser(tableView, indexPath, item) {
43-
return cell
44-
}
45-
}
46-
return nil
47-
}
38+
public static var `default`: [SPDiffableTableCellProvider] {
39+
[rowDetail, rowSubtitle, `switch`, stepper]
4840
}
4941

5042
public static var rowDetail: SPDiffableTableCellProvider {

TODO.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# TODO
22

33
Here provided ideas or features which will be implemented soon.
4+
5+
- Place cell provider inside data source.

0 commit comments

Comments
 (0)