Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ParticipantItem.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 { AudioStateIcons, MEDIA_STATE, type MediaState, 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. displayName = { displayName }
  84. participantId = { participantID }
  85. size = { 32 } />
  86. <View
  87. style = { [
  88. styles.participantDetailsContainer,
  89. raisedHand && styles.participantDetailsContainerRaisedHand
  90. ] }>
  91. <View style = { styles.participantNameContainer }>
  92. <Text
  93. numberOfLines = { 1 }
  94. style = { styles.participantName }>
  95. { displayName }
  96. {local && ` (${t('chat.you')})` }
  97. </Text>
  98. </View>
  99. {isModerator && !disableModeratorIndicator
  100. && <Text style = { styles.moderatorLabel }>{t('videothumbnail.moderator')}</Text>
  101. }
  102. </View>
  103. {
  104. !isKnockingParticipant
  105. && <>
  106. {raisedHand && <RaisedHandIndicator />}
  107. <View style = { styles.participantStatesContainer }>
  108. <View style = { styles.participantStateVideo }>{VideoStateIcons[videoMediaState]}</View>
  109. <View>{AudioStateIcons[audioMediaState]}</View>
  110. </View>
  111. </>
  112. }
  113. </TouchableOpacity>
  114. { !local && children }
  115. </View>
  116. );
  117. }
  118. export default ParticipantItem;