2021-10-06 20:30:10 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View } from 'react-native';
|
|
|
|
|
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';
|
2022-06-27 18:23:43 +00:00
|
|
|
import { IIconOrAvatar } from './interfaces';
|
2021-10-06 20:30:10 +00:00
|
|
|
|
|
|
|
const IconOrAvatar = ({
|
|
|
|
avatar,
|
|
|
|
type,
|
|
|
|
rid,
|
|
|
|
showAvatar,
|
|
|
|
prid,
|
|
|
|
status,
|
|
|
|
isGroupChat,
|
|
|
|
teamMain,
|
|
|
|
showLastMessage,
|
2022-04-15 02:27:36 +00:00
|
|
|
displayMode,
|
2022-12-12 17:47:12 +00:00
|
|
|
sourceType,
|
|
|
|
isUserProfile
|
2022-06-27 18:23:43 +00:00
|
|
|
}: IIconOrAvatar): React.ReactElement | null => {
|
2021-10-06 20:30:10 +00:00
|
|
|
if (showAvatar) {
|
|
|
|
return (
|
2022-12-12 17:47:12 +00:00
|
|
|
<Avatar
|
|
|
|
isUserProfile={isUserProfile}
|
|
|
|
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}
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IconOrAvatar;
|