-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathApp.tsx
46 lines (40 loc) · 1.12 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
import React from 'react';
import { View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { ThemeProvider, useTheme, getNavigatorTheme } from 'src/themes';
import { AuthProvider, useAuth } from 'src/contexts/AuthProvider';
import { Layout, Spinner } from 'src/components';
import { AppNavigator } from 'src/navigators/AppNavigator';
import { AuthNavigator } from 'src/navigators/AuthNavigator';
import './src/translations/i18n';
/* polyfills */
/** URL polyfill */
import 'react-native-url-polyfill/auto';
const App: React.FC = () => {
return (
<ThemeProvider>
<AuthProvider>
<Layout>
<Root />
</Layout>
</AuthProvider>
</ThemeProvider>
);
};
export default App;
const Root: React.FC = () => {
const { theme } = useTheme();
const { currentUser, loading } = useAuth();
if (loading) {
return (
<View>
<Spinner size="large" />
</View>
);
}
return (
<NavigationContainer theme={getNavigatorTheme(theme)}>
{currentUser !== null ? <AppNavigator /> : <AuthNavigator />}
</NavigationContainer>
);
};