-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
113 lines (108 loc) · 2.47 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
global.Buffer = require("buffer").Buffer
import React from "react"
import {AppRegistry} from "react-native"
import RootNavigation from "./navigation/RootNavigation"
import {Provider} from "react-redux"
import {createStore} from "redux"
import redux from "./redux"
import socket from "./socket"
const store = createStore(redux)
function moduleFound(module) {
switch (module.type) {
case "FOOD": {
store.dispatch({
type: "SET_MODULE",
payload: {
name: "Food Dispenser",
icon: {
type: "material-community",
name: "silverware-variant",
},
component: "FoodDispenser",
id: module.id,
type: module.type,
},
})
break
}
case "WATER": {
store.dispatch({
type: "SET_MODULE",
payload: {
name: "Water Dispenser",
icon: {
type: "simple-line-icon",
name: "drop",
},
component: "WaterDispenser",
id: module.id,
type: module.type,
},
})
break
}
case "LITTER": {
store.dispatch({
type: "SET_MODULE",
payload: {
name: "Litter",
icon: {
type: "simple-line-icon",
name: "drop",
},
component: "Litter",
id: module.id,
type: module.type,
},
})
break
}
case "LASER": {
store.dispatch({
type: "SET_MODULE",
payload: {
name: "Laser Control",
icon: {
type: "material-community",
name: "silverware-variant",
},
component: "LaserController",
id: module.id,
type: module.type,
},
})
break
}
}
}
socket.on("connect", () => {
socket.emit("type", "MOBILE")
})
socket.on("module", moduleFound)
socket.on("dispatch", data => {
const module = store.getState()[data.id]
switch (data.action) {
case "measure":
store.dispatch({
type: "SET_MODULE",
payload: {...module, weight: data.payload},
})
break
case "histogram":
store.dispatch({
type: "SET_MODULE",
payload: {...module, histogram: data.payload},
})
}
})
socket.on("leave", id => {
store.dispatch({
type: "DELETE_MODULE",
payload: id,
})
})
const Root = () =>
<Provider store={store}>
<RootNavigation />
</Provider>
AppRegistry.registerComponent("Domopets", () => Root)