-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.android.js
71 lines (60 loc) · 2.45 KB
/
index.android.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
import React, { Component } from 'react';
import {
AppRegistry,
DeviceEventEmitter,
} from 'react-native';
import{
Router,
Scene,
}from 'react-native-router-flux';
import{ Provider, connect }from 'react-redux';
import{ createStore, applyMiddleware }from 'redux';
import thunk from 'redux-thunk';
import config from './src/redux/config';
import { setConnectionStatus } from './src/redux/actions';
// Scenes
import Landing from './src/scenes/begin-landing';
import ConnectorOne from './src/scenes/connector-01';
import ConnectorTwo from './src/scenes/connector-02';
import ConnectorThree from './src/scenes/connector-03';
import Timer from './src/scenes/timer';
import DataLanding from './src/scenes/data-landing';
import CORVOTest from './src/scenes/corvo-test';
import DataSummary from './src/scenes/data-summary';
// reducer is a function
import reducer from './src/redux/reducer';
// Connect Router to Redux
const RouterWithRedux = connect()(Router);
// Create store
const store = createStore(reducer, applyMiddleware(thunk));
export default class Neurodoro extends Component {
componentDidMount() {
// This creates a persistent listener that will update connectionStatus when connection events are broadcast in Java
DeviceEventEmitter.addListener('DISCONNECTED', (event) => {
store.dispatch(setConnectionStatus(config.connectionStatus.DISCONNECTED));
});
DeviceEventEmitter.addListener('CONNECTED', (event) => {
store.dispatch(setConnectionStatus(config.connectionStatus.CONNECTED));
});
}
render() {
return (
<Provider store={store}>
<RouterWithRedux>
<Scene key="root" >
<Scene component={Landing} key='Landing' initial={true} hideNavBar={true}/>
<Scene component={ConnectorOne} key='ConnectorOne' hideNavBar={true}/>
<Scene component={ConnectorTwo} key='ConnectorTwo' hideNavBar={true}/>
<Scene component={ConnectorThree} key='ConnectorThree' hideNavBar={true}/>
<Scene component={Timer} key='Timer' hideNavBar={true}/>
<Scene component={DataLanding} key='DataLanding' hideNavBar={true}/>
<Scene component={CORVOTest} key='CORVOTest' hideNavBar={true}/>
<Scene component={DataSummary} key='DataSummary' hideNavBar={true}/>
</Scene>
</RouterWithRedux>
</Provider>
);
}
}
// Defines which component is the root for the whole project
AppRegistry.registerComponent('Neurodoro', () => Neurodoro);