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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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, isEveryoneModerator,
  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, { button } 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 everyoneModerator = useSelector(isEveryoneModerator);
  33. const showContextMenu = !everyoneModerator && participantsCount > 2;
  34. const muteAll = useCallback(() => dispatch(openDialog(MuteEveryoneDialog)),
  35. [ dispatch ]);
  36. const { t } = useTranslation();
  37. return (
  38. <JitsiModal
  39. hideHeaderWithNavigation = { true }
  40. style = { styles.participantsPane }>
  41. <View style = { styles.header }>
  42. <Button
  43. contentStyle = { styles.closeIcon }
  44. /* eslint-disable-next-line react/jsx-no-bind */
  45. icon = { () =>
  46. (<Icon
  47. size = { 24 }
  48. src = { IconClose } />)
  49. }
  50. mode = 'contained'
  51. onPress = { closePane }
  52. style = { styles.closeButton } />
  53. </View>
  54. <ScrollView>
  55. <LobbyParticipantList />
  56. <MeetingParticipantList />
  57. </ScrollView>
  58. {
  59. isLocalModerator
  60. && <View style = { styles.footer }>
  61. <Button
  62. children = { t('participantsPane.actions.muteAll') }
  63. contentStyle = { styles.muteAllContent }
  64. labelStyle = { styles.muteAllLabel }
  65. mode = 'contained'
  66. onPress = { muteAll }
  67. style = { showContextMenu ? styles.muteAllButton : button } />
  68. {
  69. showContextMenu
  70. && <Button
  71. contentStyle = { styles.moreIcon }
  72. /* eslint-disable-next-line react/jsx-no-bind */
  73. icon = { () =>
  74. (<Icon
  75. size = { 24 }
  76. src = { IconHorizontalPoints } />)
  77. }
  78. mode = 'contained'
  79. onPress = { openMoreMenu }
  80. style = { styles.moreButton } />
  81. }
  82. </View>
  83. }
  84. </JitsiModal>
  85. );
  86. };
  87. export default ParticipantsPane;