jiti-meet/react/features/remote-video-menu/components/native/RemoteVideoMenu.js

146 lines
3.6 KiB
JavaScript
Raw Normal View History

2018-12-19 18:40:17 +00:00
// @flow
import React, { Component } from 'react';
import { Text, View } from 'react-native';
2019-06-26 14:08:23 +00:00
import { Avatar } from '../../../base/avatar';
import { ColorSchemeRegistry } from '../../../base/color-scheme';
2019-07-11 11:32:17 +00:00
import { BottomSheet, isDialogOpen } from '../../../base/dialog';
2019-06-26 14:08:23 +00:00
import { getParticipantDisplayName } from '../../../base/participants';
2019-03-21 16:38:29 +00:00
import { connect } from '../../../base/redux';
import { StyleType } from '../../../base/styles';
2019-10-07 12:35:04 +00:00
import { PrivateMessageButton } from '../../../chat';
2018-12-19 18:40:17 +00:00
import { hideRemoteVideoMenu } from '../../actions';
import KickButton from './KickButton';
import MuteButton from './MuteButton';
2019-06-19 13:32:09 +00:00
import PinButton from './PinButton';
2018-12-19 18:40:17 +00:00
import styles from './styles';
2018-12-21 09:53:24 +00:00
/**
* Size of the rendered avatar in the menu.
*/
const AVATAR_SIZE = 25;
2018-12-19 18:40:17 +00:00
type Props = {
/**
* The Redux dispatch function.
*/
dispatch: Function,
/**
* The participant for which this menu opened for.
*/
participant: Object,
/**
* The color-schemed stylesheet of the BottomSheet.
*/
_bottomSheetStyles: StyleType,
2019-07-11 11:32:17 +00:00
/**
* True if the menu is currently open, false otherwise.
*/
_isOpen: boolean,
2018-12-19 18:40:17 +00:00
/**
* Display name of the participant retreived from Redux.
*/
_participantDisplayName: string
}
2019-07-11 11:32:17 +00:00
// eslint-disable-next-line prefer-const
let RemoteVideoMenu_;
2018-12-19 18:40:17 +00:00
/**
* Class to implement a popup menu that opens upon long pressing a thumbnail.
*/
class RemoteVideoMenu extends Component<Props> {
/**
* Constructor of the component.
*
* @inheritdoc
*/
constructor(props: Props) {
super(props);
this._onCancel = this._onCancel.bind(this);
}
/**
* Implements {@code Component#render}.
*
* @inheritdoc
*/
render() {
2019-06-26 14:08:23 +00:00
const { participant } = this.props;
2018-12-19 18:40:17 +00:00
const buttonProps = {
afterClick: this._onCancel,
showLabel: true,
2019-06-26 14:08:23 +00:00
participantID: participant.id,
2019-11-25 12:01:54 +00:00
styles: this.props._bottomSheetStyles.buttons
2018-12-19 18:40:17 +00:00
};
return (
<BottomSheet onCancel = { this._onCancel }>
<View style = { styles.participantNameContainer }>
2018-12-21 09:53:24 +00:00
<Avatar
2019-06-26 14:08:23 +00:00
participantId = { participant.id }
size = { AVATAR_SIZE } />
2018-12-19 18:40:17 +00:00
<Text style = { styles.participantNameLabel }>
{ this.props._participantDisplayName }
</Text>
</View>
<MuteButton { ...buttonProps } />
<KickButton { ...buttonProps } />
2019-06-19 13:32:09 +00:00
<PinButton { ...buttonProps } />
2019-10-07 12:35:04 +00:00
<PrivateMessageButton { ...buttonProps } />
2018-12-19 18:40:17 +00:00
</BottomSheet>
);
}
2019-07-11 11:32:17 +00:00
_onCancel: () => boolean;
2018-12-19 18:40:17 +00:00
/**
* Callback to hide the {@code RemoteVideoMenu}.
*
* @private
2019-07-11 11:32:17 +00:00
* @returns {boolean}
2018-12-19 18:40:17 +00:00
*/
_onCancel() {
2019-07-11 11:32:17 +00:00
if (this.props._isOpen) {
this.props.dispatch(hideRemoteVideoMenu());
return true;
}
return false;
2018-12-19 18:40:17 +00:00
}
}
/**
* Function that maps parts of Redux state tree into component props.
*
* @param {Object} state - Redux state.
* @param {Object} ownProps - Properties of component.
* @private
2019-07-11 11:32:17 +00:00
* @returns {Props}
2018-12-19 18:40:17 +00:00
*/
function _mapStateToProps(state, ownProps) {
2018-12-21 09:53:24 +00:00
const { participant } = ownProps;
2018-12-19 18:40:17 +00:00
return {
_bottomSheetStyles:
ColorSchemeRegistry.get(state, 'BottomSheet'),
2019-07-11 11:32:17 +00:00
_isOpen: isDialogOpen(state, RemoteVideoMenu_),
2018-12-21 09:53:24 +00:00
_participantDisplayName: getParticipantDisplayName(
state, participant.id)
2018-12-19 18:40:17 +00:00
};
}
2019-07-11 11:32:17 +00:00
RemoteVideoMenu_ = connect(_mapStateToProps)(RemoteVideoMenu);
export default RemoteVideoMenu_;