Skip to content

Commit

Permalink
feat: connection provider and splash component created
Browse files Browse the repository at this point in the history
  • Loading branch information
Fahad-Mahmood committed Mar 13, 2024
1 parent 1d9c390 commit 275ee43
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
9 changes: 6 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import {config} from './src/theme/config';

import {NavigationContainer} from '@react-navigation/native';
import OnBoardingNavigation from './src/navigation/OnBoarding';
import {ConnectionProvider} from './src/providers/ConnectionProvider';

function App(): React.JSX.Element {
return (
<GluestackUIProvider config={config}>
<NavigationContainer>
<OnBoardingNavigation />
</NavigationContainer>
<ConnectionProvider>
<NavigationContainer>
<OnBoardingNavigation />
</NavigationContainer>
</ConnectionProvider>
</GluestackUIProvider>
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/Splash.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import {Box} from '@gluestack-ui/themed';

export const Splash = () => {
return <Box bg="$primary400" flex={1} />;
};
29 changes: 29 additions & 0 deletions src/providers/ConnectionProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, {useContext, createContext} from 'react';

interface Props {
children: React.ReactNode;
}
interface ContextProps {
loading: boolean;
}
const ConnectionContext = createContext<ContextProps>({
loading: false,
});

export const ConnectionProvider = ({children}: Props) => {
return (
<ConnectionContext.Provider value={{loading: false}}>
{children}
</ConnectionContext.Provider>
);
};

export const useConnectionContext = () => {
const context = useContext(ConnectionContext);
if (context === undefined) {
throw new Error(
'useConnectionContext must be used within ConnectionProvider',
);
}
return context;
};

0 comments on commit 275ee43

Please sign in to comment.