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.

WelcomePage.native.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import React from 'react';
  2. import { TextInput, TouchableHighlight, View } from 'react-native';
  3. import { connect } from 'react-redux';
  4. import { AppSettings } from '../../app-settings';
  5. import { Icon } from '../../base/font-icons';
  6. import { translate } from '../../base/i18n';
  7. import { MEDIA_TYPE } from '../../base/media';
  8. import { Link, LoadingIndicator, Text } from '../../base/react';
  9. import { ColorPalette } from '../../base/styles';
  10. import { createDesiredLocalTracks } from '../../base/tracks';
  11. import { RecentList } from '../../recent-list';
  12. import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
  13. import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
  14. import styles, { PLACEHOLDER_TEXT_COLOR } from './styles';
  15. /**
  16. * The URL at which the privacy policy is available to the user.
  17. */
  18. const PRIVACY_URL = 'https://jitsi.org/meet/privacy';
  19. /**
  20. * The URL at which the user may send feedback.
  21. */
  22. const SEND_FEEDBACK_URL = 'mailto:support@jitsi.org';
  23. /**
  24. * The URL at which the terms (of service/use) are available to the user.
  25. */
  26. const TERMS_URL = 'https://jitsi.org/meet/terms';
  27. /**
  28. * The native container rendering the welcome page.
  29. *
  30. * @extends AbstractWelcomePage
  31. */
  32. class WelcomePage extends AbstractWelcomePage {
  33. /**
  34. * WelcomePage component's property types.
  35. *
  36. * @static
  37. */
  38. static propTypes = AbstractWelcomePage.propTypes;
  39. /**
  40. * Implements React's {@link Component#componentWillMount()}. Invoked
  41. * immediately before mounting occurs. Creates a local video track if none
  42. * is available.
  43. *
  44. * @inheritdoc
  45. * @returns {void}
  46. */
  47. componentWillMount() {
  48. super.componentWillMount();
  49. this.props.dispatch(createDesiredLocalTracks(MEDIA_TYPE.VIDEO));
  50. }
  51. /**
  52. * Implements React's {@link Component#render()}. Renders a prompt for
  53. * entering a room name.
  54. *
  55. * @inheritdoc
  56. * @returns {ReactElement}
  57. */
  58. render() {
  59. const { t } = this.props;
  60. return (
  61. <LocalVideoTrackUnderlay style = { styles.welcomePage }>
  62. <View style = { styles.roomContainer }>
  63. <TextInput
  64. accessibilityLabel = { 'Input room name.' }
  65. autoCapitalize = 'none'
  66. autoComplete = { false }
  67. autoCorrect = { false }
  68. autoFocus = { false }
  69. onChangeText = { this._onRoomChange }
  70. placeholder = { t('welcomepage.roomname') }
  71. placeholderTextColor = { PLACEHOLDER_TEXT_COLOR }
  72. style = { styles.textInput }
  73. underlineColorAndroid = 'transparent'
  74. value = { this.state.room } />
  75. <View style = { styles.buttonRow }>
  76. <TouchableHighlight
  77. accessibilityLabel = { 'Tap for Settings.' }
  78. onPress = { this._onSettingsOpen }
  79. style = { [ styles.button, styles.settingsButton ] }
  80. underlayColor = { ColorPalette.white }>
  81. <Icon
  82. name = 'settings'
  83. style = { styles.settingsIcon } />
  84. </TouchableHighlight>
  85. {
  86. this._renderJoinButton()
  87. }
  88. </View>
  89. <RecentList />
  90. </View>
  91. <AppSettings />
  92. {
  93. this._renderLegalese()
  94. }
  95. </LocalVideoTrackUnderlay>
  96. );
  97. }
  98. /**
  99. * Renders the join button.
  100. *
  101. * @private
  102. * @returns {ReactElement}
  103. */
  104. _renderJoinButton() {
  105. let children;
  106. /* eslint-disable no-extra-parens */
  107. if (this.state.joining) {
  108. // TouchableHighlight is picky about what its children can be, so
  109. // wrap it in a native component, i.e. View to avoid having to
  110. // modify non-native children.
  111. children = (
  112. <View>
  113. <LoadingIndicator color = { styles.buttonText.color } />
  114. </View>
  115. );
  116. } else {
  117. children = (
  118. <Text style = { styles.buttonText }>
  119. { this.props.t('welcomepage.join') }
  120. </Text>
  121. );
  122. }
  123. /* eslint-enable no-extra-parens */
  124. return (
  125. <TouchableHighlight
  126. accessibilityLabel = { 'Tap to Join.' }
  127. disabled = { this._isJoinDisabled() }
  128. onPress = { this._onJoin }
  129. style = { [ styles.button, styles.joinButton ] }
  130. underlayColor = { ColorPalette.white }>
  131. {
  132. children
  133. }
  134. </TouchableHighlight>
  135. );
  136. }
  137. /**
  138. * Renders legal-related content such as Terms of service/use, Privacy
  139. * policy, etc.
  140. *
  141. * @private
  142. * @returns {ReactElement}
  143. */
  144. _renderLegalese() {
  145. const { t } = this.props;
  146. return (
  147. <View style = { styles.legaleseContainer }>
  148. <Link
  149. style = { styles.legaleseItem }
  150. url = { TERMS_URL }>
  151. { t('welcomepage.terms') }
  152. </Link>
  153. <Link
  154. style = { styles.legaleseItem }
  155. url = { PRIVACY_URL }>
  156. { t('welcomepage.privacy') }
  157. </Link>
  158. <Link
  159. style = { styles.legaleseItem }
  160. url = { SEND_FEEDBACK_URL }>
  161. { t('welcomepage.sendFeedback') }
  162. </Link>
  163. </View>
  164. );
  165. }
  166. }
  167. export default translate(connect(_mapStateToProps)(WelcomePage));