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.

WelcomePageSideBar.native.js 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { SafeAreaView, ScrollView, Text } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import {
  6. Avatar,
  7. getAvatarURL,
  8. getLocalParticipant,
  9. getParticipantDisplayName
  10. } from '../../base/participants';
  11. import {
  12. Header,
  13. SideBar
  14. } from '../../base/react';
  15. import { setSettingsViewVisible } from '../../settings';
  16. import { setSideBarVisible } from '../actions';
  17. import SideBarItem from './SideBarItem';
  18. import styles from './styles';
  19. /**
  20. * The URL at which the privacy policy is available to the user.
  21. */
  22. const PRIVACY_URL = 'https://jitsi.org/meet/privacy';
  23. /**
  24. * The URL at which the user may send feedback.
  25. */
  26. const SEND_FEEDBACK_URL = 'mailto:support@jitsi.org';
  27. /**
  28. * The URL at which the terms (of service/use) are available to the user.
  29. */
  30. const TERMS_URL = 'https://jitsi.org/meet/terms';
  31. type Props = {
  32. /**
  33. * Redux dispatch action
  34. */
  35. dispatch: Function,
  36. /**
  37. * The avatar URL to be rendered.
  38. */
  39. _avatar: string,
  40. /**
  41. * Display name of the local participant.
  42. */
  43. _displayName: string,
  44. /**
  45. * Sets the side bar visible or hidden.
  46. */
  47. _visible: boolean
  48. };
  49. /**
  50. * A component rendering a welcome page sidebar.
  51. */
  52. class WelcomePageSideBar extends Component<Props> {
  53. /**
  54. * Constructs a new SideBar instance.
  55. *
  56. * @inheritdoc
  57. */
  58. constructor(props) {
  59. super(props);
  60. // Bind event handlers so they are only bound once per instance.
  61. this._onHideSideBar = this._onHideSideBar.bind(this);
  62. this._onOpenSettings = this._onOpenSettings.bind(this);
  63. }
  64. /**
  65. * Implements React's {@link Component#render()}, renders the sidebar.
  66. *
  67. * @inheritdoc
  68. * @returns {ReactElement}
  69. */
  70. render() {
  71. return (
  72. <SideBar
  73. onHide = { this._onHideSideBar }
  74. show = { this.props._visible }>
  75. <Header style = { styles.sideBarHeader }>
  76. <Avatar
  77. style = { styles.avatar }
  78. uri = { this.props._avatar } />
  79. <Text style = { styles.displayName }>
  80. { this.props._displayName }
  81. </Text>
  82. </Header>
  83. <SafeAreaView style = { styles.sideBarBody }>
  84. <ScrollView
  85. style = { styles.itemContainer }>
  86. <SideBarItem
  87. i18Label = 'settings.title'
  88. icon = 'settings'
  89. onPress = { this._onOpenSettings } />
  90. <SideBarItem
  91. i18Label = 'welcomepage.terms'
  92. icon = 'info'
  93. url = { TERMS_URL } />
  94. <SideBarItem
  95. i18Label = 'welcomepage.privacy'
  96. icon = 'info'
  97. url = { PRIVACY_URL } />
  98. <SideBarItem
  99. i18Label = 'welcomepage.sendFeedback'
  100. icon = 'info'
  101. url = { SEND_FEEDBACK_URL } />
  102. </ScrollView>
  103. </SafeAreaView>
  104. </SideBar>
  105. );
  106. }
  107. _onHideSideBar: () => void;
  108. /**
  109. * Invoked when the sidebar has closed itself (e.g. overlay pressed).
  110. *
  111. * @private
  112. * @returns {void}
  113. */
  114. _onHideSideBar() {
  115. this.props.dispatch(setSideBarVisible(false));
  116. }
  117. _onOpenSettings: () => void;
  118. /**
  119. * Shows the {@link SettingsView}.
  120. *
  121. * @private
  122. * @returns {void}
  123. */
  124. _onOpenSettings() {
  125. const { dispatch } = this.props;
  126. dispatch(setSideBarVisible(false));
  127. dispatch(setSettingsViewVisible(true));
  128. }
  129. }
  130. /**
  131. * Maps (parts of) the redux state to the React {@code Component} props.
  132. *
  133. * @param {Object} state - The redux state.
  134. * @protected
  135. * @returns {Object}
  136. */
  137. function _mapStateToProps(state: Object) {
  138. const _localParticipant = getLocalParticipant(state);
  139. return {
  140. _avatar: getAvatarURL(_localParticipant),
  141. _displayName: getParticipantDisplayName(state, _localParticipant.id),
  142. _visible: state['features/welcome'].sideBarVisible
  143. };
  144. }
  145. export default connect(_mapStateToProps)(WelcomePageSideBar);