diff --git a/mobile/Screens/chatScreen.js b/mobile/Screens/chatScreen.js index 938e3464093d4013885e1c039bdfca67fee0ccc7..a46bc1b1ea496a9e21251c0192607c5ae706d555 100644 --- a/mobile/Screens/chatScreen.js +++ b/mobile/Screens/chatScreen.js @@ -10,16 +10,22 @@ class ChatScreen extends Component { this.state = { msg : "", msgList: [], - user: this.props.route.params.user }; } + + componentDidMount() { + //Now we have the informations about the user + //so we can display for example the name in + //themessages + //const {user} = this.props.route.params; + //alert(user.username); + this.socket = io("http://192.168.196.145:3000", { //192.168.178.92 ric ip transports: ['websocket'] //this line is fundamental }); this.socket.on('msg', msg =>{ - alert(msg); this.setState({msgList: [...this.state.msgList, msg]}) }) } diff --git a/mobile/Screens/homeScreen.js b/mobile/Screens/homeScreen.js index 8b137891791fe96927ad78e64b0aad7bded08bdc..abdeda896c130543452c0020105e4545bb39608c 100644 --- a/mobile/Screens/homeScreen.js +++ b/mobile/Screens/homeScreen.js @@ -1 +1,24 @@ +import React from 'react'; +import { StyleSheet, Text, View } from 'react-native'; +class HomeScreen extends React.Component { + render() { + return ( + <View style={styles.container}> + <Text>HOMEPAGE</Text> + </View> + ); + } +} + +// ... +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#fff', + alignItems: 'center', + justifyContent: 'center', + }, + }); + +export default HomeScreen; diff --git a/mobile/Screens/loginScreen.js b/mobile/Screens/loginScreen.js index 30417d441644de61198aa43fdd8e9a86d0bcb57f..2ede41e16a5b176b28c3b906f62715571d958c05 100644 --- a/mobile/Screens/loginScreen.js +++ b/mobile/Screens/loginScreen.js @@ -31,7 +31,10 @@ class LoginScreen extends Component { console.log(obj.body.result); if (obj.status == 200) { alert('Succesful login') - this.props.navigation.navigate('Chat', {user : obj.body.result}) + this.props.navigation.navigate('Chat', { + screen : 'Chat', + params: {user : obj.body.result}, + }) } else if (obj.status == 201){ alert('Succesful login')