-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppNavigator.js
109 lines (100 loc) · 3.57 KB
/
AppNavigator.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
import React from 'react';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';
import { useTheme } from './Context/ThemeContext';
import { MaterialIcons } from '@expo/vector-icons'; // Import icons
import SignUpScreen from './Screens/SignUpScreen';
import LoginScreen from './Screens/LoginScreen';
import WelcomeScreen from './Screens/WelcomeScreen';
import ItemsListScreen from './Screens/ItemsListScreen';
import FavouriteScreen from './Screens/FavouriteScreen';
import CartScreen from './Screens/CartScreen';
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
const BottomTabNavigator = () => {
const { theme } = useTheme();
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ color, size }) => {
let iconName;
if (route.name === 'ItemsList') {
iconName = 'list'; // List icon
} else if (route.name === 'Favourites') {
iconName = 'favorite'; // Heart icon
} else if (route.name === 'Cart') {
iconName = 'shopping-cart'; // Cart icon
}
return <MaterialIcons name={iconName} size={size} color={color} />;
},
tabBarStyle: { backgroundColor: theme.background },
tabBarActiveTintColor: theme.button,
tabBarInactiveTintColor: theme.text,
})}
>
<Tab.Screen name="ItemsList" component={ItemsListScreen} />
<Tab.Screen name="Favourites" component={FavouriteScreen} />
<Tab.Screen name="Cart" component={CartScreen} />
</Tab.Navigator>
);
};
const AppNavigator = () => {
const { theme } = useTheme();
const handleLogout = () => {
// Implement your logout logic here
alert('Logged out');
};
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="SignUp"
component={SignUpScreen}
options={{
headerStyle: { backgroundColor: theme.headerBackground },
headerTintColor: theme.text,
}}
/>
<Stack.Screen
name="Login"
component={LoginScreen}
options={{
headerStyle: { backgroundColor: theme.headerBackground },
headerTintColor: theme.text,
}}
/>
<Stack.Screen
name="Welcome"
component={WelcomeScreen}
options={{
headerStyle: { backgroundColor: theme.headerBackground },
headerTintColor: theme.text,
}}
/>
<Stack.Screen
name="ItemsList"
component={BottomTabNavigator}
options={({ navigation }) => ({
headerRight: () => (
<MaterialIcons
name="logout"
size={24}
color={theme.text}
style={{ marginRight: 15 }}
onPress={() => {
handleLogout();
// Optional: Navigate to another screen after logout
navigation.navigate('SignUp'); // Replace 'SignUp' with the screen you want to navigate to after logout
}}
/>
),
headerStyle: { backgroundColor: theme.headerBackground },
headerTintColor: theme.text,
})}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
export default AppNavigator;