generated from ibm-developer-skills-network/coding-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SignUpScreen.js
130 lines (119 loc) · 3.13 KB
/
SignUpScreen.js
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
121
122
123
124
125
126
127
128
129
130
import React, { useState } from 'react';
import { View, TextInput, Image, Pressable, Text, StyleSheet } from 'react-native';
import { createUserWithEmailAndPassword } from 'firebase/auth';
import { useNavigation } from '@react-navigation/native';
import { auth } from './firebase';
const SignUpScreen = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [confirmPassword, setConfirmPassword] = useState('');
const navigation = useNavigation();
const handleSignUp = async () => {
if (email && password && confirmPassword && password !== confirmPassword) {
alert("Please provide all required details for SignUp");
return;
}
try {
await createUserWithEmailAndPassword(auth, email, password);
}
catch(error) {
const errorMessage = error.message;
if(errorMessage.indexOf("email-already-in-use") != -1) {
alert("Email already in use.");
} else {
alert(errorMessage)
}
console.log(errorMessage);
};
};
return (
<View style={styles.container}>
<Image
source={require('./assets/logo.png')} // Replace with your logo path
style={styles.logo}
/>
<Text style={styles.header}>Let's start Buddying</Text>
<TextInput
style={styles.input}
placeholder="Email"
value={email}
onChangeText={setEmail}
keyboardType="email-address"
autoCapitalize="none"
/>
<TextInput
style={styles.input}
placeholder="Password"
value={password}
onChangeText={setPassword}
secureTextEntry
/>
<TextInput
style={styles.input}
placeholder="Confirm Password"
value={confirmPassword}
onChangeText={setConfirmPassword}
secureTextEntry
/>
<Pressable style={styles.button} onPress={handleSignUp}>
<Text style={styles.buttonText}>Sign Up</Text>
</Pressable>
<View style={styles.loginLinkContainer}>
<Text>Already have an account? </Text>
<Pressable onPress={() => navigation.navigate('Login')}>
<Text style={styles.loginLink}>Log In</Text>
</Pressable>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 20,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#a1eda4'
},
header: {
fontSize: 24,
marginBottom: 20,
textAlign: 'center',
fontWeight: 'bold',
},
input: {
borderWidth: 1,
borderColor: '#ccc',
padding: 10,
marginBottom: 15,
borderRadius: 5,
width:'80%'
},
loginLinkContainer: {
flexDirection: 'row',
justifyContent: 'center',
marginTop: 20,
},
loginLink: {
color: 'blue',
fontWeight: 'bold',
},
logo: {
width: 180,
height: 180,
marginBottom: 30,
},
button: {
backgroundColor: 'black',
paddingVertical: 10,
paddingHorizontal: 20,
borderRadius: 8,
alignItems: 'center',
},
buttonText: {
color: 'white',
fontSize: 16,
fontWeight: 'bold',
},
});
export default SignUpScreen;