login register

This commit is contained in:
2025-11-10 16:59:33 +07:00
parent 62f8299aef
commit 87269a6615
10 changed files with 249 additions and 4 deletions

View File

@@ -0,0 +1,27 @@
import { Stack, router } from "expo-router";
import { useEffect, useState } from "react";
import AsyncStorage from "@react-native-async-storage/async-storage";
export default function RootLayout() {
const [isLoading, setIsLoading] = useState(true);
const [isLoggedIn, setIsLoggedIn] = useState(false);
useEffect(() => {
const checkAuth = async () => {
const token = await AsyncStorage.getItem("authToken");
setIsLoggedIn(!!token);
setIsLoading(false);
};
checkAuth();
}, []);
if (isLoading) return null;
return (
<Stack>
{!isLoggedIn && <Stack.Screen name="index" options={{ title: "Đăng ký / Đăng nhập" }} />}
{isLoggedIn && <Stack.Screen name="(tabs)" options={{ headerShown: false }} />}
</Stack>
);
}