2021-05-19 10:08:30 +00:00
|
|
|
import React from 'react';
|
2021-05-20 16:06:52 +00:00
|
|
|
import type { Node } from 'react';
|
2021-05-19 10:08:30 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2021-06-03 16:23:18 +00:00
|
|
|
import { TouchableOpacity, View } from 'react-native';
|
2021-05-26 07:15:37 +00:00
|
|
|
import { Text } from 'react-native-paper';
|
2021-05-19 10:08:30 +00:00
|
|
|
|
|
|
|
import { Avatar } from '../../../base/avatar';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { AudioStateIcons, MEDIA_STATE, type MediaState, VideoStateIcons } from '../../constants';
|
2021-05-19 10:08:30 +00:00
|
|
|
|
|
|
|
import { RaisedHandIndicator } from './RaisedHandIndicator';
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Media state for audio.
|
2021-05-19 10:08:30 +00:00
|
|
|
*/
|
2021-09-14 15:31:30 +00:00
|
|
|
audioMediaState?: MediaState,
|
2021-05-19 10:08:30 +00:00
|
|
|
|
2021-05-20 16:06:52 +00:00
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* React children.
|
2021-05-20 16:06:52 +00:00
|
|
|
*/
|
2021-05-26 07:15:37 +00:00
|
|
|
children?: Node,
|
2021-05-20 16:06:52 +00:00
|
|
|
|
2021-09-28 08:46:20 +00:00
|
|
|
/**
|
|
|
|
* Whether or not to disable the moderator indicator.
|
|
|
|
*/
|
|
|
|
disableModeratorIndicator?: boolean,
|
|
|
|
|
2021-07-12 15:14:38 +00:00
|
|
|
/**
|
|
|
|
* The name of the participant. Used for showing lobby names.
|
|
|
|
*/
|
|
|
|
displayName: string,
|
|
|
|
|
2021-06-09 12:41:00 +00:00
|
|
|
/**
|
|
|
|
* Is the participant waiting?
|
|
|
|
*/
|
|
|
|
isKnockingParticipant: boolean,
|
|
|
|
|
2021-09-22 14:05:42 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the user is a moderator.
|
|
|
|
*/
|
|
|
|
isModerator?: boolean,
|
|
|
|
|
2021-06-02 15:27:50 +00:00
|
|
|
/**
|
2021-07-12 15:14:38 +00:00
|
|
|
* True if the participant is local.
|
2021-06-02 15:27:50 +00:00
|
|
|
*/
|
2021-09-14 15:31:30 +00:00
|
|
|
local?: boolean,
|
2021-06-02 15:27:50 +00:00
|
|
|
|
2021-06-03 16:23:18 +00:00
|
|
|
/**
|
|
|
|
* Callback to be invoked on pressing the participant item.
|
|
|
|
*/
|
|
|
|
onPress?: Function,
|
|
|
|
|
2021-05-19 10:08:30 +00:00
|
|
|
/**
|
2021-07-12 15:14:38 +00:00
|
|
|
* The ID of the participant.
|
|
|
|
*/
|
|
|
|
participantID: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the participant have raised hand.
|
2021-05-19 10:08:30 +00:00
|
|
|
*/
|
2021-09-14 15:31:30 +00:00
|
|
|
raisedHand?: boolean,
|
2021-05-19 10:08:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Media state for video.
|
2021-05-19 10:08:30 +00:00
|
|
|
*/
|
2021-09-14 15:31:30 +00:00
|
|
|
videoMediaState?: MediaState
|
2021-05-19 10:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Participant item.
|
|
|
|
*
|
|
|
|
* @returns {React$Element<any>}
|
|
|
|
*/
|
|
|
|
function ParticipantItem({
|
2021-06-02 15:27:50 +00:00
|
|
|
children,
|
2021-07-12 15:14:38 +00:00
|
|
|
displayName,
|
2021-09-28 08:46:20 +00:00
|
|
|
disableModeratorIndicator,
|
2021-06-09 12:41:00 +00:00
|
|
|
isKnockingParticipant,
|
2021-09-22 14:05:42 +00:00
|
|
|
isModerator,
|
2021-07-12 15:14:38 +00:00
|
|
|
local,
|
2021-06-03 16:23:18 +00:00
|
|
|
onPress,
|
2021-07-12 15:14:38 +00:00
|
|
|
participantID,
|
|
|
|
raisedHand,
|
2021-06-29 14:05:11 +00:00
|
|
|
audioMediaState = MEDIA_STATE.NONE,
|
|
|
|
videoMediaState = MEDIA_STATE.NONE
|
2021-05-19 10:08:30 +00:00
|
|
|
}: Props) {
|
2021-06-03 16:23:18 +00:00
|
|
|
|
2021-05-19 10:08:30 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style = { styles.participantContainer } >
|
2021-06-03 16:23:18 +00:00
|
|
|
<TouchableOpacity
|
|
|
|
onPress = { onPress }
|
|
|
|
style = { styles.participantContent }>
|
|
|
|
<Avatar
|
|
|
|
className = 'participant-avatar'
|
2021-09-14 15:31:30 +00:00
|
|
|
displayName = { displayName }
|
2021-07-12 15:14:38 +00:00
|
|
|
participantId = { participantID }
|
2021-06-03 16:23:18 +00:00
|
|
|
size = { 32 } />
|
2021-11-24 07:46:01 +00:00
|
|
|
<View
|
|
|
|
style = { [
|
|
|
|
styles.participantDetailsContainer,
|
|
|
|
raisedHand && styles.participantDetailsContainerRaisedHand
|
|
|
|
] }>
|
2021-09-22 14:05:42 +00:00
|
|
|
<View style = { styles.participantNameContainer }>
|
2021-11-24 07:46:01 +00:00
|
|
|
<Text
|
|
|
|
numberOfLines = { 1 }
|
|
|
|
style = { styles.participantName }>
|
2021-09-22 14:05:42 +00:00
|
|
|
{ displayName }
|
2021-11-24 07:46:01 +00:00
|
|
|
{local && ` (${t('chat.you')})` }
|
2021-09-22 14:05:42 +00:00
|
|
|
</Text>
|
|
|
|
</View>
|
2021-09-28 08:46:20 +00:00
|
|
|
{isModerator && !disableModeratorIndicator
|
|
|
|
&& <Text style = { styles.moderatorLabel }>{t('videothumbnail.moderator')}</Text>
|
|
|
|
}
|
2021-05-19 10:08:30 +00:00
|
|
|
</View>
|
2021-06-09 12:41:00 +00:00
|
|
|
{
|
2021-06-09 15:35:58 +00:00
|
|
|
!isKnockingParticipant
|
|
|
|
&& <>
|
2022-11-22 16:13:36 +00:00
|
|
|
{ raisedHand && <RaisedHandIndicator /> }
|
2021-06-09 12:41:00 +00:00
|
|
|
<View style = { styles.participantStatesContainer }>
|
2021-06-24 13:26:55 +00:00
|
|
|
<View style = { styles.participantStateVideo }>{VideoStateIcons[videoMediaState]}</View>
|
|
|
|
<View>{AudioStateIcons[audioMediaState]}</View>
|
2021-06-09 12:41:00 +00:00
|
|
|
</View>
|
|
|
|
</>
|
|
|
|
}
|
2021-06-03 16:23:18 +00:00
|
|
|
</TouchableOpacity>
|
2021-07-12 15:14:38 +00:00
|
|
|
{ !local && children }
|
2021-05-19 10:08:30 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ParticipantItem;
|