forked from Aishwarya-Surana/carProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
80 lines (65 loc) · 1.69 KB
/
index.ios.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
import React, { Component } from 'react'
import * as firebase from 'firebase'
import {
AppRegistry,
View,
Navigator,
} from 'react-native'
// Load configs from .env file
import {
apiKey,
authDomain,
databaseURL,
storageBucket,
messagingSenderId,
mapBoxAccessToken,
} from 'react-native-dotenv'
import Login from './components/login'
import SetPickupPosition from './components/pickup'
import SetDestination from './components/destination'
import styles from './styles'
export default class CarProject extends Component {
state = {
layout: null,
}
constructor(props) {
super(props)
firebase.initializeApp({apiKey, authDomain, databaseURL, storageBucket,
messagingSenderId})
this.onLayout = this._onLayout.bind(this)
this.renderScene = this._renderScene.bind(this)
}
_onLayout(e) {
this.setState({layout: e.nativeEvent.layout})
}
_renderScene(route, navigator) {
let props = {
layout: this.state.layout,
route,
navigator,
}
Object.assign(props, route.passProps || {})
switch (route.id) {
case 'Login':
return <Login {...props} />
case 'SetPickupPosition':
return <SetPickupPosition {...props} />
case 'SetDestination':
return <SetDestination {...props} />
}
}
render() {
return (
<View onLayout={this.onLayout} style={{flex: 1}}>
{this.state.layout ?
<Navigator
initialRoute={{title: 'Login', id: 'Login'}}
renderScene={this.renderScene}
style={styles.navigator}
/>
: null}
</View>
)
}
}
AppRegistry.registerComponent('CarProject', () => CarProject)