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.

AppSettings.native.js 5.1KB

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