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.tsx 3.3KB

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