-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
83 lines (67 loc) · 2.31 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React, { useEffect, useState } from 'react';
import { Provider } from "react-redux";
import Home from './pages/home'
import Login from './pages/login'
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { StyleSheet, Text, View } from 'react-native';
import {firebaseConfig} from './config'
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as firebase from 'firebase'
import Dashboard from './pages/dashboard';
import Chat from './pages/chat';
import Pay from './pages/pay';
import Register from './pages/register'
import Midtrans from './pages/midtrans';
// firebase.initializeApp(firebaseConfig)
import store from './store'
import AddSuggestion from './pages/addSuggestion';
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
} else {
firebase.app(); // if already initialized, use that one
}
const Stack = createStackNavigator();
export default function App() {
console.disableYellowBox = true;
const [isLogin, setIsLogin] = useState(null)
async function getToken() {
const token = await AsyncStorage.getItem('token')
if (token) {
setIsLogin(true)
}else{
setIsLogin(false)
}
}
useEffect(()=>{
console.log("dari app");
getToken()
},[isLogin])
if (isLogin === null) {
return <Text>loading ...</Text>
}
return (
<Provider store={store}>
<NavigationContainer>
<Stack.Navigator initialRouteName={isLogin ? "Dashboard":"Login"} screenOptions={{headerShown: false}} >
{/* <Stack.Screen name="Notif" component={Notif} /> */}
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="Register" component={Register} />
<Stack.Screen name="Dashboard" component={Dashboard} />
<Stack.Screen name="Chat" component={Chat} options={{ headerShown: true }} />
<Stack.Screen name="Pay" component={Pay} />
<Stack.Screen name="Midtrans" component={Midtrans} />
<Stack.Screen name="AddSuggestion" component={AddSuggestion} />
</Stack.Navigator>
</NavigationContainer>
</Provider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});