@@ -27,15 +27,12 @@ public struct BasicCellConfiguration<CellToConfigure, ObjectOfCell>: CellConfigu
2727 public typealias Object = ObjectOfCell
2828
2929 public let cellIdentifier : String
30+
31+ #if os(iOS) || os(tvOS)
3032 public let nib : UINib ?
33+ #endif
3134 public let configuration : ( Object , Cell ) -> Void
3235
33- public init ( cellIdentifier: String , configuration: @escaping ( Object , Cell ) -> Void , nib: UINib ? = nil ) {
34- self . cellIdentifier = cellIdentifier
35- self . configuration = configuration
36- self . nib = nib
37- }
38-
3936 public func configure( _ cell: AnyObject , with object: Any ) -> AnyObject {
4037 if let object = object as? Object , let cell = cell as? Cell {
4138 configuration ( object, cell)
@@ -44,6 +41,15 @@ public struct BasicCellConfiguration<CellToConfigure, ObjectOfCell>: CellConfigu
4441 }
4542}
4643
44+ #if os(iOS) || os(tvOS)
45+ extension BasicCellConfiguration {
46+ public init ( cellIdentifier: String , configuration: @escaping ( Object , Cell ) -> Void , nib: UINib ? = nil ) {
47+ self . cellIdentifier = cellIdentifier
48+ self . configuration = configuration
49+ self . nib = nib
50+ }
51+ }
52+
4753extension BasicCellConfiguration where CellToConfigure: ConfigurableCell , CellToConfigure. DataSource == ObjectOfCell {
4854 public init ( cellIdentifier: String , nib: UINib ? = nil , additionalConfiguration: ( ( Object , Cell ) -> Void ) ? = nil ) {
4955 self . init ( cellIdentifier: cellIdentifier, configuration: { object, cell in
@@ -64,3 +70,27 @@ extension BasicCellConfiguration where CellToConfigure: CellIdentifierProviding
6470 self . init ( cellIdentifier: CellToConfigure . cellIdentifier, configuration: configuration, nib: nib)
6571 }
6672}
73+ #else
74+
75+ extension BasicCellConfiguration where CellToConfigure: ConfigurableCell , CellToConfigure. DataSource == ObjectOfCell {
76+ public init ( cellIdentifier: String , additionalConfiguration: ( ( Object , Cell ) -> Void ) ? = nil ) {
77+ self . init ( cellIdentifier: cellIdentifier, configuration: { object, cell in
78+ cell. configure ( with: object)
79+ additionalConfiguration ? ( object, cell)
80+ } )
81+ }
82+ }
83+
84+ extension BasicCellConfiguration where CellToConfigure: ConfigurableCell & CellIdentifierProviding , CellToConfigure. DataSource == ObjectOfCell {
85+ public init ( additionalConfiguration: ( ( Object , Cell ) -> Void ) ? = nil ) {
86+ self . init ( cellIdentifier: CellToConfigure . cellIdentifier, additionalConfiguration: additionalConfiguration)
87+ }
88+ }
89+
90+ extension BasicCellConfiguration where CellToConfigure: CellIdentifierProviding {
91+ public init ( configuration: @escaping ( Object , Cell ) -> Void ) {
92+ self . init ( cellIdentifier: CellToConfigure . cellIdentifier, configuration: configuration)
93+ }
94+ }
95+
96+ #endif
0 commit comments