import React, { useState, useContext } from "react"; import { SafeAreaView, ScrollView, View, Text, TextInput, TouchableOpacity, StyleSheet, Platform, } from "react-native"; import DateTimePicker from "@react-native-community/datetimepicker"; import InputField from "../components/InputField"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; import Ionicons from "@expo/vector-icons/Ionicons"; import RegistrationSVG from "../assets/images/registration.svg"; import GoogleSVG from "../assets/images/google.svg"; import FacebookSVG from "../assets/images/facebook.svg"; import TwitterSVG from "../assets/images/twitter.svg"; import CustomButton from "../components/Buttons/CustomButton"; import { globalStyles } from "../styles/global"; import { AuthContext } from "../context/AuthContext"; import Spinner from "react-native-loading-spinner-overlay/lib"; import Loader from "../components/Loader"; const RegisterScreen = ({ navigation }) => { const { isLoading, register } = useContext(AuthContext); const [date, setDate] = useState(new Date()); const [open, setOpen] = useState(false); const [dateOfBirthLabel, setDateOfBirthLabel] = useState("Date of Birth"); const [username, setUsername] = useState(null); const [email, setEmail] = useState(null); const [password, setPassword] = useState(null); const [confirmPassword, setConfirmPassword] = useState(null); const [error, setError] = useState(null); const onChange = (event, selectedDate) => { const currentDate = selectedDate || date; setDate(currentDate); let tempDate = new Date(currentDate); let fDate = tempDate.getDate() + "/" + (tempDate.getMonth() + 1) + "/" + tempDate.getFullYear(); setDateOfBirthLabel(fDate); setOpen(false); }; const handleSignup = () => { if (password !== confirmPassword) { setError("Passwords must match"); return; } register(username, email, password, function (result) { setError(result.error.message); }); }; return ( Sign Up {}} style={globalStyles.iconButton}> {}} style={globalStyles.iconButton}> {}} style={globalStyles.iconButton}> Or, sign up with email... setUsername(text)} label={"Full Name"} icon={ } /> setEmail(text)} label={"Email"} icon={ } keyboardType="email-address" /> setPassword(text)} label={"Password"} icon={ } inputType="password" /> setConfirmPassword(text)} label={"Confirm Password"} icon={ } inputType="password" /> {/* setOpen(true)}> {dateOfBirthLabel} {open && } */} {error && {error}} Already Registered? navigation.goBack()}> Sign In ); }; const styles = StyleSheet.create({ providersContainer: { flexDirection: "row", justifyContent: "space-between", marginBottom: 30, }, dateOfBirthContainer: { flexDirection: "row", borderBottomColor: "#ccc", borderBottomWidth: 1, paddingBottom: 8, marginBottom: 30, }, dateOfBirthLabel: { color: "#666", marginLeft: 5, marginTop: 5, }, alreadyRegistered: { flexDirection: "row", justifyContent: "center", marginBottom: 30, }, errorMessage: { marginBottom: 30, color: "red", }, }); export default RegisterScreen;