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 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { ScrollView, 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, IconClose, 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. hideHeaderWithNavigation = { true }
  39. style = { styles.participantsPane }>
  40. <View style = { styles.header }>
  41. <Button
  42. /* eslint-disable-next-line react/jsx-no-bind */
  43. icon = { () =>
  44. (<Icon
  45. size = { 20 }
  46. src = { IconClose } />)
  47. }
  48. labelStyle = { styles.closeIcon }
  49. mode = 'contained'
  50. onPress = { closePane }
  51. style = { styles.closeButton } />
  52. </View>
  53. <ScrollView>
  54. <LobbyParticipantList />
  55. <MeetingParticipantList />
  56. </ScrollView>
  57. {
  58. isLocalModerator
  59. && <View style = { styles.footer }>
  60. <Button
  61. children = { t('participantsPane.actions.muteAll') }
  62. labelStyle = { styles.muteAllLabel }
  63. mode = 'contained'
  64. onPress = { muteAll }
  65. style = { showContextMenu ? styles.muteAllMoreButton : styles.muteAllButton } />
  66. {
  67. showContextMenu
  68. && <Button
  69. /* eslint-disable-next-line react/jsx-no-bind */
  70. icon = { () =>
  71. (<Icon
  72. size = { 20 }
  73. src = { IconHorizontalPoints } />)
  74. }
  75. labelStyle = { styles.moreIcon }
  76. mode = 'contained'
  77. onPress = { openMoreMenu }
  78. style = { styles.moreButton } />
  79. }
  80. </View>
  81. }
  82. </JitsiModal>
  83. );
  84. };
  85. export default ParticipantsPane;