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.

LanguageSelectView.tsx 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { useNavigation } from '@react-navigation/native';
  2. import React, { useCallback, useLayoutEffect } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { ScrollView, Text, TouchableHighlight, View, ViewStyle } from 'react-native';
  5. import { useSelector } from 'react-redux';
  6. import { IReduxState } from '../../../app/types';
  7. import i18next, { DEFAULT_LANGUAGE, LANGUAGES } from '../../../base/i18n/i18next';
  8. import { IconArrowLeft } from '../../../base/icons/svg';
  9. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  10. import BaseThemeNative from '../../../base/ui/components/BaseTheme.native';
  11. import HeaderNavigationButton from '../../../mobile/navigation/components/HeaderNavigationButton';
  12. import { goBack, navigate } from '../../../mobile/navigation/components/settings/SettingsNavigationContainerRef';
  13. import { screen } from '../../../mobile/navigation/routes';
  14. import styles from './styles';
  15. const LanguageSelectView = ({ isInWelcomePage }: { isInWelcomePage?: boolean; }) => {
  16. const { t } = useTranslation();
  17. const navigation = useNavigation();
  18. const { conference } = useSelector((state: IReduxState) => state['features/base/conference']);
  19. const { language: currentLanguage = DEFAULT_LANGUAGE } = i18next;
  20. const setLanguage = useCallback(language => () => {
  21. i18next.changeLanguage(language);
  22. conference?.setTranscriptionLanguage(language);
  23. navigate(screen.settings.main);
  24. }, [ conference, i18next ]);
  25. const headerLeft = () => (
  26. <HeaderNavigationButton
  27. color = { BaseThemeNative.palette.link01 }
  28. onPress = { goBack }
  29. src = { IconArrowLeft }
  30. style = { styles.backBtn }
  31. twoActions = { true } />
  32. );
  33. useLayoutEffect(() => {
  34. navigation.setOptions({
  35. headerLeft
  36. });
  37. }, [ navigation ]);
  38. return (
  39. <JitsiScreen
  40. disableForcedKeyboardDismiss = { true }
  41. // @ts-ignore
  42. safeAreaInsets = { [ !isInWelcomePage && 'bottom', 'left', 'right' ].filter(Boolean) }
  43. style = { styles.settingsViewContainer }>
  44. <ScrollView
  45. bounces = { isInWelcomePage }
  46. contentContainerStyle = { styles.profileView as ViewStyle }>
  47. {
  48. LANGUAGES.map(language => (
  49. <TouchableHighlight
  50. disabled = { currentLanguage === language }
  51. key = { language }
  52. onPress = { setLanguage(language) }>
  53. <View
  54. style = { styles.languageOption as ViewStyle }>
  55. <Text
  56. style = { [
  57. styles.text,
  58. styles.fieldLabelText,
  59. currentLanguage === language && styles.selectedLanguage ] }>
  60. { t(`languages:${language}`) }
  61. </Text>
  62. </View>
  63. </TouchableHighlight>
  64. ))
  65. }
  66. </ScrollView>
  67. </JitsiScreen>
  68. );
  69. };
  70. export default LanguageSelectView;