Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

LocalVideoMenu.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { Text, View } from 'react-native';
  4. import { Avatar } from '../../../base/avatar';
  5. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  6. import { BottomSheet, isDialogOpen } from '../../../base/dialog';
  7. import { translate } from '../../../base/i18n';
  8. import {
  9. getLocalParticipant,
  10. getParticipantDisplayName
  11. } from '../../../base/participants';
  12. import { connect } from '../../../base/redux';
  13. import { StyleType } from '../../../base/styles';
  14. import ToggleSelfViewButton from '../../../toolbox/components/native/ToggleSelfViewButton';
  15. import { hideLocalVideoMenu } from '../../actions.native';
  16. import ConnectionStatusButton from './ConnectionStatusButton';
  17. import styles from './styles';
  18. /**
  19. * Size of the rendered avatar in the menu.
  20. */
  21. const AVATAR_SIZE = 24;
  22. type Props = {
  23. /**
  24. * The color-schemed stylesheet of the BottomSheet.
  25. */
  26. _bottomSheetStyles: StyleType,
  27. /**
  28. * True if the menu is currently open, false otherwise.
  29. */
  30. _isOpen: boolean,
  31. /**
  32. * The local participant.
  33. */
  34. _participant: Object,
  35. /**
  36. * Display name of the participant retrieved from Redux.
  37. */
  38. _participantDisplayName: string,
  39. /**
  40. * The Redux dispatch function.
  41. */
  42. dispatch: Function,
  43. /**
  44. * Translation function.
  45. */
  46. t: Function
  47. }
  48. // eslint-disable-next-line prefer-const
  49. let LocalVideoMenu_;
  50. /**
  51. * Class to implement a popup menu that opens upon long pressing a thumbnail.
  52. */
  53. class LocalVideoMenu extends PureComponent<Props> {
  54. /**
  55. * Constructor of the component.
  56. *
  57. * @inheritdoc
  58. */
  59. constructor(props: Props) {
  60. super(props);
  61. this._onCancel = this._onCancel.bind(this);
  62. this._renderMenuHeader = this._renderMenuHeader.bind(this);
  63. }
  64. /**
  65. * Implements {@code Component#render}.
  66. *
  67. * @inheritdoc
  68. */
  69. render() {
  70. const { _participant, _bottomSheetStyles } = this.props;
  71. const buttonProps = {
  72. afterClick: this._onCancel,
  73. showLabel: true,
  74. participantID: _participant.id,
  75. styles: _bottomSheetStyles.buttons
  76. };
  77. return (
  78. <BottomSheet
  79. onCancel = { this._onCancel }
  80. renderHeader = { this._renderMenuHeader }
  81. showSlidingView = { true }>
  82. <ToggleSelfViewButton { ...buttonProps } />
  83. <ConnectionStatusButton { ...buttonProps } />
  84. </BottomSheet>
  85. );
  86. }
  87. _onCancel: () => boolean;
  88. /**
  89. * Callback to hide the {@code RemoteVideoMenu}.
  90. *
  91. * @private
  92. * @returns {boolean}
  93. */
  94. _onCancel() {
  95. if (this.props._isOpen) {
  96. this.props.dispatch(hideLocalVideoMenu());
  97. return true;
  98. }
  99. return false;
  100. }
  101. _renderMenuHeader: () => React$Element<any>;
  102. /**
  103. * Function to render the menu's header.
  104. *
  105. * @returns {React$Element}
  106. */
  107. _renderMenuHeader() {
  108. const { _bottomSheetStyles, _participant } = this.props;
  109. return (
  110. <View
  111. style = { [
  112. _bottomSheetStyles.sheet,
  113. styles.participantNameContainer ] }>
  114. <Avatar
  115. participantId = { _participant.id }
  116. size = { AVATAR_SIZE } />
  117. <Text style = { styles.participantNameLabel }>
  118. { this.props._participantDisplayName }
  119. </Text>
  120. </View>
  121. );
  122. }
  123. }
  124. /**
  125. * Function that maps parts of Redux state tree into component props.
  126. *
  127. * @param {Object} state - Redux state.
  128. * @private
  129. * @returns {Props}
  130. */
  131. function _mapStateToProps(state) {
  132. const participant = getLocalParticipant(state);
  133. return {
  134. _bottomSheetStyles: ColorSchemeRegistry.get(state, 'BottomSheet'),
  135. _isOpen: isDialogOpen(state, LocalVideoMenu_),
  136. _participant: participant,
  137. _participantDisplayName: getParticipantDisplayName(state, participant.id)
  138. };
  139. }
  140. LocalVideoMenu_ = translate(connect(_mapStateToProps)(LocalVideoMenu));
  141. export default LocalVideoMenu_;