-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroute.js
190 lines (162 loc) · 4.73 KB
/
route.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
import React from 'react';
import { Platform ,TouchableOpacity,Text} from 'react-native';
import { graphql, compose } from 'react-apollo';
import { StackNavigator,TabNavigator,TabBarBottom ,NavigationActions,DrawerNavigator} from 'react-navigation';
import {computeSize} from './utils/DeviceRatio'
import { Auth } from 'aws-amplify';
///ui components
import { Modal} from 'antd-mobile';
import { Ionicons,MaterialCommunityIcons} from '@expo/vector-icons';
const alert = Modal.alert;
//compose
import AllEventWithData from './compose/AllEventWithData'
import AddEventData from './compose/AddEventData'
//Component
import About from './components/About'
import MapPage from './components/MapPage'
import ListMap from './components/ListMap'
//Login Component
import Login from './components/Auth/Login'
import Signup from './components/Auth/Signup'
//chat components
import ChatPage from './components/ChatPage'
import Test from './components/Test'
_logout = function(navigation){
return(<TouchableOpacity onPress={this._confirm(navigation)}><Ionicons name="ios-log-out" size={computeSize(60)} style={{marginRight:computeSize(20)}}/></TouchableOpacity>)
}
_openDrawer = function(navigation){
return(<TouchableOpacity onPress={()=>{navigation.navigate('DrawerToggle')}} ><Ionicons name="ios-menu" size={computeSize(60)} style={{marginLeft:computeSize(20)}}/></TouchableOpacity>)
}
_confirm = function(navigation){
return ()=>{
alert('Logout', 'Are you sure???', [
{ text: 'Cancel', onPress: () => console.log('cancel'), style: 'default' },
{ text: 'OK', onPress: () =>{this._signout(navigation)} },
]);
}
}
_signout = function(navigation){
Auth.signOut()
.then(data =>{
console.log(data,'sucess signout')
console.log(navigation,'unsa navigation niya ane gd');
const newAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({routeName: 'Auth'})
]
});
navigation.dispatch(newAction)
})
.catch(err => console.log(err,'error signout'));
}
// _button = function(navigation){
// if(Platform.OS === 'ios'){
// return <Button title='Create' color='#ffffff' onPress={()=> navigation.navigate('AddEvent')} />
// }else {
// return <Button title='Create' onPress={()=> navigation.navigate('AddEvent')} />
// }
// }
// const Route = StackNavigator({
// AllEvents : {
// screen : (props) => <AllEventWithData {...props}/>,
// navigationOptions: ({navigation}) => ({
// title: 'Upcoming Events',
// headerRight: this._button(navigation),
// headerStyle:{
// backgroundColor:'#42a1f4',
// },
// headerTitleStyle:{
// color: '#ffffff'
// },
// headerTintColor:'#ffffff'
// })
// },
// AddEvent: {
// screen: (props) => <AddEventData {...props} />,
// navigationOptions: ({navigation, screenProps}) => {
// return {
// title: 'Create Event',
// headerStyle:{
// backgroundColor:'#42a1f4'
// },
// headerTitleStyle:{
// color: '#ffffff'
// },
// headerTintColor:'#ffffff'
// };
// }
// }
// });
const AppTabNavigator = TabNavigator(
{
About:{screen:About},
MapPage:{screen:MapPage},
ListMap:{screen:ListMap}
},
{
initialRouteName:'About',
tabBarComponent: TabBarBottom,
tabBarPosition: 'bottom',
swipeEnabled: true,
animationEnabled: true,
lazyLoad: true,
tabBarOptions: {
activeTintColor: Platform.OS === 'ios' ? '#2196F3' : '#fff',
},
}
)
const AuthNavigator = TabNavigator(
{
Login:{screen:Login},
Signup:{screen:Signup}
},
{
initialRouteName:'Login',
tabBarComponent: TabBarBottom,
tabBarPosition: 'bottom',
swipeEnabled: true,
animationEnabled: true,
lazyLoad: true,
tabBarOptions: {
activeTintColor: Platform.OS === 'ios' ? '#2196F3' : '#fff',
},
}
)
const HomeDrawerNavigator = DrawerNavigator({
Main:{
screen:AppTabNavigator,
navigationOptions:({navigation})=>({
drawerLabel: 'Home'
})
},
Chats:{
screen:ChatPage,
navigationOptions:({navigation})=>({
drawerLabel: 'Chat'
})
}
},{
initialRouteName:'Chats',
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle'
}
)
const Route = StackNavigator({
Home:{
screen:HomeDrawerNavigator,
navigationOptions: ({navigation}) => ({
headerRight: this._logout(navigation),
headerLeft: this._openDrawer(navigation)
})
},
Auth:{
screen:AuthNavigator
},
},
{
initialRouteName:'Auth',
headerMode: 'float'
})
export default Route;