2018-02-05 10:57:40 +00:00
|
|
|
// @flow
|
2017-05-24 17:01:46 +00:00
|
|
|
|
2020-06-02 09:03:17 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
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';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
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 = {
|
|
|
|
|
2020-06-02 09:03:17 +00:00
|
|
|
/**
|
|
|
|
* Application's viewport height.
|
|
|
|
*/
|
|
|
|
_height: number,
|
|
|
|
|
2018-02-05 10:57:40 +00:00
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
|
2020-06-02 09:03:17 +00:00
|
|
|
/**
|
|
|
|
* Application's viewport height.
|
|
|
|
*/
|
|
|
|
_width: number,
|
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2020-06-02 09:03:17 +00:00
|
|
|
class LargeVideo extends PureComponent<Props, State> {
|
2018-02-05 10:57:40 +00:00
|
|
|
state = {
|
|
|
|
...DEFAULT_STATE
|
|
|
|
};
|
|
|
|
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2020-06-02 09:03:17 +00:00
|
|
|
* Handles dimension changes. In case we deem it's too
|
2018-02-05 10:57:40 +00:00
|
|
|
* 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
|
|
|
*
|
2020-06-02 09:03:17 +00:00
|
|
|
* @inheritdoc
|
2016-12-01 01:52:39 +00:00
|
|
|
*/
|
2020-06-02 09:03:17 +00:00
|
|
|
static getDerivedStateFromProps(props: Props) {
|
|
|
|
const { _height, _width } = props;
|
|
|
|
|
2018-02-05 10:57:40 +00:00
|
|
|
// Get the size, rounded to the nearest even number.
|
2020-06-02 09:03:17 +00:00
|
|
|
const size = 2 * Math.round(Math.min(_height, _width) / 2);
|
2018-02-05 10:57:40 +00:00
|
|
|
|
|
|
|
if (size < AVATAR_SIZE * 1.5) {
|
2020-06-02 09:03:17 +00:00
|
|
|
return {
|
2018-02-05 10:57:40 +00:00
|
|
|
avatarSize: size - 15, // Leave some margin.
|
|
|
|
useConnectivityInfoLabel: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-06-02 09:03:17 +00:00
|
|
|
return DEFAULT_STATE;
|
|
|
|
|
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 (
|
2020-06-02 09:03:17 +00:00
|
|
|
<ParticipantView
|
|
|
|
avatarSize = { avatarSize }
|
|
|
|
onPress = { onClick }
|
|
|
|
participantId = { _participantId }
|
|
|
|
style = { _styles.largeVideo }
|
|
|
|
testHintId = 'org.jitsi.meet.LargeVideo'
|
|
|
|
useConnectivityInfoLabel = { useConnectivityInfoLabel }
|
|
|
|
zOrder = { 0 }
|
|
|
|
zoomEnabled = { true } />
|
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
|
2020-06-02 09:03:17 +00:00
|
|
|
* @returns {Props}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-01-28 23:34:57 +00:00
|
|
|
function _mapStateToProps(state) {
|
2020-06-02 09:03:17 +00:00
|
|
|
const { clientHeight: height, clientWidth: width } = state['features/base/responsive-ui'];
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
2020-06-02 09:03:17 +00:00
|
|
|
_height: height,
|
2019-01-22 10:35:28 +00:00
|
|
|
_participantId: state['features/large-video'].participantId,
|
2020-06-02 09:03:17 +00:00
|
|
|
_styles: ColorSchemeRegistry.get(state, 'LargeVideo'),
|
|
|
|
_width: width
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-01-28 23:34:57 +00:00
|
|
|
export default connect(_mapStateToProps)(LargeVideo);
|