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

DisplayNameLabel.js 1.9KB

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