2018-02-19 22:52:21 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-11-06 16:44:03 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { View } from 'react-native';
|
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
2019-05-28 13:30:57 +00:00
|
|
|
import { Container } from '../../../base/react';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2019-01-22 10:35:28 +00:00
|
|
|
import { StyleType } from '../../../base/styles';
|
2019-01-13 19:34:38 +00:00
|
|
|
import { ChatButton } from '../../../chat';
|
2019-01-30 17:19:40 +00:00
|
|
|
import { isToolboxVisible } from '../../functions';
|
2018-05-10 23:01:55 +00:00
|
|
|
import AudioMuteButton from '../AudioMuteButton';
|
|
|
|
import HangupButton from '../HangupButton';
|
2020-05-20 10:57:03 +00:00
|
|
|
import VideoMuteButton from '../VideoMuteButton';
|
2019-01-30 17:19:40 +00:00
|
|
|
|
2018-05-15 11:18:42 +00:00
|
|
|
import OverflowMenuButton from './OverflowMenuButton';
|
2019-01-22 10:35:28 +00:00
|
|
|
import styles from './styles';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2018-04-18 14:34:40 +00:00
|
|
|
/**
|
|
|
|
* The type of {@link Toolbox}'s React {@code Component} props.
|
|
|
|
*/
|
|
|
|
type Props = {
|
2018-02-06 10:41:23 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* The color-schemed stylesheet of the feature.
|
|
|
|
*/
|
|
|
|
_styles: StyleType,
|
|
|
|
|
2018-02-19 22:52:21 +00:00
|
|
|
/**
|
2018-05-15 11:18:42 +00:00
|
|
|
* The indicator which determines whether the toolbox is visible.
|
2018-02-19 22:52:21 +00:00
|
|
|
*/
|
2018-05-15 11:18:42 +00:00
|
|
|
_visible: boolean,
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2018-02-19 22:52:21 +00:00
|
|
|
/**
|
2018-05-15 11:18:42 +00:00
|
|
|
* The redux {@code dispatch} function.
|
2018-02-19 22:52:21 +00:00
|
|
|
*/
|
2018-05-15 11:18:42 +00:00
|
|
|
dispatch: Function
|
|
|
|
};
|
|
|
|
|
2018-02-19 22:52:21 +00:00
|
|
|
/**
|
|
|
|
* Implements the conference toolbox on React Native.
|
|
|
|
*/
|
2019-11-06 16:44:03 +00:00
|
|
|
class Toolbox extends PureComponent<Props> {
|
2017-10-19 18:29:34 +00:00
|
|
|
/**
|
2018-05-15 11:18:42 +00:00
|
|
|
* Implements React's {@link Component#render()}.
|
2017-10-19 18:29:34 +00:00
|
|
|
*
|
2018-05-15 11:18:42 +00:00
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
2017-10-19 18:29:34 +00:00
|
|
|
*/
|
2018-05-15 11:18:42 +00:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Container
|
2018-08-29 19:04:05 +00:00
|
|
|
style = { styles.toolbox }
|
2018-05-18 19:35:58 +00:00
|
|
|
visible = { this.props._visible }>
|
2018-05-18 11:42:16 +00:00
|
|
|
{ this._renderToolbar() }
|
2018-05-15 11:18:42 +00:00
|
|
|
</Container>
|
|
|
|
);
|
2017-10-19 18:29:34 +00:00
|
|
|
}
|
2018-05-16 21:49:03 +00:00
|
|
|
|
2019-01-13 19:34:38 +00: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 10:35:28 +00:00
|
|
|
const { _styles } = this.props;
|
|
|
|
|
2019-01-13 19:34:38 +00:00
|
|
|
if (Array.isArray(baseStyle.style)) {
|
|
|
|
return {
|
|
|
|
...baseStyle,
|
|
|
|
style: [
|
|
|
|
...baseStyle.style,
|
2019-01-22 10:35:28 +00:00
|
|
|
_styles.chatButtonOverride.toggled
|
2019-01-13 19:34:38 +00:00
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...baseStyle,
|
|
|
|
style: [
|
|
|
|
baseStyle.style,
|
2019-01-22 10:35:28 +00:00
|
|
|
_styles.chatButtonOverride.toggled
|
2019-01-13 19:34:38 +00:00
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-05-18 19:35:58 +00: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 07:35:18 +00:00
|
|
|
const { _styles } = this.props;
|
2019-07-16 13:13:41 +00:00
|
|
|
const { buttonStyles, buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles;
|
2018-05-18 19:35:58 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<View
|
2020-04-10 13:07:48 +00:00
|
|
|
accessibilityRole = 'toolbar'
|
2018-05-18 19:35:58 +00:00
|
|
|
pointerEvents = 'box-none'
|
|
|
|
style = { styles.toolbar }>
|
2020-04-29 07:35:18 +00:00
|
|
|
<ChatButton
|
|
|
|
styles = { buttonStylesBorderless }
|
|
|
|
toggledStyles = { this._getChatButtonToggledStyle(toggledButtonStyles) } />
|
2018-05-18 19:35:58 +00:00
|
|
|
<AudioMuteButton
|
|
|
|
styles = { buttonStyles }
|
|
|
|
toggledStyles = { toggledButtonStyles } />
|
2019-01-22 10:35:28 +00:00
|
|
|
<HangupButton
|
2019-07-12 08:32:47 +00:00
|
|
|
styles = { hangupButtonStyles } />
|
2018-05-18 19:35:58 +00:00
|
|
|
<VideoMuteButton
|
|
|
|
styles = { buttonStyles }
|
|
|
|
toggledStyles = { toggledButtonStyles } />
|
|
|
|
<OverflowMenuButton
|
2019-07-12 08:32:47 +00:00
|
|
|
styles = { buttonStylesBorderless }
|
2018-05-18 19:35:58 +00:00
|
|
|
toggledStyles = { toggledButtonStyles } />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
2018-04-18 14:34:40 +00:00
|
|
|
* Maps parts of the redux state to {@link Toolbox} (React {@code Component})
|
2018-02-19 22:52:21 +00:00
|
|
|
* props.
|
2017-02-16 23:02:40 +00:00
|
|
|
*
|
2018-04-18 14:34:40 +00:00
|
|
|
* @param {Object} state - The redux state of which parts are to be mapped to
|
|
|
|
* {@code Toolbox} props.
|
2018-05-11 02:10:26 +00:00
|
|
|
* @private
|
2020-04-29 07:35:18 +00:00
|
|
|
* @returns {Props}
|
2017-02-16 23:02:40 +00:00
|
|
|
*/
|
2018-04-18 14:34:40 +00:00
|
|
|
function _mapStateToProps(state: Object): Object {
|
2017-02-16 23:02:40 +00:00
|
|
|
return {
|
2019-01-22 10:35:28 +00:00
|
|
|
_styles: ColorSchemeRegistry.get(state, 'Toolbox'),
|
2019-01-30 17:19:40 +00:00
|
|
|
_visible: isToolboxVisible(state)
|
2017-02-16 23:02:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-08-29 19:04:05 +00:00
|
|
|
export default connect(_mapStateToProps)(Toolbox);
|