You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Toolbox.tsx 5.7KB

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