Added: fully working signin/signup system with routing

This commit is contained in:
2024-05-06 22:18:22 +02:00
parent bd5f7388b8
commit 89075eb6ae
19 changed files with 1199 additions and 41 deletions

View File

@ -0,0 +1,22 @@
import { Redirect, Stack } from "expo-router";
import { useAuth } from "../context/AuthContext";
import { View, Text } from "react-native";
export default function AppLayout() {
const { authState } = useAuth();
if (authState.authenticated === null) {
// micro loading co neni skoro videt ale get the fuck out se uz neloguje
return (
<View>
<Text>Loading...</Text>
</View>
);
}
if (!authState.authenticated) {
console.log("get the fuck out");
return <Redirect href="/login" />;
}
return <Stack />;
}

View File

@ -0,0 +1,21 @@
import { Text, View } from "react-native";
import { useAuth } from "../context/AuthContext";
export default function Index() {
const { onLogout } = useAuth();
const user = "debil"
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Welcome {user}</Text>
<Text
onPress={() => {
// The `app/(app)/_layout.tsx` will redirect to the sign-in screen.
onLogout();
}}
>
Sign Out
</Text>
</View>
);
}