import React from 'react'; import { ActionSheetIOSOptions, Text, TouchableHighlight, View } from 'react-native'; import Modal from '../modal/ModalView'; import { WithTheme, WithThemeStyles } from '../style'; import ActionSheetStyles, { ActionSheetStyle } from './style'; export interface ActionSheetNativeProps extends WithThemeStyles { onAnimationEnd?: (visible: boolean) => void; visible?: boolean; config: ActionSheetIOSOptions; callback?: (index: number) => void; } class ActionSheetAndroid extends React.PureComponent< ActionSheetNativeProps, any > { constructor(props: ActionSheetNativeProps) { super(props); this.state = { visible: this.props.visible || false, }; } confirm(index: number) { const { callback } = this.props; if (callback) { callback(index); } this.setState({ visible: false, }); } close = () => { this.setState({ visible: false, }); }; render() { const { config, onAnimationEnd } = this.props; const { title, message, options, destructiveButtonIndex, cancelButtonIndex, } = config; return ( {(styles, theme) => { const titleMsg = !!title && ( {title} ); const content = (options as string[]).map((item, index) => ( this.confirm(index)} > {item} {cancelButtonIndex === index ? ( ) : null} )); return ( this.confirm(cancelButtonIndex || -1)} > {titleMsg} {!!message && ( {message} )} {content} ); }} ); } } export default ActionSheetAndroid;