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

Toolbox.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // @flow
  2. import React from 'react';
  3. import { SafeAreaView, View } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { getFeatureFlag, REACTIONS_ENABLED } from '../../../base/flags';
  6. import { connect } from '../../../base/redux';
  7. import { StyleType } from '../../../base/styles';
  8. import { ChatButton } from '../../../chat';
  9. import { ParticipantsPaneButton } from '../../../participants-pane/components/native';
  10. import { ReactionsMenuButton } from '../../../reactions/components';
  11. import { TileViewButton } from '../../../video-layout';
  12. import { isToolboxVisible, getMovableButtons } from '../../functions.native';
  13. import AudioMuteButton from '../AudioMuteButton';
  14. import HangupButton from '../HangupButton';
  15. import VideoMuteButton from '../VideoMuteButton';
  16. import OverflowMenuButton from './OverflowMenuButton';
  17. import RaiseHandButton from './RaiseHandButton';
  18. import ToggleCameraButton from './ToggleCameraButton';
  19. import styles from './styles';
  20. /**
  21. * The type of {@link Toolbox}'s React {@code Component} props.
  22. */
  23. type Props = {
  24. /**
  25. * The color-schemed stylesheet of the feature.
  26. */
  27. _styles: StyleType,
  28. /**
  29. * The indicator which determines whether the toolbox is visible.
  30. */
  31. _visible: boolean,
  32. /**
  33. * The width of the screen.
  34. */
  35. _width: number,
  36. /**
  37. * Whether or not the reactions feature is enabled.
  38. */
  39. _reactionsEnabled: boolean,
  40. /**
  41. * The redux {@code dispatch} function.
  42. */
  43. dispatch: Function
  44. };
  45. /**
  46. * Implements the conference Toolbox on React Native.
  47. *
  48. * @param {Object} props - The props of the component.
  49. * @returns {React$Element}.
  50. */
  51. function Toolbox(props: Props) {
  52. if (!props._visible) {
  53. return null;
  54. }
  55. const { _styles, _width, _reactionsEnabled } = props;
  56. const { buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles;
  57. const additionalButtons = getMovableButtons(_width);
  58. const backgroundToggledStyle = {
  59. ...toggledButtonStyles,
  60. style: [
  61. toggledButtonStyles.style,
  62. _styles.backgroundToggle
  63. ]
  64. };
  65. return (
  66. <View
  67. pointerEvents = 'box-none'
  68. style = { styles.toolboxContainer }>
  69. <SafeAreaView
  70. accessibilityRole = 'toolbar'
  71. pointerEvents = 'box-none'
  72. style = { styles.toolbox }>
  73. <AudioMuteButton
  74. styles = { buttonStylesBorderless }
  75. toggledStyles = { toggledButtonStyles } />
  76. <VideoMuteButton
  77. styles = { buttonStylesBorderless }
  78. toggledStyles = { toggledButtonStyles } />
  79. { additionalButtons.has('chat')
  80. && <ChatButton
  81. styles = { buttonStylesBorderless }
  82. toggledStyles = { backgroundToggledStyle } />}
  83. { additionalButtons.has('raisehand') && (_reactionsEnabled
  84. ? <ReactionsMenuButton
  85. styles = { buttonStylesBorderless }
  86. toggledStyles = { backgroundToggledStyle } />
  87. : <RaiseHandButton
  88. styles = { buttonStylesBorderless }
  89. toggledStyles = { backgroundToggledStyle } />)}
  90. {additionalButtons.has('tileview') && <TileViewButton styles = { buttonStylesBorderless } />}
  91. {additionalButtons.has('participantspane')
  92. && <ParticipantsPaneButton
  93. styles = { buttonStylesBorderless } />
  94. }
  95. {additionalButtons.has('togglecamera')
  96. && <ToggleCameraButton
  97. styles = { buttonStylesBorderless }
  98. toggledStyles = { backgroundToggledStyle } />}
  99. <OverflowMenuButton
  100. styles = { buttonStylesBorderless }
  101. toggledStyles = { toggledButtonStyles } />
  102. <HangupButton
  103. styles = { hangupButtonStyles } />
  104. </SafeAreaView>
  105. </View>
  106. );
  107. }
  108. /**
  109. * Maps parts of the redux state to {@link Toolbox} (React {@code Component})
  110. * props.
  111. *
  112. * @param {Object} state - The redux state of which parts are to be mapped to
  113. * {@code Toolbox} props.
  114. * @private
  115. * @returns {Props}
  116. */
  117. function _mapStateToProps(state: Object): Object {
  118. return {
  119. _styles: ColorSchemeRegistry.get(state, 'Toolbox'),
  120. _visible: isToolboxVisible(state),
  121. _width: state['features/base/responsive-ui'].clientWidth,
  122. _reactionsEnabled: getFeatureFlag(state, REACTIONS_ENABLED, false)
  123. };
  124. }
  125. export default connect(_mapStateToProps)(Toolbox);