import { ActionSheetProvider, connectActionSheet } from '@expo/react-native-action-sheet'; import React from 'react'; import { ActionSheetIOS, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, TouchableOpacityProps, View, } from 'react-native'; import ShowActionSheetButton from '../components/ShowActionSheetButton'; import { Colors } from '../constants'; const Button: React.FunctionComponent = (props) => { return ( {props.children} ); }; const ActionSheetProviderScreen = () => ( ); function ActionSheetScreen() { return ( {Platform.OS === 'ios' && } ); } function ActionSheetIOSExample() { const showActionSheet = () => { ActionSheetIOS.showActionSheetWithOptions( { options: ['Option 0', 'Option 1', 'Delete', 'Cancel'], cancelButtonIndex: 3, destructiveButtonIndex: 2, }, (buttonIndex) => { console.log({ buttonIndex }); } ); }; const showShareSheet = () => { ActionSheetIOS.showShareActionSheetWithOptions( { url: 'https://expo.dev', message: 'message to go with the shared url', subject: 'a subject to go in the email heading', }, (error) => alert(error), (success, method) => { if (success) { alert(`Shared via ${method}`); } } ); }; return ( ); } ActionSheetScreen.navigationOptions = { title: 'Action Sheet', }; export default ActionSheetScreen; interface State { selectedIndex?: number; } // @ts-ignore @connectActionSheet class App extends React.Component<{ showActionSheetWithOptions?: any }, State> { readonly state: State = {}; _updateSelectionText = (selectedIndex: number) => { this.setState({ selectedIndex }); }; _renderSelectionText() { const { selectedIndex } = this.state; const text = selectedIndex === undefined ? 'No Option Selected' : `Option #${selectedIndex + 1} Selected`; return {text}; } _renderSectionHeader(text: string) { return {text}; } _renderButtons() { const { showActionSheetWithOptions } = this.props; return ( {this._renderSectionHeader('Universal Options')} {this._renderSectionHeader('Android-Only Options')} ); } render() { return ( {'Hello!\n\nThis is a simple example app to demonstrate @expo/react-native-action-sheet.'} {this._renderButtons()} {this._renderSelectionText()} Note: Icons and custom text styles are only available on Android and web. Separators can only be toggled on Android or web; they always show on iOS. ); } } const styles = StyleSheet.create({ flex: { flex: 1, }, contentContainer: { padding: 16, paddingVertical: 20, }, headerText: { textAlign: 'center', fontSize: 16, marginBottom: 10, }, notes: { marginTop: 32, }, sectionHeaderText: { color: 'orange', textAlign: 'center', fontWeight: 'bold', fontSize: 20, marginTop: 20, marginBottom: 10, }, selectionText: { textAlign: 'center', color: 'blue', fontSize: 16, marginTop: 20, }, });