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';
|
2018-05-18 16:41:47 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2020-06-05 13:28:58 +00:00
|
|
|
icon: {
|
|
|
|
marginTop: 3,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
const color = themes[theme].auxiliaryText;
|
|
|
|
|
2020-06-05 13:28:58 +00:00
|
|
|
let icon = 'lock';
|
2019-04-08 12:35:28 +00:00
|
|
|
if (type === 'discussion') {
|
2020-06-05 13:28:58 +00:00
|
|
|
icon = 'chat';
|
|
|
|
} else if (type === 'c') {
|
|
|
|
icon = 'hash';
|
|
|
|
} else if (type === 'd') {
|
2020-04-01 12:28:54 +00:00
|
|
|
if (isGroupChat) {
|
2020-06-05 13:28:58 +00:00
|
|
|
icon = 'team';
|
|
|
|
} else {
|
|
|
|
icon = 'at';
|
2020-04-01 12:28:54 +00:00
|
|
|
}
|
2020-06-05 13:28:58 +00:00
|
|
|
} else if (type === 'l') {
|
|
|
|
icon = 'livechat';
|
2018-08-31 16:46:33 +00:00
|
|
|
}
|
2020-06-05 13:28:58 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<CustomIcon
|
|
|
|
name={icon}
|
|
|
|
size={size}
|
|
|
|
style={[
|
2020-06-26 20:22:56 +00:00
|
|
|
type === 'l' && status ? { color: STATUS_COLORS[status] } : { color },
|
2020-06-05 13:28:58 +00:00
|
|
|
styles.icon,
|
|
|
|
style
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
);
|
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
|
|
|
};
|
|
|
|
|
|
|
|
export default RoomTypeIcon;
|