You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KnockingParticipantList.js 3.5KB

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