您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RemoteVideoMenu.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Text, View } from 'react-native';
  4. import { Avatar } from '../../../base/avatar';
  5. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  6. import { BottomSheet, isDialogOpen } from '../../../base/dialog';
  7. import { getParticipantDisplayName } from '../../../base/participants';
  8. import { connect } from '../../../base/redux';
  9. import { StyleType } from '../../../base/styles';
  10. import { PrivateMessageButton } from '../../../chat';
  11. import { hideRemoteVideoMenu } from '../../actions';
  12. import KickButton from './KickButton';
  13. import MuteButton from './MuteButton';
  14. import PinButton from './PinButton';
  15. import styles from './styles';
  16. /**
  17. * Size of the rendered avatar in the menu.
  18. */
  19. const AVATAR_SIZE = 25;
  20. type Props = {
  21. /**
  22. * The Redux dispatch function.
  23. */
  24. dispatch: Function,
  25. /**
  26. * The participant for which this menu opened for.
  27. */
  28. participant: Object,
  29. /**
  30. * The color-schemed stylesheet of the BottomSheet.
  31. */
  32. _bottomSheetStyles: StyleType,
  33. /**
  34. * Whether or not to display the kick button.
  35. */
  36. _disableKick: boolean,
  37. /**
  38. * Whether or not to display the remote mute buttons.
  39. */
  40. _disableRemoteMute: boolean,
  41. /**
  42. * True if the menu is currently open, false otherwise.
  43. */
  44. _isOpen: boolean,
  45. /**
  46. * Display name of the participant retreived from Redux.
  47. */
  48. _participantDisplayName: string
  49. }
  50. // eslint-disable-next-line prefer-const
  51. let RemoteVideoMenu_;
  52. /**
  53. * Class to implement a popup menu that opens upon long pressing a thumbnail.
  54. */
  55. class RemoteVideoMenu extends Component<Props> {
  56. /**
  57. * Constructor of the component.
  58. *
  59. * @inheritdoc
  60. */
  61. constructor(props: Props) {
  62. super(props);
  63. this._onCancel = this._onCancel.bind(this);
  64. }
  65. /**
  66. * Implements {@code Component#render}.
  67. *
  68. * @inheritdoc
  69. */
  70. render() {
  71. const { _disableKick, _disableRemoteMute, participant } = this.props;
  72. const buttonProps = {
  73. afterClick: this._onCancel,
  74. showLabel: true,
  75. participantID: participant.id,
  76. styles: this.props._bottomSheetStyles.buttons
  77. };
  78. const buttons = [];
  79. if (!_disableRemoteMute) {
  80. buttons.push(<MuteButton { ...buttonProps } />);
  81. }
  82. if (!_disableKick) {
  83. buttons.push(<KickButton { ...buttonProps } />);
  84. }
  85. buttons.push(<PinButton { ...buttonProps } />);
  86. buttons.push(<PrivateMessageButton { ...buttonProps } />);
  87. return (
  88. <BottomSheet onCancel = { this._onCancel }>
  89. <View style = { styles.participantNameContainer }>
  90. <Avatar
  91. participantId = { participant.id }
  92. size = { AVATAR_SIZE } />
  93. <Text style = { styles.participantNameLabel }>
  94. { this.props._participantDisplayName }
  95. </Text>
  96. </View>
  97. { buttons }
  98. </BottomSheet>
  99. );
  100. }
  101. _onCancel: () => boolean;
  102. /**
  103. * Callback to hide the {@code RemoteVideoMenu}.
  104. *
  105. * @private
  106. * @returns {boolean}
  107. */
  108. _onCancel() {
  109. if (this.props._isOpen) {
  110. this.props.dispatch(hideRemoteVideoMenu());
  111. return true;
  112. }
  113. return false;
  114. }
  115. }
  116. /**
  117. * Function that maps parts of Redux state tree into component props.
  118. *
  119. * @param {Object} state - Redux state.
  120. * @param {Object} ownProps - Properties of component.
  121. * @private
  122. * @returns {Props}
  123. */
  124. function _mapStateToProps(state, ownProps) {
  125. const { participant } = ownProps;
  126. const { remoteVideoMenu = {}, disableRemoteMute } = state['features/base/config'];
  127. const { disableKick } = remoteVideoMenu;
  128. return {
  129. _bottomSheetStyles: ColorSchemeRegistry.get(state, 'BottomSheet'),
  130. _disableKick: Boolean(disableKick),
  131. _disableRemoteMute: Boolean(disableRemoteMute),
  132. _isOpen: isDialogOpen(state, RemoteVideoMenu_),
  133. _participantDisplayName: getParticipantDisplayName(state, participant.id)
  134. };
  135. }
  136. RemoteVideoMenu_ = connect(_mapStateToProps)(RemoteVideoMenu);
  137. export default RemoteVideoMenu_;