2018-05-15 11:18:42 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { Component } from 'react';
|
2018-12-20 09:33:10 +00:00
|
|
|
import { Platform } from 'react-native';
|
2018-05-15 11:18:42 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
2019-07-11 11:32:17 +00:00
|
|
|
import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
|
2019-05-28 13:30:57 +00:00
|
|
|
import { CHAT_ENABLED, IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
|
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-04-02 13:16:52 +00:00
|
|
|
import { InfoDialogButton, InviteButton } from '../../../invite';
|
2018-05-15 11:18:42 +00:00
|
|
|
import { AudioRouteButton } from '../../../mobile/audio-mode';
|
2018-07-05 11:17:45 +00:00
|
|
|
import { LiveStreamButton, RecordButton } from '../../../recording';
|
2018-05-15 11:18:42 +00:00
|
|
|
import { RoomLockButton } from '../../../room-lock';
|
2018-08-24 18:12:12 +00:00
|
|
|
import { ClosedCaptionButton } from '../../../subtitles';
|
2018-09-13 15:20:22 +00:00
|
|
|
import { TileViewButton } from '../../../video-layout';
|
2018-05-15 11:18:42 +00:00
|
|
|
|
|
|
|
import AudioOnlyButton from './AudioOnlyButton';
|
2019-03-27 13:47:19 +00:00
|
|
|
import RaiseHandButton from './RaiseHandButton';
|
2018-05-16 21:49:03 +00:00
|
|
|
import ToggleCameraButton from './ToggleCameraButton';
|
2018-05-15 11:18:42 +00:00
|
|
|
|
2018-05-16 21:49:03 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link OverflowMenu}.
|
|
|
|
*/
|
2018-05-15 11:18:42 +00:00
|
|
|
type Props = {
|
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* The color-schemed stylesheet of the dialog feature.
|
|
|
|
*/
|
|
|
|
_bottomSheetStyles: StyleType,
|
|
|
|
|
2019-05-28 13:30:57 +00:00
|
|
|
/**
|
|
|
|
* Whether the chat feature has been enabled. The meeting info button will be displayed in its place when disabled.
|
|
|
|
*/
|
|
|
|
_chatEnabled: boolean,
|
|
|
|
|
2019-07-11 11:32:17 +00:00
|
|
|
/**
|
|
|
|
* True if the overflow menu is currently visible, false otherwise.
|
|
|
|
*/
|
|
|
|
_isOpen: boolean,
|
|
|
|
|
2019-05-24 15:11:54 +00:00
|
|
|
/**
|
|
|
|
* Whether the recoding button should be enabled or not.
|
|
|
|
*/
|
|
|
|
_recordingEnabled: boolean,
|
|
|
|
|
2018-05-15 11:18:42 +00:00
|
|
|
/**
|
|
|
|
* Used for hiding the dialog when the selection was completed.
|
|
|
|
*/
|
2019-01-22 10:35:28 +00:00
|
|
|
dispatch: Function
|
2018-05-15 11:18:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2018-05-16 21:49:03 +00:00
|
|
|
* The exported React {@code Component}. We need it to execute
|
|
|
|
* {@link hideDialog}.
|
|
|
|
*
|
|
|
|
* XXX It does not break our coding style rule to not utilize globals for state,
|
|
|
|
* because it is merely another name for {@code export}'s {@code default}.
|
2018-05-15 11:18:42 +00:00
|
|
|
*/
|
2018-05-16 21:49:03 +00:00
|
|
|
let OverflowMenu_; // eslint-disable-line prefer-const
|
2018-05-15 11:18:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a React {@code Component} with some extra actions in addition to
|
|
|
|
* those in the toolbar.
|
|
|
|
*/
|
|
|
|
class OverflowMenu extends Component<Props> {
|
|
|
|
/**
|
|
|
|
* Initializes a new {@code OverflowMenu} instance.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
2018-05-16 21:49:03 +00:00
|
|
|
// Bind event handlers so they are only bound once per instance.
|
2018-05-15 11:18:42 +00:00
|
|
|
this._onCancel = this._onCancel.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2018-05-22 09:33:03 +00:00
|
|
|
const buttonProps = {
|
|
|
|
afterClick: this._onCancel,
|
|
|
|
showLabel: true,
|
2019-01-22 10:35:28 +00:00
|
|
|
styles: this.props._bottomSheetStyles
|
2018-05-22 09:33:03 +00:00
|
|
|
};
|
|
|
|
|
2018-05-15 11:18:42 +00:00
|
|
|
return (
|
|
|
|
<BottomSheet onCancel = { this._onCancel }>
|
2018-05-22 09:33:03 +00:00
|
|
|
<AudioRouteButton { ...buttonProps } />
|
|
|
|
<ToggleCameraButton { ...buttonProps } />
|
|
|
|
<AudioOnlyButton { ...buttonProps } />
|
|
|
|
<RoomLockButton { ...buttonProps } />
|
2018-08-24 18:12:12 +00:00
|
|
|
<ClosedCaptionButton { ...buttonProps } />
|
2018-12-20 09:33:10 +00:00
|
|
|
{
|
2019-05-24 15:11:54 +00:00
|
|
|
this.props._recordingEnabled
|
2018-12-20 09:33:10 +00:00
|
|
|
&& <RecordButton { ...buttonProps } />
|
|
|
|
}
|
2018-07-05 11:17:45 +00:00
|
|
|
<LiveStreamButton { ...buttonProps } />
|
2018-09-13 15:20:22 +00:00
|
|
|
<TileViewButton { ...buttonProps } />
|
2019-01-13 19:34:38 +00:00
|
|
|
<InviteButton { ...buttonProps } />
|
2019-05-28 13:30:57 +00:00
|
|
|
{
|
|
|
|
this.props._chatEnabled
|
|
|
|
&& <InfoDialogButton { ...buttonProps } />
|
|
|
|
}
|
2019-03-27 13:47:19 +00:00
|
|
|
<RaiseHandButton { ...buttonProps } />
|
2018-05-15 11:18:42 +00:00
|
|
|
</BottomSheet>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-07-11 11:32:17 +00:00
|
|
|
_onCancel: () => boolean;
|
2018-05-15 11:18:42 +00:00
|
|
|
|
|
|
|
/**
|
2018-05-16 21:49:03 +00:00
|
|
|
* Hides this {@code OverflowMenu}.
|
2018-05-15 11:18:42 +00:00
|
|
|
*
|
|
|
|
* @private
|
2019-07-11 11:32:17 +00:00
|
|
|
* @returns {boolean}
|
2018-05-15 11:18:42 +00:00
|
|
|
*/
|
|
|
|
_onCancel() {
|
2019-07-11 11:32:17 +00:00
|
|
|
if (this.props._isOpen) {
|
|
|
|
this.props.dispatch(hideDialog(OverflowMenu_));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2018-05-15 11:18:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @private
|
2019-07-11 11:32:17 +00:00
|
|
|
* @returns {Props}
|
2019-01-22 10:35:28 +00:00
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
_bottomSheetStyles:
|
2019-05-24 15:11:54 +00:00
|
|
|
ColorSchemeRegistry.get(state, 'BottomSheet'),
|
2019-05-28 13:30:57 +00:00
|
|
|
_chatEnabled: getFeatureFlag(state, CHAT_ENABLED, true),
|
2019-07-11 11:32:17 +00:00
|
|
|
_isOpen: isDialogOpen(state, OverflowMenu_),
|
2019-05-24 15:11:54 +00:00
|
|
|
_recordingEnabled: Platform.OS !== 'ios' || getFeatureFlag(state, IOS_RECORDING_ENABLED)
|
2019-01-22 10:35:28 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
|
2018-05-15 11:18:42 +00:00
|
|
|
|
|
|
|
export default OverflowMenu_;
|