Cross platform action sheet design which supports on both Android and iOS.
npm install react-native-action-sheet-modal
npm i react-native-action-sheet-modal.
javascript
import Actionsheet from 'react-native-action-sheet-modal';
`
2. Create a modal and nest its content inside of it:
`javascript
function OptionsWindow() {
return (
onClose()} onChange={onChange}/>
)
}
`
A complete example
`javascript
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, { useState } from 'react';
import {
StyleSheet,
View,
Text,
TouchableOpacity,
} from 'react-native';
import ActionSheet from 'react-native-action-sheet-modal'
const App = () => {
const [visible, setVisible] = useState(false)
const [result, setResult] = useState('')
const list = [{ name: "Choose from camera", value: 'Choose from camera', extraData:{type:"video"} }, { name: "Choose from gallery", value: 'Choose from gallery', extraData:{type:"video"} }]
function onChange(value, extraData) {
setResult(value)
onClose()
}
function onClose(){
setVisible(false)
}
return (
<>
onClose()} onChange={onChange}/>
onPress={()=>setVisible(true)}
style={styles.button}>Open
{result}
>
);
};
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
button:{ paddingHorizontal: 20, marginVertical:20, paddingVertical: 10, backgroundColor: "cyan", borderRadius: 10, },
});
export default App;
``