-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
88 lines (74 loc) · 2.93 KB
/
App.tsx
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
import { StatusBar } from 'expo-status-bar';
import { useState, useEffect } from 'react';
import {SafeAreaView} from 'react-native-safe-area-context';
import { Pressable, StyleSheet, Text, View, Button, Image } from 'react-native';
// import Map from './components/Map';
import MapNavigator from './components/MapNavigator';
import Login from './components/auth/LoginHome';
import Map from './components/Map'
import AuthStack from './components/auth/AuthStack';
import FlashMessage from 'react-native-flash-message';
import React from 'react';
import {API_KEY} from "@env";
import { NavigationContainer, StackActions } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import EmailRegister from './components/auth/EmailRegister';
import { createDrawerNavigator, DrawerContentScrollView, DrawerItemList,DrawerItem } from '@react-navigation/drawer';
import { useNavigation } from '@react-navigation/native';
import Wallet from './components/drawer/Wallet';
import History from './components/drawer/History';
import Profile from './components/drawer/Profile';
const Stack = createNativeStackNavigator();
const Drawer = createDrawerNavigator();
function CustomDrawerContent(props) {
return (
<DrawerContentScrollView {...props}>
<Image style={styles.drawerImage} source={require('./assets/logo_dark.png')}></Image>
<DrawerItemList {...props} />
</DrawerContentScrollView>
);
}
export default function App() {
const [position, setPosition] = useState({});
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [token, setToken] = useState(null);
const [toggleDrawer, setToggelDrawer] = useState(false);
return (
<View style={styles.container}>
<NavigationContainer>
<Drawer.Navigator screenOptions={{headerShown: false}} useLegacyImplementation
drawerContent={(props) => <CustomDrawerContent {...props} />}>
{isLoggedIn ?
<Drawer.Screen name="Map">
{(screenProps) => <MapNavigator {...screenProps} token={token} API_KEY={API_KEY} position={position} setPosition={setPosition}/>}
</Drawer.Screen>
:
<Drawer.Screen name="Auth">
{() => <AuthStack setToken={setToken} setIsLoggedIn={setIsLoggedIn}/>}
</Drawer.Screen>
}
<Drawer.Screen name='Wallet'>
{(screenProps) => <Wallet {...screenProps} />}
</Drawer.Screen>
<Drawer.Screen name='Ride History'>
{(screenProps) => <History {...screenProps} />}
</Drawer.Screen>
<Drawer.Screen name='Profile'>
{(screenProps) => <Profile {...screenProps} setIsLoggedIn={setIsLoggedIn}/>}
</Drawer.Screen>
</Drawer.Navigator>
</NavigationContainer>
<FlashMessage position={'top'}/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
drawerImage: {
margin: 20,
marginBottom: 50,
marginTop: 30
},
});