UNPKG

airbridge-react-native-sdk

Version:

Airbridge SDK for React Native

81 lines (70 loc) 2.6 kB
import React, { Component } from 'react' import propTypes from 'prop-types' import { View, Modal, Text, TextInput } from 'react-native' import { Styles } from '../common/Styles' import CustomButton from './CustomButton' import { Colors } from '../common/Colors' import CustomTextInput from './CustomTextInput' export default class ValueInputDialog extends Component { constructor(props) { super(props) this.state = { visible: false, value: '' } } show = () => { this.setState({ visible: true }) } close = () => { this.setState({ visible: false, value: '' }) } confirm = () => { if (this.props.onConfirm != null) { this.props.onConfirm(this.state.value) } this.close() } render() { return ( <Modal visible={this.state.visible} transparent={true}> <View style={Styles.centeredView}> <View style={Styles.modalView}> <Text style={ Styles.h2 }>Input Value</Text> <View style={{ margin: 4 }} /> <CustomTextInput title={'VALUE'} placeholder={'Enter value'} accessibilityLabel='value' onChangeText={newText => this.setState({ value: newText })} value={this.state.value} /> <View style={{ margin: 4 }} /> <View style={{ flexDirection: 'row'}}> <CustomButton buttonColor={Colors.deepBlue} title={'cancel'} titleColor='white' accessibilityLabel={'cancel'} onPress={() => this.close()} /> <View style={{ margin: 4 }} /> <CustomButton buttonColor={Colors.deepBlue} title={'save'} titleColor='white' accessibilityLabel={'save'} onPress={() => this.confirm()} /> </View> </View> </View> </Modal> ) } } ValueInputDialog.propTypes = { onConfirm: propTypes.func.isRequired }