2021-10-06 20:30:10 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View } from 'react-native';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2022-04-20 21:37:54 +00:00
|
|
|
import Avatar from '../Avatar';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { DisplayMode } from '../../lib/constants';
|
2021-10-06 20:30:10 +00:00
|
|
|
import TypeIcon from './TypeIcon';
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
const IconOrAvatar = ({
|
|
|
|
avatar,
|
|
|
|
type,
|
|
|
|
rid,
|
|
|
|
showAvatar,
|
|
|
|
prid,
|
|
|
|
status,
|
|
|
|
isGroupChat,
|
|
|
|
teamMain,
|
|
|
|
showLastMessage,
|
|
|
|
theme,
|
2022-04-15 02:27:36 +00:00
|
|
|
displayMode,
|
|
|
|
sourceType
|
2021-10-06 20:30:10 +00:00
|
|
|
}) => {
|
|
|
|
if (showAvatar) {
|
|
|
|
return (
|
2022-01-11 14:47:23 +00:00
|
|
|
<Avatar text={avatar} size={displayMode === DisplayMode.Condensed ? 36 : 48} type={type} style={styles.avatar} rid={rid} />
|
2021-10-06 20:30:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-11 14:47:23 +00:00
|
|
|
if (displayMode === DisplayMode.Expanded && showLastMessage) {
|
2021-10-06 20:30:10 +00:00
|
|
|
return (
|
|
|
|
<View style={styles.typeIcon}>
|
|
|
|
<TypeIcon
|
|
|
|
type={type}
|
|
|
|
prid={prid}
|
|
|
|
status={status}
|
|
|
|
isGroupChat={isGroupChat}
|
|
|
|
theme={theme}
|
|
|
|
teamMain={teamMain}
|
|
|
|
size={24}
|
|
|
|
style={{ marginRight: 12 }}
|
2022-04-15 02:27:36 +00:00
|
|
|
sourceType={sourceType}
|
2021-10-06 20:30:10 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
IconOrAvatar.propTypes = {
|
|
|
|
avatar: PropTypes.string,
|
|
|
|
type: PropTypes.string,
|
|
|
|
theme: PropTypes.string,
|
|
|
|
rid: PropTypes.string,
|
|
|
|
showAvatar: PropTypes.bool,
|
|
|
|
displayMode: PropTypes.string,
|
|
|
|
prid: PropTypes.string,
|
|
|
|
status: PropTypes.string,
|
|
|
|
isGroupChat: PropTypes.bool,
|
|
|
|
teamMain: PropTypes.bool,
|
|
|
|
showLastMessage: PropTypes.bool
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IconOrAvatar;
|