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.

SettingsView.tsx 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import React from 'react';
  2. import {
  3. ScrollView,
  4. Text,
  5. TextStyle,
  6. TouchableHighlight,
  7. View,
  8. ViewStyle
  9. } from 'react-native';
  10. import { Divider } from 'react-native-paper';
  11. import { Edge } from 'react-native-safe-area-context';
  12. import { useSelector } from 'react-redux';
  13. import { IReduxState } from '../../../app/types';
  14. import Avatar from '../../../base/avatar/components/Avatar';
  15. import Icon from '../../../base/icons/components/Icon';
  16. import { IconArrowRight } from '../../../base/icons/svg';
  17. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  18. import { getLocalParticipant } from '../../../base/participants/functions';
  19. import { navigate } from '../../../mobile/navigation/components/settings/SettingsNavigationContainerRef';
  20. import { screen } from '../../../mobile/navigation/routes';
  21. import { shouldShowModeratorSettings } from '../../functions.native';
  22. import AdvancedSection from './AdvancedSection';
  23. import ConferenceSection from './ConferenceSection';
  24. import GeneralSection from './GeneralSection';
  25. import LinksSection from './LinksSection';
  26. import ModeratorSection from './ModeratorSection';
  27. import NotificationsSection from './NotificationsSection';
  28. import { AVATAR_SIZE } from './constants';
  29. import styles from './styles';
  30. interface IProps {
  31. isInWelcomePage?: boolean | undefined;
  32. }
  33. const SettingsView = ({ isInWelcomePage }: IProps) => {
  34. const { displayName } = useSelector((state: IReduxState) => state['features/base/settings']);
  35. const localParticipant = useSelector((state: IReduxState) => getLocalParticipant(state));
  36. const showModeratorSettings = useSelector((state: IReduxState) => shouldShowModeratorSettings(state));
  37. const { visible } = useSelector((state: IReduxState) => state['features/settings']);
  38. const addBottomInset = !isInWelcomePage;
  39. const localParticipantId = localParticipant?.id;
  40. const scrollBounces = Boolean(isInWelcomePage);
  41. if (visible !== undefined && !visible) {
  42. return null;
  43. }
  44. return (
  45. <JitsiScreen
  46. disableForcedKeyboardDismiss = { true }
  47. safeAreaInsets = { [ addBottomInset && 'bottom', 'left', 'right' ].filter(Boolean) as Edge[] }
  48. style = { styles.settingsViewContainer }>
  49. <ScrollView bounces = { scrollBounces }>
  50. <View style = { styles.profileContainerWrapper as ViewStyle }>
  51. <TouchableHighlight
  52. /* eslint-disable react/jsx-no-bind */
  53. onPress = { () => navigate(screen.settings.profile) }>
  54. <View
  55. style = { styles.profileContainer as ViewStyle }>
  56. <Avatar
  57. participantId = { localParticipantId }
  58. size = { AVATAR_SIZE } />
  59. <Text style = { styles.displayName as TextStyle }>
  60. { displayName }
  61. </Text>
  62. <Icon
  63. size = { 24 }
  64. src = { IconArrowRight }
  65. style = { styles.profileViewArrow } />
  66. </View>
  67. </TouchableHighlight>
  68. </View>
  69. <GeneralSection />
  70. { isInWelcomePage && <>
  71. <Divider style = { styles.fieldSeparator as ViewStyle } />
  72. <ConferenceSection />
  73. </> }
  74. <Divider style = { styles.fieldSeparator as ViewStyle } />
  75. <NotificationsSection />
  76. { showModeratorSettings
  77. && <>
  78. <Divider style = { styles.fieldSeparator as ViewStyle } />
  79. <ModeratorSection />
  80. </> }
  81. <Divider style = { styles.fieldSeparator as ViewStyle } />
  82. <AdvancedSection />
  83. <Divider style = { styles.fieldSeparator as ViewStyle } />
  84. <LinksSection />
  85. </ScrollView>
  86. </JitsiScreen>
  87. );
  88. };
  89. export default SettingsView;