@@ -10,10 +10,16 @@ import IGListKit
10
10
import RxCocoa
11
11
import RxSwift
12
12
13
- public typealias RxListSingleSectionCellConfigureBlock < E: ListDiffable , Cell: UICollectionViewCell > = ( E , Cell ) -> Void
14
- public typealias RxListSingleSectionCellSizeBlock < E: ListDiffable > = ( E , ListCollectionContext ? ) -> CGSize
15
-
16
13
extension Reactive where Base == ListAdapter {
14
+ /**
15
+ Binds sequences of elements to adapter objects using a custom reactive data used to perform the transformation.
16
+ In case `source` observable sequence terminates successfully, the data source will present latest element
17
+ until the subscription isn't disposed.
18
+
19
+ - parameter dataSource: Data source used to transform elements to adapter sections.
20
+ - parameter source: Observable sequence of items.
21
+ - returns: Disposable object that can be used to unbind.
22
+ */
17
23
public func objects< DataSource: ListAdapterDataSource & RxListAdapterDataSourceType , O: ObservableType > ( dataSource: DataSource ) ->
18
24
( _ source: O ) -> Disposable
19
25
where DataSource. Element == O . Element {
@@ -28,6 +34,16 @@ extension Reactive where Base == ListAdapter {
28
34
}
29
35
}
30
36
37
+ /// Binds sequences of elements to adapter objects using a custom reactive data used to perform the transformation for IGListSingleSectionController.
38
+ ///
39
+ /// - Parameters:
40
+ /// - cellClass: Type of collection view cell.
41
+ /// - selectionDelegate: ListSingleSectionControllerDelegate
42
+ /// - source: Observable sequence of objects.
43
+ /// - configureBlock: Transform between sequence elements and view cells.
44
+ /// - sizeBlock: The size for the cells.
45
+ /// - emptyViewProvider: The empty view for the collection view.
46
+ /// - Returns: Disposable object that can be used to unbind.
31
47
public func objects< S: Sequence , Cell: UICollectionViewCell , O: ObservableType > ( cellClass: Cell . Type , selectionDelegate: ListSingleSectionControllerDelegate ? = nil )
32
48
-> ( _ source: O )
33
49
-> ( _ configureBlock: @escaping RxListSingleSectionCellConfigureBlock < S . Element , Cell > )
@@ -49,41 +65,79 @@ extension Reactive where Base == ListAdapter {
49
65
}
50
66
}
51
67
68
+ /// Binds sequences of elements to adapter objects using a custom reactive data used to perform the transformation for IGListSingleSectionController.
69
+ ///
70
+ /// - Parameters:
71
+ /// - storyboardCellIdentifier: StoryboardIdentifier used to dequeue cells.
72
+ /// - cellClass: Type of collection view cell.
73
+ /// - selectionDelegate: ListSingleSectionControllerDelegate
74
+ /// - source: Observable sequence of objects.
75
+ /// - configureBlock: Transform between sequence elements and view cells.
76
+ /// - sizeBlock: The size for the cells.
77
+ /// - emptyViewProvider: The empty view for the collection view.
78
+ /// - Returns: Disposable object that can be used to unbind.
52
79
public func objects< S: Sequence , Cell: UICollectionViewCell , O: ObservableType > ( storyboardCellIdentifier: String , cellClass: Cell . Type , selectionDelegate: ListSingleSectionControllerDelegate ? = nil )
53
80
-> ( _ source: O )
54
81
-> ( _ configureBlock: @escaping RxListSingleSectionCellConfigureBlock < S . Element , Cell > )
55
82
-> ( _ sizeBlock: @escaping RxListSingleSectionCellSizeBlock < S . Element > )
56
83
-> ( _ emptyViewProvider: EmptyViewProvider ? )
57
84
-> Disposable where O. Element == S , S. Element: ListDiffable {
58
- return { source in
59
- { configureBlock1 in
60
- { sizeBlock in
61
- { emptyViewProvider in
62
- let dataSource = RxListAdapterSingleSectionDataSourceSequenceWrapper < S , Cell > ( dequeueWay: . storyboard( id: storyboardCellIdentifier) , configureBlock: { obj, cell in
63
- configureBlock1 ( obj, cell)
64
- } , sizeBlock: sizeBlock, emptyViewProvider: emptyViewProvider)
65
- dataSource. delegate = selectionDelegate
66
- return self . objects ( dataSource: dataSource) ( source)
67
- }
85
+ return { source in
86
+ { configureBlock1 in
87
+ { sizeBlock in
88
+ { emptyViewProvider in
89
+ let dataSource = RxListAdapterSingleSectionDataSourceSequenceWrapper < S , Cell > ( dequeueWay: . storyboard( id: storyboardCellIdentifier) , configureBlock: { obj, cell in
90
+ configureBlock1 ( obj, cell)
91
+ } , sizeBlock: sizeBlock, emptyViewProvider: emptyViewProvider)
92
+ dataSource. delegate = selectionDelegate
93
+ return self . objects ( dataSource: dataSource) ( source)
68
94
}
69
95
}
70
96
}
97
+ }
71
98
}
72
99
73
-
100
+ /// Binds sequences of elements to adapter objects using a custom reactive data used to perform the transformation for IGListSingleSectionController.
101
+ ///
102
+ /// - Parameters:
103
+ /// - nibName: Nib name used to dequeue cells.
104
+ /// - bundle: Bundle of the nib.
105
+ /// - cellClass: Type of collection view cell.
106
+ /// - selectionDelegate: ListSingleSectionControllerDelegate
107
+ /// - source: Observable sequence of objects.
108
+ /// - configureBlock: Transform between sequence elements and view cells.
109
+ /// - sizeBlock: The size for the cells.
110
+ /// - emptyViewProvider: The empty view for the collection view.
111
+ /// - Returns: Disposable object that can be used to unbind.
112
+ public func objects< S: Sequence , Cell: UICollectionViewCell , O: ObservableType > ( nibName: String , bundle: Bundle ? , cellClass: Cell . Type , selectionDelegate: ListSingleSectionControllerDelegate ? = nil )
113
+ -> ( _ source: O )
114
+ -> ( _ configureBlock: @escaping RxListSingleSectionCellConfigureBlock < S . Element , Cell > )
115
+ -> ( _ sizeBlock: @escaping RxListSingleSectionCellSizeBlock < S . Element > )
116
+ -> ( _ emptyViewProvider: EmptyViewProvider ? )
117
+ -> Disposable where O. Element == S , S. Element: ListDiffable {
118
+ return { source in
119
+ { configureBlock1 in
120
+ { sizeBlock in
121
+ { emptyViewProvider in
122
+ let dataSource = RxListAdapterSingleSectionDataSourceSequenceWrapper < S , Cell > ( dequeueWay: . nib( name: nibName, bundle: bundle) , configureBlock: { obj, cell in
123
+ configureBlock1 ( obj, cell)
124
+ } , sizeBlock: sizeBlock, emptyViewProvider: emptyViewProvider)
125
+ dataSource. delegate = selectionDelegate
126
+ return self . objects ( dataSource: dataSource) ( source)
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
74
132
}
75
133
76
- public typealias WillDisplayObjectEvent = ( object: ListDiffable , index: NSInteger )
77
- public typealias DidEndDisplayingObjectEvent = ( object: ListDiffable , index: NSInteger )
78
- public typealias MoveObjectEvent = ( object: ListDiffable , from: [ ListDiffable ] , to: [ ListDiffable ] )
79
-
80
134
extension Reactive where Base == ListAdapter {
81
135
var delegate : DelegateProxy < ListAdapter , IGListAdapterDelegate > {
82
136
return RxListAdapterDelegateProxy . proxy ( for: base)
83
137
}
84
138
85
139
/**
86
- Reactive wrapper for `delegate` message `listAdapter:(IGListAdapter *)listAdapter willDisplayObject:(id)object atIndex:(NSInteger)index `.
140
+ Reactive wrapper for `delegate` message `listAdapter:willDisplayObject:atIndex:`.
87
141
*/
88
142
public var willDisplayObject : ControlEvent < WillDisplayObjectEvent > {
89
143
let source = RxListAdapterDelegateProxy . proxy ( for: base) . willDisplaySubject. map { ( obj, idx) -> WillDisplayObjectEvent in
@@ -93,7 +147,7 @@ extension Reactive where Base == ListAdapter {
93
147
}
94
148
95
149
/**
96
- Reactive wrapper for `delegate` message `- (void) listAdapter:(IGListAdapter *)listAdapter didEndDisplayingObject:(id)object atIndex:(NSInteger)index; `.
150
+ Reactive wrapper for `delegate` message `listAdapter:didEndDisplayingObject:atIndex:`.
97
151
*/
98
152
public var didEndDisplayingObject : ControlEvent < DidEndDisplayingObjectEvent > {
99
153
let source = RxListAdapterDelegateProxy . proxy ( for: base) . didEndDisplayingSubject. map { ( obj, idx) -> WillDisplayObjectEvent in
@@ -103,7 +157,7 @@ extension Reactive where Base == ListAdapter {
103
157
}
104
158
105
159
/**
106
- Reactive wrapper for `moveDelegate` message ``.
160
+ Reactive wrapper for `moveDelegate` message `listAdapter:moveObject:from:to: `.
107
161
*/
108
162
@available ( iOS 9 . 0 , * )
109
163
public func moveObject( _ delegate: ListAdapterMoving ) -> ControlEvent < MoveObjectEvent > {
@@ -117,13 +171,17 @@ extension Reactive where Base == ListAdapter {
117
171
return ControlEvent ( events: source)
118
172
}
119
173
174
+ /**
175
+ Reactive wrapper for `delegate` message `collectionView(_:didSelectItemAtIndexPath:)`.
176
+ */
120
177
public var itemSelected : ControlEvent < IndexPath > {
121
178
guard let view = base. collectionView else { fatalError ( ) }
122
179
return view. rx. itemSelected
123
180
}
124
181
125
- public typealias ListWillEndDraggingEvent = ( view: UICollectionView , velocity: CGPoint , targetContentOffset: UnsafeMutablePointer < CGPoint > )
126
-
182
+ /**
183
+ Reactive wrapper for delegate method `scrollViewWillEndDragging(_:withVelocity:targetContentOffset:)`
184
+ */
127
185
public var willEndDragging : ControlEvent < ListWillEndDraggingEvent > {
128
186
guard let view = base. collectionView else { fatalError ( ) }
129
187
let source = view. rx. willEndDragging. map ( { ( v, targetContentOffset) -> ListWillEndDraggingEvent in
0 commit comments