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

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