changes to all
This commit is contained in:
+1
-1
@@ -142,7 +142,7 @@ const styles = {
|
|||||||
position: 'relative'
|
position: 'relative'
|
||||||
},
|
},
|
||||||
navbar: {
|
navbar: {
|
||||||
flex: 2
|
flex: 1
|
||||||
},
|
},
|
||||||
chat: {
|
chat: {
|
||||||
flex: 15
|
flex: 15
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ const styles = {
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
backgroundColor: '#0e8f9e',
|
backgroundColor: 'black',
|
||||||
margin: 30,
|
margin: 30,
|
||||||
padding: 10,
|
padding: 10,
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
@@ -87,7 +87,6 @@ const styles = {
|
|||||||
typeTxt: {
|
typeTxt: {
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: 'gold',
|
color: 'gold',
|
||||||
backgroundColor: 'black',
|
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
padding: 5
|
padding: 5
|
||||||
},
|
},
|
||||||
|
|||||||
+39
-16
@@ -24,6 +24,8 @@ import './UserAgent';
|
|||||||
import TwitterPost from './apis/twitter.js';
|
import TwitterPost from './apis/twitter.js';
|
||||||
import NewsPost from './apis/news.js';
|
import NewsPost from './apis/news.js';
|
||||||
|
|
||||||
|
import WelcomeMsg from './components/welcomemsg.js';
|
||||||
|
|
||||||
window.navigator.userAgent = "react-native";
|
window.navigator.userAgent = "react-native";
|
||||||
const io = require('socket.io-client/dist/socket.io');
|
const io = require('socket.io-client/dist/socket.io');
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ export default class Chat extends Component<Props> {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
var stored_userId = this.retrieveUserId();
|
var stored_userId = this.retrieveUserId();
|
||||||
|
|
||||||
this.socket = io('https://murmuring-sierra-86040.herokuapp.com/', {jsonp: false});
|
this.socket = io('http://10.0.2.2:3000', {jsonp: false});
|
||||||
this.socket.on('connect', () => {
|
this.socket.on('connect', () => {
|
||||||
this.socket.emit('initial', {position: this.props.position, avatar: this.props.avatar});
|
this.socket.emit('initial', {position: this.props.position, avatar: this.props.avatar});
|
||||||
});
|
});
|
||||||
@@ -102,23 +104,20 @@ export default class Chat extends Component<Props> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var oldDOM = this.state.messagesDOM;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.socket.on('initNews', (posts) => {
|
this.socket.on('initNews', (posts) => {
|
||||||
console.log(posts);
|
console.log(posts);
|
||||||
|
|
||||||
|
oldDOM.push(
|
||||||
|
<WelcomeMsg key={0} />
|
||||||
|
);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
news: posts,
|
news: posts,
|
||||||
postNum: 0
|
postNum: 0
|
||||||
}, () => {
|
|
||||||
var welcomeMessage = {
|
|
||||||
id: 0,
|
|
||||||
text: 'Welcome to Nexto! Break the ice by starting a conversation!',
|
|
||||||
user_id: this.state.userId,
|
|
||||||
created: new Date(),
|
|
||||||
long: 0,
|
|
||||||
lat: 0,
|
|
||||||
avatar: this.props.avatar
|
|
||||||
};
|
|
||||||
|
|
||||||
this.addMessage(welcomeMessage);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -131,7 +130,9 @@ export default class Chat extends Component<Props> {
|
|||||||
console.log('New message received!');
|
console.log('New message received!');
|
||||||
var oldDOM = this.state.messagesDOM;
|
var oldDOM = this.state.messagesDOM;
|
||||||
|
|
||||||
if (oldDOM.length % 5 == 0) {
|
var newNews = oldDOM.length % 5 == 0;
|
||||||
|
|
||||||
|
if (newNews) {
|
||||||
var actualPost = this.state.news[this.state.postNum];
|
var actualPost = this.state.news[this.state.postNum];
|
||||||
var newPost = (
|
var newPost = (
|
||||||
<NewsPost key={actualPost.uuid} title={actualPost.title} source={actualPost.thread.site} url={actualPost.url} />
|
<NewsPost key={actualPost.uuid} title={actualPost.title} source={actualPost.thread.site} url={actualPost.url} />
|
||||||
@@ -142,17 +143,29 @@ export default class Chat extends Component<Props> {
|
|||||||
|
|
||||||
var newMessage = this.createMessage(msg);
|
var newMessage = this.createMessage(msg);
|
||||||
|
|
||||||
if (this.state.prevMessageUser != msg.user_id && this.state.prevMessageUser) {
|
if (this.state.prevMessageUser != msg.user_id && this.state.prevMessageUser || newNews) {
|
||||||
var dotSeparator = (
|
var dotSeparator = (
|
||||||
<View key={msg.created} style={styles.separatorCont}>
|
<View key={msg.created} style={styles.separatorCont}>
|
||||||
<Text>. .</Text>
|
<Text>. .</Text>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
oldDOM.push(dotSeparator);
|
oldDOM.push(dotSeparator);
|
||||||
|
|
||||||
|
var dateParts = isoFormatDateString.split("-");
|
||||||
|
var jsDate = new Date(dateParts[0], dateParts[1] - 1, dateParts[2].substr(0,2));
|
||||||
|
|
||||||
|
var dateUpdate = (
|
||||||
|
<View key={msg.created} style={styles.dateUpdateCont}>
|
||||||
|
<Text style={styles.dateUpdateTxt}>{jsDate}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
oldDOM.push(dateUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
oldDOM.push(newMessage);
|
oldDOM.push(newMessage);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
messagesDOM: oldDOM,
|
messagesDOM: oldDOM,
|
||||||
prevMessageUser: msg.user_id,
|
prevMessageUser: msg.user_id,
|
||||||
@@ -191,6 +204,7 @@ export default class Chat extends Component<Props> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
var avatarAlready = this.state.prevMessageUser == msg.user_id;
|
var avatarAlready = this.state.prevMessageUser == msg.user_id;
|
||||||
|
|
||||||
var result = (
|
var result = (
|
||||||
<View key={msg.id}
|
<View key={msg.id}
|
||||||
style={[contStyle, styles.msgCont, avatarAlready ? styles.avatarAlready : null]}>
|
style={[contStyle, styles.msgCont, avatarAlready ? styles.avatarAlready : null]}>
|
||||||
@@ -225,7 +239,7 @@ export default class Chat extends Component<Props> {
|
|||||||
{this.state.messagesDOM.length == 0 ?
|
{this.state.messagesDOM.length == 0 ?
|
||||||
(<View style={styles.chatFieldEmpty}>
|
(<View style={styles.chatFieldEmpty}>
|
||||||
<Image style={styles.loadingGif} source={require(loadingGIF)} />
|
<Image style={styles.loadingGif} source={require(loadingGIF)} />
|
||||||
<Text>No conversation around you! Start it!</Text>
|
<Text>Looking for conversations going around you!!!</Text>
|
||||||
</View>)
|
</View>)
|
||||||
:
|
:
|
||||||
(
|
(
|
||||||
@@ -387,5 +401,14 @@ const styles = {
|
|||||||
sendIconColor: {
|
sendIconColor: {
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
color: '#0e8f9e'
|
color: '#0e8f9e'
|
||||||
|
},
|
||||||
|
dateUpdateCont: {
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
margin: 10
|
||||||
|
},
|
||||||
|
dateUpdateTxt: {
|
||||||
|
fontSize: 12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Twitter view component for the chat
|
||||||
|
*/
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import {
|
||||||
|
Dimensions,
|
||||||
|
View,
|
||||||
|
Text
|
||||||
|
} from 'react-native';
|
||||||
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||||
|
|
||||||
|
const windowWidth = Dimensions.get('window').width;
|
||||||
|
const windowHeight = Dimensions.get('window').height;
|
||||||
|
|
||||||
|
type Props = {};
|
||||||
|
export default class WelcomeMsg extends Component<Props> {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<View style={styles.welcomeMsg}>
|
||||||
|
<Text style={styles.welcomeTxt}>Welcome to Tixto! Break the ice by starting a conversation!</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
welcomeMsg: {
|
||||||
|
margin: 30,
|
||||||
|
padding: 20,
|
||||||
|
backgroundColor: 'black',
|
||||||
|
borderRadius: 8,
|
||||||
|
borderWidth: 3,
|
||||||
|
borderColor: 'gold'
|
||||||
|
},
|
||||||
|
welcomeTxt: {
|
||||||
|
textAlign: 'center',
|
||||||
|
fontSize: 15,
|
||||||
|
color: 'gold'
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,8 +39,6 @@ export default class Navbar extends Component<Props> {
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.headerTxt}>
|
<View style={styles.headerTxt}>
|
||||||
<Text style={styles.head}>Chat</Text>
|
|
||||||
|
|
||||||
<View style={styles.statusCont}>
|
<View style={styles.statusCont}>
|
||||||
<Icon style={styles.statusIcon} name='check-circle' />
|
<Icon style={styles.statusIcon} name='check-circle' />
|
||||||
<Text style={styles.statusTxt}>online</Text>
|
<Text style={styles.statusTxt}>online</Text>
|
||||||
|
|||||||
Reference in New Issue
Block a user