From e6d880ef8ac871ac453938d0cbcd020c51e6648a Mon Sep 17 00:00:00 2001 From: Vinicius Souza Date: Wed, 30 Oct 2024 09:36:35 -0300 Subject: [PATCH] feat: create and share auth context --- App.tsx | 22 ++++++++++++---------- src/contexts/AuthContext.tsx | 3 +++ src/routes/index.tsx | 5 +++++ 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 src/contexts/AuthContext.tsx diff --git a/App.tsx b/App.tsx index d8fa01c..da09be5 100644 --- a/App.tsx +++ b/App.tsx @@ -4,6 +4,8 @@ import { GluestackUIProvider } from '@gluestack-ui/themed'; import { config } from './config/gluestack-ui.config'; +import { AuthContext } from '@contexts/AuthContext'; + import { Loading } from '@components/Loading'; import { Routes } from '@routes/index'; @@ -15,16 +17,16 @@ export default function App() { return ( - {fontsLoaded ? ( - - ) : ( - - )} - + + {fontsLoaded ? : } + + ); } diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx new file mode 100644 index 0000000..426cf75 --- /dev/null +++ b/src/contexts/AuthContext.tsx @@ -0,0 +1,3 @@ +import { createContext } from 'react'; + +export const AuthContext = createContext({}); diff --git a/src/routes/index.tsx b/src/routes/index.tsx index ec4ea50..6ed94d5 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,13 +1,18 @@ +import { useContext } from 'react'; import { DefaultTheme, NavigationContainer } from '@react-navigation/native'; import { Box } from '@gluestack-ui/themed'; import { AuthRoutes } from './auth.routes'; import { AppRoutes } from './app.routes'; +import { AuthContext } from '@contexts/AuthContext'; + import { gluestackUIConfig } from '../../config/gluestack-ui.config'; export function Routes() { const theme = DefaultTheme; + const contextData = useContext(AuthContext); + theme.colors.background = gluestackUIConfig.tokens.colors.gray700; return (