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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { SafeAreaView, ScrollView, Text } from 'react-native';
  4. import { Avatar } from '../../base/avatar';
  5. import { IconInfo, IconSettings, IconHelp } from '../../base/icons';
  6. import { setActiveModalId } from '../../base/modal';
  7. import {
  8. getLocalParticipant,
  9. getParticipantDisplayName
  10. } from '../../base/participants';
  11. import {
  12. Header,
  13. SlidingView
  14. } from '../../base/react';
  15. import { connect } from '../../base/redux';
  16. import { HELP_VIEW_MODAL_ID } from '../../help';
  17. import { SETTINGS_VIEW_ID } from '../../settings';
  18. import { setSideBarVisible } from '../actions';
  19. import SideBarItem from './SideBarItem';
  20. import styles, { SIDEBAR_AVATAR_SIZE } from './styles';
  21. /**
  22. * The URL at which the privacy policy is available to the user.
  23. */
  24. const PRIVACY_URL = 'https://jitsi.org/meet/privacy';
  25. /**
  26. * The URL at which the terms (of service/use) are available to the user.
  27. */
  28. const TERMS_URL = 'https://jitsi.org/meet/terms';
  29. type Props = {
  30. /**
  31. * Redux dispatch action
  32. */
  33. dispatch: Function,
  34. /**
  35. * Display name of the local participant.
  36. */
  37. _displayName: ?string,
  38. /**
  39. * ID of the local participant.
  40. */
  41. _localParticipantId: ?string,
  42. /**
  43. * Sets the side bar visible or hidden.
  44. */
  45. _visible: boolean
  46. };
  47. /**
  48. * A component rendering a welcome page sidebar.
  49. */
  50. class WelcomePageSideBar extends Component<Props> {
  51. /**
  52. * Constructs a new SideBar instance.
  53. *
  54. * @inheritdoc
  55. */
  56. constructor(props: Props) {
  57. super(props);
  58. // Bind event handlers so they are only bound once per instance.
  59. this._onHideSideBar = this._onHideSideBar.bind(this);
  60. this._onOpenHelpPage = this._onOpenHelpPage.bind(this);
  61. this._onOpenSettings = this._onOpenSettings.bind(this);
  62. }
  63. /**
  64. * Implements React's {@link Component#render()}, renders the sidebar.
  65. *
  66. * @inheritdoc
  67. * @returns {ReactElement}
  68. */
  69. render() {
  70. return (
  71. <SlidingView
  72. onHide = { this._onHideSideBar }
  73. position = 'left'
  74. show = { this.props._visible }
  75. style = { styles.sideBar } >
  76. <Header style = { styles.sideBarHeader }>
  77. <Avatar
  78. participantId = { this.props._localParticipantId }
  79. size = { SIDEBAR_AVATAR_SIZE } />
  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 = { IconSettings }
  89. label = 'settings.title'
  90. onPress = { this._onOpenSettings } />
  91. <SideBarItem
  92. icon = { IconInfo }
  93. label = 'welcomepage.terms'
  94. url = { TERMS_URL } />
  95. <SideBarItem
  96. icon = { IconInfo }
  97. label = 'welcomepage.privacy'
  98. url = { PRIVACY_URL } />
  99. <SideBarItem
  100. icon = { IconHelp }
  101. label = 'welcomepage.getHelp'
  102. onPress = { this._onOpenHelpPage } />
  103. </ScrollView>
  104. </SafeAreaView>
  105. </SlidingView>
  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. _onOpenHelpPage: () => void;
  119. /**
  120. * Shows the {@link HelpView}.
  121. *
  122. * @returns {void}
  123. */
  124. _onOpenHelpPage() {
  125. const { dispatch } = this.props;
  126. dispatch(setSideBarVisible(false));
  127. dispatch(setActiveModalId(HELP_VIEW_MODAL_ID));
  128. }
  129. _onOpenSettings: () => void;
  130. /**
  131. * Shows the {@link SettingsView}.
  132. *
  133. * @private
  134. * @returns {void}
  135. */
  136. _onOpenSettings() {
  137. const { dispatch } = this.props;
  138. dispatch(setSideBarVisible(false));
  139. dispatch(setActiveModalId(SETTINGS_VIEW_ID));
  140. }
  141. }
  142. /**
  143. * Maps (parts of) the redux state to the React {@code Component} props.
  144. *
  145. * @param {Object} state - The redux state.
  146. * @protected
  147. * @returns {Props}
  148. */
  149. function _mapStateToProps(state: Object) {
  150. const _localParticipant = getLocalParticipant(state);
  151. const _localParticipantId = _localParticipant?.id;
  152. const _displayName = _localParticipant && getParticipantDisplayName(state, _localParticipantId);
  153. return {
  154. _displayName,
  155. _localParticipantId,
  156. _visible: state['features/welcome'].sideBarVisible
  157. };
  158. }
  159. export default connect(_mapStateToProps)(WelcomePageSideBar);