-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.js
102 lines (80 loc) · 2.35 KB
/
dashboard.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
import React, {
StyleSheet,
Text,
View,
AsyncStorage,
AlertIOS
} from 'react-native';
import Firebase from 'firebase';
import Button from './button.js';
import moment from 'moment';
const auth = new Firebase("https://burning-torch-1074.firebaseIO.com/users");
export default React.createClass({
watchID: (null: ?number),
getInitialState: function() {
return {
lastPosition: 'unknown',
user: 'unknown'
};
},
componentDidMount: function() {
AsyncStorage.getItem('user').then((user) => {
var user = JSON.parse(user);
this.setState({"user": user.uid});
}).done();
this.watchID = navigator.geolocation.getCurrentPosition((position) => {
var lastPosition = JSON.stringify(position);
this.setState({lastPosition});
auth.child(this.state.user).update({
geo: lastPosition
});
//AlertIOS.alert('tomato', this.state);
});
},
componentWillUnmount: function() {
navigator.geolocation.clearWatch(this.watchID);
},
render() {
return (
<View style={styles.container}>
<Text>Welcome</Text>
<Text>
<Text style={styles.title}>UID: </Text>
{this.state.user}
{this.state.lastPosition}
</Text>
<Button text={'TOFU'} onPress={this.onTofu} />
<Button text={'Settings'} onPress={this.onSettingsPress} />
</View>
);
},
getBackgroundImage(position) {
fetch('http://www.panoramio.com/map/get_panoramas.php?callback=JSON_CALLBACK&set=public&from=0&to=10' +
'&minx=' + (position.longitude - 1) +
'&miny=' + (position.latitude - 1) +
'&maxx=' + (position.longitude + 1) +
'&maxy=' + (position.latitude + 1) +
'&size=original&mapfilter=true', {method: "GET"})
.then((response) => response.json())
.then((responseData) => {
AlertIOS.alert("GET RESPONSE",
"Search Query -> " + responseData.count)
}).done();
},
onTofu() {
auth.child(this.state.user).update({
tofu: moment().format()
});
},
onSettingsPress() {
this.props.navigator.push({name: 'settings'})
}
});
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white'
}
});