UNPKG

airbridge-react-native-sdk

Version:

Airbridge SDK for React Native

73 lines (63 loc) 2.16 kB
import React, { Component } from 'react' import propTypes from 'prop-types' import { View, Modal, Text } from 'react-native' import { Styles } from '../common/Styles' import CustomButton from './CustomButton' import { Colors } from '../common/Colors' import CustomTextInput from './CustomTextInput' export default class ConfirmDialog extends Component { constructor(props) { super(props) this.state = { visible: false, } } show = () => { this.setState({ visible: true }) } close = () => { this.setState({ visible: false, value: '' }) } confirm = () => { if (this.props.onConfirm != null) { this.props.onConfirm() } this.close() } render() { return ( <Modal visible={this.state.visible} transparent={true}> <View style={Styles.centeredView}> <View style={Styles.modalView}> <Text style={ Styles.h2 }>{this.props.message}</Text> <View style={{ margin: 4 }} /> <View style={{ flexDirection: 'row'}}> <CustomButton buttonColor={Colors.grey} title={'cancel'} titleColor='white' accessibilityLabel={'cancel'} onPress={() => this.close()} /> <View style={{ margin: 4 }} /> <CustomButton buttonColor={Colors.deepBlue} title={'ok'} titleColor='white' accessibilityLabel={'ok'} onPress={() => this.confirm()} /> </View> </View> </View> </Modal> ) } } ConfirmDialog.propTypes = { message: propTypes.string, onConfirm: propTypes.func.isRequired }