diff --git a/app/(auth)/sign-in.tsx b/app/(auth)/sign-in.tsx index 640cccb..b06e3da 100644 --- a/app/(auth)/sign-in.tsx +++ b/app/(auth)/sign-in.tsx @@ -1,22 +1,63 @@ -import { SignIn } from '@clerk/clerk-react' -import { dark } from '@clerk/themes' +import { useSignIn } from '@clerk/clerk-expo' +import { router } from 'expo-router' import React from 'react' -import { StyleSheet, View } from 'react-native' +import { StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native' + +export default function LoginScreen() { + const { signIn, setActive, isLoaded } = useSignIn() + const [username, setUsername] = React.useState('') + const [password, setPassword] = React.useState('') + + async function handleSignIn() { + if (!isLoaded) return + + try { + const signInAttempt = await signIn.create({ + identifier: username, + password + }) + + if (signInAttempt.status === 'complete') { + await setActive({ session: signInAttempt.createdSessionId }) + router.replace('/') + } + } catch (e) { + console.log(JSON.stringify(e)) + } + } -export default function SignInScreen() { return ( - + Login + + Username + + Password + + { + handleSignIn() + }} + > + Login + + Don't have an account? + { + router.navigate('/sign-up') + }} + > + Sign Up + {' '} + ) } @@ -25,7 +66,35 @@ const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#25292e', - padding: 5, + justifyContent: 'center', + alignItems: 'center' + }, + text: { + color: '#fff' + }, + textCenter: { + color: '#ffffff', + alignSelf: 'center', + marginBottom: 6 + }, + textlabel: { + color: '#fff', + marginBottom: 3 + }, + input: { + backgroundColor: '#fff', + borderRadius: 5, + padding: 10, + marginBottom: 15 + }, + button: { + backgroundColor: '#1e90ff', + padding: 12, + borderRadius: 5, + alignItems: 'center', + marginBottom: 15 + }, + signup: { alignItems: 'center' } }) diff --git a/app/(auth)/sign-in2.tsx b/app/(auth)/sign-in2.tsx new file mode 100644 index 0000000..640cccb --- /dev/null +++ b/app/(auth)/sign-in2.tsx @@ -0,0 +1,31 @@ +import { SignIn } from '@clerk/clerk-react' +import { dark } from '@clerk/themes' +import React from 'react' +import { StyleSheet, View } from 'react-native' + +export default function SignInScreen() { + return ( + + + + ) +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#25292e', + padding: 5, + alignItems: 'center' + } +}) diff --git a/app/(auth)/sign-up.tsx b/app/(auth)/sign-up.tsx index 202a8d8..b085e4e 100644 --- a/app/(auth)/sign-up.tsx +++ b/app/(auth)/sign-up.tsx @@ -1,22 +1,72 @@ -import { SignUp } from '@clerk/clerk-expo/web' -import { dark } from '@clerk/themes' -import * as React from 'react' -import { StyleSheet, View } from 'react-native' +import { useSignUp } from '@clerk/clerk-expo' +import { router } from 'expo-router' +import React from 'react' +import { StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native' export default function SignUpScreen() { + const { signUp, setActive, isLoaded } = useSignUp() + const [fname, setFname] = React.useState('') + const [lname, setLname] = React.useState('') + const [email, setUsername] = React.useState('') + const [password, setPassword] = React.useState('') + + async function handleSignUp() { + if (!isLoaded) return + + try { + // Start Auth + await signUp.create({ + firstName: fname, + lastName: lname, + emailAddress: email, + password + }) + // Set confirmation + await signUp.prepareEmailAddressVerification({ + strategy: 'email_link', + redirectUrl: '/' + }) + } catch (e) { + console.log(JSON.stringify(e)) + } + } + return ( - + Create an account + + First name + + Last name + + Email + + Password + + { + handleSignUp() + }} + > + Sign Up + + Already have an account? + { + router.navigate('/sign-in') + }} + > + Sign In + {' '} + ) } @@ -25,7 +75,35 @@ const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#25292e', - padding: 5, + justifyContent: 'center', + alignItems: 'center' + }, + text: { + color: '#fff' + }, + textCenter: { + color: '#ffffff', + alignSelf: 'center', + marginBottom: 6 + }, + textlabel: { + color: '#fff', + marginBottom: 3 + }, + input: { + backgroundColor: '#fff', + borderRadius: 5, + padding: 10, + marginBottom: 15 + }, + button: { + backgroundColor: '#1e90ff', + padding: 12, + borderRadius: 5, + alignItems: 'center', + marginBottom: 15 + }, + signIn: { alignItems: 'center' } }) diff --git a/app/(auth)/sign-up2.tsx b/app/(auth)/sign-up2.tsx new file mode 100644 index 0000000..202a8d8 --- /dev/null +++ b/app/(auth)/sign-up2.tsx @@ -0,0 +1,31 @@ +import { SignUp } from '@clerk/clerk-expo/web' +import { dark } from '@clerk/themes' +import * as React from 'react' +import { StyleSheet, View } from 'react-native' + +export default function SignUpScreen() { + return ( + + + + ) +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#25292e', + padding: 5, + alignItems: 'center' + } +})