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 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. onSubmitEditing = { this._onJoin }
  71. placeholder = { t('welcomepage.roomname') }
  72. placeholderTextColor = { PLACEHOLDER_TEXT_COLOR }
  73. returnKeyType = { 'go' }
  74. style = { styles.textInput }
  75. underlineColorAndroid = 'transparent'
  76. value = { this.state.room } />
  77. <View style = { styles.buttonRow }>
  78. <TouchableHighlight
  79. accessibilityLabel = { 'Tap for Settings.' }
  80. onPress = { this._onSettingsOpen }
  81. style = { [ styles.button, styles.settingsButton ] }
  82. underlayColor = { ColorPalette.white }>
  83. <Icon
  84. name = 'settings'
  85. style = { styles.settingsIcon } />
  86. </TouchableHighlight>
  87. {
  88. this._renderJoinButton()
  89. }
  90. </View>
  91. <RecentList />
  92. </View>
  93. <AppSettings />
  94. {
  95. this._renderLegalese()
  96. }
  97. </LocalVideoTrackUnderlay>
  98. );
  99. }
  100. /**
  101. * Renders the join button.
  102. *
  103. * @private
  104. * @returns {ReactElement}
  105. */
  106. _renderJoinButton() {
  107. let children;
  108. /* eslint-disable no-extra-parens */
  109. if (this.state.joining) {
  110. // TouchableHighlight is picky about what its children can be, so
  111. // wrap it in a native component, i.e. View to avoid having to
  112. // modify non-native children.
  113. children = (
  114. <View>
  115. <LoadingIndicator color = { styles.buttonText.color } />
  116. </View>
  117. );
  118. } else {
  119. children = (
  120. <Text style = { styles.buttonText }>
  121. { this.props.t('welcomepage.join') }
  122. </Text>
  123. );
  124. }
  125. /* eslint-enable no-extra-parens */
  126. return (
  127. <TouchableHighlight
  128. accessibilityLabel = { 'Tap to Join.' }
  129. disabled = { this._isJoinDisabled() }
  130. onPress = { this._onJoin }
  131. style = { [ styles.button, styles.joinButton ] }
  132. underlayColor = { ColorPalette.white }>
  133. {
  134. children
  135. }
  136. </TouchableHighlight>
  137. );
  138. }
  139. /**
  140. * Renders legal-related content such as Terms of service/use, Privacy
  141. * policy, etc.
  142. *
  143. * @private
  144. * @returns {ReactElement}
  145. */
  146. _renderLegalese() {
  147. const { t } = this.props;
  148. return (
  149. <View style = { styles.legaleseContainer }>
  150. <Link
  151. style = { styles.legaleseItem }
  152. url = { TERMS_URL }>
  153. { t('welcomepage.terms') }
  154. </Link>
  155. <Link
  156. style = { styles.legaleseItem }
  157. url = { PRIVACY_URL }>
  158. { t('welcomepage.privacy') }
  159. </Link>
  160. <Link
  161. style = { styles.legaleseItem }
  162. url = { SEND_FEEDBACK_URL }>
  163. { t('welcomepage.sendFeedback') }
  164. </Link>
  165. </View>
  166. );
  167. }
  168. }
  169. export default translate(connect(_mapStateToProps)(WelcomePage));