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

ParticipantItem.js 2.3KB

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