Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

DisplayNameLabel.tsx 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import * as React from 'react';
  2. import { Text, View } from 'react-native';
  3. import {
  4. getParticipantById,
  5. getParticipantDisplayName
  6. } from '../../../base/participants/functions';
  7. import { connect } from '../../../base/redux/functions';
  8. import styles from './styles';
  9. type Props = {
  10. /**
  11. * The name of the participant to render.
  12. */
  13. _participantName: string;
  14. /**
  15. * True of the label needs to be rendered. False otherwise.
  16. */
  17. _render: boolean;
  18. /**
  19. * Whether ot not the name is in a container.
  20. */
  21. contained?: boolean;
  22. /**
  23. * The ID of the participant to render the label for.
  24. */
  25. participantId: string;
  26. }
  27. /**
  28. * Renders a label with the display name of the on-stage participant.
  29. */
  30. class DisplayNameLabel extends React.Component<Props> {
  31. /**
  32. * Implements {@code Component#render}.
  33. *
  34. * @inheritdoc
  35. */
  36. render() {
  37. if (!this.props._render) {
  38. return null;
  39. }
  40. return (
  41. <View style = { this.props.contained ? styles.displayNamePadding : styles.displayNameBackdrop }>
  42. <Text
  43. numberOfLines = { 1 }
  44. style = { styles.displayNameText }>
  45. { this.props._participantName }
  46. </Text>
  47. </View>
  48. );
  49. }
  50. }
  51. /**
  52. * Maps part of the Redux state to the props of this component.
  53. *
  54. * @param {any} state - The Redux state.
  55. * @param {Props} ownProps - The own props of the component.
  56. * @returns {Props}
  57. */
  58. function _mapStateToProps(state: any, ownProps) {
  59. const participant = getParticipantById(state, ownProps.participantId);
  60. return {
  61. _participantName: getParticipantDisplayName(state, ownProps.participantId),
  62. _render: participant && (!participant?.local || ownProps.contained) && !participant?.isFakeParticipant
  63. };
  64. }
  65. export default connect(_mapStateToProps)(DisplayNameLabel);