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

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