Skip to content

Instantly share code, notes, and snippets.

@stackman27
Created August 31, 2018 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stackman27/e6fb6bbcc1614c662a016c7beaad5e5c to your computer and use it in GitHub Desktop.
Save stackman27/e6fb6bbcc1614c662a016c7beaad5e5c to your computer and use it in GitHub Desktop.
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