|
1
|
|
|
import { StatusBar } from 'expo-status-bar'; |
|
2
|
|
|
import { useState, useEffect } from 'react'; |
|
3
|
|
|
import {SafeAreaView} from 'react-native-safe-area-context'; |
|
4
|
|
|
import { Pressable, StyleSheet, Text, View, Button, Image } from 'react-native'; |
|
5
|
|
|
// import Map from './components/Map'; |
|
6
|
|
|
import MapNavigator from './components/MapNavigator'; |
|
7
|
|
|
import Login from './components/auth/LoginHome'; |
|
8
|
|
|
import Map from './components/Map' |
|
9
|
|
|
import AuthStack from './components/auth/AuthStack'; |
|
10
|
|
|
import FlashMessage from 'react-native-flash-message'; |
|
11
|
|
|
import React from 'react'; |
|
12
|
|
|
import {API_KEY} from "@env"; |
|
13
|
|
|
import { NavigationContainer, StackActions } from '@react-navigation/native'; |
|
14
|
|
|
import { createNativeStackNavigator } from '@react-navigation/native-stack'; |
|
15
|
|
|
import EmailRegister from './components/auth/EmailRegister'; |
|
16
|
|
|
import { createDrawerNavigator, DrawerContentScrollView, DrawerItemList,DrawerItem } from '@react-navigation/drawer'; |
|
17
|
|
|
import { useNavigation } from '@react-navigation/native'; |
|
18
|
|
|
import Wallet from './components/drawer/Wallet'; |
|
19
|
|
|
import History from './components/drawer/History'; |
|
20
|
|
|
import Profile from './components/drawer/Profile'; |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
const Stack = createNativeStackNavigator(); |
|
24
|
|
|
const Drawer = createDrawerNavigator(); |
|
25
|
|
|
|
|
26
|
|
|
function CustomDrawerContent(props) { |
|
27
|
|
|
return ( |
|
28
|
|
|
<DrawerContentScrollView {...props}> |
|
29
|
|
|
<Image style={styles.drawerImage} source={require('./assets/logo_dark.png')}></Image> |
|
30
|
|
|
<DrawerItemList {...props} /> |
|
31
|
|
|
</DrawerContentScrollView> |
|
32
|
|
|
); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
export default function App() { |
|
36
|
|
|
const [position, setPosition] = useState({}); |
|
37
|
|
|
const [isLoggedIn, setIsLoggedIn] = useState(false); |
|
38
|
|
|
const [token, setToken] = useState(null); |
|
39
|
|
|
const [toggleDrawer, setToggelDrawer] = useState(false); |
|
40
|
|
|
|
|
41
|
|
|
return ( |
|
42
|
|
|
<View style={styles.container}> |
|
43
|
|
|
|
|
44
|
|
|
<NavigationContainer> |
|
45
|
|
|
<Drawer.Navigator screenOptions={{headerShown: false}} useLegacyImplementation |
|
46
|
|
|
drawerContent={(props) => <CustomDrawerContent {...props} />}> |
|
47
|
|
|
|
|
48
|
|
|
{isLoggedIn ? |
|
49
|
|
|
<Drawer.Screen name="Map"> |
|
50
|
|
|
{(screenProps) => <MapNavigator {...screenProps} token={token} API_KEY={API_KEY} position={position} setPosition={setPosition}/>} |
|
51
|
|
|
</Drawer.Screen> |
|
52
|
|
|
: |
|
53
|
|
|
<Drawer.Screen name="Auth"> |
|
54
|
|
|
{() => <AuthStack setToken={setToken} setIsLoggedIn={setIsLoggedIn}/>} |
|
55
|
|
|
</Drawer.Screen> |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
<Drawer.Screen name='Wallet'> |
|
59
|
|
|
{(screenProps) => <Wallet {...screenProps} />} |
|
60
|
|
|
</Drawer.Screen> |
|
61
|
|
|
|
|
62
|
|
|
<Drawer.Screen name='Ride History'> |
|
63
|
|
|
{(screenProps) => <History {...screenProps} />} |
|
64
|
|
|
</Drawer.Screen> |
|
65
|
|
|
|
|
66
|
|
|
<Drawer.Screen name='Profile'> |
|
67
|
|
|
{(screenProps) => <Profile {...screenProps} setIsLoggedIn={setIsLoggedIn}/>} |
|
68
|
|
|
</Drawer.Screen> |
|
69
|
|
|
</Drawer.Navigator> |
|
70
|
|
|
</NavigationContainer> |
|
71
|
|
|
|
|
72
|
|
|
<FlashMessage position={'top'}/> |
|
73
|
|
|
</View> |
|
74
|
|
|
); |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
const styles = StyleSheet.create({ |
|
79
|
|
|
container: { |
|
80
|
|
|
flex: 1, |
|
81
|
|
|
}, |
|
82
|
|
|
|
|
83
|
|
|
drawerImage: { |
|
84
|
|
|
margin: 20, |
|
85
|
|
|
marginBottom: 50, |
|
86
|
|
|
marginTop: 30 |
|
87
|
|
|
}, |
|
88
|
|
|
}); |