您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LanguageSelectView.tsx 3.0KB

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