Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

functions.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { Platform } from 'react-native';
  4. import { useDispatch } from 'react-redux';
  5. import { appNavigate } from '../../app/actions';
  6. import {
  7. PREJOIN_PAGE_ENABLED,
  8. getFeatureFlag
  9. } from '../../base/flags';
  10. import { IconClose } from '../../base/icons';
  11. import { toState } from '../../base/redux';
  12. import { cancelKnocking } from '../../lobby/actions.native';
  13. import HeaderNavigationButton from './components/HeaderNavigationButton';
  14. /**
  15. * Close icon/text button based on platform.
  16. *
  17. * @param {Function} goBack - Goes back to the previous screen function.
  18. * @returns {React.Component}
  19. */
  20. export function screenHeaderCloseButton(goBack: Function) {
  21. const { t } = useTranslation();
  22. if (Platform.OS === 'ios') {
  23. return (
  24. <HeaderNavigationButton
  25. label = { t('dialog.close') }
  26. onPress = { goBack } />
  27. );
  28. }
  29. return (
  30. <HeaderNavigationButton
  31. onPress = { goBack }
  32. src = { IconClose } />
  33. );
  34. }
  35. /**
  36. * Determines whether the {@code Prejoin page} is enabled by the app itself
  37. * (e.g. Programmatically via the Jitsi Meet SDK for Android and iOS).
  38. *
  39. * @param {Function|Object} stateful - The redux state or {@link getState}
  40. * function.
  41. * @returns {boolean} If the {@code Prejoin} is enabled by the app, then
  42. * {@code true}; otherwise, {@code false}.
  43. */
  44. export function isPrejoinPageEnabled(stateful: Function | Object) {
  45. return getFeatureFlag(toState(stateful), PREJOIN_PAGE_ENABLED, true);
  46. }
  47. /**
  48. * Close icon/text button for lobby screen based on platform.
  49. *
  50. * @returns {React.Component}
  51. */
  52. export function lobbyScreenHeaderCloseButton() {
  53. const dispatch = useDispatch();
  54. const { t } = useTranslation();
  55. const goBack = useCallback(() => {
  56. dispatch(cancelKnocking());
  57. dispatch(appNavigate(undefined));
  58. }, [ dispatch ]);
  59. if (Platform.OS === 'ios') {
  60. return (
  61. <HeaderNavigationButton
  62. label = { t('dialog.close') }
  63. onPress = { goBack } />
  64. );
  65. }
  66. return (
  67. <HeaderNavigationButton
  68. onPress = { goBack }
  69. src = { IconClose } />
  70. );
  71. }
  72. /**
  73. * Returns true if we should auto-knock in case prejoin is enabled for the room.
  74. *
  75. * @param {Function|Object} stateful - The redux state or {@link getState}
  76. * function.
  77. * @returns {boolean}
  78. */
  79. export function shouldEnableAutoKnock(stateful: Function | Object) {
  80. const state = toState(stateful);
  81. const { displayName } = state['features/base/settings'];
  82. if (isPrejoinPageEnabled(state)) {
  83. if (displayName) {
  84. return true;
  85. }
  86. } else {
  87. return false;
  88. }
  89. }