Skip to content

Commit 67f8f80

Browse files
committed
Add screenshot
1 parent dcb5de5 commit 67f8f80

File tree

4 files changed

+167
-1
lines changed

4 files changed

+167
-1
lines changed

README.md

Lines changed: 167 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,167 @@
1-
# react-native-simple-modal-picker
1+
# react-native-simple-modal-picker
2+
3+
Easy to use and fully customized modal picker for both iOS and Android. Have same look and feel in both plateform.
4+
5+
## Installation
6+
7+
`$ npm install react-native-simple-modal-picker --save`
8+
9+
### Properties
10+
11+
| Prop | DataType | Description | IsRequired |
12+
|---|---|---|---|
13+
|**`data`**|Array| Data in json format | true |
14+
|**`value`**|String|Name of field which you want tobe return on selection from array | true |
15+
|**`label`**|String|Name of field which you want tobe shown in list of selection | true |
16+
|**`onValueChange`**|function(value)|Will be called on item selection and get value as a argument| true |
17+
|**`renderRow`**|function(rowData)|Custom component for render row and get row data as a argument| false |
18+
19+
## Usage
20+
21+
For simple modal picker example
22+
23+
```js
24+
import React, {Component} from 'react';
25+
import {StyleSheet, Text, View, Button, TouchableOpacity} from 'react-native';
26+
import Picker from 'react-native-simple-modal-picker';
27+
28+
export default class Example extends Component {
29+
constructor(props){
30+
super(props)
31+
this.state={
32+
selectedIndex: 0
33+
}
34+
this.data=[
35+
{
36+
name:'Option 1',
37+
value: '1'
38+
},
39+
{
40+
name:'Option 2',
41+
value: '2'
42+
},
43+
{
44+
name:'Option 3',
45+
value: '3'
46+
},
47+
{
48+
name:'Option 4',
49+
value: '4'
50+
},
51+
{
52+
name:'Option 5',
53+
value: '5'
54+
}
55+
]
56+
}
57+
58+
render() {
59+
return (
60+
<View style={styles.container}>
61+
{this.simplePickerView()}
62+
{this.customRowPickerView()}
63+
{this.dropDownView()}
64+
</View>
65+
);
66+
}
67+
68+
simplePickerView(){
69+
return(
70+
<View>
71+
<Picker
72+
ref={instance => this.simplePicker = instance}
73+
data={this.data}
74+
label={'name'}
75+
value={'value'}
76+
onValueChange={(value) => alert(value + ' selected')} />
77+
78+
<View style={styles.subContainer}>
79+
<Button
80+
title={'Open Simple Picker'}
81+
onPress={() => this.simplePicker.setModalVisible(true)} />
82+
</View>
83+
</View>
84+
)
85+
}
86+
87+
}
88+
89+
const styles = StyleSheet.create({
90+
container: {
91+
flex: 1,
92+
justifyContent: 'center',
93+
backgroundColor: '#F5FCFF',
94+
},
95+
subContainer:{
96+
margin: 8
97+
},
98+
rowStyle:{
99+
backgroundColor: '#FFF',
100+
color: '#333',
101+
padding: 8,
102+
fontSize: 20
103+
},
104+
dropDownContainer:{
105+
borderBottomWidth: 1,
106+
padding: 8
107+
},
108+
dropDownText:{
109+
fontSize: 20,
110+
margin: 8
111+
}
112+
});
113+
114+
```
115+
116+
#### Simple Modal Picker
117+
118+
```js
119+
120+
<Picker
121+
ref={instance => this.simplePicker = instance}
122+
data={this.data}
123+
label={'name'}
124+
value={'value'}
125+
onValueChange={(value) => alert(value + ' selected')} />
126+
127+
```
128+
129+
![Simple](https://github.com/binbytes/react-native-simple-modal-picker/blob/master/screenshot/simple.gif)
130+
131+
#### Modal Picker with Custom Row
132+
133+
```js
134+
135+
<Picker
136+
ref={instance => this.customRowPicker = instance}
137+
data={this.data}
138+
label={'name'}
139+
value={'value'}
140+
onValueChange={(value) => alert(value + ' selected')}
141+
renderRow={(rowData) => <Text style={styles.rowStyle}>{rowData.name}</Text>} />
142+
143+
```
144+
145+
![Custom](https://github.com/binbytes/react-native-simple-modal-picker/blob/master/screenshot/custom.gif)
146+
147+
#### DropDown View
148+
149+
```js
150+
151+
<View>
152+
<Picker
153+
ref={instance => this.dropDownPicker = instance}
154+
data={this.data}
155+
label={'name'}
156+
value={'value'}
157+
onValueChange={(value, selectedIndex) => this.setState({selectedIndex})} />
158+
<View style={styles.subContainer}>
159+
<TouchableOpacity style={styles.dropDownContainer} onPress={() => this.dropDownPicker.setModalVisible(true)}>
160+
<Text style={styles.dropDownText}>{this.data[this.state.selectedIndex].name}</Text>
161+
</TouchableOpacity>
162+
</View>
163+
</View>
164+
165+
```
166+
167+
![DropDown](https://github.com/binbytes/react-native-simple-modal-picker/blob/master/screenshot/dropdown.gif)

screenshot/custom.gif

279 KB
Loading

screenshot/dropdown.gif

208 KB
Loading

screenshot/simple.gif

257 KB
Loading

0 commit comments

Comments
 (0)