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.

RoomParticipantMenu.tsx 4.0KB

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