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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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, { SIDEBAR_AVATAR_SIZE } 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. _avatarURL: 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. size = { SIDEBAR_AVATAR_SIZE }
  78. style = { styles.avatar }
  79. uri = { this.props._avatarURL } />
  80. <Text style = { styles.displayName }>
  81. { this.props._displayName }
  82. </Text>
  83. </Header>
  84. <SafeAreaView style = { styles.sideBarBody }>
  85. <ScrollView
  86. style = { styles.itemContainer }>
  87. <SideBarItem
  88. icon = 'settings'
  89. label = 'settings.title'
  90. onPress = { this._onOpenSettings } />
  91. <SideBarItem
  92. icon = 'info'
  93. label = 'welcomepage.terms'
  94. url = { TERMS_URL } />
  95. <SideBarItem
  96. icon = 'info'
  97. label = 'welcomepage.privacy'
  98. url = { PRIVACY_URL } />
  99. <SideBarItem
  100. icon = 'info'
  101. label = 'welcomepage.sendFeedback'
  102. url = { SEND_FEEDBACK_URL } />
  103. </ScrollView>
  104. </SafeAreaView>
  105. </SideBar>
  106. );
  107. }
  108. _onHideSideBar: () => void;
  109. /**
  110. * Invoked when the sidebar has closed itself (e.g. overlay pressed).
  111. *
  112. * @private
  113. * @returns {void}
  114. */
  115. _onHideSideBar() {
  116. this.props.dispatch(setSideBarVisible(false));
  117. }
  118. _onOpenSettings: () => void;
  119. /**
  120. * Shows the {@link SettingsView}.
  121. *
  122. * @private
  123. * @returns {void}
  124. */
  125. _onOpenSettings() {
  126. const { dispatch } = this.props;
  127. dispatch(setSideBarVisible(false));
  128. dispatch(setSettingsViewVisible(true));
  129. }
  130. }
  131. /**
  132. * Maps (parts of) the redux state to the React {@code Component} props.
  133. *
  134. * @param {Object} state - The redux state.
  135. * @protected
  136. * @returns {{
  137. * _avatarURL: string,
  138. * _displayName: string,
  139. * _visible: boolean
  140. * }}
  141. */
  142. function _mapStateToProps(state: Object) {
  143. const localParticipant = getLocalParticipant(state);
  144. return {
  145. _avatarURL: getAvatarURL(localParticipant),
  146. _displayName: getParticipantDisplayName(state, localParticipant.id),
  147. _visible: state['features/welcome'].sideBarVisible
  148. };
  149. }
  150. export default connect(_mapStateToProps)(WelcomePageSideBar);