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

LocalVideoMenuTriggerButton.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // @flow
  2. import React from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { Icon, IconMenuThumb } from '../../../base/icons';
  5. import { Popover } from '../../../base/popover';
  6. import { connect } from '../../../base/redux';
  7. import { getLocalVideoTrack } from '../../../base/tracks';
  8. import { getCurrentLayout, LAYOUTS } from '../../../video-layout';
  9. import FlipLocalVideoButton from './FlipLocalVideoButton';
  10. import VideoMenu from './VideoMenu';
  11. /**
  12. * The type of the React {@code Component} props of
  13. * {@link LocalVideoMenuTriggerButton}.
  14. */
  15. type Props = {
  16. /**
  17. * The position relative to the trigger the local video menu should display
  18. * from. Valid values are those supported by AtlasKit
  19. * {@code InlineDialog}.
  20. */
  21. _menuPosition: string,
  22. /**
  23. * Whether to display the Popover as a drawer.
  24. */
  25. _overflowDrawer: boolean,
  26. /**
  27. * Shows/hides the local video flip button.
  28. */
  29. _showLocalVideoFlipButton: boolean,
  30. /**
  31. * Invoked to obtain translated strings.
  32. */
  33. t: Function
  34. };
  35. /**
  36. * React Component for displaying an icon associated with opening the
  37. * the video menu for the local participant.
  38. *
  39. * @param {Props} props - The props passed to the component.
  40. * @returns {ReactElement}
  41. */
  42. function LocalVideoMenuTriggerButton(props: Props) {
  43. return (
  44. props._showLocalVideoFlipButton
  45. ? <Popover
  46. content = {
  47. <VideoMenu id = 'localVideoMenu'>
  48. <FlipLocalVideoButton />
  49. </VideoMenu>
  50. }
  51. overflowDrawer = { props._overflowDrawer }
  52. position = { props._menuPosition }>
  53. <span
  54. className = 'popover-trigger local-video-menu-trigger'>
  55. <Icon
  56. ariaLabel = { props.t('dialog.localUserControls') }
  57. role = 'button'
  58. size = '1em'
  59. src = { IconMenuThumb }
  60. tabIndex = { 0 }
  61. title = { props.t('dialog.localUserControls') } />
  62. </span>
  63. </Popover>
  64. : null
  65. );
  66. }
  67. /**
  68. * Maps (parts of) the Redux state to the associated {@code LocalVideoMenuTriggerButton}'s props.
  69. *
  70. * @param {Object} state - The Redux state.
  71. * @private
  72. * @returns {Props}
  73. */
  74. function _mapStateToProps(state) {
  75. const currentLayout = getCurrentLayout(state);
  76. const { disableLocalVideoFlip } = state['features/base/config'];
  77. const videoTrack = getLocalVideoTrack(state['features/base/tracks']);
  78. const { overflowDrawer } = state['features/toolbox'];
  79. let _menuPosition;
  80. switch (currentLayout) {
  81. case LAYOUTS.TILE_VIEW:
  82. _menuPosition = 'left-start';
  83. break;
  84. case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
  85. _menuPosition = 'left-end';
  86. break;
  87. default:
  88. _menuPosition = 'auto';
  89. }
  90. return {
  91. _menuPosition,
  92. _showLocalVideoFlipButton: !disableLocalVideoFlip && videoTrack?.videoType !== 'desktop',
  93. _overflowDrawer: overflowDrawer
  94. };
  95. }
  96. export default translate(connect(_mapStateToProps)(LocalVideoMenuTriggerButton));