import React from 'react'; import { View, StyleSheet, Text } from 'react-native'; import PropTypes from 'prop-types'; import moment from 'moment'; import I18n from '../../i18n'; import sharedStyles from '../Styles'; import { COLOR_DANGER, COLOR_TEXT_DESCRIPTION } from '../../constants/colors'; const styles = StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center', marginTop: 16, marginBottom: 4, marginHorizontal: 14 }, line: { backgroundColor: COLOR_TEXT_DESCRIPTION, height: 1, flex: 1 }, text: { fontSize: 14, ...sharedStyles.textMedium, ...sharedStyles.textColorDescription }, unreadLine: { backgroundColor: COLOR_DANGER }, unreadText: { color: COLOR_DANGER }, marginLeft: { marginLeft: 14 }, marginRight: { marginRight: 14 }, marginHorizontal: { marginHorizontal: 14 } }); const DateSeparator = React.memo(({ ts, unread }) => { const date = ts ? moment(ts).format('MMM DD, YYYY') : null; if (ts && unread) { return ( {I18n.t('unread_messages')} {date} ); } if (ts) { return ( {date} ); } return ( {I18n.t('unread_messages')} ); }); DateSeparator.propTypes = { ts: PropTypes.instanceOf(Date), unread: PropTypes.bool }; export default DateSeparator;