vn-verdnaturachat/app/views/RoomView/Header/Icon.js

70 lines
1.4 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,
2019-12-04 16:39:53 +00:00
marginRight: 8
2019-03-27 20:06:57 +00:00
},
status: {
2019-04-08 12:35:28 +00:00
marginLeft: 4,
marginRight: 12
2019-03-27 20:06:57 +00:00
}
});
2019-12-04 16:39:53 +00:00
const Icon = React.memo(({ type, status, theme }) => {
2019-03-27 20:06:57 +00:00
if (type === 'd') {
return <Status size={10} style={styles.status} status={status} />;
}
2019-12-04 16:39:53 +00:00
let colorStyle = {};
if (type === 'd') {
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';
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 = {
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;