README.md 1.92 KB
Newer Older
xwenliang's avatar
init  
xwenliang committed
1 2 3 4
# react-native-picker

A Picker written in pure javascript for cross-platform support.

xwenliang's avatar
bugs  
xwenliang committed
5
It was most likely an example of how to build a cross-platform Picker Component use [react-native-picker-android](https://github.com/beefe/react-native-picker-android).
xwenliang's avatar
init  
xwenliang committed
6 7 8

Needs react-native >= 0.14.2

xwenliang's avatar
xwenliang committed
9 10
![ui](./doc/ui.gif)

xwenliang's avatar
init  
xwenliang committed
11 12
###Documentation

xwenliang's avatar
bugs  
xwenliang committed
13
####Props
xwenliang's avatar
xwenliang committed
14 15 16
- <b>pickerBtnText</b> string, tool bar's btn text
- <b>pickerBtnStyle</b> textStylePropType, tool bar's btn style
- <b>pickerToolBarStyle</b> viewStylePropType, tool bar's style
xwenliang's avatar
bugs  
xwenliang committed
17 18 19 20 21 22
- <b>pickerHeight</b> number
- <b>showDuration</b> number
- <b>pickerData</b> array
- <b>selectedValue</b> any
- <b>onPickerDone</b> function

xwenliang's avatar
xwenliang committed
23 24 25
####Methods
- <b>toggle</b> show or hide picker, default to be hiden

xwenliang's avatar
bugs  
xwenliang committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
###Usage

####Step 1 - install

```
	npm install react-native-picker --save
```

####Step 2 - import and use in project

```javascript
	import Picker from 'react-native-picker'
	
	<Picker
		ref={picker => {this.picker = picker;}}
		pickerHeight={300}
		showDuration={300}
		pickerData={}//picker`s value List
		selectedValue={}//default to be selected value
		onPickerDone={}//when confirm your choice
	/>
xwenliang's avatar
xwenliang committed
47 48 49 50 51 52
```

###Notice

####support two modes:

xwenliang's avatar
xwenliang committed
53
<b>1. parallel:</b> such as time picker, wheels have no connection with each other
xwenliang's avatar
xwenliang committed
54

xwenliang's avatar
xwenliang committed
55
<b>2. cascade:</b> such as date picker, address picker .etc, when front wheel changed, the behind wheels will all be reset
xwenliang's avatar
xwenliang committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

####parallel:

- single wheel:

```javascript
	pickerData = [1,2,3,4];
	selectedValue = 3;
```

- two or more wheel:

```javascript
	pickerData = [
		[1,2,3,4],
		[5,6,7,8],
		...
	];
	selectedValue = [1, 5];
```

####cascade:

- two wheel

```javascript
	pickerData = {
		{
			a: [1,2,3,4],
			b: [5,6,7,8],
			...
		}
	};
	selectedValue = ['a', 2];
```

- three wheel

```javascript
	pickerData = {
		a: {
			a1: [1,2,3,4],
			a2: [5,6,7,8],
			a3: [9,10,11,12]
		},
		b: {
			b1: [1,2,3,4],
			b2: [5,6,7,8],
			b3: [9,10,12,12]
		}
		...
	};
	selectedValue = ['a', 'a1', 1];
```