Advertisement
Guest User

Untitled

a guest
Mar 10th, 2019
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. import React, {Component} from 'react';
  2. import {StyleSheet, Text, View, TouchableOpacity, TextInput, Image} from 'react-native';
  3. import firebase from 'react-native-firebase';
  4.  
  5.  
  6.  
  7. export default class FormSignUp extends Component {
  8.  
  9. state = { email: '', password: '', errorMessage: null }
  10.  
  11. signUpButtonPress = () =>{
  12. const { email, password } = this.state
  13. firebase
  14. .auth()
  15. .createUserWithEmailAndPassword(email, password)
  16. .then(user => this.props.navigation.navigate('Login'))
  17. .catch(error => this.setState({ errorMessage: error.message }))
  18. }
  19. render() {
  20. firebase.analytics().logEvent('openAppSignUp');
  21. return (
  22. <View style={styles.container}>
  23. <Image style={{marginBottom:50, width:70, height:70}} source={require('./asset/icon-app.png')} />
  24.  
  25. {this.state.errorMessage &&
  26. <Text style={{ color: 'red' }}>
  27. {this.state.errorMessage}
  28. </Text>}
  29. <TextInput
  30. style={styles.textInput}
  31. placeholder='Email'
  32. autoCapitalize="none"
  33. placeholderTextColor='#ffffff'
  34. onChangeText={email => this.setState({ email })}
  35. value={this.state.email}
  36. />
  37. <TextInput
  38. secureTextEntry
  39. style={[styles.textInput]}
  40. placeholder='Password'
  41. placeholderTextColor='#ffffff'
  42. onChangeText={password =>this.setState({password})}
  43. value={this.state.password}
  44. />
  45.  
  46. <TouchableOpacity style={styles.buttonStyle} onPress={this.signUpButtonPress}>
  47. <Text style={styles.textSignup}>Register</Text>
  48. </TouchableOpacity>
  49. <TouchableOpacity onPress={()=>this.props.navigation.navigate('Login')}>
  50. <Text style={styles.instructions}>Have account? Login</Text>
  51. </TouchableOpacity>
  52.  
  53. </View>
  54. );
  55. }
  56. }
  57.  
  58. const styles = StyleSheet.create({
  59. container: {
  60. flex: 1,
  61. justifyContent: 'center',
  62. alignItems: 'center',
  63. backgroundColor: '#1ABC9C',
  64. flexDirection: 'column'
  65. },
  66. textInput:{
  67. height: 40,
  68. borderColor: '#ffffff',
  69. borderWidth: 1,
  70. color:'#ffffff',
  71. paddingLeft:10,
  72. paddingRight:10,
  73. marginBottom:10,
  74. width:350
  75. },
  76. buttonStyle:{
  77. backgroundColor:'#ffffff',
  78. paddingLeft:10,
  79. paddingRight:10,
  80. marginTop:10,
  81. width:350
  82. },
  83. textSignup: {
  84. fontSize: 16,
  85. textAlign: 'center',
  86. margin: 10,
  87. color:'#1ABC9C'
  88. },
  89. instructions: {
  90. textAlign: 'center',
  91. color: '#ffffff',
  92. marginBottom: 5,
  93. marginTop:10
  94. },
  95. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement