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.

LocalVideoMenu.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import React, { PureComponent } from 'react';
  2. import { Text, View } from 'react-native';
  3. import { Avatar } from '../../../base/avatar';
  4. import { BottomSheet } from '../../../base/dialog';
  5. import { bottomSheetStyles } from '../../../base/dialog/components/native/styles';
  6. import { translate } from '../../../base/i18n';
  7. import {
  8. getLocalParticipant,
  9. getParticipantDisplayName
  10. } from '../../../base/participants';
  11. import { connect } from '../../../base/redux';
  12. import ToggleSelfViewButton from '../../../toolbox/components/native/ToggleSelfViewButton';
  13. import ConnectionStatusButton from './ConnectionStatusButton';
  14. import styles from './styles';
  15. /**
  16. * Size of the rendered avatar in the menu.
  17. */
  18. const AVATAR_SIZE = 24;
  19. type Props = {
  20. /**
  21. * The local participant.
  22. */
  23. _participant: Object,
  24. /**
  25. * Display name of the participant retrieved from Redux.
  26. */
  27. _participantDisplayName: string,
  28. /**
  29. * The Redux dispatch function.
  30. */
  31. dispatch: Function,
  32. /**
  33. * Translation function.
  34. */
  35. t: Function
  36. }
  37. /**
  38. * Class to implement a popup menu that opens upon long pressing a thumbnail.
  39. */
  40. class LocalVideoMenu extends PureComponent<Props> {
  41. /**
  42. * Constructor of the component.
  43. *
  44. * @inheritdoc
  45. */
  46. constructor(props: Props) {
  47. super(props);
  48. this._renderMenuHeader = this._renderMenuHeader.bind(this);
  49. }
  50. /**
  51. * Implements {@code Component#render}.
  52. *
  53. * @inheritdoc
  54. */
  55. render() {
  56. const { _participant } = this.props;
  57. const buttonProps = {
  58. showLabel: true,
  59. participantID: _participant.id,
  60. styles: bottomSheetStyles.buttons
  61. };
  62. return (
  63. <BottomSheet
  64. renderHeader = { this._renderMenuHeader }
  65. showSlidingView = { true }>
  66. <ToggleSelfViewButton { ...buttonProps } />
  67. <ConnectionStatusButton { ...buttonProps } />
  68. </BottomSheet>
  69. );
  70. }
  71. /**
  72. * Function to render the menu's header.
  73. *
  74. * @returns {React$Element}
  75. */
  76. _renderMenuHeader() {
  77. const { _participant } = this.props;
  78. return (
  79. <View
  80. style = { [
  81. bottomSheetStyles.sheet,
  82. styles.participantNameContainer ] }>
  83. <Avatar
  84. participantId = { _participant.id }
  85. size = { AVATAR_SIZE } />
  86. <Text style = { styles.participantNameLabel }>
  87. { this.props._participantDisplayName }
  88. </Text>
  89. </View>
  90. );
  91. }
  92. }
  93. /**
  94. * Function that maps parts of Redux state tree into component props.
  95. *
  96. * @param {Object} state - Redux state.
  97. * @private
  98. * @returns {Props}
  99. */
  100. function _mapStateToProps(state) {
  101. const participant = getLocalParticipant(state);
  102. return {
  103. _participant: participant,
  104. _participantDisplayName: getParticipantDisplayName(state, participant.id)
  105. };
  106. }
  107. export default translate(connect(_mapStateToProps)(LocalVideoMenu));