-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ios.js
93 lines (85 loc) · 2.63 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
81
82
83
84
85
86
87
88
89
90
91
92
93
import React, { Component } from 'react';
import {
ActivityIndicator,
AppRegistry,
RefreshControl,
SafeAreaView,
ScrollView,
Text,
TouchableWithoutFeedback,
View,
} from 'react-native';
import Storage from './src/data/storage';
import Menu from './src/components/menu';
import SideMenu from 'react-native-side-menu';
import ContentView from './src/components/content-view';
import dismissKeyboard from 'dismissKeyboard';
import UserActions from './src/actions/user';
import Styles from './src/styles/styles.ios';
import Api from './src/api/api';
class AllAboard extends Component {
constructor() {
super();
this.openMenu = this.openMenu.bind(this);
UserActions.handleRouteSelection = UserActions.handleRouteSelection.bind(this);
UserActions.updateDirection = UserActions.updateDirection.bind(this);
UserActions.getPredictions = UserActions.getPredictions.bind(this);
this.state = {
isMenuOpen: true,
isLoading: false,
}
}
render() {
const Dimensions = require('Dimensions');
const deviceWidth = Dimensions.get('window').width;
const deviceHeight = Dimensions.get('window').height;
return (
<TouchableWithoutFeedback onPress={dismissKeyboard}>
<SafeAreaView style={Styles.safeArea}>
<SideMenu
animation='spring'
touchToClose={true}
openMenuOffset={deviceWidth * 0.86}
isOpen={this.state.isMenuOpen}
menu={
<Menu
activeRoute={this.state.selectedRoute}
onSelect={UserActions.handleRouteSelection}
recentlyViewedRoutes={this.state.recentRoutes}
/>
}
>
<ContentView
onLeftButtonPress={this.openMenu}
onChooseDirection={UserActions.updateDirection}
activeRoute={this.state.selectedRoute}
directions={this.state.directions}
selectedDirection={this.state.selectedDirection}
selectedStop={this.state.selectedStop}
predictions={this.state.predictions}
error={this.state.error}
/>
</SideMenu>
</SafeAreaView>
</TouchableWithoutFeedback>
);
}
componentDidMount() {
UserActions.listenForRefreshPredictions(((predictions) => {
this.setState({
predictions: predictions.prediction.prd
});
}).bind(this));
Storage.getRecentlyViewedRoutes().then((recentlyViewedRoutes) => {
this.setState({
recentRoutes: recentlyViewedRoutes,
});
});
}
openMenu() {
this.setState({
isMenuOpen: true
});
}
}
AppRegistry.registerComponent('AllAboard', () => AllAboard);