Skip to content

Commit 533538e

Browse files
authored
chore: update README.md
1 parent 8c35298 commit 533538e

File tree

1 file changed

+92
-1
lines changed

1 file changed

+92
-1
lines changed

README.md

+92-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,93 @@
11
# react-native-platform-specific-hook-selector
2-
Simple wrapper for actionSheetIOS and native android picker
2+
Hook based simple wrapper for actionSheetIOS and native android picker. under the hood on IOS it uses actionSheetIOS and on android react-native-dialogs(because native android Picker don't have any method for calling it programmatically)
3+
4+
| Showcase IOS | Showcase Android |
5+
| :--------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------: |
6+
| ![](https://github.com/beqramo/react-native-platform-specific-hook-selector/blob/master/assets/ios.gif) | ![](https://github.com/beqramo/react-native-platform-specific-hook-selector/blob/master/assets/android.gif) |
7+
8+
## Installation
9+
10+
```
11+
npm i react-native-platform-specific-hook-selector react-native-dialogs --save
12+
```
13+
14+
### or
15+
16+
```
17+
yarn add react-native-platform-specific-hook-selector react-native-dialogs
18+
```
19+
20+
21+
## Example
22+
23+
```jsx
24+
import React, {useEffect} from 'react';
25+
import {SafeAreaView, Text, StatusBar, Button, Alert} from 'react-native';
26+
27+
import useBaseActionSheetPicker from 'react-native-platform-specific-hook-selector';
28+
29+
const App = () => {
30+
const {selectedItem, renderPicker} = useBaseActionSheetPicker({
31+
cancelText: 'Cancel',
32+
title: 'Choose color',
33+
});
34+
35+
useEffect(() => {
36+
if (selectedItem) {
37+
Alert.alert(selectedItem);
38+
}
39+
}, [selectedItem]);
40+
41+
return (
42+
<>
43+
<StatusBar barStyle="dark-content" />
44+
<SafeAreaView>
45+
<Button
46+
onPress={() => renderPicker(['green', 'blue', 'red'])}
47+
title={'Choose color'}
48+
/>
49+
<Text>{selectedItem}</Text>
50+
</SafeAreaView>
51+
</>
52+
);
53+
};
54+
55+
export default App;
56+
57+
```
58+
59+
#### Predefined hook arguments
60+
61+
62+
| param | type | description |
63+
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
64+
| cancelText | String | Cancel text on IOS |
65+
| title | String | title on both platform |
66+
| onCancel | callback | return on close event |
67+
68+
69+
#### hook returned values
70+
71+
72+
| values | type | description |
73+
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
74+
| selectedItem | String or undefined | value that has been selected |
75+
| renderPicker | ( params: string[] ) => void | renderer |
76+
77+
78+
79+
80+
81+
82+
## License
83+
84+
This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/beqramo/react-native-platform-specific-hook-selector/blob/master/LICENSE) file for details
85+
86+
87+
### Credits
88+
89+
[react-native-dialogs](https://github.com/react-native-dialogs/react-native-dialogs)
90+
91+
## Author
92+
93+
Made with ❤️ by [beqramo](https://github.com/beqramo).

0 commit comments

Comments
 (0)