-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoom.js
72 lines (67 loc) · 1.56 KB
/
Room.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react';
import { Col, Row, Grid } from 'react-native-easy-grid';
import { StyleSheet } from 'react-native';
import {
Container,
Header,
Title,
Content,
Card,
CardItem,
Body,
Item,
Input,
Text } from 'native-base';
import Client from './clientChat.js'
export default class Room extends React.Component {
constructor (props) {
super(props);
this.state = {
roomUserName: '',
numberOfUsers: 0
}
}
componentWillMount () {
this.getUserName();
}
getUserName () {
const { params } = this.props.navigation.state;
const title = params ? params.title : null;
fetch(`http://e99bfd18.ngrok.io/rooms/${title.toLowerCase()}/`, {
method: 'POST',
body: JSON.stringify({
'action': 'join'
})
}).then((response) => response.json())
.then((data) => this.setState({ roomUserName: data.username }));
}
render () {
const { params } = this.props.navigation.state;
const title = params ? params.title : null;
return (
<Container>
<Content>
<Card>
<CardItem>
<Body>
<Text>
You are posting in this room as {this.state.roomUserName}
</Text>
</Body>
</CardItem>
</Card>
<Client userName={this.state.roomUserName} category={title.toLowerCase()} />
</Content>
</Container>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
roomStyle: {
flex: 1,
justifyContent: 'space-between'
}
});