-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppWrapper.js
47 lines (41 loc) · 1.41 KB
/
AppWrapper.js
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
import * as React from 'react';
import { UserContext } from './UserContext';
import { useTranslation } from 'react-i18next';
import { Platform, StatusBar, View, StyleSheet } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import BottomTabNavigator from './navigation/BottomTabNavigator';
import LoginScreen from './screens/LoginScreen';
const Stack = createStackNavigator();
export default function AppWrapper() {
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});
const containerRef = React.useRef();
const { t } = useTranslation();
const user = React.useContext(UserContext);
if(!user.loggedInUid){
console.log('User is not logged in!');
return (
<View style={styles.container}>
<LoginScreen/>
</View>
)
}
console.log('User is logged in!');
return (
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<NavigationContainer
ref={containerRef}
>
<Stack.Navigator>
<Stack.Screen name={t('appName')} component={BottomTabNavigator} />
</Stack.Navigator>
</NavigationContainer>
</View>
);
}