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 4.6KB

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