2018-02-19 16:52:21 -06:00
|
|
|
// @flow
|
|
|
|
|
|
2019-11-06 17:44:03 +01:00
|
|
|
import React, { PureComponent } from 'react';
|
2016-10-05 09:36:59 -05:00
|
|
|
import { View } from 'react-native';
|
|
|
|
|
|
2019-01-22 11:35:28 +01:00
|
|
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
2019-05-28 15:30:57 +02:00
|
|
|
import { Container } from '../../../base/react';
|
2019-03-21 17:38:29 +01:00
|
|
|
import { connect } from '../../../base/redux';
|
2019-01-22 11:35:28 +01:00
|
|
|
import { StyleType } from '../../../base/styles';
|
2019-01-13 20:34:38 +01:00
|
|
|
import { ChatButton } from '../../../chat';
|
2018-04-18 16:34:40 +02:00
|
|
|
|
2019-01-30 18:19:40 +01:00
|
|
|
import { isToolboxVisible } from '../../functions';
|
|
|
|
|
|
2018-05-10 18:01:55 -05:00
|
|
|
import AudioMuteButton from '../AudioMuteButton';
|
|
|
|
|
import HangupButton from '../HangupButton';
|
2019-01-30 18:19:40 +01:00
|
|
|
|
2018-05-15 13:18:42 +02:00
|
|
|
import OverflowMenuButton from './OverflowMenuButton';
|
2019-01-22 11:35:28 +01:00
|
|
|
import styles from './styles';
|
|
|
|
|
import VideoMuteButton from '../VideoMuteButton';
|
2016-10-05 09:36:59 -05:00
|
|
|
|
2018-04-18 16:34:40 +02:00
|
|
|
/**
|
|
|
|
|
* The type of {@link Toolbox}'s React {@code Component} props.
|
|
|
|
|
*/
|
|
|
|
|
type Props = {
|
2018-02-06 11:41:23 +01:00
|
|
|
|
2019-01-22 11:35:28 +01:00
|
|
|
/**
|
|
|
|
|
* The color-schemed stylesheet of the feature.
|
|
|
|
|
*/
|
|
|
|
|
_styles: StyleType,
|
|
|
|
|
|
2018-02-19 16:52:21 -06:00
|
|
|
/**
|
2018-05-15 13:18:42 +02:00
|
|
|
* The indicator which determines whether the toolbox is visible.
|
2018-02-19 16:52:21 -06:00
|
|
|
*/
|
2018-05-15 13:18:42 +02:00
|
|
|
_visible: boolean,
|
2016-10-05 09:36:59 -05:00
|
|
|
|
2018-02-19 16:52:21 -06:00
|
|
|
/**
|
2018-05-15 13:18:42 +02:00
|
|
|
* The redux {@code dispatch} function.
|
2018-02-19 16:52:21 -06:00
|
|
|
*/
|
2018-05-15 13:18:42 +02:00
|
|
|
dispatch: Function
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-19 16:52:21 -06:00
|
|
|
/**
|
|
|
|
|
* Implements the conference toolbox on React Native.
|
|
|
|
|
*/
|
2019-11-06 17:44:03 +01:00
|
|
|
class Toolbox extends PureComponent<Props> {
|
2017-10-19 13:29:34 -05:00
|
|
|
/**
|
2018-05-15 13:18:42 +02:00
|
|
|
* Implements React's {@link Component#render()}.
|
2017-10-19 13:29:34 -05:00
|
|
|
*
|
2018-05-15 13:18:42 +02:00
|
|
|
* @inheritdoc
|
|
|
|
|
* @returns {ReactElement}
|
2017-10-19 13:29:34 -05:00
|
|
|
*/
|
2018-05-15 13:18:42 +02:00
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
|
<Container
|
2018-08-29 14:04:05 -05:00
|
|
|
style = { styles.toolbox }
|
2018-05-18 14:35:58 -05:00
|
|
|
visible = { this.props._visible }>
|
2018-05-18 13:42:16 +02:00
|
|
|
{ this._renderToolbar() }
|
2018-05-15 13:18:42 +02:00
|
|
|
</Container>
|
|
|
|
|
);
|
2017-10-19 13:29:34 -05:00
|
|
|
}
|
2018-05-16 16:49:03 -05:00
|
|
|
|
2019-01-13 20:34:38 +01:00
|
|
|
/**
|
|
|
|
|
* Constructs the toggled style of the chat button. This cannot be done by
|
|
|
|
|
* simple style inheritance due to the size calculation done in this
|
|
|
|
|
* component.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} baseStyle - The base style that was originally
|
|
|
|
|
* calculated.
|
|
|
|
|
* @returns {Object | Array}
|
|
|
|
|
*/
|
|
|
|
|
_getChatButtonToggledStyle(baseStyle) {
|
2019-01-22 11:35:28 +01:00
|
|
|
const { _styles } = this.props;
|
|
|
|
|
|
2019-01-13 20:34:38 +01:00
|
|
|
if (Array.isArray(baseStyle.style)) {
|
|
|
|
|
return {
|
|
|
|
|
...baseStyle,
|
|
|
|
|
style: [
|
|
|
|
|
...baseStyle.style,
|
2019-01-22 11:35:28 +01:00
|
|
|
_styles.chatButtonOverride.toggled
|
2019-01-13 20:34:38 +01:00
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...baseStyle,
|
|
|
|
|
style: [
|
|
|
|
|
baseStyle.style,
|
2019-01-22 11:35:28 +01:00
|
|
|
_styles.chatButtonOverride.toggled
|
2019-01-13 20:34:38 +01:00
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-18 14:35:58 -05:00
|
|
|
/**
|
|
|
|
|
* Renders the toolbar. In order to avoid a weird visual effect in which the
|
|
|
|
|
* toolbar is (visually) rendered and then visibly changes its size, it is
|
|
|
|
|
* rendered only after we've figured out the width available to the toolbar.
|
|
|
|
|
*
|
|
|
|
|
* @returns {React$Node}
|
|
|
|
|
*/
|
|
|
|
|
_renderToolbar() {
|
2020-04-29 09:35:18 +02:00
|
|
|
const { _styles } = this.props;
|
2019-07-16 14:13:41 +01:00
|
|
|
const { buttonStyles, buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles;
|
2018-05-18 14:35:58 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<View
|
2020-04-10 15:07:48 +02:00
|
|
|
accessibilityRole = 'toolbar'
|
2018-05-18 14:35:58 -05:00
|
|
|
pointerEvents = 'box-none'
|
|
|
|
|
style = { styles.toolbar }>
|
2020-04-29 09:35:18 +02:00
|
|
|
<ChatButton
|
|
|
|
|
styles = { buttonStylesBorderless }
|
|
|
|
|
toggledStyles = { this._getChatButtonToggledStyle(toggledButtonStyles) } />
|
2018-05-18 14:35:58 -05:00
|
|
|
<AudioMuteButton
|
|
|
|
|
styles = { buttonStyles }
|
|
|
|
|
toggledStyles = { toggledButtonStyles } />
|
2019-01-22 11:35:28 +01:00
|
|
|
<HangupButton
|
2019-07-12 10:32:47 +02:00
|
|
|
styles = { hangupButtonStyles } />
|
2018-05-18 14:35:58 -05:00
|
|
|
<VideoMuteButton
|
|
|
|
|
styles = { buttonStyles }
|
|
|
|
|
toggledStyles = { toggledButtonStyles } />
|
|
|
|
|
<OverflowMenuButton
|
2019-07-12 10:32:47 +02:00
|
|
|
styles = { buttonStylesBorderless }
|
2018-05-18 14:35:58 -05:00
|
|
|
toggledStyles = { toggledButtonStyles } />
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-10-05 09:36:59 -05:00
|
|
|
}
|
|
|
|
|
|
2017-02-16 17:02:40 -06:00
|
|
|
/**
|
2018-04-18 16:34:40 +02:00
|
|
|
* Maps parts of the redux state to {@link Toolbox} (React {@code Component})
|
2018-02-19 16:52:21 -06:00
|
|
|
* props.
|
2017-02-16 17:02:40 -06:00
|
|
|
*
|
2018-04-18 16:34:40 +02:00
|
|
|
* @param {Object} state - The redux state of which parts are to be mapped to
|
|
|
|
|
* {@code Toolbox} props.
|
2018-05-10 21:10:26 -05:00
|
|
|
* @private
|
2020-04-29 09:35:18 +02:00
|
|
|
* @returns {Props}
|
2017-02-16 17:02:40 -06:00
|
|
|
*/
|
2018-04-18 16:34:40 +02:00
|
|
|
function _mapStateToProps(state: Object): Object {
|
2017-02-16 17:02:40 -06:00
|
|
|
return {
|
2019-01-22 11:35:28 +01:00
|
|
|
_styles: ColorSchemeRegistry.get(state, 'Toolbox'),
|
2019-01-30 18:19:40 +01:00
|
|
|
_visible: isToolboxVisible(state)
|
2017-02-16 17:02:40 -06:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-29 14:04:05 -05:00
|
|
|
export default connect(_mapStateToProps)(Toolbox);
|