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.js 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 { ReactionsMenuButton } from '../../../reactions/components';
  11. import { isReactionsEnabled } from '../../../reactions/functions.any';
  12. import { TileViewButton } from '../../../video-layout';
  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. _visitorsModeEnabled: 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, _visitorsModeEnabled, _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. return (
  74. <View
  75. pointerEvents = 'box-none'
  76. style = { styles.toolboxContainer }>
  77. <SafeAreaView
  78. accessibilityRole = 'toolbar'
  79. edges = { [ bottomEdge && 'bottom' ].filter(Boolean) }
  80. pointerEvents = 'box-none'
  81. style = { styles.toolbox }>
  82. {!_visitorsModeEnabled && <AudioMuteButton
  83. styles = { buttonStylesBorderless }
  84. toggledStyles = { toggledButtonStyles } />
  85. }
  86. {!_visitorsModeEnabled && <VideoMuteButton
  87. styles = { buttonStylesBorderless }
  88. toggledStyles = { toggledButtonStyles } />
  89. }
  90. {!_visitorsModeEnabled && additionalButtons.has('chat')
  91. && <ChatButton
  92. styles = { buttonStylesBorderless }
  93. toggledStyles = { backgroundToggledStyle } />
  94. }
  95. {!_visitorsModeEnabled && additionalButtons.has('screensharing')
  96. && <ScreenSharingButton styles = { buttonStylesBorderless } />}
  97. { !_visitorsModeEnabled && additionalButtons.has('raisehand') && (_reactionsEnabled
  98. ? <ReactionsMenuButton
  99. styles = { buttonStylesBorderless }
  100. toggledStyles = { backgroundToggledStyle } />
  101. : <RaiseHandButton
  102. styles = { buttonStylesBorderless }
  103. toggledStyles = { backgroundToggledStyle } />)}
  104. {additionalButtons.has('tileview') && <TileViewButton styles = { buttonStylesBorderless } />}
  105. {!_visitorsModeEnabled && <OverflowMenuButton
  106. styles = { buttonStylesBorderless }
  107. toggledStyles = { toggledButtonStyles } />
  108. }
  109. { _endConferenceSupported
  110. ? <HangupMenuButton
  111. styles = { hangupMenuButtonStyles }
  112. toggledStyles = { toggledButtonStyles } />
  113. : <HangupButton
  114. styles = { hangupButtonStyles } />
  115. }
  116. </SafeAreaView>
  117. </View>
  118. );
  119. }
  120. /**
  121. * Maps parts of the redux state to {@link Toolbox} (React {@code Component})
  122. * props.
  123. *
  124. * @param {Object} state - The redux state of which parts are to be mapped to
  125. * {@code Toolbox} props.
  126. * @private
  127. * @returns {Props}
  128. */
  129. function _mapStateToProps(state: Object): Object {
  130. const { conference } = state['features/base/conference'];
  131. const endConferenceSupported = conference?.isEndConferenceSupported();
  132. return {
  133. _endConferenceSupported: Boolean(endConferenceSupported),
  134. _styles: ColorSchemeRegistry.get(state, 'Toolbox'),
  135. _visible: isToolboxVisible(state),
  136. _visitorsModeEnabled: iAmVisitor(state),
  137. _width: state['features/base/responsive-ui'].clientWidth,
  138. _reactionsEnabled: isReactionsEnabled(state)
  139. };
  140. }
  141. export default connect(_mapStateToProps)(Toolbox);