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

139 lines
3.3 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';
import { ColorSchemeRegistry } from '../../../base/color-scheme';
2018-12-19 18:40:17 +00:00
import {
BottomSheet
2018-12-19 18:40:17 +00:00
} from '../../../base/dialog';
2018-12-21 09:53:24 +00:00
import {
Avatar,
getAvatarURL,
getParticipantDisplayName
} from '../../../base/participants';
2019-03-21 16:38:29 +00:00
import { connect } from '../../../base/redux';
import { StyleType } from '../../../base/styles';
2018-12-19 18:40:17 +00:00
import { hideRemoteVideoMenu } from '../../actions';
import KickButton from './KickButton';
import MuteButton from './MuteButton';
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,
2018-12-21 09:53:24 +00:00
/**
* URL of the avatar of the participant.
*/
_avatarURL: string,
/**
* The color-schemed stylesheet of the BottomSheet.
*/
_bottomSheetStyles: StyleType,
2018-12-19 18:40:17 +00:00
/**
* Display name of the participant retreived from Redux.
*/
_participantDisplayName: string
}
/**
* 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() {
const buttonProps = {
afterClick: this._onCancel,
showLabel: true,
2019-01-05 16:49:21 +00:00
participantID: this.props.participant.id,
styles: this.props._bottomSheetStyles
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
size = { AVATAR_SIZE }
uri = { this.props._avatarURL } />
2018-12-19 18:40:17 +00:00
<Text style = { styles.participantNameLabel }>
{ this.props._participantDisplayName }
</Text>
</View>
<MuteButton { ...buttonProps } />
<KickButton { ...buttonProps } />
</BottomSheet>
);
}
_onCancel: () => void;
/**
* Callback to hide the {@code RemoteVideoMenu}.
*
* @private
* @returns {void}
*/
_onCancel() {
this.props.dispatch(hideRemoteVideoMenu());
}
}
/**
* Function that maps parts of Redux state tree into component props.
*
* @param {Object} state - Redux state.
* @param {Object} ownProps - Properties of component.
* @private
* @returns {{
2018-12-21 09:53:24 +00:00
* _avatarURL: string,
* _bottomSheetStyles: StyleType,
2018-12-19 18:40:17 +00:00
* _participantDisplayName: string
* }}
*/
function _mapStateToProps(state, ownProps) {
2018-12-21 09:53:24 +00:00
const { participant } = ownProps;
2018-12-19 18:40:17 +00:00
return {
2018-12-21 09:53:24 +00:00
_avatarURL: getAvatarURL(participant),
_bottomSheetStyles:
ColorSchemeRegistry.get(state, 'BottomSheet'),
2018-12-21 09:53:24 +00:00
_participantDisplayName: getParticipantDisplayName(
state, participant.id)
2018-12-19 18:40:17 +00:00
};
}
export default connect(_mapStateToProps)(RemoteVideoMenu);