-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.vr.js
48 lines (38 loc) · 1.36 KB
/
index.vr.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
import React from 'react';
import { AppRegistry, NativeModules } from 'react-vr';
import { Place } from './components';
import places from './places';
const Location = NativeModules.Location;
export default class GrodnoVR extends React.Component {
constructor() {
super();
this.placeKeys = Object.keys(places);
const [firstPlace] = this.placeKeys;
this.state = { currentPlace: firstPlace, locale: 'en' };
const parameters = Location.search.replace('?', '').split('&');
for (let i = 0; i < parameters.length; i++) {
const [name, value] = parameters[i].split('=');
if (name === 'place' && this.placeKeys.indexOf(value) > -1) {
console.log(value, this.placeKeys.indexOf(value));
this.state.currentPlace = value;
}
if (name === 'locale') {
this.state.locale = value;
}
}
}
render() {
const { currentPlace, locale } = this.state;
console.log(this.state, places[currentPlace]);
return (
<Place
locale={locale}
place={places[currentPlace]}
onChange={(placeId) => {
this.setState({ currentPlace: placeId })
}}
/>
);
}
};
AppRegistry.registerComponent('GrodnoVR', () => GrodnoVR);