Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

Toolbox.js 4.9KB

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