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

AppSettings.native.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import React from 'react';
  2. import {
  3. Modal,
  4. ScrollView,
  5. Switch,
  6. Text,
  7. TextInput,
  8. View
  9. } from 'react-native';
  10. import { connect } from 'react-redux';
  11. import { ASPECT_RATIO_NARROW } from '../../base/aspect-ratio';
  12. import { translate } from '../../base/i18n';
  13. import { isIPad } from '../../base/react';
  14. import { _mapStateToProps, AbstractAppSettings } from './AbstractAppSettings';
  15. import BackButton from './BackButton';
  16. import FormRow from './FormRow';
  17. import FormSectionHeader from './FormSectionHeader';
  18. import { getSafetyOffset } from '../functions';
  19. import styles, { HEADER_PADDING } from './styles';
  20. /**
  21. * The native container rendering the app settings page.
  22. *
  23. * @extends AbstractAppSettings
  24. */
  25. class AppSettings extends AbstractAppSettings {
  26. /**
  27. * Instantiates a new {@code AppSettings} instance.
  28. *
  29. * @inheritdoc
  30. */
  31. constructor(props) {
  32. super(props);
  33. this._getSafetyPadding = this._getSafetyPadding.bind(this);
  34. }
  35. /**
  36. * Implements React's {@link Component#render()}, renders the settings page.
  37. *
  38. * @inheritdoc
  39. * @returns {ReactElement}
  40. */
  41. render() {
  42. const { _profile, t } = this.props;
  43. // FIXME: presentationStyle is added to workaround orientation issue on
  44. // iOS
  45. return (
  46. <Modal
  47. animationType = 'slide'
  48. onRequestClose = { this._onRequestClose }
  49. presentationStyle = 'overFullScreen'
  50. supportedOrientations = { [
  51. 'landscape',
  52. 'portrait'
  53. ] }
  54. visible = { this.props._visible }>
  55. <View
  56. style = { [
  57. styles.headerContainer,
  58. this._getSafetyPadding()
  59. ] } >
  60. <BackButton
  61. onPress = { this._onRequestClose }
  62. style = { styles.settingsBackButton } />
  63. <Text style = { [ styles.text, styles.headerTitle ] } >
  64. { t('profileModal.header') }
  65. </Text>
  66. </View>
  67. <ScrollView style = { styles.settingsContainer } >
  68. <FormSectionHeader
  69. i18nLabel = 'profileModal.profileSection' />
  70. <FormRow
  71. fieldSeparator = { true }
  72. i18nLabel = 'profileModal.displayName' >
  73. <TextInput
  74. onChangeText = { this._onChangeDisplayName }
  75. placeholder = 'John Doe'
  76. value = { _profile.displayName } />
  77. </FormRow>
  78. <FormRow
  79. i18nLabel = 'profileModal.email' >
  80. <TextInput
  81. keyboardType = { 'email-address' }
  82. onChangeText = { this._onChangeEmail }
  83. placeholder = 'email@example.com'
  84. value = { _profile.email } />
  85. </FormRow>
  86. <FormSectionHeader
  87. i18nLabel = 'profileModal.conferenceSection' />
  88. <FormRow
  89. fieldSeparator = { true }
  90. i18nLabel = 'profileModal.serverURL' >
  91. <TextInput
  92. autoCapitalize = 'none'
  93. onChangeText = { this._onChangeServerURL }
  94. placeholder = { this.props._serverURL }
  95. value = { _profile.serverURL } />
  96. </FormRow>
  97. <FormRow
  98. fieldSeparator = { true }
  99. i18nLabel = 'profileModal.startWithAudioMuted' >
  100. <Switch
  101. onValueChange = {
  102. this._onStartAudioMutedChange
  103. }
  104. value = {
  105. _profile.startWithAudioMuted
  106. } />
  107. </FormRow>
  108. <FormRow
  109. i18nLabel = 'profileModal.startWithVideoMuted' >
  110. <Switch
  111. onValueChange = {
  112. this._onStartVideoMutedChange
  113. }
  114. value = {
  115. _profile.startWithVideoMuted
  116. } />
  117. </FormRow>
  118. </ScrollView>
  119. </Modal>
  120. );
  121. }
  122. /**
  123. * Calculates header safety padding for mobile devices. See comment in
  124. * functions.js.
  125. *
  126. * @private
  127. * @returns {Object}
  128. */
  129. _getSafetyPadding() {
  130. if (isIPad() || this.props._aspectRatio === ASPECT_RATIO_NARROW) {
  131. const safeOffset = Math.max(getSafetyOffset(), HEADER_PADDING);
  132. return {
  133. paddingTop: safeOffset
  134. };
  135. }
  136. return undefined;
  137. }
  138. }
  139. export default translate(connect(_mapStateToProps)(AppSettings));