Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

LanguageSelectView.tsx 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { ScrollView, Text, TouchableHighlight, View, ViewStyle } from 'react-native';
  4. import i18next, { DEFAULT_LANGUAGE, LANGUAGES } from '../../../base/i18n/i18next';
  5. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  6. import { navigate } from '../../../mobile/navigation/components/settings/SettingsNavigationContainerRef';
  7. import { screen } from '../../../mobile/navigation/routes';
  8. import styles from './styles';
  9. const LanguageSelectView = ({ isInWelcomePage }: { isInWelcomePage?: boolean; }) => {
  10. const { t } = useTranslation();
  11. const { language: currentLanguage = DEFAULT_LANGUAGE } = i18next;
  12. const setLanguage = useCallback(language => () => {
  13. i18next.changeLanguage(language);
  14. navigate(screen.settings.main);
  15. }, [ i18next ]);
  16. return (
  17. <JitsiScreen
  18. disableForcedKeyboardDismiss = { true }
  19. // @ts-ignore
  20. safeAreaInsets = { [ !isInWelcomePage && 'bottom', 'left', 'right' ].filter(Boolean) }
  21. style = { styles.settingsViewContainer }>
  22. <ScrollView
  23. bounces = { isInWelcomePage }
  24. contentContainerStyle = { styles.profileView as ViewStyle }>
  25. {
  26. LANGUAGES.map(language => (
  27. <TouchableHighlight
  28. disabled = { currentLanguage === language }
  29. key = { language }
  30. onPress = { setLanguage(language) }>
  31. <View
  32. style = { styles.languageOption as ViewStyle }>
  33. <Text
  34. style = { [
  35. styles.text,
  36. styles.fieldLabelText,
  37. currentLanguage === language && styles.selectedLanguage ] }>
  38. { t(`languages:${language}`) }
  39. </Text>
  40. </View>
  41. </TouchableHighlight>
  42. ))
  43. }
  44. </ScrollView>
  45. </JitsiScreen>
  46. );
  47. };
  48. export default LanguageSelectView;