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.

RemoteVideoMenu.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Text, View } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import {
  6. BottomSheet,
  7. bottomSheetItemStylesCombined
  8. } from '../../../base/dialog';
  9. import { getParticipantDisplayName } from '../../../base/participants';
  10. import { hideRemoteVideoMenu } from '../../actions';
  11. import KickButton from './KickButton';
  12. import MuteButton from './MuteButton';
  13. import styles from './styles';
  14. type Props = {
  15. /**
  16. * The Redux dispatch function.
  17. */
  18. dispatch: Function,
  19. /**
  20. * The participant for which this menu opened for.
  21. */
  22. participant: Object,
  23. /**
  24. * Display name of the participant retreived from Redux.
  25. */
  26. _participantDisplayName: string
  27. }
  28. /**
  29. * Class to implement a popup menu that opens upon long pressing a thumbnail.
  30. */
  31. class RemoteVideoMenu extends Component<Props> {
  32. /**
  33. * Constructor of the component.
  34. *
  35. * @inheritdoc
  36. */
  37. constructor(props: Props) {
  38. super(props);
  39. this._onCancel = this._onCancel.bind(this);
  40. }
  41. /**
  42. * Implements {@code Component#render}.
  43. *
  44. * @inheritdoc
  45. */
  46. render() {
  47. const buttonProps = {
  48. afterClick: this._onCancel,
  49. showLabel: true,
  50. participant: this.props.participant,
  51. styles: bottomSheetItemStylesCombined
  52. };
  53. return (
  54. <BottomSheet onCancel = { this._onCancel }>
  55. <View style = { styles.participantNameContainer }>
  56. <Text style = { styles.participantNameLabel }>
  57. { this.props._participantDisplayName }
  58. </Text>
  59. </View>
  60. <MuteButton { ...buttonProps } />
  61. <KickButton { ...buttonProps } />
  62. </BottomSheet>
  63. );
  64. }
  65. _onCancel: () => void;
  66. /**
  67. * Callback to hide the {@code RemoteVideoMenu}.
  68. *
  69. * @private
  70. * @returns {void}
  71. */
  72. _onCancel() {
  73. this.props.dispatch(hideRemoteVideoMenu());
  74. }
  75. }
  76. /**
  77. * Function that maps parts of Redux state tree into component props.
  78. *
  79. * @param {Object} state - Redux state.
  80. * @param {Object} ownProps - Properties of component.
  81. * @private
  82. * @returns {{
  83. * _participantDisplayName: string
  84. * }}
  85. */
  86. function _mapStateToProps(state, ownProps) {
  87. const { id } = ownProps.participant;
  88. return {
  89. _participantDisplayName: getParticipantDisplayName(state, id)
  90. };
  91. }
  92. export default connect(_mapStateToProps)(RemoteVideoMenu);