2019-03-27 20:06:57 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet } from 'react-native';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
import { STATUS_COLORS, themes } from '../../../constants/colors';
|
2019-03-27 20:06:57 +00:00
|
|
|
import { CustomIcon } from '../../../lib/Icons';
|
|
|
|
import Status from '../../../containers/Status/Status';
|
|
|
|
|
2020-06-05 13:28:58 +00:00
|
|
|
const ICON_SIZE = 15;
|
2019-03-27 20:06:57 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
type: {
|
|
|
|
width: ICON_SIZE,
|
|
|
|
height: ICON_SIZE,
|
2020-03-30 20:19:01 +00:00
|
|
|
marginRight: 4,
|
|
|
|
marginLeft: -4
|
2019-03-27 20:06:57 +00:00
|
|
|
},
|
|
|
|
status: {
|
2020-03-30 20:19:01 +00:00
|
|
|
marginRight: 8
|
2019-03-27 20:06:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-04-01 12:28:54 +00:00
|
|
|
const Icon = React.memo(({
|
2020-10-30 17:35:07 +00:00
|
|
|
roomUserId, type, status, theme, tmid
|
2020-04-01 12:28:54 +00:00
|
|
|
}) => {
|
2020-10-30 17:35:07 +00:00
|
|
|
if ((type === 'd' || tmid) && roomUserId) {
|
2019-03-27 20:06:57 +00:00
|
|
|
return <Status size={10} style={styles.status} status={status} />;
|
|
|
|
}
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
let colorStyle = {};
|
2020-05-08 17:36:10 +00:00
|
|
|
if (type === 'l') {
|
2019-12-04 16:39:53 +00:00
|
|
|
colorStyle = { color: STATUS_COLORS[status] };
|
|
|
|
} else {
|
2020-07-06 20:56:28 +00:00
|
|
|
colorStyle = { color: themes[theme].auxiliaryText };
|
2019-12-04 16:39:53 +00:00
|
|
|
}
|
|
|
|
|
2019-04-08 12:35:28 +00:00
|
|
|
let icon;
|
|
|
|
if (type === 'discussion') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'discussions';
|
2019-04-08 12:35:28 +00:00
|
|
|
} else if (type === 'c') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'channel-public';
|
2020-02-07 13:24:16 +00:00
|
|
|
} else if (type === 'l') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'omnichannel';
|
2020-04-01 12:28:54 +00:00
|
|
|
} else if (type === 'd') {
|
|
|
|
icon = 'team';
|
2019-04-08 12:35:28 +00:00
|
|
|
} else {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'channel-private';
|
2019-04-08 12:35:28 +00:00
|
|
|
}
|
2019-03-27 20:06:57 +00:00
|
|
|
return (
|
|
|
|
<CustomIcon
|
|
|
|
name={icon}
|
|
|
|
size={ICON_SIZE * 1}
|
|
|
|
style={[
|
|
|
|
styles.type,
|
|
|
|
{
|
|
|
|
width: ICON_SIZE * 1,
|
|
|
|
height: ICON_SIZE * 1
|
|
|
|
},
|
2019-12-04 16:39:53 +00:00
|
|
|
colorStyle
|
2019-03-27 20:06:57 +00:00
|
|
|
]}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
Icon.propTypes = {
|
2020-04-01 12:28:54 +00:00
|
|
|
roomUserId: PropTypes.string,
|
2019-03-27 20:06:57 +00:00
|
|
|
type: PropTypes.string,
|
2019-12-04 16:39:53 +00:00
|
|
|
status: PropTypes.string,
|
2020-10-30 17:35:07 +00:00
|
|
|
theme: PropTypes.string,
|
|
|
|
tmid: PropTypes.string
|
2019-03-27 20:06:57 +00:00
|
|
|
};
|
|
|
|
export default Icon;
|