2022-04-08 12:24:58 +00:00
|
|
|
import * as React from 'react';
|
2019-01-28 14:55:37 +00:00
|
|
|
import { Text, View } from 'react-native';
|
|
|
|
|
|
|
|
import {
|
2020-06-12 10:15:16 +00:00
|
|
|
getParticipantById,
|
2022-02-14 10:13:18 +00:00
|
|
|
getParticipantDisplayName
|
2022-04-08 12:24:58 +00:00
|
|
|
} from '../../../base/participants/functions';
|
|
|
|
import { connect } from '../../../base/redux/functions';
|
2019-01-28 14:55:37 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of the participant to render.
|
|
|
|
*/
|
2022-04-08 12:24:58 +00:00
|
|
|
_participantName: string;
|
2019-01-28 14:55:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True of the label needs to be rendered. False otherwise.
|
|
|
|
*/
|
2022-04-08 12:24:58 +00:00
|
|
|
_render: boolean;
|
2019-04-11 10:04:50 +00:00
|
|
|
|
2022-02-14 10:13:18 +00:00
|
|
|
/**
|
|
|
|
* Whether ot not the name is in a container.
|
|
|
|
*/
|
2022-04-08 12:24:58 +00:00
|
|
|
contained?: boolean;
|
2022-02-14 10:13:18 +00:00
|
|
|
|
2019-04-11 10:04:50 +00:00
|
|
|
/**
|
|
|
|
* The ID of the participant to render the label for.
|
|
|
|
*/
|
2022-04-08 12:24:58 +00:00
|
|
|
participantId: string;
|
2019-01-28 14:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a label with the display name of the on-stage participant.
|
|
|
|
*/
|
2022-04-08 12:24:58 +00:00
|
|
|
class DisplayNameLabel extends React.Component<Props> {
|
2019-01-28 14:55:37 +00:00
|
|
|
/**
|
|
|
|
* Implements {@code Component#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
if (!this.props._render) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-02-14 10:13:18 +00:00
|
|
|
<View style = { this.props.contained ? styles.displayNamePadding : styles.displayNameBackdrop }>
|
|
|
|
<Text
|
|
|
|
numberOfLines = { 1 }
|
|
|
|
style = { styles.displayNameText }>
|
2019-01-28 14:55:37 +00:00
|
|
|
{ this.props._participantName }
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
2022-04-08 12:24:58 +00:00
|
|
|
* @param {any} state - The Redux state.
|
2019-04-11 10:04:50 +00:00
|
|
|
* @param {Props} ownProps - The own props of the component.
|
2022-04-08 12:24:58 +00:00
|
|
|
* @returns {Props}
|
2019-01-28 14:55:37 +00:00
|
|
|
*/
|
2022-04-08 12:24:58 +00:00
|
|
|
function _mapStateToProps(state: any, ownProps) {
|
|
|
|
const participant = getParticipantById(state, ownProps.participantId);
|
2019-01-28 14:55:37 +00:00
|
|
|
|
|
|
|
return {
|
2022-04-08 12:24:58 +00:00
|
|
|
_participantName: getParticipantDisplayName(state, ownProps.participantId),
|
|
|
|
_render: participant && (!participant?.local || ownProps.contained) && !participant?.isFakeParticipant
|
2019-01-28 14:55:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(DisplayNameLabel);
|