Skip to content

Commit 98156ca

Browse files
committed
Improves documentation.
1 parent cefd3b4 commit 98156ca

File tree

3 files changed

+116
-13
lines changed

3 files changed

+116
-13
lines changed

Example/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"idiom" : "iphone",
515
"size" : "29x29",
@@ -30,6 +40,16 @@
3040
"size" : "60x60",
3141
"scale" : "3x"
3242
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "20x20",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"size" : "20x20",
51+
"scale" : "2x"
52+
},
3353
{
3454
"idiom" : "ipad",
3555
"size" : "29x29",

Example/Example5_UIPickerView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class ReactivePickerViewControllerExample: UIViewController {
1818
@IBOutlet weak var thirdPickerView: UIPickerView!
1919

2020
let disposeBag = DisposeBag()
21-
21+
2222
private let stringPickerAdapter = RxPickerViewStringAdapter<[String]>(components: [],
2323
numberOfComponents: { _ in 1 },
2424
numberOfRowsInComponent: { (_, _, items, _) -> Int in

Sources/DataSources+Rx/RxPickerViewAdapter.swift

Lines changed: 95 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import UIKit
1313
import RxCocoa
1414
#endif
1515

16-
/// A reactive UIPickerView adapter which uses `func pickerView(UIPickerView, titleForRow: Int, forComponent: Int)` to desplay content
16+
/// A reactive UIPickerView adapter which uses `func pickerView(UIPickerView, titleForRow: Int, forComponent: Int)` to display the content
1717
/**
1818
Example:
1919

@@ -25,10 +25,29 @@ items
2525

2626
*/
2727
open class RxPickerViewStringAdapter<T>: RxPickerViewDataSource<T>, UIPickerViewDelegate {
28-
public typealias TitleForRow = (RxPickerViewStringAdapter<T>, UIPickerView, T,Int, Int) -> String?
28+
/**
29+
- parameter dataSource
30+
- parameter pickerView
31+
- parameter components
32+
- parameter row
33+
- parameter component
34+
*/
35+
public typealias TitleForRow = (
36+
_ dataSource: RxPickerViewStringAdapter<T>,
37+
_ pickerView: UIPickerView,
38+
_ components: T,
39+
_ row: Int,
40+
_ component: Int
41+
) -> String?
2942

3043
private let titleForRow: TitleForRow
31-
44+
45+
/**
46+
- parameter components: Initial content value.
47+
- parameter numberOfComponents: Implementation of corresponding delegate method.
48+
- parameter numberOfRowsInComponent: Implementation of corresponding delegate method.
49+
- parameter titleForRow: Implementation of corresponding adapter method that converts component to `String`.
50+
*/
3251
public init(components: T,
3352
numberOfComponents: @escaping NumberOfComponents,
3453
numberOfRowsInComponent: @escaping NumberOfRowsInComponent,
@@ -44,7 +63,7 @@ open class RxPickerViewStringAdapter<T>: RxPickerViewDataSource<T>, UIPickerView
4463
}
4564
}
4665

47-
/// A reactive UIPickerView adapter which uses `func pickerView(UIPickerView, viewForRow: Int, forComponent: Int, reusing: UIView?)` to desplay content
66+
/// A reactive UIPickerView adapter which uses `func pickerView(UIPickerView, viewForRow: Int, forComponent: Int, reusing: UIView?)` to display the content
4867
/**
4968
Example:
5069

@@ -56,10 +75,29 @@ open class RxPickerViewStringAdapter<T>: RxPickerViewDataSource<T>, UIPickerView
5675

5776
*/
5877
open class RxPickerViewAttributedStringAdapter<T>: RxPickerViewDataSource<T>, UIPickerViewDelegate {
59-
public typealias AttributedTitleForRow = (RxPickerViewAttributedStringAdapter<T>, UIPickerView, T, Int, Int) -> NSAttributedString?
78+
/**
79+
- parameter dataSource
80+
- parameter pickerView
81+
- parameter components
82+
- parameter row
83+
- parameter component
84+
*/
85+
public typealias AttributedTitleForRow = (
86+
_ dataSource: RxPickerViewAttributedStringAdapter<T>,
87+
_ pickerView: UIPickerView,
88+
_ components: T,
89+
_ row: Int,
90+
_ component: Int
91+
) -> NSAttributedString?
6092

6193
private let attributedTitleForRow: AttributedTitleForRow
62-
94+
95+
/**
96+
- parameter components: Initial content value.
97+
- parameter numberOfComponents: Implementation of corresponding delegate method.
98+
- parameter numberOfRowsInComponent: Implementation of corresponding delegate method.
99+
- parameter attributedTitleForRow: Implementation of corresponding adapter method that converts component to `NSAttributedString`.
100+
*/
63101
public init(components: T,
64102
numberOfComponents: @escaping NumberOfComponents,
65103
numberOfRowsInComponent: @escaping NumberOfRowsInComponent,
@@ -75,7 +113,7 @@ open class RxPickerViewAttributedStringAdapter<T>: RxPickerViewDataSource<T>, UI
75113
}
76114
}
77115

78-
/// A reactive UIPickerView adapter which uses `func pickerView(pickerView:, viewForRow row:, forComponent component:)` to desplay content
116+
/// A reactive UIPickerView adapter which uses `func pickerView(pickerView:, viewForRow row:, forComponent component:)` to display the content
79117
/**
80118
Example:
81119

@@ -87,10 +125,31 @@ open class RxPickerViewAttributedStringAdapter<T>: RxPickerViewDataSource<T>, UI
87125

88126
*/
89127
open class RxPickerViewViewAdapter<T>: RxPickerViewDataSource<T>, UIPickerViewDelegate {
90-
public typealias ViewForRow = (RxPickerViewViewAdapter<T>, UIPickerView, T, Int, Int, UIView?) -> UIView
128+
/**
129+
- parameter dataSource
130+
- parameter pickerView
131+
- parameter components
132+
- parameter row
133+
- parameter component
134+
- parameter view
135+
*/
136+
public typealias ViewForRow = (
137+
_ dataSource: RxPickerViewViewAdapter<T>,
138+
_ pickerView: UIPickerView,
139+
_ components: T,
140+
_ row: Int,
141+
_ component: Int,
142+
_ view: UIView?
143+
) -> UIView
91144

92145
private let viewForRow: ViewForRow
93-
146+
147+
/**
148+
- parameter components: Initial content value.
149+
- parameter numberOfComponents: Implementation of corresponding delegate method.
150+
- parameter numberOfRowsInComponent: Implementation of corresponding delegate method.
151+
- parameter attributedTitleForRow: Implementation of corresponding adapter method that converts component to `UIView`.
152+
*/
94153
public init(components: T,
95154
numberOfComponents: @escaping NumberOfComponents,
96155
numberOfRowsInComponent: @escaping NumberOfRowsInComponent,
@@ -108,11 +167,35 @@ open class RxPickerViewViewAdapter<T>: RxPickerViewDataSource<T>, UIPickerViewDe
108167

109168
/// A reactive UIPickerView data source
110169
open class RxPickerViewDataSource<T>: NSObject, UIPickerViewDataSource {
111-
public typealias NumberOfComponents = (RxPickerViewDataSource, UIPickerView, T) -> Int
112-
public typealias NumberOfRowsInComponent = (RxPickerViewDataSource, UIPickerView, T, Int) -> Int
170+
/**
171+
- parameter dataSource
172+
- parameter pickerView
173+
- parameter components
174+
*/
175+
public typealias NumberOfComponents = (
176+
_ dataSource: RxPickerViewDataSource,
177+
_ pickerView: UIPickerView,
178+
_ components: T) -> Int
179+
/**
180+
- parameter dataSource
181+
- parameter pickerView
182+
- parameter components
183+
- parameter component
184+
*/
185+
public typealias NumberOfRowsInComponent = (
186+
_ dataSource: RxPickerViewDataSource,
187+
_ pickerView: UIPickerView,
188+
_ components: T,
189+
_ component: Int
190+
) -> Int
113191

114192
fileprivate var components: T
115-
193+
194+
/**
195+
- parameter components: Initial content value.
196+
- parameter numberOfComponents: Implementation of corresponding delegate method.
197+
- parameter numberOfRowsInComponent: Implementation of corresponding delegate method.
198+
*/
116199
init(components: T,
117200
numberOfComponents: @escaping NumberOfComponents,
118201
numberOfRowsInComponent: @escaping NumberOfRowsInComponent) {

0 commit comments

Comments
 (0)