Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Toolbox.js 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // @flow
  2. import React from 'react';
  3. import { SafeAreaView, View } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { connect } from '../../../base/redux';
  6. import { StyleType } from '../../../base/styles';
  7. import { ChatButton } from '../../../chat';
  8. import { ParticipantsPaneButton } from '../../../participants-pane/components/native';
  9. import { ReactionsMenuButton } from '../../../reactions/components';
  10. import { isReactionsEnabled } from '../../../reactions/functions.any';
  11. import { TileViewButton } from '../../../video-layout';
  12. import { isToolboxVisible, getMovableButtons } from '../../functions.native';
  13. import AudioMuteButton from '../AudioMuteButton';
  14. import HangupButton from '../HangupButton';
  15. import VideoMuteButton from '../VideoMuteButton';
  16. import OverflowMenuButton from './OverflowMenuButton';
  17. import RaiseHandButton from './RaiseHandButton';
  18. import ToggleCameraButton from './ToggleCameraButton';
  19. import styles from './styles';
  20. /**
  21. * The type of {@link Toolbox}'s React {@code Component} props.
  22. */
  23. type Props = {
  24. /**
  25. * The color-schemed stylesheet of the feature.
  26. */
  27. _styles: StyleType,
  28. /**
  29. * The indicator which determines whether the toolbox is visible.
  30. */
  31. _visible: boolean,
  32. /**
  33. * The width of the screen.
  34. */
  35. _width: number,
  36. /**
  37. * Whether or not the reactions feature is enabled.
  38. */
  39. _reactionsEnabled: boolean
  40. };
  41. /**
  42. * Implements the conference Toolbox on React Native.
  43. *
  44. * @param {Object} props - The props of the component.
  45. * @returns {React$Element}.
  46. */
  47. function Toolbox(props: Props) {
  48. if (!props._visible) {
  49. return null;
  50. }
  51. const { _styles, _width, _reactionsEnabled } = props;
  52. const { buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles;
  53. const additionalButtons = getMovableButtons(_width);
  54. const backgroundToggledStyle = {
  55. ...toggledButtonStyles,
  56. style: [
  57. toggledButtonStyles.style,
  58. _styles.backgroundToggle
  59. ]
  60. };
  61. return (
  62. <View
  63. pointerEvents = 'box-none'
  64. style = { styles.toolboxContainer }>
  65. <SafeAreaView
  66. accessibilityRole = 'toolbar'
  67. pointerEvents = 'box-none'
  68. style = { styles.toolbox }>
  69. <AudioMuteButton
  70. styles = { buttonStylesBorderless }
  71. toggledStyles = { toggledButtonStyles } />
  72. <VideoMuteButton
  73. styles = { buttonStylesBorderless }
  74. toggledStyles = { toggledButtonStyles } />
  75. {
  76. additionalButtons.has('chat')
  77. && <ChatButton
  78. styles = { buttonStylesBorderless }
  79. toggledStyles = { backgroundToggledStyle } />
  80. }
  81. { additionalButtons.has('raisehand') && (_reactionsEnabled
  82. ? <ReactionsMenuButton
  83. styles = { buttonStylesBorderless }
  84. toggledStyles = { backgroundToggledStyle } />
  85. : <RaiseHandButton
  86. styles = { buttonStylesBorderless }
  87. toggledStyles = { backgroundToggledStyle } />)}
  88. {additionalButtons.has('tileview') && <TileViewButton styles = { buttonStylesBorderless } />}
  89. {additionalButtons.has('participantspane')
  90. && <ParticipantsPaneButton
  91. styles = { buttonStylesBorderless } />
  92. }
  93. {additionalButtons.has('togglecamera')
  94. && <ToggleCameraButton
  95. styles = { buttonStylesBorderless }
  96. toggledStyles = { backgroundToggledStyle } />}
  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);