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 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 { hideRemoteVideoMenu } from '../../actions';
  11. import KickButton from './KickButton';
  12. import MuteButton from './MuteButton';
  13. import PinButton from './PinButton';
  14. import styles from './styles';
  15. /**
  16. * Size of the rendered avatar in the menu.
  17. */
  18. const AVATAR_SIZE = 25;
  19. type Props = {
  20. /**
  21. * The Redux dispatch function.
  22. */
  23. dispatch: Function,
  24. /**
  25. * The participant for which this menu opened for.
  26. */
  27. participant: Object,
  28. /**
  29. * The color-schemed stylesheet of the BottomSheet.
  30. */
  31. _bottomSheetStyles: StyleType,
  32. /**
  33. * True if the menu is currently open, false otherwise.
  34. */
  35. _isOpen: boolean,
  36. /**
  37. * Display name of the participant retreived from Redux.
  38. */
  39. _participantDisplayName: string
  40. }
  41. // eslint-disable-next-line prefer-const
  42. let RemoteVideoMenu_;
  43. /**
  44. * Class to implement a popup menu that opens upon long pressing a thumbnail.
  45. */
  46. class RemoteVideoMenu extends Component<Props> {
  47. /**
  48. * Constructor of the component.
  49. *
  50. * @inheritdoc
  51. */
  52. constructor(props: Props) {
  53. super(props);
  54. this._onCancel = this._onCancel.bind(this);
  55. }
  56. /**
  57. * Implements {@code Component#render}.
  58. *
  59. * @inheritdoc
  60. */
  61. render() {
  62. const { participant } = this.props;
  63. const buttonProps = {
  64. afterClick: this._onCancel,
  65. showLabel: true,
  66. participantID: participant.id,
  67. styles: this.props._bottomSheetStyles
  68. };
  69. return (
  70. <BottomSheet onCancel = { this._onCancel }>
  71. <View style = { styles.participantNameContainer }>
  72. <Avatar
  73. participantId = { participant.id }
  74. size = { AVATAR_SIZE } />
  75. <Text style = { styles.participantNameLabel }>
  76. { this.props._participantDisplayName }
  77. </Text>
  78. </View>
  79. <MuteButton { ...buttonProps } />
  80. <KickButton { ...buttonProps } />
  81. <PinButton { ...buttonProps } />
  82. </BottomSheet>
  83. );
  84. }
  85. _onCancel: () => boolean;
  86. /**
  87. * Callback to hide the {@code RemoteVideoMenu}.
  88. *
  89. * @private
  90. * @returns {boolean}
  91. */
  92. _onCancel() {
  93. if (this.props._isOpen) {
  94. this.props.dispatch(hideRemoteVideoMenu());
  95. return true;
  96. }
  97. return false;
  98. }
  99. }
  100. /**
  101. * Function that maps parts of Redux state tree into component props.
  102. *
  103. * @param {Object} state - Redux state.
  104. * @param {Object} ownProps - Properties of component.
  105. * @private
  106. * @returns {Props}
  107. */
  108. function _mapStateToProps(state, ownProps) {
  109. const { participant } = ownProps;
  110. return {
  111. _bottomSheetStyles:
  112. ColorSchemeRegistry.get(state, 'BottomSheet'),
  113. _isOpen: isDialogOpen(state, RemoteVideoMenu_),
  114. _participantDisplayName: getParticipantDisplayName(
  115. state, participant.id)
  116. };
  117. }
  118. RemoteVideoMenu_ = connect(_mapStateToProps)(RemoteVideoMenu);
  119. export default RemoteVideoMenu_;