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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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/constants';
  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. show = { this.props._visible }
  74. style = { styles.sideBar } >
  75. <Header style = { styles.sideBarHeader }>
  76. <Avatar
  77. participantId = { this.props._localParticipantId }
  78. size = { SIDEBAR_AVATAR_SIZE } />
  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. icon = { IconSettings }
  88. label = 'settings.title'
  89. onPress = { this._onOpenSettings } />
  90. <SideBarItem
  91. icon = { IconInfo }
  92. label = 'welcomepage.terms'
  93. url = { TERMS_URL } />
  94. <SideBarItem
  95. icon = { IconInfo }
  96. label = 'welcomepage.privacy'
  97. url = { PRIVACY_URL } />
  98. <SideBarItem
  99. icon = { IconHelp }
  100. label = 'welcomepage.getHelp'
  101. onPress = { this._onOpenHelpPage } />
  102. </ScrollView>
  103. </SafeAreaView>
  104. </SlidingView>
  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. _onOpenHelpPage: () => void;
  118. /**
  119. * Shows the {@link HelpView}.
  120. *
  121. * @returns {void}
  122. */
  123. _onOpenHelpPage() {
  124. const { dispatch } = this.props;
  125. dispatch(setSideBarVisible(false));
  126. dispatch(setActiveModalId(HELP_VIEW_MODAL_ID));
  127. }
  128. _onOpenSettings: () => void;
  129. /**
  130. * Shows the {@link SettingsView}.
  131. *
  132. * @private
  133. * @returns {void}
  134. */
  135. _onOpenSettings() {
  136. const { dispatch } = this.props;
  137. dispatch(setSideBarVisible(false));
  138. dispatch(setActiveModalId(SETTINGS_VIEW_ID));
  139. }
  140. }
  141. /**
  142. * Maps (parts of) the redux state to the React {@code Component} props.
  143. *
  144. * @param {Object} state - The redux state.
  145. * @protected
  146. * @returns {Props}
  147. */
  148. function _mapStateToProps(state: Object) {
  149. const _localParticipant = getLocalParticipant(state);
  150. const _localParticipantId = _localParticipant?.id;
  151. const _displayName = _localParticipant && getParticipantDisplayName(state, _localParticipantId);
  152. return {
  153. _displayName,
  154. _localParticipantId,
  155. _visible: state['features/welcome'].sideBarVisible
  156. };
  157. }
  158. export default connect(_mapStateToProps)(WelcomePageSideBar);