import React, {Component} from 'react'; import { Modal, Text, TouchableOpacity, View, StyleSheet } from 'react-native'; import BAPicker from './BAPicker'; import PropTypes from 'prop-types'; class BAButton extends Component { render() { const { style, title, onPress } = this.props; return ( onPress()}> {title} ) } } BAButton.propTypes = { style: PropTypes.any, title: PropTypes.string, onPress: PropTypes.func }; export default class BAPickerModal extends Component { constructor(props) { super(props); this.state = { selectedIndex: this.props.selectedIndex } } render() { const { modalVisible, onClosePress, list, onConfirm, itemStyle, topBarStyle, cancelTitle=null, confirmTitle=null, title = "" } = this.props; return ( { onClosePress() }}> onClosePress()} /> {title?title: ""} onConfirm({index: this.state.selectedIndex, item: list[this.state.selectedIndex]})} /> { this.setState({selectedIndex: resultObj.index}); }}/> ) } } BAPickerModal.propTypes = { modalVisible: PropTypes.bool, onClosePress: PropTypes.func, list: PropTypes.array, selectedIndex: PropTypes.number, onConfirm: PropTypes.func, itemStyle: PropTypes.object, topBarStyle: PropTypes.object, cancelTitle: PropTypes.string, confirmTitle: PropTypes.string, title: PropTypes.string }; const styles = StyleSheet.create({ modalContainer: { width: '100%', height: '100%', justifyContent: 'flex-end', backgroundColor: '#00000033' }, topContainer: { width: '100%', height: 44, flexDirection: 'row', backgroundColor: '#58A8F5' }, pickerStyle: { flex: 0, width: '100%', height: 200, backgroundColor: 'white', overflow: "hidden" }, btnStyle: { width: 60, height: '100%', justifyContent: 'center', alignItems: 'center' } });