import React from 'react'; import PropTypes from 'prop-types'; import { View, Text, StyleSheet } from 'react-native'; import { withTheme } from '../../theme'; import Avatar from '../../containers/Avatar'; import Touch from '../../utils/touch'; import sharedStyles from '../Styles'; import { themes } from '../../constants/colors'; import Markdown from '../../containers/markdown'; import { CustomIcon } from '../../lib/Icons'; import { formatDateThreads, makeThreadName } from '../../utils/room'; const styles = StyleSheet.create({ container: { flexDirection: 'row', padding: 16 }, contentContainer: { flexDirection: 'column', flex: 1 }, titleContainer: { flexDirection: 'row', marginBottom: 2, alignItems: 'center' }, title: { flexShrink: 1, fontSize: 18, ...sharedStyles.textMedium }, time: { fontSize: 14, marginLeft: 4, ...sharedStyles.textRegular }, avatar: { marginRight: 8 }, detailsContainer: { marginTop: 8, flexDirection: 'row' }, detailContainer: { marginRight: 8, flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }, detailText: { fontSize: 10, marginLeft: 2, ...sharedStyles.textSemibold }, badgeContainer: { marginLeft: 8, justifyContent: 'center' }, badge: { width: 12, height: 12, borderRadius: 6 } }); const Item = ({ item, baseUrl, theme, useRealName, user, badgeColor, onPress }) => { const username = (useRealName && item?.u?.name) || item?.u?.username; let time; if (item?.ts) { time = formatDateThreads(item.ts); } let tlm; if (item?.tlm) { tlm = formatDateThreads(item.tlm); } return ( onPress(item)} testID={`thread-messages-view-${ item.msg }`} style={{ backgroundColor: themes[theme].backgroundColor }}> {username} {time} {item?.tcount} {item?.replies?.length} {tlm} {badgeColor ? ( ) : null} ); }; Item.propTypes = { item: PropTypes.object, baseUrl: PropTypes.string, theme: PropTypes.string, useRealName: PropTypes.bool, user: PropTypes.object, badgeColor: PropTypes.string, onPress: PropTypes.func }; export default withTheme(Item);