You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ParticipantItem.js 2.5KB

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