This repository has been archived by the owner on Jan 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
232 lines (219 loc) · 6.33 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import React, {Component} from 'react';
//import react in our code.
import {
View,
StyleSheet,
Dimensions,
Image,
TouchableOpacity,
Button,
Platform,
Text,
} from 'react-native';
import {createAppContainer} from 'react-navigation';
import {createDrawerNavigator} from 'react-navigation-drawer';
import {createStackNavigator} from 'react-navigation-stack';
//Import all the screens
// import Edible from './pages/Edible';
// import NonEdible from './pages/NonEdible';
// import Deadly from './pages/Deadly';
import Retete from './pages/Retete';
import Details from './pages/Details';
import Search from './pages/Search';
import MushroomItem from './pages/MushroomItem';
import BackButton from './components/BackButton';
import {Provider, connect} from 'react-redux';
import store from './store/store';
//Import Custom Sidebar
import CustomSidebarMenu from './CustomSidebarMenu';
global.currentScreenIndex = 0;
//Navigation Drawer Structure for all screen
class NavigationDrawerStructure extends Component {
//Top Navigation Header with Donute Button
toggleDrawer = () => {
//Props to open/close the drawer
this.props.navigationProps.toggleDrawer();
};
render() {
return (
<View style={{flexDirection: 'row'}}>
<TouchableOpacity onPress={this.toggleDrawer.bind(this)}>
{/*Donute Button Image */}
<Image
source={require('./image/drawer.png')}
style={{width: 25, height: 25, marginLeft: 5}}
/>
</TouchableOpacity>
</View>
);
}
}
// let EdibleContainer = connect(state => ({ search: state.search }), null)(Edible);
let Edible = (props) => { return (<MushroomItem cat='1' backgroundColor='#769743' {...props} />) }
let NonEdible = (props) => { return (<MushroomItem cat='2' backgroundColor='#ECF71E' {...props} />) }
let Deadly = (props) => { return (<MushroomItem cat='3' backgroundColor='#E61A23' {...props} />) }
//Stack Navigator for the First Option of Navigation Drawer
const FirstActivity_StackNavigator = createStackNavigator({
//All the screen from the First Option will be indexed here
First: {
screen: Edible,
navigationOptions: ({navigation}) => ({
title: 'Ciuperci comestibile',
headerLeft: <NavigationDrawerStructure navigationProps={navigation} />,
headerRight: <Search />,
headerStyle: {
backgroundColor: '#313218',
},
headerTintColor: '#fff',
}),
},
Details: {
screen: Details,
navigationOptions: ({navigation}) => ({
title: navigation.state.params.name,
// headerRight: <NavigationDrawerStructure navigationProps={navigation} />,
headerLeft: () => (
<BackButton
icon="arrow-back"
size={30}
color="white"
navigation={navigation}
/>
),
headerStyle: {
backgroundColor: '#313218',
},
headerTintColor: '#fff',
}),
},
});
//Stack Navigator for the Second Option of Navigation Drawer
const Screen2_StackNavigator = createStackNavigator({
//All the screen from the Second Option will be indexed here
NonEdible: {
screen: NonEdible,
navigationOptions: ({navigation}) => ({
title: 'Ciuperci necomestibile',
headerLeft: <NavigationDrawerStructure navigationProps={navigation} />,
headerRight: <Search />,
headerStyle: {
backgroundColor: '#313218',
},
headerTintColor: '#fff',
}),
},
Details: {
screen: Details,
navigationOptions: ({navigation}) => ({
title: navigation.state.params.name,
headerRight: <NavigationDrawerStructure navigationProps={navigation} />,
headerLeft: () => (
<BackButton
icon="arrow-back"
size={30}
color="white"
navigation={navigation}
/>
),
headerStyle: {
backgroundColor: '#313218',
},
headerTintColor: '#fff',
}),
},
});
//
const Deadly_StackNavigator = createStackNavigator({
Deadly: {
screen: Deadly,
navigationOptions: ({navigation}) => ({
title: 'Toxice si Mortale',
headerLeft: <NavigationDrawerStructure navigationProps={navigation} />,
headerRight: <Search />,
headerStyle: {
backgroundColor: '#313218',
},
headerTintColor: '#fff',
}),
},
Details: {
screen: Details,
navigationOptions: ({navigation}) => ({
title: navigation.state.params.name,
headerRight: <NavigationDrawerStructure navigationProps={navigation} />,
headerLeft: () => (
<BackButton
icon="arrow-back"
size={30}
color="white"
navigation={navigation}
/>
),
headerStyle: {
backgroundColor: '#313218',
},
headerTintColor: '#fff',
}),
},
});
//Stack Navigator for the Third Option of Navigation Drawer
// const Retete_StackNavigator = createStackNavigator({
// //All the screen from the Third Option will be indexed here
// Retete: {
// screen: Retete,
// navigationOptions: ({navigation}) => ({
// title: 'Retete',
// headerLeft: <NavigationDrawerStructure navigationProps={navigation} />,
// headerStyle: {
// backgroundColor: '#313218',
// },
// headerTintColor: '#fff',
// }),
// },
// });
//Drawer Navigator Which will provide the structure of our App
const DrawerNavigatorExample = createDrawerNavigator(
{
//Drawer Optons and indexing
NavScreen1: {
screen: FirstActivity_StackNavigator,
navigationOptions: {
drawerLabel: 'Ciuperci comestibile',
},
},
NavScreen2: {
screen: Screen2_StackNavigator,
navigationOptions: {
drawerLabel: 'Ciuperci necomestibile',
},
},
NavScreen3: {
screen: Deadly_StackNavigator,
navigationOptions: {
drawerLabel: 'Deadly',
},
},
// NavScreen4: {
// screen: Retete_StackNavigator,
// navigationOptions: {
// drawerLabel: 'Retete',
// },
// },
},
{
//For the Custom sidebar menu we have to provide our CustomSidebarMenu
contentComponent: CustomSidebarMenu,
//Sidebar width
drawerWidth: Dimensions.get('window').width - 130,
},
);
let Navigation = createAppContainer(DrawerNavigatorExample);
export default class App extends Component {
render() {
return (
<Provider store={store}>
<Navigation />
</Provider>
);
}
}