Skip to content

Commit aece327

Browse files
committed
Fixed cell provider.
1 parent c9e4644 commit aece327

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

SPDiffable.podspec

+1-1
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 = '1.6.6'
4+
s.version = '1.6.7'
55
s.summary = 'Extenshion of Diffable API which allow not duplicate code and use less models.'
66
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }

Sources/SPDiffable/Table/SPDiffableTableCellProviders.swift

+18-18
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,7 @@ public enum SPDiffableTableCellProviders {
3131
For change style of cells requerid register new cell provider.
3232
*/
3333
public static var `default`: [SPDiffableTableCellProvider] {
34-
return [rowDetail, rowSubtitle, self.switch, stepper]
35-
}
36-
37-
public static var customCell: SPDiffableTableCellProvider {
38-
let cellProvider: SPDiffableTableCellProvider = { (tableView, indexPath, item) -> UITableViewCell? in
39-
guard let item = item as? SPDiffableCustomTableRow else { return nil }
40-
let cell = tableView.dequeueReusableCell(withIdentifier: SPDiffableCustomTableViewCell.reuseIdentifier, for: indexPath) as! SPDiffableCustomTableViewCell
41-
cell.textLabel?.text = item.text
42-
cell.textLabel?.textColor = item.textColor
43-
cell.textLabel?.font = item.textFont
44-
cell.detailTextLabel?.text = item.detail
45-
cell.imageView?.image = item.icon
46-
cell.accessoryType = item.accessoryType
47-
cell.selectionStyle = item.selectionStyle
48-
cell.higlightStyle = item.higlightStyle
49-
return cell
50-
}
51-
return cellProvider
34+
return [rowDetail, rowSubtitle, `switch`, stepper, customisable]
5235
}
5336

5437
public static var rowDetail: SPDiffableTableCellProvider {
@@ -111,4 +94,21 @@ public enum SPDiffableTableCellProviders {
11194
}
11295
return cellProvider
11396
}
97+
98+
public static var customisable: SPDiffableTableCellProvider {
99+
let cellProvider: SPDiffableTableCellProvider = { (tableView, indexPath, item) -> UITableViewCell? in
100+
guard let item = item as? SPDiffableCustomTableRow else { return nil }
101+
let cell = tableView.dequeueReusableCell(withIdentifier: SPDiffableCustomTableViewCell.reuseIdentifier, for: indexPath) as! SPDiffableCustomTableViewCell
102+
cell.textLabel?.text = item.text
103+
cell.textLabel?.textColor = item.textColor
104+
cell.textLabel?.font = item.textFont
105+
cell.detailTextLabel?.text = item.detail
106+
cell.imageView?.image = item.icon
107+
cell.accessoryType = item.accessoryType
108+
cell.selectionStyle = item.selectionStyle
109+
cell.higlightStyle = item.higlightStyle
110+
return cell
111+
}
112+
return cellProvider
113+
}
114114
}

Sources/SPDiffable/Table/SPDiffableTableController.swift

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ open class SPDiffableTableController: UITableViewController {
4040
super.viewDidLoad()
4141
tableView.register(SPDiffableTableViewCell.self, forCellReuseIdentifier: SPDiffableTableViewCell.reuseIdentifier)
4242
tableView.register(SPDiffableSubtitleTableViewCell.self, forCellReuseIdentifier: SPDiffableSubtitleTableViewCell.reuseIdentifier)
43+
tableView.register(SPDiffableCustomTableViewCell.self, forCellReuseIdentifier: SPDiffableCustomTableViewCell.reuseIdentifier)
4344
}
4445

4546
// MARK: - Init

0 commit comments

Comments
 (0)