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.1KB

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