feat: introduced Authentification Context
This commit is contained in:
parent
7c9fdad01f
commit
6592864bc4
9 changed files with 215 additions and 16 deletions
|
|
@ -1,15 +1,22 @@
|
|||
import { Tabs } from "expo-router/tabs";
|
||||
import {StyleSheet, View} from "react-native"
|
||||
import {StyleSheet, View, Text} from "react-native"
|
||||
|
||||
import { FontAwesome } from "@expo/vector-icons";
|
||||
import {useThemeColor} from "../../hooks/hooks";
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { Redirect } from "expo-router";
|
||||
import { useAuth } from "../contexts/AuthContext";
|
||||
|
||||
export default function Layout() {
|
||||
// const selectedColor: string = useThemeColor( "tabIconSelected");
|
||||
// const defaultColor: string = useThemeColor("tabIconDefault");
|
||||
// const backgroundColor: string = useThemeColor("backgroundColor");
|
||||
// const tabBarColor: string = useThemeColor("tabBarColor");
|
||||
const {authState} = useAuth()
|
||||
useEffect(()=>{
|
||||
console.log(authState, "in root Layout")
|
||||
},[authState])
|
||||
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
sceneContainer: {
|
||||
|
|
@ -27,6 +34,11 @@ export default function Layout() {
|
|||
tabBarStyle: styles.tabBar,
|
||||
}
|
||||
|
||||
if(!authState?.authenticated){
|
||||
return (
|
||||
<Redirect href={"/"} />)
|
||||
}
|
||||
|
||||
return (
|
||||
<Tabs sceneContainerStyle={styles.sceneContainer} screenOptions={screenOptions}>
|
||||
<Tabs.Screen name="budget/index" options={
|
||||
|
|
|
|||
Reference in a new issue