2019-05-20 20:43:50 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View, Text } from 'react-native';
|
|
|
|
import Touchable from 'react-native-platform-touchable';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { formatLastMessage, formatMessageCount, BUTTON_HIT_SLOP } from './utils';
|
|
|
|
import styles from './styles';
|
|
|
|
import I18n from '../../i18n';
|
|
|
|
import { CustomIcon } from '../../lib/Icons';
|
|
|
|
import { DISCUSSION } from './constants';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../../constants/colors';
|
2019-05-20 20:43:50 +00:00
|
|
|
|
|
|
|
const Discussion = React.memo(({
|
2019-12-04 16:39:53 +00:00
|
|
|
msg, dcount, dlm, onDiscussionPress, theme
|
2019-05-20 20:43:50 +00:00
|
|
|
}) => {
|
|
|
|
const time = formatLastMessage(dlm);
|
|
|
|
const buttonText = formatMessageCount(dcount, DISCUSSION);
|
|
|
|
return (
|
2019-09-24 20:26:56 +00:00
|
|
|
<>
|
2019-12-04 16:39:53 +00:00
|
|
|
<Text style={[styles.startedDiscussion, { color: themes[theme].auxiliaryText }]}>{I18n.t('Started_discussion')}</Text>
|
2019-12-17 14:08:06 +00:00
|
|
|
<Text style={[styles.text, { color: themes[theme].bodyText }]}>{msg}</Text>
|
2019-05-20 20:43:50 +00:00
|
|
|
<View style={styles.buttonContainer}>
|
|
|
|
<Touchable
|
|
|
|
onPress={onDiscussionPress}
|
2019-12-04 16:39:53 +00:00
|
|
|
background={Touchable.Ripple(themes[theme].bannerBackground)}
|
|
|
|
style={[styles.button, styles.smallButton, { backgroundColor: themes[theme].tintColor }]}
|
2019-05-20 20:43:50 +00:00
|
|
|
hitSlop={BUTTON_HIT_SLOP}
|
|
|
|
>
|
2019-09-24 20:26:56 +00:00
|
|
|
<>
|
2019-12-04 16:39:53 +00:00
|
|
|
<CustomIcon name='chat' size={20} style={styles.buttonIcon} color={themes[theme].buttonText} />
|
2019-12-17 14:08:06 +00:00
|
|
|
<Text style={[styles.buttonText, { color: themes[theme].buttonText }]}>{buttonText}</Text>
|
2019-09-24 20:26:56 +00:00
|
|
|
</>
|
2019-05-20 20:43:50 +00:00
|
|
|
</Touchable>
|
2019-12-04 16:39:53 +00:00
|
|
|
<Text style={[styles.time, { color: themes[theme].auxiliaryText }]}>{time}</Text>
|
2019-05-20 20:43:50 +00:00
|
|
|
</View>
|
2019-09-24 20:26:56 +00:00
|
|
|
</>
|
2019-05-20 20:43:50 +00:00
|
|
|
);
|
|
|
|
}, (prevProps, nextProps) => {
|
|
|
|
if (prevProps.msg !== nextProps.msg) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (prevProps.dcount !== nextProps.dcount) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (prevProps.dlm !== nextProps.dlm) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-12-04 16:39:53 +00:00
|
|
|
if (prevProps.theme !== nextProps.theme) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-05-20 20:43:50 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
Discussion.propTypes = {
|
|
|
|
msg: PropTypes.string,
|
|
|
|
dcount: PropTypes.number,
|
|
|
|
dlm: PropTypes.string,
|
2019-12-04 16:39:53 +00:00
|
|
|
theme: PropTypes.string,
|
2019-05-20 20:43:50 +00:00
|
|
|
onDiscussionPress: PropTypes.func
|
|
|
|
};
|
|
|
|
Discussion.displayName = 'MessageDiscussion';
|
|
|
|
|
|
|
|
export default Discussion;
|