2018-02-05 10:57:40 +00:00
|
|
|
// @flow
|
2017-05-24 17:01:46 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
import { ColorSchemeRegistry } from '../../base/color-scheme';
|
2017-02-27 20:37:53 +00:00
|
|
|
import { ParticipantView } from '../../base/participants';
|
2018-02-05 10:57:40 +00:00
|
|
|
import { DimensionsDetector } from '../../base/responsive-ui';
|
2019-01-22 10:35:28 +00:00
|
|
|
import { StyleType } from '../../base/styles';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
import { AVATAR_SIZE } from './styles';
|
2018-02-05 10:57:40 +00:00
|
|
|
|
2018-02-13 15:55:18 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@link Component} props of {@link LargeVideo}.
|
|
|
|
*/
|
2018-02-05 10:57:40 +00:00
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the participant (to be) depicted by LargeVideo.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
2019-01-22 10:35:28 +00:00
|
|
|
_participantId: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The color-schemed stylesheet of the feature.
|
|
|
|
*/
|
|
|
|
_styles: StyleType,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to invoke when the {@code LargeVideo} is clicked/pressed.
|
|
|
|
*/
|
|
|
|
onClick: Function,
|
2018-02-05 10:57:40 +00:00
|
|
|
};
|
|
|
|
|
2018-02-13 15:55:18 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@link Component} state of {@link LargeVideo}.
|
|
|
|
*/
|
2018-02-05 10:57:40 +00:00
|
|
|
type State = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size for the Avatar. It will be dynamically adjusted based on the
|
|
|
|
* available size.
|
|
|
|
*/
|
|
|
|
avatarSize: number,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the connectivity indicator will be shown or not. It will be true
|
|
|
|
* by default, but it may be turned off if there is not enough space.
|
|
|
|
*/
|
|
|
|
useConnectivityInfoLabel: boolean
|
|
|
|
};
|
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
|
|
|
avatarSize: AVATAR_SIZE,
|
|
|
|
useConnectivityInfoLabel: true
|
|
|
|
};
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-24 17:01:46 +00:00
|
|
|
* Implements a React {@link Component} which represents the large video (a.k.a.
|
|
|
|
* the conference participant who is on the local stage) on mobile/React Native.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
2018-02-05 10:57:40 +00:00
|
|
|
class LargeVideo extends Component<Props, State> {
|
|
|
|
state = {
|
|
|
|
...DEFAULT_STATE
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Initializes a new {@code LargeVideo} instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
constructor(props: Props) {
|
2018-02-05 10:57:40 +00:00
|
|
|
super(props);
|
|
|
|
|
2018-02-13 15:55:18 +00:00
|
|
|
// Bind event handlers so they are only bound once per instance.
|
2018-02-05 10:57:40 +00:00
|
|
|
this._onDimensionsChanged = this._onDimensionsChanged.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onDimensionsChanged: (width: number, height: number) => void;
|
|
|
|
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2018-02-05 10:57:40 +00:00
|
|
|
* Handle this component's dimension changes. In case we deem it's too
|
|
|
|
* small, the connectivity indicator won't be rendered and the avatar
|
|
|
|
* will occupy the entirety of the available screen state.
|
2016-12-01 01:52:39 +00:00
|
|
|
*
|
2018-02-05 10:57:40 +00:00
|
|
|
* @param {number} width - The component's current width.
|
|
|
|
* @param {number} height - The component's current height.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
2016-12-01 01:52:39 +00:00
|
|
|
*/
|
2018-02-05 10:57:40 +00:00
|
|
|
_onDimensionsChanged(width: number, height: number) {
|
|
|
|
// Get the size, rounded to the nearest even number.
|
|
|
|
const size = 2 * Math.round(Math.min(height, width) / 2);
|
2018-02-13 15:55:18 +00:00
|
|
|
let nextState;
|
2018-02-05 10:57:40 +00:00
|
|
|
|
|
|
|
if (size < AVATAR_SIZE * 1.5) {
|
2018-02-13 15:55:18 +00:00
|
|
|
nextState = {
|
2018-02-05 10:57:40 +00:00
|
|
|
avatarSize: size - 15, // Leave some margin.
|
|
|
|
useConnectivityInfoLabel: false
|
|
|
|
};
|
|
|
|
} else {
|
2018-02-13 15:55:18 +00:00
|
|
|
nextState = DEFAULT_STATE;
|
2018-02-05 10:57:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-13 15:55:18 +00:00
|
|
|
this.setState(nextState);
|
2018-02-05 10:57:40 +00:00
|
|
|
}
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2018-02-05 10:57:40 +00:00
|
|
|
const {
|
|
|
|
avatarSize,
|
|
|
|
useConnectivityInfoLabel
|
|
|
|
} = this.state;
|
2018-04-06 21:11:01 +00:00
|
|
|
const {
|
2018-09-13 15:20:22 +00:00
|
|
|
_participantId,
|
2019-01-22 10:35:28 +00:00
|
|
|
_styles,
|
2018-09-13 15:20:22 +00:00
|
|
|
onClick
|
2018-04-06 21:11:01 +00:00
|
|
|
} = this.props;
|
2018-02-05 10:57:40 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
return (
|
2018-02-05 10:57:40 +00:00
|
|
|
<DimensionsDetector
|
2018-04-06 21:11:01 +00:00
|
|
|
onDimensionsChanged = { this._onDimensionsChanged }>
|
2018-02-05 10:57:40 +00:00
|
|
|
<ParticipantView
|
|
|
|
avatarSize = { avatarSize }
|
2018-09-13 15:20:22 +00:00
|
|
|
onPress = { onClick }
|
2018-04-06 21:11:01 +00:00
|
|
|
participantId = { _participantId }
|
2019-01-22 10:35:28 +00:00
|
|
|
style = { _styles.largeVideo }
|
2018-04-18 18:37:33 +00:00
|
|
|
testHintId = 'org.jitsi.meet.LargeVideo'
|
2018-02-05 10:57:40 +00:00
|
|
|
useConnectivityInfoLabel = { useConnectivityInfoLabel }
|
2018-04-07 07:52:38 +00:00
|
|
|
zOrder = { 0 }
|
|
|
|
zoomEnabled = { true } />
|
2018-02-05 10:57:40 +00:00
|
|
|
</DimensionsDetector>
|
2016-10-05 14:36:59 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated LargeVideo's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
2017-01-28 23:34:57 +00:00
|
|
|
* @private
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2019-01-22 10:35:28 +00:00
|
|
|
* _participantId: string,
|
|
|
|
* _styles: StyleType
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2017-01-28 23:34:57 +00:00
|
|
|
function _mapStateToProps(state) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
2019-01-22 10:35:28 +00:00
|
|
|
_participantId: state['features/large-video'].participantId,
|
|
|
|
_styles: ColorSchemeRegistry.get(state, 'LargeVideo')
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-03-19 15:42:25 +00:00
|
|
|
// $FlowExpectedError
|
2017-01-28 23:34:57 +00:00
|
|
|
export default connect(_mapStateToProps)(LargeVideo);
|