-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
176 lines (162 loc) · 4.63 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
176
import React from 'react';
import { StyleSheet, Text, View, Image, YellowBox, Dimensions } from 'react-native';
import firebase from 'firebase';
import config from './services/firebase-config';
import FontLoad from './components/FontLoad';
import { createBottomTabNavigator, createAppContainer, createStackNavigator } from 'react-navigation';
import AccountProfile from './screens/AccountProfile';
import AvailablePackages from './screens/AvailablePackages';
import Checkout from './screens/Checkout';
import AuthorizeDriver from './screens/AuthorizeDriver';
import Deliveries from './screens/Deliveries';
import Item from './screens/Item';
import Login from './screens/Login';
import OrderComplete from './screens/OrderComplete';
import Rating from './screens/Rating';
import Register from './screens/Register';
import RequestOptions from './screens/RequestOptions';
import RequestStatus from './screens/RequestStatus';
import RequestProfile from './screens/RequestProfile';
import ShoppingList from './screens/ShoppingList';
import ShopSearch from './screens/ShopSearch';
import Welcome from './screens/Welcome';
import YourCart from './screens/YourCart';
import YourResults from './screens/YourResults';
import Payment from './screens/Payment';
import LoadingScreen from './screens/LoadingScreen';
import SignUp from './screens/SignUp';
import { createStore, applyMiddleware } from 'redux';
import { Provider, connect } from 'react-redux';
import axios from 'axios';
import axiosMiddleware from 'redux-axios-middleware';
import completedReducer from './reducers/completedReducer';
import { AsyncStorage } from "react-native";
const client = axios.create({
baseURL: 'https://api.github.com',
responseType: 'json'
});
const store = createStore(completedReducer, applyMiddleware(axiosMiddleware(client)));
YellowBox.ignoreWarnings([
'Require cycle:',
]);
FontLoad.then((res) => {
})
console.disableYellowBox = true;
const shopStackNavigator = createStackNavigator({
Welcome: {
screen: Welcome,
},
SignUp: {
screen: SignUp
},
Login: {
screen: Login
},
ShopSearch: {
screen: ShopSearch
},
LoadingScreen: {
screen: LoadingScreen
},
AuthorizeDriver: {
screen: AuthorizeDriver
},
YourCart: {
screen: YourCart
},
Checkout: {
screen: Checkout
},
OrderComplete: {
screen: OrderComplete
},
Rating: {
screen: Rating
},
AccountProfile: {
screen: AccountProfile
}
});
const driverStackNavigator = createStackNavigator({
AvailablePackages: {
screen: AvailablePackages
},
RequestOptions: {
screen: RequestOptions
},
RequestStatus: {
screen: RequestStatus
},
ShoppingList: {
screen: ShoppingList
},
Rating: {
screen: Rating
},
RequestStatus: {
screen: RequestStatus
},
Payment: {
screen: Payment
},
AccountProfile: {
screen: AccountProfile
},
Deliveries: {
screen: Deliveries
},
});
const TabNavigator = createBottomTabNavigator({
ShopSearch: shopStackNavigator,
DriverSearch: driverStackNavigator,
},
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused }) => {
const { routeName } = navigation.state;
let imageName;
if (routeName === 'ShopSearch') {
imageName = require('./assets/images/blue-nav-cart.png');
if (focused) {
imageName = require('./assets/images/filled_cart.png');
}
} else if (routeName === 'Notifications') {
imageName = require('./assets/images/home_icon.png');
if (focused) {
imageName = require('./assets/images/filled_house.png');
}
} else if (routeName === 'DriverSearch') {
imageName = require('./assets/images/blue_person_w_bag.png');
if (focused) {
imageName = require('./assets/images/blue_filled_person.png');
}
}
return <Image source={imageName} style={{ width: Dimensions.get("screen").width * .1, height: Dimensions.get("screen").height * .05, marginTop: Dimensions.get("screen").height * .005, resizeMode: 'contain' }} />;
},
}),
tabBarOptions: {
showLabel: false,
style: {
height: Dimensions.get("screen").height * .08
}
},
}
);
const JuicedAppContainer = createAppContainer(TabNavigator);
class App extends React.Component {
componentWillMount = async () => {
const navigation = this.props.navigation;
const userId = await AsyncStorage.getItem('userId');
if(userId !== null) {
navigation.navigate('ShopSearch')
}
}
render() {
return (
<Provider store={store}>
<JuicedAppContainer />
</Provider>
)
}
}
export default App;