Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

SettingsView.tsx 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. _urlField: Object;
  68. /**
  69. * Opens the profile settings screen.
  70. *
  71. * @returns {void}
  72. */
  73. _onPressProfile() {
  74. navigate(screen.settings.profile);
  75. }
  76. /**
  77. * Implements React's {@link Component#render()}, renders the settings page.
  78. *
  79. * @inheritdoc
  80. * @returns {ReactElement}
  81. */
  82. render() {
  83. const {
  84. _displayName
  85. } = this.props;
  86. const {
  87. isInWelcomePage,
  88. _showModeratorSettings
  89. } = this.props;
  90. const addBottomInset = !isInWelcomePage;
  91. const scrollBounces = Boolean(isInWelcomePage);
  92. return (
  93. <JitsiScreen
  94. disableForcedKeyboardDismiss = { true }
  95. // @ts-ignore
  96. safeAreaInsets = { [ addBottomInset && 'bottom', 'left', 'right' ].filter(Boolean) }
  97. style = { styles.settingsViewContainer }>
  98. <ScrollView bounces = { scrollBounces }>
  99. <View style = { styles.profileContainerWrapper }>
  100. <TouchableHighlight onPress = { this._onPressProfile }>
  101. <View
  102. style = { styles.profileContainer as ViewStyle }>
  103. <Avatar
  104. participantId = { this.props._localParticipantId }
  105. size = { AVATAR_SIZE } />
  106. <Text style = { styles.displayName }>
  107. { _displayName }
  108. </Text>
  109. <Icon
  110. size = { 24 }
  111. src = { IconArrowRight }
  112. style = { styles.profileViewArrow } />
  113. </View>
  114. </TouchableHighlight>
  115. </View>
  116. <GeneralSection />
  117. { isInWelcomePage && <>
  118. {/* @ts-ignore */}
  119. <Divider style = { styles.fieldSeparator } />
  120. <ConferenceSection />
  121. </> }
  122. {/* @ts-ignore */}
  123. <Divider style = { styles.fieldSeparator } />
  124. <NotificationsSection />
  125. { _showModeratorSettings
  126. && <>
  127. {/* @ts-ignore */}
  128. <Divider style = { styles.fieldSeparator } />
  129. <ModeratorSection />
  130. </> }
  131. {/* @ts-ignore */}
  132. <Divider style = { styles.fieldSeparator } />
  133. <AdvancedSection />
  134. {/* @ts-ignore */}
  135. <Divider style = { styles.fieldSeparator } />
  136. <LinksSection />
  137. </ScrollView>
  138. </JitsiScreen>
  139. );
  140. }
  141. }
  142. /**
  143. * Maps part of the Redux state to the props of this component.
  144. *
  145. * @param {Object} state - The Redux state.
  146. * @returns {IProps}
  147. */
  148. function _mapStateToProps(state: IReduxState) {
  149. const localParticipant = getLocalParticipant(state);
  150. return {
  151. _localParticipantId: localParticipant?.id,
  152. _displayName: state['features/base/settings'].displayName,
  153. _visible: state['features/settings'].visible,
  154. _showModeratorSettings: shouldShowModeratorSettings(state)
  155. };
  156. }
  157. export default translate(connect(_mapStateToProps)(SettingsView));