UNPKG

airbridge-react-native-sdk

Version:

Airbridge SDK for React Native

90 lines (79 loc) 3.03 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 EntryInputDialog extends Component { constructor(props) { super(props) this.state = { visible: false, key: '', value: '' } } show = () => { this.setState({ visible: true }) } close = () => { this.setState({ visible: false, key: '', value: '' }) } confirm = () => { if (this.props.onConfirm != null) { this.props.onConfirm(this.state.key, 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 Entry</Text> <View style={{ margin: 4 }} /> <CustomTextInput title={'KEY'} placeholder={'Enter key'} accessibilityLabel={'key'} onChangeText={newText => this.setState({ key: newText })} value={this.state.key} /> <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> ) } } EntryInputDialog.propTypes = { onConfirm: propTypes.func.isRequired }