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.

UnsafeRoomWarning.tsx 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import React, { useCallback, useLayoutEffect } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { Platform, StyleProp, Text, TextStyle, View, ViewStyle } from 'react-native';
  4. import { useDispatch, useSelector } from 'react-redux';
  5. import { appNavigate } from '../../../app/actions.native';
  6. import { IReduxState } from '../../../app/types';
  7. import { getConferenceName } from '../../../base/conference/functions';
  8. import Icon from '../../../base/icons/components/Icon';
  9. import { IconCloseLarge, IconWarning } from '../../../base/icons/svg';
  10. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  11. import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui/constants';
  12. import Button from '../../../base/ui/components/native/Button';
  13. import { BUTTON_TYPES } from '../../../base/ui/constants.native';
  14. import getUnsafeRoomText from '../../../base/util/getUnsafeRoomText.native';
  15. import HeaderNavigationButton from '../../../mobile/navigation/components/HeaderNavigationButton';
  16. import { navigateRoot } from '../../../mobile/navigation/rootNavigationContainerRef';
  17. import { screen } from '../../../mobile/navigation/routes';
  18. import { IPrejoinProps } from '../../types';
  19. import { preJoinStyles as styles } from './styles';
  20. const UnsafeRoomWarning: React.FC<IPrejoinProps> = ({ navigation }: IPrejoinProps) => {
  21. const dispatch = useDispatch();
  22. const { t } = useTranslation();
  23. const roomName = useSelector((state: IReduxState) => getConferenceName(state));
  24. const aspectRatio = useSelector(
  25. (state: IReduxState) => state['features/base/responsive-ui']?.aspectRatio
  26. );
  27. const unsafeRoomText = useSelector((state: IReduxState) => getUnsafeRoomText(state, t, 'prejoin'));
  28. const goBack = useCallback(() => {
  29. dispatch(appNavigate(undefined));
  30. return true;
  31. }, [ dispatch ]);
  32. const onProceed = useCallback(() => {
  33. navigateRoot(screen.preJoin);
  34. return true;
  35. }, [ dispatch ]);
  36. const headerLeft = () => {
  37. if (Platform.OS === 'ios') {
  38. return (
  39. <HeaderNavigationButton
  40. label = { t('dialog.close') }
  41. onPress = { goBack } />
  42. );
  43. }
  44. return (
  45. <HeaderNavigationButton
  46. onPress = { goBack }
  47. src = { IconCloseLarge } />
  48. );
  49. };
  50. useLayoutEffect(() => {
  51. navigation.setOptions({
  52. headerLeft,
  53. headerTitle: t('prejoin.joinMeeting')
  54. });
  55. }, [ navigation ]);
  56. let unsafeRoomContentContainer;
  57. if (aspectRatio === ASPECT_RATIO_NARROW) {
  58. unsafeRoomContentContainer = styles.unsafeRoomContentContainer;
  59. } else {
  60. unsafeRoomContentContainer = styles.unsafeRoomContentContainerWide;
  61. }
  62. return (
  63. <JitsiScreen
  64. addBottomPadding = { false }
  65. safeAreaInsets = { [ 'right' ] }
  66. style = { styles.unsafeRoomWarningContainer } >
  67. <View style = { styles.displayRoomNameBackdrop as StyleProp<TextStyle> }>
  68. <Text
  69. numberOfLines = { 1 }
  70. style = { styles.preJoinRoomName as StyleProp<TextStyle> }>
  71. { roomName }
  72. </Text>
  73. </View>
  74. <View style = { unsafeRoomContentContainer as StyleProp<ViewStyle> }>
  75. <View style = { styles.warningIconWrapper as StyleProp<ViewStyle> }>
  76. <Icon
  77. src = { IconWarning }
  78. style = { styles.warningIcon } />
  79. </View>
  80. <Text
  81. dataDetectorType = 'link'
  82. style = { styles.warningText as StyleProp<TextStyle> }>
  83. { unsafeRoomText }
  84. </Text>
  85. <Button
  86. accessibilityLabel = 'prejoin.proceedAnyway'
  87. disabled = { false }
  88. labelKey = 'prejoin.proceedAnyway'
  89. onClick = { onProceed }
  90. style = { styles.joinButton }
  91. type = { BUTTON_TYPES.SECONDARY } />
  92. </View>
  93. </JitsiScreen>
  94. );
  95. };
  96. export default UnsafeRoomWarning;