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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // @flow
  2. import React, { PureComponent } 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 { isToolboxVisible } from '../../functions';
  9. import AudioMuteButton from '../AudioMuteButton';
  10. import HangupButton from '../HangupButton';
  11. import VideoMuteButton from '../VideoMuteButton';
  12. import OverflowMenuButton from './OverflowMenuButton';
  13. import styles from './styles';
  14. /**
  15. * The type of {@link Toolbox}'s React {@code Component} props.
  16. */
  17. type Props = {
  18. /**
  19. * The color-schemed stylesheet of the feature.
  20. */
  21. _styles: StyleType,
  22. /**
  23. * The indicator which determines whether the toolbox is visible.
  24. */
  25. _visible: boolean,
  26. /**
  27. * The redux {@code dispatch} function.
  28. */
  29. dispatch: Function
  30. };
  31. /**
  32. * Implements the conference toolbox on React Native.
  33. */
  34. class Toolbox extends PureComponent<Props> {
  35. /**
  36. * Implements React's {@link Component#render()}.
  37. *
  38. * @inheritdoc
  39. * @returns {ReactElement}
  40. */
  41. render() {
  42. if (!this.props._visible) {
  43. return null;
  44. }
  45. const { _styles } = this.props;
  46. const { buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles;
  47. return (
  48. <View
  49. pointerEvents = 'box-none'
  50. style = { styles.toolboxContainer }>
  51. <SafeAreaView
  52. accessibilityRole = 'toolbar'
  53. pointerEvents = 'box-none'
  54. style = { styles.toolbox }>
  55. <AudioMuteButton
  56. styles = { buttonStylesBorderless }
  57. toggledStyles = { toggledButtonStyles } />
  58. <VideoMuteButton
  59. styles = { buttonStylesBorderless }
  60. toggledStyles = { toggledButtonStyles } />
  61. <ChatButton
  62. styles = { buttonStylesBorderless }
  63. toggledStyles = { this._getChatButtonToggledStyle(toggledButtonStyles) } />
  64. <OverflowMenuButton
  65. styles = { buttonStylesBorderless }
  66. toggledStyles = { toggledButtonStyles } />
  67. <HangupButton
  68. styles = { hangupButtonStyles } />
  69. </SafeAreaView>
  70. </View>
  71. );
  72. }
  73. /**
  74. * Constructs the toggled style of the chat button. This cannot be done by
  75. * simple style inheritance due to the size calculation done in this
  76. * component.
  77. *
  78. * @param {Object} baseStyle - The base style that was originally
  79. * calculated.
  80. * @returns {Object | Array}
  81. */
  82. _getChatButtonToggledStyle(baseStyle) {
  83. const { _styles } = this.props;
  84. if (Array.isArray(baseStyle.style)) {
  85. return {
  86. ...baseStyle,
  87. style: [
  88. ...baseStyle.style,
  89. _styles.chatButtonOverride.toggled
  90. ]
  91. };
  92. }
  93. return {
  94. ...baseStyle,
  95. style: [
  96. baseStyle.style,
  97. _styles.chatButtonOverride.toggled
  98. ]
  99. };
  100. }
  101. }
  102. /**
  103. * Maps parts of the redux state to {@link Toolbox} (React {@code Component})
  104. * props.
  105. *
  106. * @param {Object} state - The redux state of which parts are to be mapped to
  107. * {@code Toolbox} props.
  108. * @private
  109. * @returns {Props}
  110. */
  111. function _mapStateToProps(state: Object): Object {
  112. return {
  113. _styles: ColorSchemeRegistry.get(state, 'Toolbox'),
  114. _visible: isToolboxVisible(state)
  115. };
  116. }
  117. export default connect(_mapStateToProps)(Toolbox);