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

112 lines
3.2 KiB
JavaScript
Raw Normal View History

// @flow
import React, { Component } from 'react';
import { Platform } from 'react-native';
import { connect } from 'react-redux';
2018-12-19 18:40:17 +00:00
import {
BottomSheet,
bottomSheetItemStylesCombined,
hideDialog
} from '../../../base/dialog';
import { InviteButton } from '../../../invite';
import { AudioRouteButton } from '../../../mobile/audio-mode';
import { PictureInPictureButton } from '../../../mobile/picture-in-picture';
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';
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 = {
/**
* 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,
2018-12-19 18:40:17 +00:00
styles: bottomSheetItemStylesCombined
};
return (
<BottomSheet onCancel = { this._onCancel }>
<AudioRouteButton { ...buttonProps } />
<ToggleCameraButton { ...buttonProps } />
<AudioOnlyButton { ...buttonProps } />
<RoomLockButton { ...buttonProps } />
<ClosedCaptionButton { ...buttonProps } />
{
// Apple rejected our app because they claim requiring a
// Dropbox account for recording is not acceptable.
// Ddisable it until we can find a way around it.
Platform.OS !== 'ios'
&& <RecordButton { ...buttonProps } />
}
2018-07-05 11:17:45 +00:00
<LiveStreamButton { ...buttonProps } />
<TileViewButton { ...buttonProps } />
<InviteButton { ...buttonProps } />
<PictureInPictureButton { ...buttonProps } />
</BottomSheet>
);
}
_onCancel: () => void;
/**
2018-05-16 21:49:03 +00:00
* Hides this {@code OverflowMenu}.
*
* @private
* @returns {void}
*/
_onCancel() {
this.props.dispatch(hideDialog(OverflowMenu_));
}
}
OverflowMenu_ = connect()(OverflowMenu);
export default OverflowMenu_;