Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import {
  3.   View,
  4.   TouchableWithoutFeedback,
  5.   TouchableHighlight,
  6.   Text,
  7.   Image,
  8.   Modal,
  9.   StyleSheet,
  10.   Dimensions
  11. } from 'react-native';
  12.  
  13. const { height, width } = Dimensions.get('window');
  14. const MODAL_HEIGHT = height/3;
  15.  
  16. export default class Respostas extends React.Component {
  17.   state = {
  18.     modalVisible: false,
  19.   };
  20.  
  21.   setModalVisible(visible) {
  22.     this.setState({ modalVisible: visible });
  23.   }
  24.  
  25.   render() {
  26.     return (
  27.       <View style={styles.container}>
  28.         <Modal
  29.           animationType="fade"
  30.           transparent={true}
  31.           visible={this.state.modalVisible}
  32.           onRequestClose={() => {
  33.             this.setModalVisible(false);
  34.           }}>
  35.           <TouchableWithoutFeedback
  36.             onPress={() => {
  37.               this.setModalVisible(false);
  38.             }}>
  39.             <View style={styles.modalstyle}>
  40.               <View style={styles.modalcontent}>
  41.                 <Text style={styles.title}>Parabéns!</Text>
  42.                 <Text style={styles.body}>Cadastro realizado com sucesso</Text>
  43.                 <TouchableHighlight
  44.                   style={styles.btnyes}
  45.                   underlayColor="#D6F22C"
  46.                   onPress={() => {
  47.                     this.setModalVisible(!this.state.modalVisible);
  48.                   }}>
  49.                   <Text
  50.                     style={{
  51.                       color: 'white',
  52.                       fontSize: 14,
  53.                       fontWeight: 'bold',
  54.                     }}>
  55.                     Concluir
  56.                   </Text>
  57.                 </TouchableHighlight>
  58.               </View>
  59.             </View>
  60.           </TouchableWithoutFeedback>
  61.         </Modal>
  62.  
  63.         <TouchableHighlight
  64.           style={styles.button}
  65.           onPress={() => {
  66.             this.setModalVisible(true);
  67.           }}>
  68.           <Text>Show Modal</Text>
  69.         </TouchableHighlight>
  70.       </View>
  71.     );
  72.   }
  73. }
  74.  
  75. const styles = StyleSheet.create({
  76.   container: {
  77.     flex: 1,
  78.     backgroundColor: 'white',
  79.     justifyContent: 'center',
  80.   },
  81.   modalstyle: {
  82.     position: 'absolute',
  83.     transform: [{translateY: (height/2)-(MODAL_HEIGHT/2)}],
  84.     alignSelf: 'center',
  85.     height: 300,
  86.     backgroundColor: 'grey'
  87.   }
  88. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement