import React from 'react'; import PropTypes from 'prop-types'; import { View, Text, StyleSheet } from 'react-native'; import moment from 'moment'; import Icon from 'react-native-vector-icons/FontAwesome'; import Avatar from '../Avatar'; const styles = StyleSheet.create({ username: { fontWeight: 'bold' }, usernameView: { flexDirection: 'row', alignItems: 'center', marginBottom: 2 }, alias: { fontSize: 10, color: '#888', paddingLeft: 5 }, time: { fontSize: 10, color: '#888', paddingLeft: 5 }, edited: { marginLeft: 5, flexDirection: 'row', alignItems: 'center' } }); export default class Message extends React.PureComponent { static propTypes = { item: PropTypes.object.isRequired, Message_TimeFormat: PropTypes.string.isRequired, onPress: PropTypes.func, baseUrl: PropTypes.string } renderEdited(item) { if (!item.editedBy) { return null; } return ( ); } render() { const { item } = this.props; const extraStyle = {}; if (item.temp) { extraStyle.opacity = 0.3; } const username = item.alias || item.u.username; const aliasUsername = item.alias ? (@{item.u.username}) : null; const time = moment(item.ts).format(this.props.Message_TimeFormat); return ( {username} {aliasUsername} {time} {this.renderEdited(item)} ); } }