您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RemoteVideoMenu.js 2.9KB

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