-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
138 lines (124 loc) · 3.59 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
'use strict';
/**********************************************************************
*
* Import Libraries
*
**********************************************************************/
import React, { Component } from 'react';
import {
I18nManager,
Alert,
BackHandler
} from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import { createDrawerNavigator,createAppContainer, createStackNavigator,NavigationActions } from 'react-navigation';
import getSlideFromRightTransition from 'react-navigation-slide-from-right-transition';
/**********************************************************************
*
* Screens
*
**********************************************************************/
import DrawerContainer from './src/screens/drawer'
import SplashScreen from './src/screens/SplashScreen';
import Logic from './src/screens/Logic';
import Intro from './src/screens/intro';
import Home from './src/screens/home';
import Login from './src/screens/login';
import Search from './src/screens/search';
import SearchNearBy from './src/screens/searchNearby';
import Car from './src/screens/car';
const Navigator = createStackNavigator({
SplashScreen: {
screen: SplashScreen,
},
Logic: {
screen: Logic,
},
Intro: {
screen: Intro,
},
Home: {
screen: Home,
},
Login: {
screen: Login,
},
Search: {
screen: Search,
},
SearchNearBy: {
screen: SearchNearBy,
},
Car: {
screen: Car,
},
}, {
initialRouteName: 'Logic',
headerMode:'none',
transitionConfig: getSlideFromRightTransition
})
const RootStack = createDrawerNavigator({
Stack: { screen: Navigator },
},
{
drawerPosition: I18nManager.isRTL ? 'right' : 'left',
contentComponent: DrawerContainer,
drawerType:'back',
navigationOptions: {
drawerLockMode: 'locked-closed'
}
}
);
const AppContainer = createAppContainer(RootStack);
export default class App extends Component {
constructor(properties) {
super(properties);
this.state ={
currentScreen:''
}
//disable Yellow Box
console.disableYellowBox = true;
}
async componentDidMount(){
// this.navigator.dispatch({
// type: NavigationActions.NAVIGATE,
// routeName: 'SplashScreen',
// });
await AsyncStorage.getItem('Intro').then((Intro) => {
if (!Intro) {
this.navigator.dispatch({
type: NavigationActions.NAVIGATE,
routeName: 'Intro',
});
}
})
}
getActiveRouteName(navigationState) {
if (!navigationState) {
return null;
}
const route = navigationState.routes[navigationState.index];
// dive into nested navigators
if (route.routes) {
return this.getActiveRouteName(route);
}
return route.routeName;
}
render() {
return (
<AppContainer
ref={nav => (this.navigator = nav)}
onNavigationStateChange={(prevState, currentState) => {
const currentScreen = this.getActiveRouteName(currentState);
const prevScreen = this.getActiveRouteName(prevState);
this.state.currentScreen = currentScreen;
{/*if (prevScreen !== currentScreen) {
// the line below uses the Google Analytics tracker
// change the tracker here to use other Mobile analytics SDK.
tracker.trackScreenView(currentScreen);
}*/}
}}
/>
);
}
}