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.6KB

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