-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathMessageBubble.tsx
More file actions
63 lines (59 loc) · 1.44 KB
/
MessageBubble.tsx
File metadata and controls
63 lines (59 loc) · 1.44 KB
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
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import type { Message } from './utils';
type Props = {
item: Message;
};
export const MessageBubble: React.FC<Props> = ({ item, index }) => {
if (item.isMyMessage) {
return (
<View style={styles.container} key={`item-${item.id}`}>
<View
style={[styles.messageBubble, styles.myMessageBubble]}
>
<Text style={styles.myMessageText}>{item.text}</Text>
<Text style={[styles.myMessageText, {
marginTop: 10,
fontWeight: 'bold'
}]}>ID: {item.id} Index: {index}</Text>
</View>
</View>
);
}
return (
<View style={styles.container} key={`item-${item.id}`}>
<View style={styles.messageBubble}>
<Text style={styles.messageText}>{item.text}</Text>
<Text style={[styles.messageText, {
marginTop: 10,
fontWeight: 'bold'
}]}>ID: {item.id} Index: {index}</Text>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
width: '100%'
},
messageBubble: {
maxWidth: 300,
padding: 10,
borderRadius: 10,
marginVertical: 5,
marginHorizontal: 5,
backgroundColor: '#F1F0F0',
height: 100
},
myMessageBubble: {
alignSelf: 'flex-end',
backgroundColor: '#3784FF',
},
messageText: {
fontSize: 15,
},
myMessageText: {
color: 'white',
fontSize: 15,
},
});