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.

GeneralSection.tsx 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { Text, TouchableHighlight, View, ViewStyle } from 'react-native';
  4. import { useDispatch, useSelector } from 'react-redux';
  5. import { IReduxState } from '../../../app/types';
  6. import i18next, { DEFAULT_LANGUAGE } from '../../../base/i18n/i18next';
  7. import Icon from '../../../base/icons/components/Icon';
  8. import { IconArrowRight } from '../../../base/icons/svg';
  9. import { updateSettings } from '../../../base/settings/actions';
  10. import Switch from '../../../base/ui/components/native/Switch';
  11. import { navigate } from '../../../mobile/navigation/components/settings/SettingsNavigationContainerRef';
  12. import { screen } from '../../../mobile/navigation/routes';
  13. import { isPrejoinEnabledInConfig } from '../../../prejoin/functions';
  14. import FormRow from './FormRow';
  15. import FormSection from './FormSection';
  16. import styles from './styles';
  17. const GeneralSection = () => {
  18. const { t } = useTranslation();
  19. const dispatch = useDispatch();
  20. const {
  21. disableSelfView,
  22. userSelectedSkipPrejoin
  23. } = useSelector((state: IReduxState) => state['features/base/settings']);
  24. const showPrejoinPage = !userSelectedSkipPrejoin;
  25. let showPrejoinSettings = useSelector(isPrejoinEnabledInConfig);
  26. const { language = DEFAULT_LANGUAGE } = i18next;
  27. const onSelfViewToggled = useCallback((enabled?: boolean) =>
  28. dispatch(updateSettings({ disableSelfView: enabled }))
  29. , [ dispatch, updateSettings ]);
  30. const onShowPejoinToggled = useCallback((enabled?: boolean) => {
  31. dispatch(updateSettings({ userSelectedSkipPrejoin: !enabled }));
  32. }
  33. , [ dispatch, updateSettings ]);
  34. const navigateToLanguageSelect = useCallback(() => {
  35. navigate(screen.settings.language);
  36. }, [ navigate, screen ]);
  37. // TODO:
  38. // Delete this line when prejoin skipping is available on mobile
  39. showPrejoinSettings = false;
  40. return (
  41. <FormSection>
  42. <FormRow label = 'videothumbnail.hideSelfView'>
  43. <Switch
  44. checked = { Boolean(disableSelfView) }
  45. onChange = { onSelfViewToggled } />
  46. </FormRow>
  47. {showPrejoinSettings && <FormRow label = 'prejoin.showScreen'>
  48. <Switch
  49. checked = { showPrejoinPage }
  50. onChange = { onShowPejoinToggled } />
  51. </FormRow>}
  52. <FormRow label = 'settings.language'>
  53. <View style = { styles.languageButtonContainer as ViewStyle }>
  54. <TouchableHighlight onPress = { navigateToLanguageSelect }>
  55. <View style = { styles.languageButton as ViewStyle }>
  56. <Text
  57. style = { styles.languageText }>{t(`languages:${language}`)}</Text>
  58. <Icon
  59. size = { 24 }
  60. src = { IconArrowRight } />
  61. </View>
  62. </TouchableHighlight>
  63. </View>
  64. </FormRow>
  65. </FormSection>
  66. );
  67. };
  68. export default GeneralSection;