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

ParticipantItem.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. // /**
  18. // * Participant actions component mapping depending on trigger type.
  19. // */
  20. // const Actions = {
  21. // [ActionTrigger.Hover]: ParticipantActionsHover,
  22. // [ActionTrigger.Permanent]: ParticipantActionsPermanent
  23. // };
  24. type Props = {
  25. /**
  26. * Media state for audio
  27. */
  28. audioMuteState: MediaState,
  29. /**
  30. * React children
  31. */
  32. children?: Node,
  33. /**
  34. * Callback for when the mouse leaves this component
  35. */
  36. onLeave?: Function,
  37. /**
  38. * Participant reference
  39. */
  40. participant: Object,
  41. /**
  42. * Media state for video
  43. */
  44. videoMuteState: MediaState
  45. }
  46. /**
  47. * Participant item.
  48. *
  49. * @returns {React$Element<any>}
  50. */
  51. function ParticipantItem({
  52. children,
  53. audioMuteState = MediaState.None,
  54. videoMuteState = MediaState.None,
  55. participant: p
  56. }: Props) {
  57. const { t } = useTranslation();
  58. const name = useSelector(getParticipantDisplayNameWithId(p.id));
  59. return (
  60. <View style = { styles.participantContainer } >
  61. <Avatar
  62. className = 'participant-avatar'
  63. participantId = { p.id }
  64. size = { 32 } />
  65. <View style = { styles.participantContent }>
  66. <View style = { styles.participantNameContainer }>
  67. <Text style = { styles.participantName }>
  68. { name }
  69. </Text>
  70. { p.local ? <Text style = { styles.isLocal }>({t('chat.you')})</Text> : null }
  71. </View>
  72. <View style = { styles.participantStatesContainer } >
  73. {p.raisedHand && <RaisedHandIndicator />}
  74. <View style = { styles.participantStateVideo }>{VideoStateIcons[videoMuteState]}</View>
  75. <View style = { styles.participantStateAudio }>{AudioStateIcons[audioMuteState]}</View>
  76. </View>
  77. </View>
  78. { children }
  79. </View>
  80. );
  81. }
  82. export default ParticipantItem;