From 745105437ed4c578ab59d382faae7739161b7344 Mon Sep 17 00:00:00 2001 From: Hein-HtetSan Date: Tue, 29 Oct 2024 23:26:03 +0630 Subject: [PATCH] #22/fix - fixed sign up form --- app/(auth)/sign-in.jsx | 58 ---------------------------- app/(auth)/sign-up.jsx | 88 ++++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 92 deletions(-) delete mode 100644 app/(auth)/sign-in.jsx diff --git a/app/(auth)/sign-in.jsx b/app/(auth)/sign-in.jsx deleted file mode 100644 index 123856b5..00000000 --- a/app/(auth)/sign-in.jsx +++ /dev/null @@ -1,58 +0,0 @@ -import { View, Text } from 'react-native' -import React from 'react' - -const SignIn = () => { - return ( - - SignIn - - ) -} - -export default SignIn - -// import { SafeAreaView, Text, StyleSheet, TextInput, Dimensions, ScrollView, View } from "react-native"; -// import React from "react"; - -// const SignIn = () => { -// const { height } = Dimensions.get("window"); - -// return ( -// -// -// -// -// Maha -// Link -// -// -// -// -// ); -// }; - -// const styles = StyleSheet.create({ -// brandText: { -// width: "90%", -// }, -// contentWrapper: { -// width: "90%", -// marginTop: height * 0.35, // 35% of the screen height -// }, -// input: { -// height: 60, -// margin: 12, -// borderWidth: 2, -// paddingLeft: 20, -// borderRadius: 20, -// }, -// customButton: { -// width: "40%", -// alignSelf: "center", -// }, -// }); - -// export default SignIn; diff --git a/app/(auth)/sign-up.jsx b/app/(auth)/sign-up.jsx index 6d79ddfa..a1cc6755 100644 --- a/app/(auth)/sign-up.jsx +++ b/app/(auth)/sign-up.jsx @@ -1,13 +1,11 @@ -import { SafeAreaView } from "react-native-safe-area-context"; -import { View, Text, StyleSheet, Dimensions, TextInput, TouchableOpacity, ScrollView, KeyboardAvoidingView, Platform } from "react-native"; -import React, { useState } from "react"; -import { Link } from "expo-router"; +import { Link, useRouter } from "expo-router"; import { createUserWithEmailAndPassword } from "firebase/auth"; -import { auth } from "../../firebaseConfig"; -import { useRouter } from "expo-router"; -import Icon from "react-native-vector-icons/Ionicons"; -import { db } from "../../firebaseConfig"; import { doc, setDoc } from "firebase/firestore"; // Update import from addDoc to setDoc +import React, { useState } from "react"; +import { Dimensions, KeyboardAvoidingView, Platform, ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View } from "react-native"; +import { SafeAreaView } from "react-native-safe-area-context"; +import Icon from "react-native-vector-icons/Ionicons"; +import { auth, db } from "../../firebaseConfig"; const { height } = Dimensions.get("window"); @@ -16,8 +14,8 @@ const SignUp = () => { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); - const [passwordVisible, setPasswordVisible] = useState(false); - const [confirmPasswordVisible, setConfirmPasswordVisible] = useState(false); + const [passwordVisible, setPasswordVisible] = useState(false); + const [confirmPasswordVisible, setConfirmPasswordVisible] = useState(false); const router = useRouter(); const handleSignUp = async () => { @@ -31,15 +29,15 @@ const SignUp = () => { const userCredential = await createUserWithEmailAndPassword(auth, email, password); const user = userCredential.user; console.log("User registered: ", user); - + // Store additional user information in Firestore with UID as document ID await setDoc(doc(db, "Users", user.uid), { email: user.email, name: name, }); - + alert("Registration successful!"); - router.push("../(auth)/Login"); + router.push("../(auth)/Login"); } catch (error) { console.error(error); alert("Registration failed: " + error.message); @@ -48,7 +46,7 @@ const SignUp = () => { return ( @@ -86,7 +84,7 @@ const SignUp = () => { placeholder="Create a Password" value={password} onChangeText={setPassword} - secureTextEntry={!passwordVisible} + secureTextEntry={!passwordVisible} placeholderTextColor="#999999" /> setPasswordVisible(!passwordVisible)}> @@ -100,7 +98,7 @@ const SignUp = () => { placeholder="Re-enter your Password" value={confirmPassword} onChangeText={setConfirmPassword} - secureTextEntry={!confirmPasswordVisible} + secureTextEntry={!confirmPasswordVisible} placeholderTextColor="#999999" /> setConfirmPasswordVisible(!confirmPasswordVisible)}> @@ -109,8 +107,8 @@ const SignUp = () => { - - Back + + Back Continue @@ -130,48 +128,70 @@ const styles = StyleSheet.create({ }, contentWrapper: { width: "90%", - marginTop: height * 0.25, + marginTop: height * 0.25, }, input: { height: 60, margin: 12, borderWidth: 2, paddingLeft: 20, - borderRadius: 20, + borderRadius: 10, + borderColor: "#347928", }, passwordContainer: { flexDirection: "row", alignItems: "center", borderWidth: 2, - borderRadius: 20, + borderRadius: 10, margin: 12, paddingLeft: 20, paddingRight: 10, + borderColor: "#347928", }, passwordInput: { flex: 1, height: 60, }, customButton: { - width: "40%", - alignItems: "center", - justifyContent: "center", - paddingVertical: 10, - backgroundColor: "#347928", - borderRadius: 10, - margin: 5, - overflow: "hidden", + alignItems: "center", + justifyContent: "center", + paddingVertical: 10, + paddingHorizontal: 30, + backgroundColor: "#347928", + borderRadius: 10, + margin: 5, + overflow: "hidden", + }, + backButton: { + alignItems: "center", + justifyContent: "center", + paddingVertical: 10, + paddingHorizontal: 30, + backgroundColor: "#888", + borderRadius: 10, + margin: 5, + overflow: "hidden", }, btmContainer: { - paddingTop: 30, + display: "flex", + alignItems: "center", + textAlign: "center", + paddingHorizontal: 10, + marginTop: 20, flexDirection: "row", - justifyContent: "space-evenly", + justifyContent: "space-between", }, linkText: { color: "white", - fontSize: 18, - textAlign: "center", - width: "100%", + fontSize: 18, + textAlign: "center", + width: "100%", + }, + backText: { + color: "#eee", + fontSize: 18, + textAlign: "center", + width: "100%", }, });