-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignup.js
More file actions
120 lines (116 loc) · 2.84 KB
/
Signup.js
File metadata and controls
120 lines (116 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import React from "react";
import firebase from "firebase";
import { YellowBox } from "react-native";
import "@firebase/firestore";
import {
StyleSheet,
Text,
View,
TextInput,
TouchableOpacity,
Alert,
} from "react-native";
export default class Signup extends React.Component {
componentDidMount() {
YellowBox.ignoreWarnings(["Setting a timer"]);
}
state = {
email: "",
password: "",
displayName: "",
};
signUp = () => {
const { email, password, displayName } = this.state;
try {
firebase
.auth()
.createUserWithEmailAndPassword(email, password)
.then((result) => {
console.log("Signup successfully");
this.props.navigation.navigate("LoginScreen");
return result.user.updateProfile({
displayName: displayName,
});
})
.catch((error) => {
alert(error);
});
} catch (error) {
alert(error);
}
};
render() {
return (
<View style={styles.container}>
<Text style={styles.logo}>Register</Text>
<TextInput
style={styles.inputText}
placeholder="Email..."
placeholderTextColor="#767676"
onChangeText={(text) => this.setState({ email: text })}
/>
<TextInput
secureTextEntry
style={styles.inputText}
placeholder="Password..."
placeholderTextColor="#767676"
onChangeText={(text) => this.setState({ password: text })}
/>
<TextInput
style={styles.inputText}
placeholder="Display Name..."
placeholderTextColor="#767676"
onChangeText={(text) => this.setState({ displayName: text })}
/>
<TouchableOpacity
style={[styles.loginBtn, { backgroundColor: "#484848" }]}
onPress={() => this.signUp()}
>
<Text style={styles.loginText}>Signup</Text>
</TouchableOpacity>
<TouchableOpacity
style={[styles.loginBtn]}
onPress={() => this.props.navigation.navigate("LoginScreen")}
>
<Text style={[styles.loginText, { color: "#fff" }]}>Login</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 16,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#00A699",
},
logo: {
fontWeight: "bold",
fontSize: 32,
color: "black",
marginBottom: 40,
},
inputText: {
backgroundColor: "#e8e8e8",
marginVertical: 8,
width: "100%",
padding: 20,
borderRadius: 8,
color: "black",
fontSize: 16,
},
loginBtn: {
alignItems: "center",
justifyContent: "center",
width: "100%",
padding: 20,
borderRadius: 8,
},
loginText: {
color: "white",
fontWeight: "500",
fontSize: 16,
},
});