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.

ParticipantsPane.js 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { View } from 'react-native';
  5. import { Button } from 'react-native-paper';
  6. import { useDispatch, useSelector } from 'react-redux';
  7. import { openDialog } from '../../../base/dialog';
  8. import { Icon, IconHorizontalPoints } from '../../../base/icons';
  9. import { JitsiModal } from '../../../base/modal';
  10. import {
  11. getParticipantCount,
  12. isLocalParticipantModerator
  13. } from '../../../base/participants';
  14. import MuteEveryoneDialog
  15. from '../../../video-menu/components/native/MuteEveryoneDialog';
  16. import { close } from '../../actions.native';
  17. import { ContextMenuMore } from './ContextMenuMore';
  18. import LobbyParticipantList from './LobbyParticipantList';
  19. import MeetingParticipantList from './MeetingParticipantList';
  20. import styles from './styles';
  21. /**
  22. * Participant pane.
  23. *
  24. * @returns {React$Element<any>}
  25. */
  26. const ParticipantsPane = () => {
  27. const dispatch = useDispatch();
  28. const openMoreMenu = useCallback(() => dispatch(openDialog(ContextMenuMore)), [ dispatch ]);
  29. const closePane = useCallback(() => dispatch(close()), [ dispatch ]);
  30. const isLocalModerator = useSelector(isLocalParticipantModerator);
  31. const participantsCount = useSelector(getParticipantCount);
  32. const showContextMenu = participantsCount > 2;
  33. const muteAll = useCallback(() => dispatch(openDialog(MuteEveryoneDialog)),
  34. [ dispatch ]);
  35. const { t } = useTranslation();
  36. return (
  37. <JitsiModal
  38. headerProps = {{
  39. headerLabelKey: 'participantsPane.header'
  40. }}
  41. onClose = { closePane }
  42. style = { styles.participantsPane }>
  43. <LobbyParticipantList />
  44. <MeetingParticipantList />
  45. {
  46. isLocalModerator
  47. && <View style = { styles.footer }>
  48. <Button
  49. children = { t('participantsPane.actions.muteAll') }
  50. labelStyle = { styles.muteAllLabel }
  51. mode = 'contained'
  52. onPress = { muteAll }
  53. style = { showContextMenu ? styles.muteAllMoreButton : styles.muteAllButton } />
  54. {
  55. showContextMenu
  56. && <Button
  57. /* eslint-disable-next-line react/jsx-no-bind */
  58. icon = { () =>
  59. (<Icon
  60. size = { 20 }
  61. src = { IconHorizontalPoints } />)
  62. }
  63. labelStyle = { styles.moreIcon }
  64. mode = 'contained'
  65. onPress = { openMoreMenu }
  66. style = { styles.moreButton } />
  67. }
  68. </View>
  69. }
  70. </JitsiModal>
  71. );
  72. };
  73. export default ParticipantsPane;