meaningful associatedtype name for ConfigurableCell
This commit is contained in:
parent
dd8e5d0625
commit
1d28233ebe
|
|
@ -4,7 +4,7 @@
|
||||||
<a href="https://travis-ci.org/maxsokolov/TableKit"><img src="https://api.travis-ci.org/maxsokolov/TableKit.svg" alt="Build Status" /></a>
|
<a href="https://travis-ci.org/maxsokolov/TableKit"><img src="https://api.travis-ci.org/maxsokolov/TableKit.svg" alt="Build Status" /></a>
|
||||||
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/Swift_4.0-compatible-4BC51D.svg?style=flat" alt="Swift 4.0 compatible" /></a>
|
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/Swift_4.0-compatible-4BC51D.svg?style=flat" alt="Swift 4.0 compatible" /></a>
|
||||||
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible" /></a>
|
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible" /></a>
|
||||||
<a href="https://cocoapods.org/pods/tablekit"><img src="https://img.shields.io/badge/pod-2.6.0-blue.svg" alt="CocoaPods compatible" /></a>
|
<a href="https://cocoapods.org/pods/tablekit"><img src="https://img.shields.io/badge/pod-2.7.0-blue.svg" alt="CocoaPods compatible" /></a>
|
||||||
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
|
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
|
||||||
<a href="https://raw.githubusercontent.com/maxsokolov/tablekit/master/LICENSE"><img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License: MIT" /></a>
|
<a href="https://raw.githubusercontent.com/maxsokolov/tablekit/master/LICENSE"><img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License: MIT" /></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@ import UIKit
|
||||||
|
|
||||||
public protocol ConfigurableCell {
|
public protocol ConfigurableCell {
|
||||||
|
|
||||||
associatedtype T
|
associatedtype CellData
|
||||||
|
|
||||||
static var reuseIdentifier: String { get }
|
static var reuseIdentifier: String { get }
|
||||||
static var estimatedHeight: CGFloat? { get }
|
static var estimatedHeight: CGFloat? { get }
|
||||||
static var defaultHeight: CGFloat? { get }
|
static var defaultHeight: CGFloat? { get }
|
||||||
|
|
||||||
func configure(with _: T)
|
func configure(with _: CellData)
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension ConfigurableCell where Self: UITableViewCell {
|
public extension ConfigurableCell where Self: UITableViewCell {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import UIKit
|
||||||
|
|
||||||
open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableViewCell {
|
open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableViewCell {
|
||||||
|
|
||||||
open let item: CellType.T
|
open let item: CellType.CellData
|
||||||
private lazy var actions = [String: [TableRowAction<CellType>]]()
|
private lazy var actions = [String: [TableRowAction<CellType>]]()
|
||||||
private(set) open var editingActions: [UITableViewRowAction]?
|
private(set) open var editingActions: [UITableViewRowAction]?
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
|
||||||
return CellType.self
|
return CellType.self
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(item: CellType.T, actions: [TableRowAction<CellType>]? = nil, editingActions: [UITableViewRowAction]? = nil) {
|
public init(item: CellType.CellData, actions: [TableRowAction<CellType>]? = nil, editingActions: [UITableViewRowAction]? = nil) {
|
||||||
|
|
||||||
self.item = item
|
self.item = item
|
||||||
self.editingActions = editingActions
|
self.editingActions = editingActions
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ import UIKit
|
||||||
|
|
||||||
open class TableRowActionOptions<CellType: ConfigurableCell> where CellType: UITableViewCell {
|
open class TableRowActionOptions<CellType: ConfigurableCell> where CellType: UITableViewCell {
|
||||||
|
|
||||||
open let item: CellType.T
|
open let item: CellType.CellData
|
||||||
open let cell: CellType?
|
open let cell: CellType?
|
||||||
open let indexPath: IndexPath
|
open let indexPath: IndexPath
|
||||||
open let userInfo: [AnyHashable: Any]?
|
open let userInfo: [AnyHashable: Any]?
|
||||||
|
|
||||||
init(item: CellType.T, cell: CellType?, path: IndexPath, userInfo: [AnyHashable: Any]?) {
|
init(item: CellType.CellData, cell: CellType?, path: IndexPath, userInfo: [AnyHashable: Any]?) {
|
||||||
|
|
||||||
self.item = item
|
self.item = item
|
||||||
self.cell = cell
|
self.cell = cell
|
||||||
|
|
@ -76,7 +76,7 @@ open class TableRowAction<CellType: ConfigurableCell> where CellType: UITableVie
|
||||||
self.handler = .action(handler)
|
self.handler = .action(handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func invokeActionOn(cell: UITableViewCell?, item: CellType.T, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any? {
|
public func invokeActionOn(cell: UITableViewCell?, item: CellType.CellData, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any? {
|
||||||
|
|
||||||
return handler.invoke(withOptions: TableRowActionOptions(item: item, cell: cell as? CellType, path: path, userInfo: userInfo))
|
return handler.invoke(withOptions: TableRowActionOptions(item: item, cell: cell as? CellType, path: path, userInfo: userInfo))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ Pod::Spec.new do |s|
|
||||||
s.name = 'TableKit'
|
s.name = 'TableKit'
|
||||||
s.module_name = 'TableKit'
|
s.module_name = 'TableKit'
|
||||||
|
|
||||||
s.version = '2.6.0'
|
s.version = '2.7.0'
|
||||||
|
|
||||||
s.homepage = 'https://github.com/maxsokolov/TableKit'
|
s.homepage = 'https://github.com/maxsokolov/TableKit'
|
||||||
s.summary = 'Type-safe declarative table views with Swift.'
|
s.summary = 'Type-safe declarative table views with Swift.'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue