jiti-meet/react/features/toolbox/components/native/OverflowMenu.js

154 lines
4.4 KiB
JavaScript
Raw Normal View History

// @flow
import React, { Component } from 'react';
import { Platform } from 'react-native';
import { ColorSchemeRegistry } from '../../../base/color-scheme';
2019-07-11 11:32:17 +00:00
import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
import { CHAT_ENABLED, IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
2019-03-21 16:38:29 +00:00
import { connect } from '../../../base/redux';
import { StyleType } from '../../../base/styles';
2019-04-02 13:16:52 +00:00
import { InfoDialogButton, InviteButton } from '../../../invite';
import { AudioRouteButton } from '../../../mobile/audio-mode';
2018-07-05 11:17:45 +00:00
import { LiveStreamButton, RecordButton } from '../../../recording';
import { RoomLockButton } from '../../../room-lock';
import { ClosedCaptionButton } from '../../../subtitles';
import { TileViewButton } from '../../../video-layout';
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-16 21:49:03 +00:00
/**
* The type of the React {@code Component} props of {@link OverflowMenu}.
*/
type Props = {
/**
* The color-schemed stylesheet of the dialog feature.
*/
_bottomSheetStyles: StyleType,
/**
* 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,
/**
* Whether the recoding button should be enabled or not.
*/
_recordingEnabled: boolean,
/**
* Used for hiding the dialog when the selection was completed.
*/
dispatch: Function
};
/**
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-16 21:49:03 +00:00
let OverflowMenu_; // eslint-disable-line prefer-const
/**
* 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.
this._onCancel = this._onCancel.bind(this);
}
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
const buttonProps = {
afterClick: this._onCancel,
showLabel: true,
styles: this.props._bottomSheetStyles
};
return (
<BottomSheet onCancel = { this._onCancel }>
<AudioRouteButton { ...buttonProps } />
<ToggleCameraButton { ...buttonProps } />
<AudioOnlyButton { ...buttonProps } />
<RoomLockButton { ...buttonProps } />
<ClosedCaptionButton { ...buttonProps } />
{
this.props._recordingEnabled
&& <RecordButton { ...buttonProps } />
}
2018-07-05 11:17:45 +00:00
<LiveStreamButton { ...buttonProps } />
<TileViewButton { ...buttonProps } />
<InviteButton { ...buttonProps } />
{
this.props._chatEnabled
&& <InfoDialogButton { ...buttonProps } />
}
2019-03-27 13:47:19 +00:00
<RaiseHandButton { ...buttonProps } />
</BottomSheet>
);
}
2019-07-11 11:32:17 +00:00
_onCancel: () => boolean;
/**
2018-05-16 21:49:03 +00:00
* Hides this {@code OverflowMenu}.
*
* @private
2019-07-11 11:32:17 +00:00
* @returns {boolean}
*/
_onCancel() {
2019-07-11 11:32:17 +00:00
if (this.props._isOpen) {
this.props.dispatch(hideDialog(OverflowMenu_));
return true;
}
return false;
}
}
/**
* 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}
*/
function _mapStateToProps(state) {
return {
_bottomSheetStyles:
ColorSchemeRegistry.get(state, 'BottomSheet'),
_chatEnabled: getFeatureFlag(state, CHAT_ENABLED, true),
2019-07-11 11:32:17 +00:00
_isOpen: isDialogOpen(state, OverflowMenu_),
_recordingEnabled: Platform.OS !== 'ios' || getFeatureFlag(state, IOS_RECORDING_ENABLED)
};
}
OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
export default OverflowMenu_;