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.4KB

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