Created
August 31, 2018 07:41
-
-
Save stackman27/e6fb6bbcc1614c662a016c7beaad5e5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View, Button, TouchableOpacity, TextInput} from 'react-native'; | |
import Dialog from "react-native-dialog"; | |
export default class App extends React.Component { | |
state = { | |
dialogVisible: false | |
}; | |
showDialog = () => { | |
this.setState({ dialogVisible: true }); | |
}; | |
handleCancel = () => { | |
this.setState({ dialogVisible: false }); | |
}; | |
handleDelete = () => { | |
// The user has pressed the "Delete" button, so here you can do your own logic. | |
// ...Your logic | |
this.setState({ dialogVisible: false }); | |
}; | |
render() { | |
return ( | |
<View style = {styles.container}> | |
<TouchableOpacity onPress={this.showDialog}> | |
<Text>Show Dialog</Text> | |
</TouchableOpacity> | |
<Dialog.Container visible={this.state.dialogVisible}> | |
<Dialog.Title>Enter the Code</Dialog.Title> | |
<TextInput | |
editable = {true} | |
style = {{ | |
padding: 20, | |
fontSize: 24 | |
}} | |
/> | |
<Dialog.Button label="Cancel" onPress={this.handleCancel} /> | |
<Dialog.Button label="Submit" onPress={this.handleDelete} /> | |
</Dialog.Container> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#fff', | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment