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 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // @flow
  2. import React from 'react';
  3. import type { Node } from 'react';
  4. import { useTranslation } from 'react-i18next';
  5. import { TouchableOpacity, View } from 'react-native';
  6. import { Text } from 'react-native-paper';
  7. import { Avatar } from '../../../base/avatar';
  8. import { MEDIA_STATE, type MediaState, AudioStateIcons, VideoStateIcons } from '../../constants';
  9. import { RaisedHandIndicator } from './RaisedHandIndicator';
  10. import styles from './styles';
  11. type Props = {
  12. /**
  13. * Media state for audio
  14. */
  15. audioMediaState: MediaState,
  16. /**
  17. * React children
  18. */
  19. children?: Node,
  20. /**
  21. * Whether or not to disable the moderator indicator.
  22. */
  23. disableModeratorIndicator?: boolean,
  24. /**
  25. * The name of the participant. Used for showing lobby names.
  26. */
  27. displayName: string,
  28. /**
  29. * Is the participant waiting?
  30. */
  31. isKnockingParticipant: boolean,
  32. /**
  33. * Whether or not the user is a moderator.
  34. */
  35. isModerator?: boolean,
  36. /**
  37. * True if the participant is local.
  38. */
  39. local: boolean,
  40. /**
  41. * Callback to be invoked on pressing the participant item.
  42. */
  43. onPress?: Function,
  44. /**
  45. * The ID of the participant.
  46. */
  47. participantID: string,
  48. /**
  49. * True if the participant have raised hand.
  50. */
  51. raisedHand: boolean,
  52. /**
  53. * Media state for video
  54. */
  55. videoMediaState: MediaState
  56. }
  57. /**
  58. * Participant item.
  59. *
  60. * @returns {React$Element<any>}
  61. */
  62. function ParticipantItem({
  63. children,
  64. displayName,
  65. disableModeratorIndicator,
  66. isKnockingParticipant,
  67. isModerator,
  68. local,
  69. onPress,
  70. participantID,
  71. raisedHand,
  72. audioMediaState = MEDIA_STATE.NONE,
  73. videoMediaState = MEDIA_STATE.NONE
  74. }: Props) {
  75. const { t } = useTranslation();
  76. return (
  77. <View style = { styles.participantContainer } >
  78. <TouchableOpacity
  79. onPress = { onPress }
  80. style = { styles.participantContent }>
  81. <Avatar
  82. className = 'participant-avatar'
  83. participantId = { participantID }
  84. size = { 32 } />
  85. <View style = { styles.participantDetailsContainer }>
  86. <View style = { styles.participantNameContainer }>
  87. <Text style = { styles.participantName }>
  88. { displayName }
  89. </Text>
  90. { local ? <Text style = { styles.isLocal }>({t('chat.you')})</Text> : null }
  91. </View>
  92. {isModerator && !disableModeratorIndicator
  93. && <Text style = { styles.moderatorLabel }>{t('videothumbnail.moderator')}</Text>
  94. }
  95. </View>
  96. {
  97. !isKnockingParticipant
  98. && <>
  99. {
  100. raisedHand && <RaisedHandIndicator />
  101. }
  102. <View style = { styles.participantStatesContainer }>
  103. <View style = { styles.participantStateVideo }>{VideoStateIcons[videoMediaState]}</View>
  104. <View>{AudioStateIcons[audioMediaState]}</View>
  105. </View>
  106. </>
  107. }
  108. </TouchableOpacity>
  109. { !local && children }
  110. </View>
  111. );
  112. }
  113. export default ParticipantItem;