// @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 { MEDIA_STATE, type MediaState, AudioStateIcons, VideoStateIcons } from '../../constants'; import { RaisedHandIndicator } from './RaisedHandIndicator'; import styles from './styles'; type Props = { /** * Media state for audio */ audioMediaState: MediaState, /** * React children */ children?: Node, /** * Is the participant waiting? */ isKnockingParticipant: boolean, /** * The name of the participant. Used for showing lobby names. */ name?: string, /** * Callback to be invoked on pressing the participant item. */ onPress?: Function, /** * Participant reference */ participant: Object, /** * Media state for video */ videoMediaState: MediaState } /** * Participant item. * * @returns {React$Element} */ function ParticipantItem({ children, isKnockingParticipant, name, onPress, participant: p, audioMediaState = MEDIA_STATE.NONE, videoMediaState = MEDIA_STATE.NONE }: Props) { const displayName = name || useSelector(getParticipantDisplayNameWithId(p.id)); const { t } = useTranslation(); return ( { displayName } { p.local ? ({t('chat.you')}) : null } { !isKnockingParticipant && <> { p.raisedHand && } {VideoStateIcons[videoMediaState]} {AudioStateIcons[audioMediaState]} } { !p.local && children } ); } export default ParticipantItem;