Created
April 28, 2019 18:48
-
-
Save darksh3ll/0de72fe4183dad49404959a77ac521ec to your computer and use it in GitHub Desktop.
modale react native
This file contains hidden or 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, { Component } from 'react'; | |
import {Modal, Text, TouchableHighlight, View, Alert,StyleSheet,TouchableOpacity} from 'react-native'; | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
backgroundColor:'red' | |
}, | |
}); | |
export default class App extends Component { | |
state = { | |
modalVisible: false, | |
} | |
setModalVisible(visible) { | |
this.setState({modalVisible: visible}); | |
} | |
toto = () => { | |
console.log("toto"); | |
} | |
render() { | |
return ( | |
<> | |
{ | |
this.state.modalVisible &&( | |
<Modal | |
transparent | |
onRequestClose={() => this.toto()} | |
animationType="slide" | |
visible={this.state.modalVisible} | |
> | |
<View style={{flex:1}}> | |
<TouchableOpacity style={{flexGrow:6}} onPress={() => this.setModalVisible(false)} /> | |
<View style={{backgroundColor:'white',flexGrow:1,justifyContent: 'space-around' }} onPress={() => this.setModalVisible(false)} > | |
<Text style={{fontWeight:'600'}}>Modifier le post</Text> | |
<Text style={{fontWeight:'600'}} >Supprimer le post</Text> | |
</View> | |
</View> | |
</Modal> | |
) | |
} | |
<View style={styles.container}> | |
<Text style={{fontSize: 40}} onPress={ () => this.setModalVisible(true)}>{this.state.modalVisible?'close':'open'}</Text> | |
</View> | |
</> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment