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.

MobileBrowserPage.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import { Platform } from '../../base/react';
  4. import { appNavigate } from '../../app';
  5. import { mobileBrowserPageIsShown } from '../actions';
  6. /**
  7. * The map of platforms to URLs at which the mobile app for the associated
  8. * platform is available for download.
  9. */
  10. const URLS = {
  11. android: 'https://play.google.com/store/apps/details?id=org.jitsi.meet',
  12. ios: 'https://itunes.apple.com/us/app/jitsi-meet/id1165103905'
  13. };
  14. /**
  15. * React component representing mobile browser page.
  16. *
  17. * @class MobileBrowserPage
  18. */
  19. class MobileBrowserPage extends Component {
  20. /**
  21. * Constructor of MobileBrowserPage component.
  22. *
  23. * @param {Object} props - The read-only React Component props with which
  24. * the new instance is to be initialized.
  25. */
  26. constructor(props) {
  27. super(props);
  28. // Bind methods
  29. this._onClickJoin = this._onClickJoin.bind(this);
  30. }
  31. /**
  32. * Mobile browser page component's property types.
  33. *
  34. * @static
  35. */
  36. static propTypes = {
  37. dispatch: React.PropTypes.func,
  38. room: React.PropTypes.string
  39. };
  40. /**
  41. * React lifecycle method triggered after component is mounted.
  42. *
  43. * @returns {void}
  44. */
  45. componentDidMount() {
  46. this.props.dispatch(mobileBrowserPageIsShown());
  47. }
  48. /**
  49. * React lifecycle method triggered before component will mount.
  50. *
  51. * @returns {void}
  52. */
  53. componentWillMount() {
  54. const { room } = this.props;
  55. let btnText;
  56. let link = '';
  57. if (room) {
  58. btnText = 'Join the conversation';
  59. link += room;
  60. } else {
  61. btnText = 'Start a conference';
  62. }
  63. this.setState({
  64. btnText,
  65. link
  66. });
  67. }
  68. /**
  69. * Navigates to the next state of the app.
  70. *
  71. * @returns {void}
  72. * @private
  73. */
  74. _onClickJoin() {
  75. const { link } = this.state;
  76. this.props.dispatch(appNavigate(link));
  77. }
  78. /**
  79. * Renders component.
  80. *
  81. * @returns {ReactElement}
  82. */
  83. render() {
  84. const { btnText } = this.state;
  85. const blockPrefix = 'mobile-browser-page';
  86. const textClasses = `${blockPrefix}__text ${blockPrefix}__text_small`;
  87. let primaryButtonClasses = `${blockPrefix}__button`;
  88. primaryButtonClasses += `${blockPrefix}__button_primary`;
  89. return (
  90. <div className = { blockPrefix }>
  91. <div className = { `${blockPrefix}__body` }>
  92. <img
  93. className = { `${blockPrefix}__logo` }
  94. src = '/images/logo-blue.svg' />
  95. <p className = { `${blockPrefix}__text` }>
  96. You need <strong>Jitsi Meet</strong> to join a
  97. conversation on your mobile
  98. </p>
  99. <a href = { URLS[Platform.OS] }>
  100. <button className = { primaryButtonClasses }>
  101. Download the App
  102. </button>
  103. </a>
  104. <p className = { textClasses }>
  105. or if you already have it
  106. <br />
  107. <strong>then</strong>
  108. </p>
  109. <button
  110. className = 'mobile-browser-page__button'
  111. onClick = { this._onClickJoin }>
  112. { btnText }
  113. </button>
  114. </div>
  115. </div>
  116. );
  117. }
  118. }
  119. /**
  120. * Maps (parts of) the Redux state to the associated MobileBrowserPage's props.
  121. *
  122. * @param {Object} state - Redux state.
  123. * @returns {{
  124. * room: string
  125. * }}
  126. */
  127. function mapStateToProps(state) {
  128. return {
  129. room: state['features/base/conference'].room
  130. };
  131. }
  132. export default connect(mapStateToProps)(MobileBrowserPage);