-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
57 lines (49 loc) · 1.57 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import AppNavigator from './src/navigation/AppNavigator';
import AuthScreen from './src/screens/AuthScreen';
import {AuthProvider, useAuth} from './src/contexts/AuthContext';
import LoadingScreen from './src/screens/LoadingScreen';
import {initializeApp, getApps} from '@react-native-firebase/app';
import {SWRProvider} from './src/api/swrConfig';
import Config from 'react-native-config';
const firebaseConfig = {
apiKey: Config.FIREBASE_API_KEY || '',
authDomain: Config.FIREBASE_AUTH_DOMAIN || '',
projectId: Config.FIREBASE_PROJECT_ID || '',
storageBucket: Config.FIREBASE_STORAGE_BUCKET || '',
messagingSenderId: Config.FIREBASE_MESSAGING_SENDER_ID || '',
appId: Config.FIREBASE_APP_ID || '',
} as const;
if (!getApps().length) {
initializeApp(firebaseConfig);
}
const Stack = createStackNavigator();
const AppContent = () => {
const {loading, serverToken} = useAuth();
if (loading) {
return <LoadingScreen />;
}
return (
<NavigationContainer>
<Stack.Navigator screenOptions={{headerShown: false}}>
{serverToken ? (
<Stack.Screen name="App" component={AppNavigator} />
) : (
<Stack.Screen name="Auth" component={AuthScreen} />
)}
</Stack.Navigator>
</NavigationContainer>
);
};
function App(): React.JSX.Element {
return (
<SWRProvider>
<AuthProvider>
<AppContent />
</AuthProvider>
</SWRProvider>
);
}
export default App;