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

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