Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

RoomParticipantMenu.tsx 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* eslint-disable lines-around-comment */
  2. import React, { PureComponent } from 'react';
  3. import { WithTranslation } from 'react-i18next';
  4. import { Text, View } from 'react-native';
  5. import { IReduxState } from '../../../app/types';
  6. // @ts-ignore
  7. import { Avatar } from '../../../base/avatar';
  8. // @ts-ignore
  9. import { BottomSheet, hideSheet } from '../../../base/dialog';
  10. // @ts-ignore
  11. import { bottomSheetStyles } from '../../../base/dialog/components/native/styles';
  12. import { translate } from '../../../base/i18n/functions';
  13. import { connect } from '../../../base/redux/functions';
  14. import { getBreakoutRooms } from '../../../breakout-rooms/functions';
  15. // @ts-ignore
  16. import SendToBreakoutRoom from '../../../video-menu/components/native/SendToBreakoutRoom';
  17. // @ts-ignore
  18. import styles from '../../../video-menu/components/native/styles';
  19. /**
  20. * Size of the rendered avatar in the menu.
  21. */
  22. const AVATAR_SIZE = 24;
  23. interface IProps extends WithTranslation {
  24. /**
  25. * The list of all breakout rooms.
  26. */
  27. _rooms: Array<any>;
  28. /**
  29. * The Redux dispatch function.
  30. */
  31. dispatch: Function;
  32. /**
  33. * The jid of the selected participant.
  34. */
  35. participantJid: string;
  36. /**
  37. * The display name of the selected participant.
  38. */
  39. participantName: string;
  40. /**
  41. * The room the participant is in.
  42. */
  43. room: any;
  44. }
  45. /**
  46. * Class to implement a popup menu that opens upon long pressing a thumbnail.
  47. */
  48. class RoomParticipantMenu extends PureComponent<IProps> {
  49. /**
  50. * Constructor of the component.
  51. *
  52. * @inheritdoc
  53. */
  54. constructor(props: IProps) {
  55. super(props);
  56. this._onCancel = this._onCancel.bind(this);
  57. this._renderMenuHeader = this._renderMenuHeader.bind(this);
  58. }
  59. /**
  60. * Implements {@code Component#render}.
  61. *
  62. * @inheritdoc
  63. */
  64. render() {
  65. const { _rooms, participantJid, room, t } = this.props;
  66. const buttonProps = {
  67. afterClick: this._onCancel,
  68. showLabel: true,
  69. participantID: participantJid,
  70. styles: bottomSheetStyles.buttons
  71. };
  72. return (
  73. <BottomSheet
  74. renderHeader = { this._renderMenuHeader }
  75. showSlidingView = { true }>
  76. <View style = { styles.contextMenuItem }>
  77. <Text style = { styles.contextMenuItemText }>
  78. {t('breakoutRooms.actions.sendToBreakoutRoom')}
  79. </Text>
  80. </View>
  81. {_rooms.map(r => room.id !== r.id && (<SendToBreakoutRoom
  82. key = { r.id }
  83. room = { r }
  84. { ...buttonProps } />))}
  85. </BottomSheet>
  86. );
  87. }
  88. /**
  89. * Callback to hide the {@code RemoteVideoMenu}.
  90. *
  91. * @private
  92. * @returns {boolean}
  93. */
  94. _onCancel() {
  95. this.props.dispatch(hideSheet());
  96. }
  97. /**
  98. * Function to render the menu's header.
  99. *
  100. * @returns {React$Element}
  101. */
  102. _renderMenuHeader() {
  103. const { participantName } = this.props;
  104. return (
  105. <View
  106. style = { [
  107. bottomSheetStyles.sheet,
  108. styles.participantNameContainer ] }>
  109. <Avatar
  110. displayName = { participantName }
  111. size = { AVATAR_SIZE } />
  112. <Text style = { styles.participantNameLabel }>
  113. { participantName }
  114. </Text>
  115. </View>
  116. );
  117. }
  118. }
  119. /**
  120. * Function that maps parts of Redux state tree into component props.
  121. *
  122. * @param {Object} state - Redux state.
  123. * @private
  124. * @returns {IProps}
  125. */
  126. function _mapStateToProps(state: IReduxState) {
  127. return {
  128. _rooms: Object.values(getBreakoutRooms(state))
  129. };
  130. }
  131. export default translate(connect(_mapStateToProps)(RoomParticipantMenu));