Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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