You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			97 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			97 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			TypeScript
		
	
| import React from 'react';
 | |
| import classNames from 'classnames';
 | |
| 
 | |
| import { Avatar } from './Avatar';
 | |
| import { Emojify } from './conversation/Emojify';
 | |
| 
 | |
| import { LocalizerType } from '../types/Util';
 | |
| 
 | |
| interface Props {
 | |
|   phoneNumber: string;
 | |
|   isMe?: boolean;
 | |
|   name?: string;
 | |
|   color: string;
 | |
|   verified: boolean;
 | |
|   profileName?: string;
 | |
|   avatarPath?: string;
 | |
|   i18n: LocalizerType;
 | |
|   onClick?: () => void;
 | |
| }
 | |
| 
 | |
| export class ContactListItem extends React.Component<Props> {
 | |
|   public renderAvatar() {
 | |
|     const {
 | |
|       avatarPath,
 | |
|       i18n,
 | |
|       color,
 | |
|       name,
 | |
|       phoneNumber,
 | |
|       profileName,
 | |
|     } = this.props;
 | |
| 
 | |
|     return (
 | |
|       <Avatar
 | |
|         avatarPath={avatarPath}
 | |
|         color={color}
 | |
|         conversationType="direct"
 | |
|         i18n={i18n}
 | |
|         name={name}
 | |
|         phoneNumber={phoneNumber}
 | |
|         profileName={profileName}
 | |
|         size={48}
 | |
|       />
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   public render() {
 | |
|     const {
 | |
|       i18n,
 | |
|       name,
 | |
|       onClick,
 | |
|       isMe,
 | |
|       phoneNumber,
 | |
|       profileName,
 | |
|       verified,
 | |
|     } = this.props;
 | |
| 
 | |
|     const title = name ? name : phoneNumber;
 | |
|     const displayName = isMe ? i18n('me') : title;
 | |
| 
 | |
|     const profileElement =
 | |
|       !isMe && profileName && !name ? (
 | |
|         <span className="module-contact-list-item__text__profile-name">
 | |
|           ~<Emojify text={profileName} i18n={i18n} />
 | |
|         </span>
 | |
|       ) : null;
 | |
| 
 | |
|     const showNumber = isMe || name;
 | |
|     const showVerified = !isMe && verified;
 | |
| 
 | |
|     return (
 | |
|       <div
 | |
|         role="button"
 | |
|         onClick={onClick}
 | |
|         className={classNames(
 | |
|           'module-contact-list-item',
 | |
|           onClick ? 'module-contact-list-item--with-click-handler' : null
 | |
|         )}
 | |
|       >
 | |
|         {this.renderAvatar()}
 | |
|         <div className="module-contact-list-item__text">
 | |
|           <div className="module-contact-list-item__text__name">
 | |
|             <Emojify text={displayName} i18n={i18n} /> {profileElement}
 | |
|           </div>
 | |
|           <div className="module-contact-list-item__text__additional-data">
 | |
|             {showVerified ? (
 | |
|               <div className="module-contact-list-item__text__verified-icon" />
 | |
|             ) : null}
 | |
|             {showVerified ? ` ${i18n('verified')}` : null}
 | |
|             {showVerified && showNumber ? ' ∙ ' : null}
 | |
|             {showNumber ? phoneNumber : null}
 | |
|           </div>
 | |
|         </div>
 | |
|       </div>
 | |
|     );
 | |
|   }
 | |
| }
 |