Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

SettingsView.tsx 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import React, { Component } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import {
  4. ScrollView,
  5. Text,
  6. TouchableHighlight,
  7. View,
  8. ViewStyle
  9. } from 'react-native';
  10. import { Divider } from 'react-native-paper';
  11. import { connect } from 'react-redux';
  12. import { IReduxState, IStore } from '../../../app/types';
  13. import Avatar from '../../../base/avatar/components/Avatar';
  14. import { translate } from '../../../base/i18n/functions';
  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. /**
  31. * The type of the React {@code Component} props of
  32. * {@link SettingsView}.
  33. */
  34. interface IProps extends WithTranslation {
  35. _displayName?: string;
  36. /**
  37. * The ID of the local participant.
  38. */
  39. _localParticipantId?: string;
  40. /**
  41. * Flag indicating whether the moderator settings are available.
  42. */
  43. _showModeratorSettings: boolean;
  44. /**
  45. * Whether {@link SettingsView} is visible.
  46. *
  47. * @protected
  48. */
  49. _visible?: boolean;
  50. /**
  51. * Redux store dispatch function.
  52. */
  53. dispatch: IStore['dispatch'];
  54. /**
  55. * Flag indicating whether the settings is launched inside welcome page.
  56. */
  57. isInWelcomePage?: boolean;
  58. /**
  59. * Default prop for navigating between screen components(React Navigation).
  60. */
  61. navigation?: Object;
  62. }
  63. /**
  64. * The native container rendering the app settings page.
  65. */
  66. class SettingsView extends Component<IProps> {
  67. /**
  68. * Opens the profile settings screen.
  69. *
  70. * @returns {void}
  71. */
  72. _onPressProfile() {
  73. navigate(screen.settings.profile);
  74. }
  75. /**
  76. * Implements React's {@link Component#render()}, renders the settings page.
  77. *
  78. * @inheritdoc
  79. * @returns {ReactElement}
  80. */
  81. render() {
  82. const {
  83. _displayName
  84. } = this.props;
  85. const {
  86. isInWelcomePage,
  87. _showModeratorSettings
  88. } = this.props;
  89. const addBottomInset = !isInWelcomePage;
  90. const scrollBounces = Boolean(isInWelcomePage);
  91. return (
  92. <JitsiScreen
  93. disableForcedKeyboardDismiss = { true }
  94. // @ts-ignore
  95. safeAreaInsets = { [ addBottomInset && 'bottom', 'left', 'right' ].filter(Boolean) }
  96. style = { styles.settingsViewContainer }>
  97. <ScrollView bounces = { scrollBounces }>
  98. <View style = { styles.profileContainerWrapper }>
  99. <TouchableHighlight onPress = { this._onPressProfile }>
  100. <View
  101. style = { styles.profileContainer as ViewStyle }>
  102. <Avatar
  103. participantId = { this.props._localParticipantId }
  104. size = { AVATAR_SIZE } />
  105. <Text style = { styles.displayName }>
  106. { _displayName }
  107. </Text>
  108. <Icon
  109. size = { 24 }
  110. src = { IconArrowRight }
  111. style = { styles.profileViewArrow } />
  112. </View>
  113. </TouchableHighlight>
  114. </View>
  115. <GeneralSection />
  116. { isInWelcomePage && <>
  117. {/* @ts-ignore */}
  118. <Divider style = { styles.fieldSeparator } />
  119. <ConferenceSection />
  120. </> }
  121. {/* @ts-ignore */}
  122. <Divider style = { styles.fieldSeparator } />
  123. <NotificationsSection />
  124. { _showModeratorSettings
  125. && <>
  126. {/* @ts-ignore */}
  127. <Divider style = { styles.fieldSeparator } />
  128. <ModeratorSection />
  129. </> }
  130. {/* @ts-ignore */}
  131. <Divider style = { styles.fieldSeparator } />
  132. <AdvancedSection />
  133. {/* @ts-ignore */}
  134. <Divider style = { styles.fieldSeparator } />
  135. <LinksSection />
  136. </ScrollView>
  137. </JitsiScreen>
  138. );
  139. }
  140. }
  141. /**
  142. * Maps part of the Redux state to the props of this component.
  143. *
  144. * @param {Object} state - The Redux state.
  145. * @returns {IProps}
  146. */
  147. function _mapStateToProps(state: IReduxState) {
  148. const localParticipant = getLocalParticipant(state);
  149. return {
  150. _localParticipantId: localParticipant?.id,
  151. _displayName: state['features/base/settings'].displayName,
  152. _visible: state['features/settings'].visible,
  153. _showModeratorSettings: shouldShowModeratorSettings(state)
  154. };
  155. }
  156. export default translate(connect(_mapStateToProps)(SettingsView));