diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index 3efef78..a88a62b 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index a5dabe5..3d6b1fd 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index a6691a7..71ee618 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index e173ace..5f42f08 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 26b8710..38c5232 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/screens/main/apis/twitter.js b/app/screens/main/apis/twitter.js index 364fa6d..4ff4635 100644 --- a/app/screens/main/apis/twitter.js +++ b/app/screens/main/apis/twitter.js @@ -14,7 +14,7 @@ const windowWidth = Dimensions.get('window').width; const windowHeight = Dimensions.get('window').height; type Props = {}; -export default class TwitterLocal extends Component { +export default class TwitterPost extends Component { render() { return ( @@ -23,7 +23,11 @@ export default class TwitterLocal extends Component { style={styles.icon} /> 'this is the content of the tweet body longer than ever....Donal TRump you genius marketer awesome man!!!!!!!!!!!!!!!!asdfasdfsdfsd' - @Arjun Patel + + + local + @Arjun Patel + ); } @@ -31,7 +35,6 @@ export default class TwitterLocal extends Component { const styles = { container: { - flex: 1, justifyContent: 'center', alignItems: 'center', flexDirection: 'column', @@ -51,17 +54,30 @@ const styles = { icon: { borderRadius: 60, fontSize: 20, - color: 'white' + color: 'gold' }, bodyTxt: { fontSize: 16, color: 'white', margin: 5 }, - screenNameTxt: { - fontSize: 12, - color: '#e5e7ea', - margin: 5, - alignSelf: 'flex-end' - } + infoCont: { + flex: 1, + alignSelf: 'stretch', + justifyContent: 'space-between', + alignItems: 'center', + flexDirection: 'row', + margin: 5 + }, + typeTxt: { + fontSize: 12, + color: 'gold', + backgroundColor: 'black', + borderRadius: 4, + padding: 5 + }, + screenNameTxt: { + fontSize: 12, + color: 'gold' + } } diff --git a/app/screens/main/chat.js b/app/screens/main/chat.js index 97f7d1c..b712549 100644 --- a/app/screens/main/chat.js +++ b/app/screens/main/chat.js @@ -21,7 +21,7 @@ require('react-native'); // Socket.io imports import './UserAgent'; -import TwitterLocal from './apis/twitter.js'; +import TwitterPost from './apis/twitter.js'; window.navigator.userAgent = "react-native"; const io = require('socket.io-client/dist/socket.io'); @@ -50,17 +50,50 @@ export default class Chat extends Component { console.log(props); } + storeUserId = async (id) => { + try { + await AsyncStorage.setItem('userId', id.toString()); + } catch (error) { + // Error saving data + console.log(error); + } + } + + retrieveUserId = async () => { + try { + const value = await AsyncStorage.getItem('userId'); + var id; + if (value !== null) { + // We have data!! + console.log("Have user id: " + value); + this.socket.emit('userId', {user_id: parseInt(value), newUser: false, position: this.props.position, avatar: this.props.avatar}); + id = parseInt(value); + } else { + this.socket.emit('userId', {user_id: value, newUser: true, position: this.props.position, avatar: this.props.avatar}); + this.socket.on('getNewUserId', (result) => { + console.log('New id: ' + result.user_id); + this.storeUserId(result.user_id); + id = result.user_id; + }); + } + + this.setState({ + userId: id + }); + } catch (error) { + // Error retrieving data + console.log(error); + } + } + componentDidMount() { + var stored_userId = this.retrieveUserId(); + this.socket = io('http://10.0.2.2:3000', {jsonp: false}); this.socket.on('connect', () => { this.socket.emit('initial', {position: this.props.position, avatar: this.props.avatar}); }); - this.socket.on("userId", (obj) => { - console.log("User Id assigned: " + obj.userId); - this.setState({userId: obj.userId}); - }); - this.socket.on('initMessages', (allMsg) => { console.log('Initial messages received: ' + allMsg); allMsg.map((msg) => { @@ -74,7 +107,7 @@ export default class Chat extends Component { } addMessage = (msg) => { - console.log('New message received: '); + console.log('New message received!'); var oldDOM = this.state.messagesDOM; var newMessage = this.createMessage(msg); @@ -97,7 +130,6 @@ export default class Chat extends Component { } sendMessage = () => { - console.log(this.state.userId); console.log('Message to send: ' + this.state.messageToSend); this.socket.emit('newMessage', { @@ -155,7 +187,7 @@ export default class Chat extends Component { {this.state.messagesDOM.length == 0 ? ( - Loading the conversation around you! + No conversation around you! Start it! ) : ( @@ -167,7 +199,7 @@ export default class Chat extends Component { }} scrollEnabled={true} contentContainerStyle={styles.chatFieldScroll}> - + {this.state.messagesDOM}