Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ParticipantItem.js 3.2KB

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