您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ParticipantItem.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import React from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { View } from 'react-native';
  5. import { Text } from 'react-native-paper';
  6. import { useSelector } from 'react-redux';
  7. import { Avatar } from '../../../base/avatar';
  8. import { getParticipantDisplayNameWithId } from '../../../base/participants';
  9. import {
  10. AudioStateIcons,
  11. MediaState,
  12. VideoStateIcons
  13. } from '../../constants';
  14. import { RaisedHandIndicator } from './RaisedHandIndicator';
  15. import styles from './styles';
  16. type Props = {
  17. /**
  18. * Media state for audio
  19. */
  20. audioMuteState: MediaState,
  21. /**
  22. * Callback for when the mouse leaves this component
  23. */
  24. onLeave?: Function,
  25. /**
  26. * Participant reference
  27. */
  28. participant: Object,
  29. /**
  30. * Media state for video
  31. */
  32. videoMuteState: MediaState
  33. }
  34. /**
  35. * Participant item.
  36. *
  37. * @returns {React$Element<any>}
  38. */
  39. function ParticipantItem({
  40. audioMuteState = MediaState.None,
  41. videoMuteState = MediaState.None,
  42. participant: p
  43. }: Props) {
  44. const { t } = useTranslation();
  45. const name = useSelector(getParticipantDisplayNameWithId(p.id));
  46. return (
  47. <View style = { styles.participantContainer } >
  48. <Avatar
  49. className = 'participant-avatar'
  50. participant = { p.id }
  51. size = { 32 } />
  52. <View style = { styles.participantContent }>
  53. <View style = { styles.participantNameContainer }>
  54. <Text style = { styles.participantName }>
  55. { name }
  56. </Text>
  57. { p.local ? <Text>({t('chat.you')})</Text> : null }
  58. </View>
  59. <View style = { styles.participantStates } >
  60. {p.raisedHand && <RaisedHandIndicator />}
  61. {VideoStateIcons[videoMuteState]}
  62. {AudioStateIcons[audioMuteState]}
  63. </View>
  64. </View>
  65. </View>
  66. );
  67. }
  68. export default ParticipantItem;