will fix asyncstorage later

midterm solution - passing lat and long as props
This commit is contained in:
Arjun Patel
2018-06-29 21:32:50 -07:00
parent 43ece13696
commit 6189437670
4 changed files with 65 additions and 9 deletions
+4 -1
View File
@@ -26,8 +26,11 @@ export default class Loading extends Component<Props> {
this.latitude = parseFloat(position.coords.latitude);
this.longitude = parseFloat(position.coords.longitude);
console.log(this.latitude.toString() + ' ' + this.longitude.toString());
/**
* todo fix AsyncStorage
*/
this.storeValues();
Actions.main();
Actions.main({long: this.longitude.toString(), lat: this.latitude.toString()});
},
(error) => console.log(error),
// high accuracy might need slight adjusting with its values
+18 -2
View File
@@ -14,6 +14,7 @@ import {
import { Fonts } from '../utils/Fonts.js';
// imported components for different sections in main component
imoprt Dash from './main/dashboard.js';
import Navbar from './main/navbar.js';
import Chat from './main/chat.js';
import AdSpace from './main/adspace.js';
@@ -23,16 +24,26 @@ const windowHeight = Dimensions.get('window').height;
type Props = {};
export default class Main extends Component<Props> {
constructor(props) {
super(props);
this.position = {
long: this.props.long,
lat: this.props.lat
};
}
render() {
console.log('in Main');
return (
<View style={styles.container}>
<View style={styles.dashboard}>
<Dash />
</View>
<View style={styles.navbar}>
<Navbar />
</View>
<View style={styles.chat}>
<Chat />
<Chat position={this.position} />
</View>
<View style={styles.adspace}>
<AdSpace />
@@ -49,6 +60,11 @@ const styles = {
justifyContent: 'space-between',
position: 'relative'
},
dashboard: {
height: windowHeight,
width: windowWidth - 60,
backgroundColor: '#595a5b'
},
navbar: {
flex: 2
},
+7 -6
View File
@@ -34,8 +34,11 @@ export default class Chat extends Component<Props> {
messagesDOM: [],
prevMessageUser: -1
};
/**
* todo fix AsyncStorage
*/
this.getValues(); // from AsyncStorage
this.position = this.props.position;
}
getValues = async () => {
@@ -57,9 +60,7 @@ export default class Chat extends Component<Props> {
componentDidMount() {
this.socket = io('10.0.2.2:3000', {jsonp: false});
this.socket.on('connect', () => {
var position = {long: this.long, lat: this.lat};
console.log(position);
this.socket.emit('initial', position);
this.socket.emit('initial', this.position);
});
this.socket.on('initMessages', (allMsg) => {
@@ -97,8 +98,8 @@ export default class Chat extends Component<Props> {
this.socket.emit('newMessage', {
userId: this.userId,
text: this.state.messageToSend,
lng: this.long,
lat: this.lat
lng: this.position.long,
lat: this.position.lat
});
this.setState({
messageToSend: ''
+36
View File
@@ -0,0 +1,36 @@
/*
* Dashboard/Menu
*/
import React, { Component } from 'react';
import {
Dimensions,
View,
Text
} from 'react-native';
import {
Actions
} from 'react-native-router-flux';
import { Fonts } from '../utils/Fonts.js';
const windowWidth = Dimensions.get('window').width;
const windowHeight = Dimensions.get('window').height;
type Props = {};
export default class Dashboard extends Component<Props> {
constructor(props) {
super(props);
}
render() {
console.log('in dashboard');
return (
<View>
<Text>hasdf</Text>
</View>
);
}
}
const styles = {
}