|
@@ -0,0 +1,56 @@
|
|
1
|
+import React, { Component } from "react";
|
|
2
|
+import { TextInput, TouchableWithoutFeedback, Keyboard, ImageBackground, Text, View } from "react-native";
|
|
3
|
+import firebase from "firebase";
|
|
4
|
+import { Picker } from "@react-native-picker/picker";
|
|
5
|
+
|
|
6
|
+import { styles } from "../config/styles";
|
|
7
|
+import CustomButton from "../components/CustomButton";
|
|
8
|
+
|
|
9
|
+export default class RegisterScreen extends Component {
|
|
10
|
+ constructor(props) {
|
|
11
|
+ super(props);
|
|
12
|
+ this.state = {
|
|
13
|
+ username: '',
|
|
14
|
+ email: '',
|
|
15
|
+ password: '',
|
|
16
|
+ interpreter: false,
|
|
17
|
+ };
|
|
18
|
+ this.onRegister = this.onRegister.bind(this)
|
|
19
|
+ };
|
|
20
|
+
|
|
21
|
+ onRegister() {
|
|
22
|
+ const { username, email, password, interpreter } = this.state;
|
|
23
|
+ firebase.auth().createUserWithEmailAndPassword(email, password)
|
|
24
|
+ .then((result) => {
|
|
25
|
+ firebase.firestore().collection("Users")
|
|
26
|
+ .doc(firebase.auth().currentUser.uid)
|
|
27
|
+ .set({
|
|
28
|
+ username,
|
|
29
|
+ email,
|
|
30
|
+ interpreter,
|
|
31
|
+ })
|
|
32
|
+ console.log(result)
|
|
33
|
+ })
|
|
34
|
+ .catch((error) => {
|
|
35
|
+ console.log(error)
|
|
36
|
+ })
|
|
37
|
+ }
|
|
38
|
+
|
|
39
|
+ render() {
|
|
40
|
+ return (
|
|
41
|
+ <TouchableWithoutFeedback style={styles.regcontainer} onPress={Keyboard.dismiss} accessible={false}>
|
|
42
|
+ <ImageBackground style={styles.regcontainer} source={require('../assets/yellow-white.jpg')}>
|
|
43
|
+ <TextInput style={styles.regtxtfield} placeholder="Userame" onChangeText={(username) => this.setState({ username })}/>
|
|
44
|
+ <TextInput style={styles.regtxtfield} placeholder="Email" onChangeText={(email) => this.setState({ email })}/>
|
|
45
|
+ <TextInput style={styles.regtxtfield} placeholder="Password" onChangeText={(password) => this.setState({ password })} secureTextEntry={ true }/>
|
|
46
|
+ <Text style={styles.qsttxt}>Are you an interpreter?</Text>
|
|
47
|
+ <Picker style={styles.picker} selectedValue={this.state.interpreter} onValueChange={(itemValue,itemIndex) => this.setState({interpreter: itemValue})}>
|
|
48
|
+ <Picker.Item label="Yes" value={true}/>
|
|
49
|
+ <Picker.Item label="No" value={false}/>
|
|
50
|
+ </Picker>
|
|
51
|
+ <CustomButton marginTop={50} title="Register" onPress={() => this.onRegister()}/>
|
|
52
|
+ </ImageBackground>
|
|
53
|
+ </TouchableWithoutFeedback>
|
|
54
|
+ );
|
|
55
|
+ }
|
|
56
|
+}
|