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

BlankPage.native.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* @flow */
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { ActivityIndicator, View } from 'react-native';
  5. import { connect } from 'react-redux';
  6. import { destroyLocalTracks } from '../../base/tracks';
  7. import { isWelcomePageAppEnabled } from '../functions';
  8. import styles from './styles';
  9. /**
  10. * The React <tt>Component</tt> displayed by <tt>AbstractApp</tt> when it has no
  11. * <tt>Route</tt> to render. Renders a progress indicator when there are ongoing
  12. * network requests.
  13. */
  14. class BlankPage extends Component {
  15. /**
  16. * <tt>BlankPage</tt> React <tt>Component</tt>'s prop types.
  17. *
  18. * @static
  19. */
  20. static propTypes = {
  21. /**
  22. * Indicates whether there is network activity i.e. ongoing network
  23. * requests.
  24. *
  25. * @private
  26. */
  27. _networkActivity: PropTypes.bool,
  28. /**
  29. * The indicator which determines whether <tt>WelcomePage</tt> is (to
  30. * be) rendered.
  31. *
  32. * @private
  33. */
  34. _welcomePageEnabled: PropTypes.bool,
  35. dispatch: PropTypes.func
  36. };
  37. /**
  38. * Destroys the local tracks (if any) since no media is desired when this
  39. * component is rendered.
  40. *
  41. * @inheritdoc
  42. * @returns {void}
  43. */
  44. componentWillMount() {
  45. this.props._welcomePageEnabled
  46. || this.props.dispatch(destroyLocalTracks());
  47. }
  48. /**
  49. * Implements React's {@link Component#render()}.
  50. *
  51. * @inheritdoc
  52. * @override
  53. * @returns {ReactElement}
  54. */
  55. render() {
  56. return (
  57. <View style = { styles.blankPage }>
  58. <ActivityIndicator
  59. animating = { this.props._networkActivity }
  60. size = { 'large' } />
  61. </View>
  62. );
  63. }
  64. }
  65. /**
  66. * Maps (parts of) the redux state to the React <tt>Component</tt> props of
  67. * <tt>BlankPage</tt>.
  68. *
  69. * @param {Object} state - The redux state.
  70. * @private
  71. * @returns {{
  72. * _networkActivity: boolean,
  73. * _welcomePageEnabled: boolean
  74. * }}
  75. */
  76. function _mapStateToProps(state) {
  77. const { requests } = state['features/network-activity'];
  78. return {
  79. _networkActivity:
  80. Boolean(requests && (requests.length || requests.size)),
  81. _welcomePageEnabled: isWelcomePageAppEnabled(state)
  82. };
  83. }
  84. export default connect(_mapStateToProps)(BlankPage);