-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
executable file
·175 lines (160 loc) · 5.11 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
Button,
StatusBar,
} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Icon from 'react-native-vector-icons/Ionicons';
import HomeScreen from './components/screens/HomeScreen';
import ProfileScreen from './components/screens/ProfileScreen';
import NotificationScreen from './components/screens/NotificationScreen';
import CartScreen from './components/screens/CartScreen';
import AuthAndInfo from './components/screens/AuthAndInfo';
import ProductsScreen from './components/ProductsScreen';
import ProductDetails from './components/ProductDetails';
import CartIconBadge from './components/CartIconBadge';
import SubCategories from './components/screens/SubCategories';
import ShoppingCartIcon from './components/ShoppingCartIcon';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';
import reducers from './reducers';
import SearchBar from './components/SearchBar';
import SearchBarProducts from './components/SearchBarProducts';
import SearchList from './components/Search/SearchList';
import SearchListHeader from './components/SearchListHeader';
const HomeStack = createStackNavigator();
const HomeStackScreen = () => {
return (
<HomeStack.Navigator>
<HomeStack.Screen
name="Home"
component={HomeScreen}
options={({ navigation }) => ({
title: 'Malamal Express',
headerRight: () => <SearchBar navigation={navigation} />,
})}
/>
<HomeStack.Screen
name="Products"
component={ProductsScreen}
options={({ navigation }) => ({
title: '',
headerShown: false,
})}
/>
<HomeStack.Screen
name="SubCategories"
component={SubCategories}
options={({ navigation }) => ({
title: 'Sub Categories',
headerShown: true,
})}
/>
<HomeStack.Screen name="Product Details" component={ProductDetails} />
<HomeStack.Screen
name="Search"
component={SearchList}
options={({ navigation }) => ({
headerShown: false,
})}
/>
</HomeStack.Navigator>
);
};
const OrderHistoryStack = createStackNavigator();
const NotificationStackScreen = () => {
return (
<OrderHistoryStack.Navigator>
<OrderHistoryStack.Screen
name="Order History"
component={NotificationScreen}
/>
</OrderHistoryStack.Navigator>
);
};
const CartStack = createStackNavigator();
const CartStackScreen = () => {
return (
<CartStack.Navigator>
<CartStack.Screen name="Cart" component={CartScreen} />
<CartStack.Screen name="AuthAndInfo" component={AuthAndInfo} />
</CartStack.Navigator>
);
};
const ProfileStack = createStackNavigator();
const ProfileStackScreen = () => {
return (
<ProfileStack.Navigator>
<ProfileStack.Screen name="Profile" component={ProfileScreen} />
</ProfileStack.Navigator>
);
};
const Tab = createBottomTabNavigator();
const App = () => {
const state = createStore(reducers, {}, applyMiddleware(ReduxThunk));
return (
<Provider store={state}>
<NavigationContainer>
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
if (route.name === 'Home') {
return (
<Icon
name={focused ? 'ios-home' : 'ios-home'}
size={size}
color={color}
/>
);
} else if (route.name === 'Order History') {
return (
<Icon
name={focused ? 'md-list' : 'md-list'}
size={size}
color={color}
/>
);
} else if (route.name === 'Cart') {
return (
<ShoppingCartIcon
name={focused ? 'md-cart' : 'md-cart'}
size={size}
color={color}
/>
);
} else if (route.name === 'Profile') {
return (
<Icon
name={focused ? 'md-contact' : 'md-contact'}
size={size}
color={color}
/>
);
}
},
})}
tabBarOptions={{
activeTintColor: 'black',
inactiveTintColor: 'gray',
}}>
<Tab.Screen name="Home" component={HomeStackScreen} />
<Tab.Screen
name="Order History"
component={NotificationStackScreen}
/>
<Tab.Screen name="Cart" component={CartStackScreen} />
<Tab.Screen name="Profile" component={ProfileStackScreen} />
</Tab.Navigator>
</NavigationContainer>
</Provider>
);
};
export default App;