import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import moment from 'moment';
import I18n from '../../i18n';
import sharedStyles from '../Styles';
import { themes } from '../../constants/colors';
import { useTheme } from '../../theme';
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'center',
marginTop: 16,
marginBottom: 4,
marginHorizontal: 14
},
line: {
height: 1,
flex: 1
},
text: {
fontSize: 14,
...sharedStyles.textMedium
},
marginLeft: {
marginLeft: 14
},
marginRight: {
marginRight: 14
},
marginHorizontal: {
marginHorizontal: 14
}
});
const DateSeparator = ({ ts, unread }: { ts: Date | string | null; unread: boolean }): React.ReactElement => {
const { theme } = useTheme();
const date = ts ? moment(ts).format('LL') : null;
const unreadLine = { backgroundColor: themes[theme].dangerColor };
const unreadText = { color: themes[theme].dangerColor };
if (ts && unread) {
return (
{I18n.t('unread_messages')}
{date}
);
}
if (ts) {
return (
{date}
);
}
return (
{I18n.t('unread_messages')}
);
};
export default DateSeparator;