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.

LobbyParticipantList.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { ScrollView, Text, View } from 'react-native';
  5. import { useDispatch, useSelector } from 'react-redux';
  6. import Button from '../../../base/ui/components/native/Button';
  7. import { BUTTON_TYPES } from '../../../base/ui/constants';
  8. import { admitMultiple } from '../../../lobby/actions.native';
  9. import { getKnockingParticipants, getLobbyEnabled } from '../../../lobby/functions';
  10. import CollapsibleList from './CollapsibleList';
  11. import { LobbyParticipantItem } from './LobbyParticipantItem';
  12. import styles from './styles';
  13. const LobbyParticipantList = () => {
  14. const lobbyEnabled = useSelector(getLobbyEnabled);
  15. const participants = useSelector(getKnockingParticipants);
  16. const dispatch = useDispatch();
  17. const admitAll = useCallback(() =>
  18. dispatch(admitMultiple(participants)),
  19. [ dispatch, participants ]);
  20. const { t } = useTranslation();
  21. if (!lobbyEnabled || !participants.length) {
  22. return null;
  23. }
  24. const title = (
  25. <View style = { styles.lobbyListDetails } >
  26. <Text style = { styles.lobbyListDescription }>
  27. {t('participantsPane.headings.waitingLobby',
  28. { count: participants.length })}
  29. </Text>
  30. {
  31. participants.length > 1 && (
  32. <Button
  33. accessibilityLabel = 'lobby.admitAll'
  34. labelKey = 'lobby.admitAll'
  35. labelStyle = { styles.admitAllButtonLabel }
  36. onClick = { admitAll }
  37. type = { BUTTON_TYPES.TERTIARY } />
  38. )
  39. }
  40. </View>
  41. );
  42. // Regarding the fact that we have 3 sections, we apply
  43. // a certain height percentage for every section in order for all to fit
  44. // inside the participants pane container
  45. const style = participants.length > 1 && styles.lobbyListContent;
  46. return (
  47. <CollapsibleList
  48. title = { title }>
  49. <ScrollView
  50. bounces = { false }
  51. style = { style } >
  52. {
  53. participants.map(p => (
  54. <LobbyParticipantItem
  55. key = { p.id }
  56. participant = { p } />)
  57. )
  58. }
  59. </ScrollView>
  60. </CollapsibleList>
  61. );
  62. };
  63. export default LobbyParticipantList;