Advertisement
Guest User

Pick

a guest
Sep 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import {
  3. StyleSheet,
  4. Text,
  5. View,
  6. Image,
  7. TextInput,
  8. TouchableHighlight
  9. } from 'react-native';
  10. import * as ImagePicker from 'expo-image-picker';
  11. import Constants from 'expo-constants';
  12. import * as Permissions from 'expo-permissions';
  13. import {Button} from 'react-native';
  14. import LogoImage from '../../../assets/images/LionKing.jpg';
  15.  
  16. export default class Profile extends Component {
  17.  
  18. state = {
  19. photo:null,
  20. adresse:'',
  21. fullName:'',
  22. telephone:''
  23. };
  24.  
  25.  
  26. onClickListener = (viewId) => {
  27. alert( "Button pressed "+viewId+"Nom"+this.state.fullName);
  28. }
  29.  
  30. /* _ChangerPhoto = () => {
  31. const options = {
  32. noData:true
  33. };
  34. ImagePicker.launchImageLibrary(options,response => {
  35. if(response.uri){this.setState({photo:response});
  36. }
  37. });
  38. };*/
  39. getPermissionAsync = async () => {
  40. if (Constants.platform.ios) {
  41. const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
  42. if (status !== 'granted') {
  43. alert('Sorry, we need camera roll permissions to make this work!');
  44. }
  45. }
  46. }
  47.  
  48. _pickImage = async () => {
  49. let result = await ImagePicker.launchImageLibraryAsync({
  50. mediaTypes: ImagePicker.MediaTypeOptions.All,
  51. allowsEditing: true,
  52. aspect: [4,3]
  53. });
  54.  
  55. console.log(result);
  56.  
  57. if (!result.cancelled) {
  58. this.setState({ photo: result.uri });
  59. }
  60. };
  61.  
  62.  
  63.  
  64.  
  65. componentDidMount() {
  66. this.getPermissionAsync();
  67. }
  68.  
  69. render() {
  70. console.log(this.state);
  71.  
  72. const { photo } = this.state;
  73.  
  74. return (
  75. <View style={styles.container}>
  76. <View style={styles.inputContainer}>
  77. <Image style={styles.inputIcon} source={{uri: 'https://png.icons8.com/male-user/ultraviolet/50/3498db'}}/>
  78. <TextInput style={styles.inputs}
  79. placeholder="Full name"
  80. keyboardType="email-address"
  81. underlineColorAndroid='transparent'
  82. onChangeText={(fullName) => this.setState({fullName})}/>
  83. </View>
  84.  
  85. <View style={styles.inputContainer}>
  86. <Image style={styles.inputIcon} source={{uri:'https://png.icons8.com/message/ultraviolet/50/3498db'}}/>
  87. <TextInput style={styles.inputs}
  88. placeholder="Adresse"
  89. keyboardType="email-address"
  90. underlineColorAndroid='transparent'
  91. onChangeText={(telephone) => this.setState({telephone})}/>
  92. </View>
  93.  
  94. <View style={styles.inputContainer}>
  95. <Image style={styles.inputIcon} source={{uri: 'https://img.icons8.com/cute-clipart/64/000000/weixing.png'}}/>
  96. <TextInput style={styles.inputs}
  97. placeholder="Number de Tel"
  98. secureTextEntry={true}
  99. underlineColorAndroid='transparent'
  100. onChangeText={(adresse) => this.setState({adresse})}/>
  101. </View>
  102.  
  103.  
  104.  
  105. <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
  106. <Button
  107. title="Pick an image from camera roll"
  108. onPress={this._pickImage}
  109. />
  110. {photo &&
  111. <Image source={{ uri: photo }} style={{ width: 200, height: 200 }} />}
  112. </View>
  113.  
  114.  
  115.  
  116. <TouchableHighlight style={[styles.buttonContainer, styles.signupButton]} onPress={() => this.onClickListener('sign_up')}>
  117. <Text style={styles.signUpText}>Sign up</Text>
  118. </TouchableHighlight>
  119. </View>
  120. );
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement