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

KnockingParticipantList.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // @flow
  2. import React from 'react';
  3. import { ScrollView, Text, View, TouchableOpacity } from 'react-native';
  4. import { Avatar } from '../../../base/avatar';
  5. import { translate } from '../../../base/i18n';
  6. import { connect } from '../../../base/redux';
  7. import { HIDDEN_EMAILS } from '../../constants';
  8. import AbstractKnockingParticipantList, {
  9. mapStateToProps as abstractMapStateToProps,
  10. type Props
  11. } from '../AbstractKnockingParticipantList';
  12. import styles from './styles';
  13. /**
  14. * Component to render a list for the actively knocking participants.
  15. */
  16. class KnockingParticipantList extends AbstractKnockingParticipantList {
  17. /**
  18. * Implements {@code PureComponent#render}.
  19. *
  20. * @inheritdoc
  21. */
  22. render() {
  23. const { _participants, _visible, t } = this.props;
  24. if (!_visible) {
  25. return null;
  26. }
  27. return (
  28. <ScrollView
  29. style = { styles.knockingParticipantList }>
  30. { _participants.map(p => (
  31. <View
  32. key = { p.id }
  33. style = { styles.knockingParticipantListEntry }>
  34. <Avatar
  35. displayName = { p.name }
  36. size = { 48 }
  37. url = { p.loadableAvatarUrl } />
  38. <View style = { styles.knockingParticipantListDetails }>
  39. <Text style = { styles.knockingParticipantListText }>
  40. { p.name }
  41. </Text>
  42. { p.email && !HIDDEN_EMAILS.includes(p.email) && (
  43. <Text style = { styles.knockingParticipantListText }>
  44. { p.email }
  45. </Text>
  46. ) }
  47. </View>
  48. <TouchableOpacity
  49. onPress = { this._onRespondToParticipant(p.id, true) }
  50. style = { [
  51. styles.knockingParticipantListButton,
  52. styles.knockingParticipantListPrimaryButton
  53. ] }>
  54. <Text style = { styles.knockingParticipantListText }>
  55. { t('lobby.allow') }
  56. </Text>
  57. </TouchableOpacity>
  58. <TouchableOpacity
  59. onPress = { this._onRespondToParticipant(p.id, false) }
  60. style = { [
  61. styles.knockingParticipantListButton,
  62. styles.knockingParticipantListSecondaryButton
  63. ] }>
  64. <Text style = { styles.knockingParticipantListText }>
  65. { t('lobby.reject') }
  66. </Text>
  67. </TouchableOpacity>
  68. </View>
  69. )) }
  70. </ScrollView>
  71. );
  72. }
  73. _onRespondToParticipant: (string, boolean) => Function;
  74. }
  75. /**
  76. * Maps part of the Redux state to the props of this component.
  77. *
  78. * @param {Object} state - The Redux state.
  79. * @returns {Props}
  80. */
  81. function _mapStateToProps(state: Object): $Shape<Props> {
  82. const abstractProps = abstractMapStateToProps(state);
  83. return {
  84. ...abstractProps,
  85. // On mobile we only show a portion of the list for screen real estate reasons
  86. _participants: abstractProps._participants.slice(0, 2)
  87. };
  88. }
  89. export default translate(connect(_mapStateToProps)(KnockingParticipantList));