Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Toolbox.js 5.2KB

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