import React from 'react';
import PropTypes from 'prop-types';
import { View, Text, StyleSheet } from 'react-native';
import { emojify } from 'react-emojione';
import Markdown from 'react-native-easy-markdown';
import moment from 'moment';
import Avatar from './avatar';
import Card from './message/card';
const styles = StyleSheet.create({
content: {
flexGrow: 1
},
message: {
padding: 12,
paddingTop: 6,
paddingBottom: 6,
flexDirection: 'row',
transform: [{ scaleY: -1 }]
},
texts: {
flex: 1
},
msg: {
flex: 1
},
username: {
fontWeight: 'bold'
},
usernameView: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 2
},
alias: {
fontSize: 10,
color: '#888',
paddingLeft: 5
},
time: {
fontSize: 10,
color: '#888',
paddingLeft: 5
}
});
export default class Message extends React.PureComponent {
static propTypes = {
item: PropTypes.object.isRequired,
baseUrl: PropTypes.string.isRequired,
Message_TimeFormat: PropTypes.string.isRequired
}
attachments() {
return this.props.item.attachments.length ? : null;
}
render() {
const { item } = this.props;
const extraStyle = {};
if (item.temp) {
extraStyle.opacity = 0.3;
}
const msg = emojify(item.msg, { output: 'unicode' });
const username = item.alias || item.u.username;
const time = moment(item.ts).format(this.props.Message_TimeFormat);
return (
{username}
{item.alias && @{item.u.username}}{time}
{this.attachments()}
{msg}
);
}
}