| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 | 
							- // @flow
 - 
 - import React, { PureComponent } from 'react';
 - import { Platform, TouchableOpacity, View } from 'react-native';
 - import Collapsible from 'react-native-collapsible';
 - 
 - import { ColorSchemeRegistry } from '../../../base/color-scheme';
 - import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
 - import { IconDragHandle } from '../../../base/icons';
 - import { CHAT_ENABLED, IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
 - import { connect } from '../../../base/redux';
 - import { StyleType } from '../../../base/styles';
 - import { SharedDocumentButton } from '../../../etherpad';
 - import { InfoDialogButton, InviteButton } from '../../../invite';
 - import { AudioRouteButton } from '../../../mobile/audio-mode';
 - import { LiveStreamButton, RecordButton } from '../../../recording';
 - import { RoomLockButton } from '../../../room-lock';
 - import { ClosedCaptionButton } from '../../../subtitles';
 - import { TileViewButton } from '../../../video-layout';
 - 
 - import HelpButton from '../HelpButton';
 - 
 - import AudioOnlyButton from './AudioOnlyButton';
 - import RaiseHandButton from './RaiseHandButton';
 - import ToggleCameraButton from './ToggleCameraButton';
 - import styles from './styles';
 - 
 - /**
 -  * 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,
 - 
 -     /**
 -      * 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
 - };
 - 
 - type State = {
 - 
 -     /**
 -      * True if the bottom scheet is scrolled to the top.
 -      */
 -     scrolledToTop: boolean,
 - 
 -     /**
 -      * True if the 'more' button set needas to be rendered.
 -      */
 -     showMore: boolean
 - }
 - 
 - /**
 -  * 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}.
 -  */
 - 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 PureComponent<Props, State> {
 -     /**
 -      * Initializes a new {@code OverflowMenu} instance.
 -      *
 -      * @inheritdoc
 -      */
 -     constructor(props: Props) {
 -         super(props);
 - 
 -         this.state = {
 -             scrolledToTop: true,
 -             showMore: false
 -         };
 - 
 -         // Bind event handlers so they are only bound once per instance.
 -         this._onCancel = this._onCancel.bind(this);
 -         this._onSwipe = this._onSwipe.bind(this);
 -         this._onToggleMenu = this._onToggleMenu.bind(this);
 -         this._renderMenuExpandToggle = this._renderMenuExpandToggle.bind(this);
 -     }
 - 
 -     /**
 -      * Implements React's {@link Component#render()}.
 -      *
 -      * @inheritdoc
 -      * @returns {ReactElement}
 -      */
 -     render() {
 -         const { _bottomSheetStyles } = this.props;
 -         const { showMore } = this.state;
 - 
 -         const buttonProps = {
 -             afterClick: this._onCancel,
 -             showLabel: true,
 -             styles: _bottomSheetStyles.buttons
 -         };
 - 
 -         return (
 -             <BottomSheet
 -                 onCancel = { this._onCancel }
 -                 onSwipe = { this._onSwipe }
 -                 renderHeader = { this._renderMenuExpandToggle }>
 -                 <AudioRouteButton { ...buttonProps } />
 -                 <ToggleCameraButton { ...buttonProps } />
 -                 <AudioOnlyButton { ...buttonProps } />
 -                 <Collapsible collapsed = { !showMore }>
 -                     <RoomLockButton { ...buttonProps } />
 -                     <ClosedCaptionButton { ...buttonProps } />
 -                     {
 -                         this.props._recordingEnabled
 -                             && <RecordButton { ...buttonProps } />
 -                     }
 -                     <LiveStreamButton { ...buttonProps } />
 -                     <TileViewButton { ...buttonProps } />
 -                     <InviteButton { ...buttonProps } />
 -                     {
 -                         this.props._chatEnabled
 -                             && <InfoDialogButton { ...buttonProps } />
 -                     }
 -                     <RaiseHandButton { ...buttonProps } />
 -                     <SharedDocumentButton { ...buttonProps } />
 -                     <HelpButton { ...buttonProps } />
 -                 </Collapsible>
 -             </BottomSheet>
 -         );
 -     }
 - 
 -     _renderMenuExpandToggle: () => React$Element<any>;
 - 
 -     /**
 -      * Function to render the menu toggle in the bottom sheet header area.
 -      *
 -      * @returns {React$Element}
 -      */
 -     _renderMenuExpandToggle() {
 -         return (
 -             <View
 -                 style = { [
 -                     this.props._bottomSheetStyles.sheet,
 -                     styles.expandMenuContainer
 -                 ] }>
 -                 <TouchableOpacity onPress = { this._onToggleMenu }>
 -                     { /* $FlowFixMeProps */ }
 -                     <IconDragHandle style = { this.props._bottomSheetStyles.expandIcon } />
 -                 </TouchableOpacity>
 -             </View>
 -         );
 -     }
 - 
 -     _onCancel: () => boolean;
 - 
 -     /**
 -      * Hides this {@code OverflowMenu}.
 -      *
 -      * @private
 -      * @returns {boolean}
 -      */
 -     _onCancel() {
 -         if (this.props._isOpen) {
 -             this.props.dispatch(hideDialog(OverflowMenu_));
 - 
 -             return true;
 -         }
 - 
 -         return false;
 -     }
 - 
 -     _onSwipe: string => void;
 - 
 -     /**
 -      * Callback to be invoked when swipe gesture is detected on the menu. Returns true
 -      * if the swipe gesture is handled by the menu, false otherwise.
 -      *
 -      * @param {string} direction - Direction of 'up' or 'down'.
 -      * @returns {boolean}
 -      */
 -     _onSwipe(direction) {
 -         const { showMore } = this.state;
 - 
 -         switch (direction) {
 -         case 'up':
 -             !showMore && this.setState({
 -                 showMore: true
 -             });
 - 
 -             return !showMore;
 -         case 'down':
 -             showMore && this.setState({
 -                 showMore: false
 -             });
 - 
 -             return showMore;
 -         }
 -     }
 - 
 -     _onToggleMenu: () => void;
 - 
 -     /**
 -      * Callback to be invoked when the expand menu button is pressed.
 -      *
 -      * @returns {void}
 -      */
 -     _onToggleMenu() {
 -         this.setState({
 -             showMore: !this.state.showMore
 -         });
 -     }
 - }
 - 
 - /**
 -  * Function that maps parts of Redux state tree into component props.
 -  *
 -  * @param {Object} state - Redux state.
 -  * @private
 -  * @returns {Props}
 -  */
 - function _mapStateToProps(state) {
 -     return {
 -         _bottomSheetStyles:
 -             ColorSchemeRegistry.get(state, 'BottomSheet'),
 -         _chatEnabled: getFeatureFlag(state, CHAT_ENABLED, true),
 -         _isOpen: isDialogOpen(state, OverflowMenu_),
 -         _recordingEnabled: Platform.OS !== 'ios' || getFeatureFlag(state, IOS_RECORDING_ENABLED)
 -     };
 - }
 - 
 - OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
 - 
 - export default OverflowMenu_;
 
 
  |