@@ -13,7 +13,7 @@ import RxCocoa
13
13
#endif
14
14
15
15
// objc monkey business
16
- public class _TableViewSectionedDataSource
16
+ open class _TableViewSectionedDataSource
17
17
: NSObject
18
18
, UITableViewDataSource {
19
19
@@ -100,7 +100,7 @@ public class _TableViewSectionedDataSource
100
100
101
101
}
102
102
103
- public class TableViewSectionedDataSource < S: SectionModelType >
103
+ open class TableViewSectionedDataSource < S: SectionModelType >
104
104
: _TableViewSectionedDataSource
105
105
, SectionedViewDataSourceType {
106
106
@@ -134,12 +134,18 @@ public class TableViewSectionedDataSource<S: SectionModelType>
134
134
return _sectionModels. map { Section ( original: $0. model, items: $0. items) }
135
135
}
136
136
137
- public func sectionAtIndex( _ section: Int ) -> S {
137
+ @available ( * , deprecated, renamed: " subscript(section:) " )
138
+ open func sectionAtIndex( _ section: Int ) -> S {
138
139
let sectionModel = _sectionModels [ section]
139
140
return Section ( original: sectionModel. model, items: sectionModel. items)
140
141
}
141
142
142
- public subscript( indexPath: IndexPath ) -> I {
143
+ open subscript( section: Int ) -> S {
144
+ let sectionModel = self . _sectionModels [ section]
145
+ return S ( original: sectionModel. model, items: sectionModel. items)
146
+ }
147
+
148
+ open subscript( indexPath: IndexPath ) -> I {
143
149
get {
144
150
return self . _sectionModels [ indexPath. section] . items [ indexPath. item]
145
151
}
@@ -150,63 +156,63 @@ public class TableViewSectionedDataSource<S: SectionModelType>
150
156
}
151
157
}
152
158
153
- public func model( _ indexPath: IndexPath ) throws -> Any {
159
+ open func model( _ indexPath: IndexPath ) throws -> Any {
154
160
return self [ indexPath]
155
161
}
156
162
157
163
public func setSections( _ sections: [ S ] ) {
158
164
self . _sectionModels = sections. map { SectionModelSnapshot ( model: $0, items: $0. items) }
159
165
}
160
166
161
- public var configureCell : CellFactory ! = nil {
167
+ open var configureCell : CellFactory ! = nil {
162
168
didSet {
163
169
#if DEBUG
164
170
ensureNotMutatedAfterBinding ( )
165
171
#endif
166
172
}
167
173
}
168
174
169
- public var titleForHeaderInSection : ( ( TableViewSectionedDataSource < S > , Int ) -> String ? ) ? {
175
+ open var titleForHeaderInSection : ( ( TableViewSectionedDataSource < S > , Int ) -> String ? ) ? {
170
176
didSet {
171
177
#if DEBUG
172
178
ensureNotMutatedAfterBinding ( )
173
179
#endif
174
180
}
175
181
}
176
- public var titleForFooterInSection : ( ( TableViewSectionedDataSource < S > , Int ) -> String ? ) ? {
182
+ open var titleForFooterInSection : ( ( TableViewSectionedDataSource < S > , Int ) -> String ? ) ? {
177
183
didSet {
178
184
#if DEBUG
179
185
ensureNotMutatedAfterBinding ( )
180
186
#endif
181
187
}
182
188
}
183
189
184
- public var canEditRowAtIndexPath : ( ( TableViewSectionedDataSource < S > , IndexPath ) -> Bool ) ? {
190
+ open var canEditRowAtIndexPath : ( ( TableViewSectionedDataSource < S > , IndexPath ) -> Bool ) ? {
185
191
didSet {
186
192
#if DEBUG
187
193
ensureNotMutatedAfterBinding ( )
188
194
#endif
189
195
}
190
196
}
191
- public var canMoveRowAtIndexPath : ( ( TableViewSectionedDataSource < S > , IndexPath ) -> Bool ) ? {
197
+ open var canMoveRowAtIndexPath : ( ( TableViewSectionedDataSource < S > , IndexPath ) -> Bool ) ? {
192
198
didSet {
193
199
#if DEBUG
194
200
ensureNotMutatedAfterBinding ( )
195
201
#endif
196
202
}
197
203
}
198
204
199
- public var rowAnimation : UITableViewRowAnimation = . automatic
205
+ open var rowAnimation : UITableViewRowAnimation = . automatic
200
206
201
207
#if os(iOS)
202
- public var sectionIndexTitles : ( ( TableViewSectionedDataSource < S > ) -> [ String ] ? ) ? {
208
+ open var sectionIndexTitles : ( ( TableViewSectionedDataSource < S > ) -> [ String ] ? ) ? {
203
209
didSet {
204
210
#if DEBUG
205
211
ensureNotMutatedAfterBinding ( )
206
212
#endif
207
213
}
208
214
}
209
- public var sectionForSectionIndexTitle : ( ( TableViewSectionedDataSource < S > , _ title: String , _ index: Int ) -> Int ) ? {
215
+ open var sectionForSectionIndexTitle : ( ( TableViewSectionedDataSource < S > , _ title: String , _ index: Int ) -> Int ) ? {
210
216
didSet {
211
217
#if DEBUG
212
218
ensureNotMutatedAfterBinding ( )
@@ -228,58 +234,58 @@ public class TableViewSectionedDataSource<S: SectionModelType>
228
234
229
235
// UITableViewDataSource
230
236
231
- override func _numberOfSectionsInTableView( _ tableView: UITableView ) -> Int {
237
+ open override func _numberOfSectionsInTableView( _ tableView: UITableView ) -> Int {
232
238
return _sectionModels. count
233
239
}
234
240
235
- override func _rx_tableView( _ tableView: UITableView , numberOfRowsInSection section: Int ) -> Int {
241
+ open override func _rx_tableView( _ tableView: UITableView , numberOfRowsInSection section: Int ) -> Int {
236
242
return _sectionModels [ section] . items. count
237
243
}
238
244
239
- override func _rx_tableView( _ tableView: UITableView , cellForRowAtIndexPath indexPath: IndexPath ) -> UITableViewCell {
245
+ open override func _rx_tableView( _ tableView: UITableView , cellForRowAtIndexPath indexPath: IndexPath ) -> UITableViewCell {
240
246
precondition ( indexPath. item < _sectionModels [ indexPath. section] . items. count)
241
247
242
248
return configureCell ( self , tableView, indexPath, self [ indexPath] )
243
249
}
244
250
245
- override func _rx_tableView( _ tableView: UITableView , titleForHeaderInSection section: Int ) -> String ? {
251
+ open override func _rx_tableView( _ tableView: UITableView , titleForHeaderInSection section: Int ) -> String ? {
246
252
return titleForHeaderInSection ? ( self , section)
247
253
}
248
254
249
- override func _rx_tableView( _ tableView: UITableView , titleForFooterInSection section: Int ) -> String ? {
255
+ open override func _rx_tableView( _ tableView: UITableView , titleForFooterInSection section: Int ) -> String ? {
250
256
return titleForFooterInSection ? ( self , section)
251
257
}
252
258
253
- override func _rx_tableView( _ tableView: UITableView , canEditRowAtIndexPath indexPath: IndexPath ) -> Bool {
259
+ open override func _rx_tableView( _ tableView: UITableView , canEditRowAtIndexPath indexPath: IndexPath ) -> Bool {
254
260
guard let canEditRow = canEditRowAtIndexPath ? ( self , indexPath) else {
255
261
return super. _rx_tableView ( tableView, canEditRowAtIndexPath: indexPath)
256
262
}
257
263
258
264
return canEditRow
259
265
}
260
266
261
- override func _rx_tableView( _ tableView: UITableView , canMoveRowAtIndexPath indexPath: IndexPath ) -> Bool {
267
+ open override func _rx_tableView( _ tableView: UITableView , canMoveRowAtIndexPath indexPath: IndexPath ) -> Bool {
262
268
guard let canMoveRow = canMoveRowAtIndexPath ? ( self , indexPath) else {
263
269
return super. _rx_tableView ( tableView, canMoveRowAtIndexPath: indexPath)
264
270
}
265
271
266
272
return canMoveRow
267
273
}
268
274
269
- override func _rx_tableView( _ tableView: UITableView , moveRowAtIndexPath sourceIndexPath: IndexPath , toIndexPath destinationIndexPath: IndexPath ) {
275
+ open override func _rx_tableView( _ tableView: UITableView , moveRowAtIndexPath sourceIndexPath: IndexPath , toIndexPath destinationIndexPath: IndexPath ) {
270
276
self . _sectionModels. moveFromSourceIndexPath ( sourceIndexPath, destinationIndexPath: destinationIndexPath)
271
277
}
272
278
273
279
#if os(iOS)
274
- override func _sectionIndexTitlesForTableView( _ tableView: UITableView ) -> [ String ] ? {
280
+ open override func _sectionIndexTitlesForTableView( _ tableView: UITableView ) -> [ String ] ? {
275
281
guard let titles = sectionIndexTitles ? ( self ) else {
276
282
return super. _sectionIndexTitlesForTableView ( tableView)
277
283
}
278
284
279
285
return titles
280
286
}
281
287
282
- override func _rx_tableView( _ tableView: UITableView , sectionForSectionIndexTitle title: String , atIndex index: Int ) -> Int {
288
+ open override func _rx_tableView( _ tableView: UITableView , sectionForSectionIndexTitle title: String , atIndex index: Int ) -> Int {
283
289
guard let section = sectionForSectionIndexTitle ? ( self , title, index) else {
284
290
return super. _rx_tableView ( tableView, sectionForSectionIndexTitle: title, atIndex: index)
285
291
}
0 commit comments