Skip to content

Commit

Permalink
feat(client): update routing
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocroh committed Feb 9, 2025
1 parent 8a0b26f commit 69a3b61
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 49 deletions.
32 changes: 32 additions & 0 deletions apps/client/app/(home)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Text, TouchableOpacity } from 'react-native'
import { Link } from 'expo-router'
import { SignedIn, SignedOut, useAuth, useUser } from '@clerk/clerk-expo'

export default function Page() {
const { signOut } = useAuth()
const { user } = useUser()

return (
<>
<SignedIn>
<Text className="text-primary">
Hello {user?.emailAddresses[0].emailAddress}
</Text>
<TouchableOpacity onPress={() => signOut()}>
<Text className="text-primary">Sign out</Text>
</TouchableOpacity>
</SignedIn>
<SignedOut>
<Link href="/auth/sign-in">
<Text className="primary">Sign in</Text>
</Link>
<Link href="/auth/sign-up">
<Text>Sign up</Text>
</Link>
<TouchableOpacity onPress={() => signOut()}>
<Text>Sign out</Text>
</TouchableOpacity>
</SignedOut>
</>
)
}
4 changes: 2 additions & 2 deletions apps/client/app/(onboarding)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Link } from 'expo-router'
export default function Page() {
return (
<View className="p-safe bg-background">
<Text className="text-foreground"> text </Text>
<Text className="text-foreground"> Onboarding </Text>
<View>
<Link href="/auth/sign-in">
<Text className="text-primary">Sign in</Text>
</Link>
<Link href="/auth/sign-up">
<Text>Sign up</Text>
<Text className="text-primary">Sign up</Text>
</Link>
<Link href="/home">
<Text>Home up</Text>
Expand Down
6 changes: 5 additions & 1 deletion apps/client/app/auth/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import { Container } from '@/components/ui/container'
import { colors } from '@/theme'
import { useAuth } from '@clerk/clerk-expo'

export const unstable_settings = {
initialRouteName: 'sign-in',
}

export default function AuthRoutesLayout() {
const { isSignedIn } = useAuth()

if (isSignedIn) {
return <Redirect href={'/'} />
return <Redirect href={'/(home)'} />
}

return (
Expand Down
14 changes: 0 additions & 14 deletions apps/client/app/auth/index.tsx

This file was deleted.

59 changes: 27 additions & 32 deletions apps/client/app/auth/sign-in.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useState } from 'react'
import { KeyboardAvoidingView, Platform, Text, View } from 'react-native'
import { Text, View } from 'react-native'
import { Link, useRouter } from 'expo-router'
import { LockKeyhole, Mail } from 'lucide-react-native'
import { Button } from '@/components/ui/button'
Expand Down Expand Up @@ -35,38 +35,33 @@ export default function Page() {

return (
<>
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
className="flex-1"
>
<View className="flex-1 items-center justify-center">
<Text className="color-primary bg-background">
Master English, Transform Your World. The new frontier in
collaborative learning.
</Text>
</View>
<View className="gap-4 px-6">
<Input
icon={Mail}
autoCapitalize="none"
value={emailAddress}
placeholder="Enter your email"
onChangeText={(emailAddress) => setEmailAddress(emailAddress)}
/>
<Input
icon={LockKeyhole}
value={password}
placeholder="Enter password"
secureTextEntry={true}
onChangeText={(password) => setPassword(password)}
/>
<Button title="Sign In" onPress={onSignInPress} />
<View className="flex-1 items-center justify-center">
<Text className="color-primary bg-background">
Master English, Transform Your World. The new frontier in
collaborative learning.
</Text>
</View>
<View className="gap-4 px-6">
<Input
icon={Mail}
autoCapitalize="none"
value={emailAddress}
placeholder="Enter your email"
onChangeText={(emailAddress) => setEmailAddress(emailAddress)}
/>
<Input
icon={LockKeyhole}
value={password}
placeholder="Enter password"
secureTextEntry={true}
onChangeText={(password) => setPassword(password)}
/>
<Button title="Sign In" onPress={onSignInPress} />

<Link href="/auth/sign-up" asChild>
<Button variant="secondary" title="Sign Up" />
</Link>
</View>
</KeyboardAvoidingView>
<Link href="/auth/sign-up" asChild>
<Button variant="secondary" title="Sign Up" />
</Link>
</View>
</>
)
}

0 comments on commit 69a3b61

Please sign in to comment.