2018-06-01 17:56:59 +00:00
|
|
|
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: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
2018-09-11 16:32:52 +00:00
|
|
|
marginBottom: 25,
|
|
|
|
marginTop: 15,
|
2019-03-01 16:49:11 +00:00
|
|
|
marginHorizontal: 15,
|
2018-09-11 16:32:52 +00:00
|
|
|
transform: [{ scaleY: -1 }]
|
2018-06-01 17:56:59 +00:00
|
|
|
},
|
|
|
|
line: {
|
2018-09-11 16:32:52 +00:00
|
|
|
backgroundColor: '#9ea2a8',
|
|
|
|
height: 1,
|
2018-06-01 17:56:59 +00:00
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
text: {
|
2018-09-11 16:32:52 +00:00
|
|
|
color: '#9ea2a8',
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: '600'
|
2018-06-01 17:56:59 +00:00
|
|
|
},
|
|
|
|
unreadLine: {
|
2018-09-11 16:32:52 +00:00
|
|
|
backgroundColor: '#f5455c'
|
2018-06-01 17:56:59 +00:00
|
|
|
},
|
|
|
|
unreadText: {
|
2018-09-11 16:32:52 +00:00
|
|
|
color: '#f5455c'
|
|
|
|
},
|
|
|
|
marginLeft: {
|
2019-03-01 16:49:11 +00:00
|
|
|
marginLeft: 15
|
2018-09-11 16:32:52 +00:00
|
|
|
},
|
|
|
|
marginRight: {
|
2019-03-01 16:49:11 +00:00
|
|
|
marginRight: 15
|
2018-09-11 16:32:52 +00:00
|
|
|
},
|
|
|
|
marginHorizontal: {
|
2019-03-01 16:49:11 +00:00
|
|
|
marginHorizontal: 15
|
2018-06-01 17:56:59 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const DateSeparator = ({ ts, unread }) => {
|
2018-09-11 16:32:52 +00:00
|
|
|
const date = ts ? moment(ts).format('MMM DD, YYYY') : null;
|
2018-06-01 17:56:59 +00:00
|
|
|
if (ts && unread) {
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
2019-03-01 16:49:11 +00:00
|
|
|
<Text style={[styles.text, styles.unreadText]}>{I18n.t('unread_messages')}</Text>
|
2018-09-11 16:32:52 +00:00
|
|
|
<View style={[styles.line, styles.unreadLine, styles.marginHorizontal]} />
|
2019-03-01 16:49:11 +00:00
|
|
|
<Text style={[styles.text, styles.unreadText]}>{date}</Text>
|
2018-06-01 17:56:59 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (ts) {
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
2019-03-01 16:49:11 +00:00
|
|
|
<View style={styles.line} />
|
|
|
|
<Text style={[styles.text, styles.marginLeft]}>{date}</Text>
|
2018-06-01 17:56:59 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
2019-03-01 16:49:11 +00:00
|
|
|
<Text style={[styles.text, styles.unreadText, styles.marginRight]}>{I18n.t('unread_messages')}</Text>
|
|
|
|
<View style={[styles.line, styles.unreadLine]} />
|
2018-06-01 17:56:59 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
DateSeparator.propTypes = {
|
|
|
|
ts: PropTypes.instanceOf(Date),
|
|
|
|
unread: PropTypes.bool
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DateSeparator;
|