-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
49 lines (40 loc) · 1.51 KB
/
App.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
48
49
import React, {useState, useEffect} from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import AuthStack from './src/components/navigation/AuthStack';
import BottomTabNavigator from './src/components/navigation/BottomTabNavigator';
import DrawerNavigator from './src/components/navigation/DrawerNavigator';
import { firebase } from './src/firebase/config';
// import StockDetail from './src/screens/StockDetail'
import { Platform} from 'react-native';
import { LogBox } from 'react-native';
const Stack = createStackNavigator()
const AuthNavigator = Platform.select({
ios: () => AuthStack,
android: () => AuthStack,
})();
const PlatformNavigator = Platform.select({
ios: () => BottomTabNavigator,
android: () => DrawerNavigator //BottomTabNavigator
})()
export default function App() {
LogBox.ignoreLogs(['Setting a timer']);
const [user, setUser] = useState(null);
useEffect(() => {
const subscriber = firebase.auth().onAuthStateChanged((authUser) => {
setUser(authUser);
})
return subscriber; // unsubscribe on unmount
}, []);
console.log("authUser", user)
return (
<SafeAreaProvider>
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen name="Root" component={user ? PlatformNavigator : AuthNavigator } />
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
);
}