2018-05-18 16:41:47 +00:00
|
|
|
import React from 'react';
|
2020-06-05 13:28:58 +00:00
|
|
|
import { StyleSheet } from 'react-native';
|
2018-05-18 16:41:47 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-04-08 12:35:28 +00:00
|
|
|
import { CustomIcon } from '../lib/Icons';
|
2020-05-08 17:36:10 +00:00
|
|
|
import { STATUS_COLORS, themes } from '../constants/colors';
|
2021-03-31 17:47:17 +00:00
|
|
|
import Status from './Status/Status';
|
|
|
|
import { withTheme } from '../theme';
|
2018-05-18 16:41:47 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2020-06-05 13:28:58 +00:00
|
|
|
icon: {
|
|
|
|
marginRight: 4
|
2018-05-18 16:41:47 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
const RoomTypeIcon = React.memo(({
|
2020-05-08 17:36:10 +00:00
|
|
|
type, size, isGroupChat, status, style, theme
|
2019-12-04 16:39:53 +00:00
|
|
|
}) => {
|
2018-05-24 20:17:45 +00:00
|
|
|
if (!type) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-31 17:47:17 +00:00
|
|
|
const color = themes[theme].titleText;
|
|
|
|
const iconStyle = [
|
|
|
|
styles.icon,
|
|
|
|
{ color },
|
|
|
|
style
|
|
|
|
];
|
|
|
|
|
|
|
|
if (type === 'd' && !isGroupChat) {
|
|
|
|
return <Status style={[iconStyle, { color: STATUS_COLORS[status] ?? STATUS_COLORS.offline }]} size={size} status={status} />;
|
|
|
|
}
|
2019-12-04 16:39:53 +00:00
|
|
|
|
2020-07-27 19:53:33 +00:00
|
|
|
let icon = 'channel-private';
|
2019-04-08 12:35:28 +00:00
|
|
|
if (type === 'discussion') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'discussions';
|
2020-06-05 13:28:58 +00:00
|
|
|
} else if (type === 'c') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'channel-public';
|
2020-06-05 13:28:58 +00:00
|
|
|
} else if (type === 'd') {
|
2020-04-01 12:28:54 +00:00
|
|
|
if (isGroupChat) {
|
2021-03-31 17:47:17 +00:00
|
|
|
icon = 'message';
|
2020-06-05 13:28:58 +00:00
|
|
|
} else {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'mention';
|
2020-04-01 12:28:54 +00:00
|
|
|
}
|
2020-06-05 13:28:58 +00:00
|
|
|
} else if (type === 'l') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'omnichannel';
|
2018-08-31 16:46:33 +00:00
|
|
|
}
|
2020-06-05 13:28:58 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<CustomIcon
|
|
|
|
name={icon}
|
|
|
|
size={size}
|
2021-03-31 17:47:17 +00:00
|
|
|
style={iconStyle}
|
2020-06-05 13:28:58 +00:00
|
|
|
/>
|
|
|
|
);
|
2019-03-01 16:49:11 +00:00
|
|
|
});
|
2018-05-18 16:41:47 +00:00
|
|
|
|
|
|
|
RoomTypeIcon.propTypes = {
|
2019-12-04 16:39:53 +00:00
|
|
|
theme: PropTypes.string,
|
2018-05-24 20:17:45 +00:00
|
|
|
type: PropTypes.string,
|
2020-04-01 12:28:54 +00:00
|
|
|
isGroupChat: PropTypes.bool,
|
2020-05-08 17:36:10 +00:00
|
|
|
status: PropTypes.string,
|
2018-08-31 16:46:33 +00:00
|
|
|
size: PropTypes.number,
|
|
|
|
style: PropTypes.object
|
2018-05-18 16:41:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
RoomTypeIcon.defaultProps = {
|
2020-06-05 13:28:58 +00:00
|
|
|
size: 16
|
2018-05-18 16:41:47 +00:00
|
|
|
};
|
|
|
|
|
2021-03-31 17:47:17 +00:00
|
|
|
export default withTheme(RoomTypeIcon);
|