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

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