-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
135 lines (103 loc) · 3.38 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View, ActivityIndicator } from 'react-native';
import Deliverynav from './nav/Deliverynav';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import Dashboard from './screens/dashboard';
import Newbookings from './screens/newbookings';
import MapScreenview from './screens/MapScreenView';
import Confirmed from './screens/confirmedscreen';
import MapconfirmedScreenview from './screens/Mapconfirmedscreen';
import Journeyscreen from './screens/journeyscreen';
import LoginScreen from './screens/LoginScreen';
import RegisterScreen from './screens/RegisterScreen';
import * as firebase from 'firebase';
import AuthIntroScreen from './screens/AuthIntroScreen';
import { firebaseConfig } from './config';
import { DefaultTheme, Provider as PaperProvider } from 'react-native-paper';
import i18n from 'i18n-js';
const AuthStack = createStackNavigator();
const HomeStack = createStackNavigator();
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
function App() {
const [state, setstate] = useState({
loggedIn: null
})
useEffect(() => {
firebase.auth().onAuthStateChanged(user => {
if (user) {
setstate({
loggedIn: true
})
} else {
setstate({
loggedIn: false
})
}
}
)
}, [])
switch (state.loggedIn) {
case false:
return (
<PaperProvider theme={theme}>
<NavigationContainer>
<AuthStack.Navigator screenOptions={{
headerShown: false
}}>
<AuthStack.Screen name="Intro" component={AuthIntroScreen} />
<AuthStack.Screen name="Login" component={LoginScreen} />
<AuthStack.Screen name="Register" component={RegisterScreen} />
</AuthStack.Navigator>
</NavigationContainer>
</PaperProvider>
)
case true:
return (
<PaperProvider theme={theme}>
<NavigationContainer>
<HomeStack.Navigator screenOptions={{
headerStyle: {
backgroundColor: '#4747d1',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
}}>
<HomeStack.Screen name="Dashboard" component={Dashboard} />
<HomeStack.Screen name="Newbookings" component={Newbookings} />
<HomeStack.Screen name="Mapview" component={MapScreenview} />
<HomeStack.Screen name="Confirmed" component={Confirmed} />
<HomeStack.Screen name="Mapconfirmedview" component={MapconfirmedScreenview} />
<HomeStack.Screen name="Mapjourneyview" component={Journeyscreen} />
</HomeStack.Navigator>
</NavigationContainer>
</PaperProvider>
)
default:
return (
<View style={{ flex: 1, justifyContent: 'center', alignContent: 'center' }}>
<ActivityIndicator size="large" />
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: '#4fc116',
},
};
export default App;