import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
import PropTypes from 'prop-types';
import moment from 'moment';
import I18n from '../../i18n';
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
marginVertical: 10
},
line: {
borderTopColor: '#eaeaea',
borderTopWidth: StyleSheet.hairlineWidth,
flex: 1
},
text: {
color: '#444444',
fontSize: 11,
paddingHorizontal: 10,
transform: [{ scaleY: -1 }]
},
unreadLine: {
borderTopColor: 'red'
},
unreadText: {
color: 'red'
}
});
const DateSeparator = ({ ts, unread }) => {
const date = ts ? moment(ts).format('MMMM DD, YYYY') : null;
if (ts && unread) {
return (
{date}
{I18n.t('unread_messages')}
);
}
if (ts) {
return (
{date}
);
}
return (
{I18n.t('unread_messages')}
);
};
DateSeparator.propTypes = {
ts: PropTypes.instanceOf(Date),
unread: PropTypes.bool
};
export default DateSeparator;