// @flow import React from 'react'; import type { Node } from 'react'; import { useTranslation } from 'react-i18next'; import { TouchableOpacity, View } from 'react-native'; import { Text } from 'react-native-paper'; import { useSelector } from 'react-redux'; import { Avatar } from '../../../base/avatar'; import { getParticipantDisplayNameWithId } from '../../../base/participants'; import { AudioStateIcons, MediaState, VideoStateIcons } from '../../constants'; import { RaisedHandIndicator } from './RaisedHandIndicator'; import styles from './styles'; type Props = { /** * Media state for audio */ audioMuteState: MediaState, /** * React children */ children?: Node, /** * The name of the participant. Used for showing lobby names. */ name?: string, /** * Callback for when the mouse leaves this component */ onLeave?: Function, /** * Callback to be invoked on pressing the participant item. */ onPress?: Function, /** * Participant reference */ participant: Object, /** * Media state for video */ videoMuteState: MediaState } /** * Participant item. * * @returns {React$Element} */ function ParticipantItem({ audioMuteState = MediaState.None, children, name, onPress, participant: p, videoMuteState = MediaState.None }: Props) { const displayName = name || useSelector(getParticipantDisplayNameWithId(p.id)); const { t } = useTranslation(); return ( { displayName } { p.local ? ({t('chat.you')}) : null } {p.raisedHand && } {VideoStateIcons[videoMuteState]} {AudioStateIcons[audioMuteState]} { children } ); } export default ParticipantItem;