-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
executable file
·106 lines (94 loc) · 2.71 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
import React, { Component } from 'react';
import { StackNavigator } from 'react-navigation';
import { Accelerometer } from 'react-native-sensors';
import {
Console as BoardConsole,
MotionController,
SettingsController,
Transport,
} from './src/packages/fm-board';
import Main from './src/containers/Main';
import Drive from './src/containers/Drive';
import About from './src/containers/About';
import Settings from './src/containers/Settings';
import Console from './src/containers/Console';
import ConnectionToast from './src/containers/TransportState';
const ACCELEROMETER_UPDATE_INTERVAL = 10; // ms
// const WS_URL = 'ws://echo.websocket.org';
const WS_URL = 'ws://10.10.100.254:81';
export default class App extends Component {
constructor(props) {
super(props);
const accelerometer = new Accelerometer({
updateInterval: ACCELEROMETER_UPDATE_INTERVAL,
});
const transport = new Transport(WS_URL);
const motionController = new MotionController(accelerometer, transport);
const settingsController = new SettingsController(transport);
const boardConsole = new BoardConsole(transport);
transport.message$.retry().subscribe((x) => {
console.log('0x', x);
}, (y) => {
console.log('0x', y);
});
this.connectionToast = <ConnectionToast key="connectionToast" transport={transport} />;
this.nav = StackNavigator({
Main: {
screen: screenProps => (<Main
{...screenProps}
connectionToast={this.connectionToast}
transport={transport}
/>),
navigationOptions: () => ({
header: null,
}),
},
Drive: {
screen: screenProps => (<Drive
{...screenProps}
motionController={motionController}
/>),
navigationOptions: () => ({
title: 'Drive',
}),
},
About: {
screen: About,
navigationOptions: () => ({
title: 'About',
}),
},
Settings: {
screen: screenProps => (<Settings
{...screenProps}
settingsController={settingsController}
connectionToast={this.connectionToast}
transport={transport}
/>),
navigationOptions: () => ({
title: 'Settings',
}),
},
Console: {
screen: screenProps => (<Console
{...screenProps}
console={boardConsole}
/>),
navigationOptions: () => ({
title: 'Console',
}),
},
});
}
render() {
// return [
// React.createElement(this.nav, {
// key: 'nav',
// }),
// this.connectionToast,
// ];
return React.createElement(this.nav, {
key: 'nav',
});
}
}