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.latitude = parseFloat(position.coords.latitude);
this.longitude = parseFloat(position.coords.longitude); this.longitude = parseFloat(position.coords.longitude);
console.log(this.latitude.toString() + ' ' + this.longitude.toString()); console.log(this.latitude.toString() + ' ' + this.longitude.toString());
/**
* todo fix AsyncStorage
*/
this.storeValues(); this.storeValues();
Actions.main(); Actions.main({long: this.longitude.toString(), lat: this.latitude.toString()});
}, },
(error) => console.log(error), (error) => console.log(error),
// high accuracy might need slight adjusting with its values // high accuracy might need slight adjusting with its values
+18 -2
View File
@@ -14,6 +14,7 @@ import {
import { Fonts } from '../utils/Fonts.js'; import { Fonts } from '../utils/Fonts.js';
// imported components for different sections in main component // imported components for different sections in main component
imoprt Dash from './main/dashboard.js';
import Navbar from './main/navbar.js'; import Navbar from './main/navbar.js';
import Chat from './main/chat.js'; import Chat from './main/chat.js';
import AdSpace from './main/adspace.js'; import AdSpace from './main/adspace.js';
@@ -23,16 +24,26 @@ const windowHeight = Dimensions.get('window').height;
type Props = {}; type Props = {};
export default class Main extends Component<Props> { export default class Main extends Component<Props> {
constructor(props) {
super(props);
this.position = {
long: this.props.long,
lat: this.props.lat
};
}
render() { render() {
console.log('in Main'); console.log('in Main');
return ( return (
<View style={styles.container}> <View style={styles.container}>
<View style={styles.dashboard}>
<Dash />
</View>
<View style={styles.navbar}> <View style={styles.navbar}>
<Navbar /> <Navbar />
</View> </View>
<View style={styles.chat}> <View style={styles.chat}>
<Chat /> <Chat position={this.position} />
</View> </View>
<View style={styles.adspace}> <View style={styles.adspace}>
<AdSpace /> <AdSpace />
@@ -49,6 +60,11 @@ const styles = {
justifyContent: 'space-between', justifyContent: 'space-between',
position: 'relative' position: 'relative'
}, },
dashboard: {
height: windowHeight,
width: windowWidth - 60,
backgroundColor: '#595a5b'
},
navbar: { navbar: {
flex: 2 flex: 2
}, },
+7 -6
View File
@@ -34,8 +34,11 @@ export default class Chat extends Component<Props> {
messagesDOM: [], messagesDOM: [],
prevMessageUser: -1 prevMessageUser: -1
}; };
/**
* todo fix AsyncStorage
*/
this.getValues(); // from AsyncStorage this.getValues(); // from AsyncStorage
this.position = this.props.position;
} }
getValues = async () => { getValues = async () => {
@@ -57,9 +60,7 @@ export default class Chat extends Component<Props> {
componentDidMount() { componentDidMount() {
this.socket = io('10.0.2.2:3000', {jsonp: false}); this.socket = io('10.0.2.2:3000', {jsonp: false});
this.socket.on('connect', () => { this.socket.on('connect', () => {
var position = {long: this.long, lat: this.lat}; this.socket.emit('initial', this.position);
console.log(position);
this.socket.emit('initial', position);
}); });
this.socket.on('initMessages', (allMsg) => { this.socket.on('initMessages', (allMsg) => {
@@ -97,8 +98,8 @@ export default class Chat extends Component<Props> {
this.socket.emit('newMessage', { this.socket.emit('newMessage', {
userId: this.userId, userId: this.userId,
text: this.state.messageToSend, text: this.state.messageToSend,
lng: this.long, lng: this.position.long,
lat: this.lat lat: this.position.lat
}); });
this.setState({ this.setState({
messageToSend: '' 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 = {
}