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

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