forked from fr/deguapp
		
	Added: fully working signin/signup system with routing
This commit is contained in:
		
							
								
								
									
										22
									
								
								frontend/app/(app)/_layout.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								frontend/app/(app)/_layout.js
									
									
									
									
									
										Normal 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 />;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								frontend/app/(app)/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								frontend/app/(app)/index.js
									
									
									
									
									
										Normal 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>
 | 
			
		||||
  );
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user