-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
45 lines (40 loc) · 1.22 KB
/
Copy pathApp.js
File metadata and controls
45 lines (40 loc) · 1.22 KB
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
import 'react-native-gesture-handler';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View, ActivityIndicator } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import Tabs from './src/navigation/Tabs';
import { AuthProvider, useAuth } from './src/context/AuthContext';
import AuthScreen from './src/screens/AuthScreen';
import { ThemeProvider, useThemeMode } from './src/context/ThemeContext';
function Root() {
const { sessionLoading, session } = useAuth();
const { navTheme } = useThemeMode();
if (sessionLoading) {
return (
<View style={[styles.container, styles.center, { backgroundColor: navTheme.colors.background }]}>
<ActivityIndicator size="large" color={navTheme.colors.text} />
</View>
);
}
return (
<NavigationContainer theme={navTheme}>
{session ? <Tabs /> : <AuthScreen />}
</NavigationContainer>
);
}
export default function App() {
return (
<ThemeProvider>
<AuthProvider>
<Root />
<StatusBar style="auto" />
</AuthProvider>
</ThemeProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
center: { alignItems: 'center', justifyContent: 'center' },
});