Rocket.Chat.ReactNative/app/views/RoomView/Header/Icon.js

75 lines
1.5 KiB
JavaScript
Raw Normal View History

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';
2019-12-04 16:39:53 +00:00
import { isAndroid } from '../../../utils/deviceInfo';
2019-03-27 20:06:57 +00:00
const ICON_SIZE = 18;
const styles = StyleSheet.create({
type: {
width: ICON_SIZE,
height: ICON_SIZE,
marginRight: 4,
marginLeft: -4
2019-03-27 20:06:57 +00:00
},
status: {
marginRight: 8
2019-03-27 20:06:57 +00:00
}
});
const Icon = React.memo(({
roomUserId, type, status, theme
}) => {
if (type === 'd' && 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 = {};
if (type === 'd' && roomUserId) {
2019-12-04 16:39:53 +00:00
colorStyle = { color: STATUS_COLORS[status] };
} else {
colorStyle = { color: isAndroid && theme === 'light' ? themes[theme].buttonText : themes[theme].auxiliaryText };
}
2019-04-08 12:35:28 +00:00
let icon;
if (type === 'discussion') {
icon = 'chat';
2019-04-17 17:01:03 +00:00
} else if (type === 'thread') {
icon = 'thread';
2019-04-08 12:35:28 +00:00
} else if (type === 'c') {
icon = 'hashtag';
2020-02-07 13:24:16 +00:00
} else if (type === 'l') {
icon = 'livechat';
} else if (type === 'd') {
icon = 'team';
2019-04-08 12:35:28 +00:00
} else {
icon = 'lock';
}
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 = {
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,
theme: PropTypes.string
2019-03-27 20:06:57 +00:00
};
export default Icon;