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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 } from '../../base/icons';
  6. import {
  7. getLocalParticipant,
  8. getParticipantDisplayName
  9. } from '../../base/participants';
  10. import {
  11. Header,
  12. SlidingView
  13. } from '../../base/react';
  14. import { connect } from '../../base/redux';
  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. * Display name of the local participant.
  38. */
  39. _displayName: ?string,
  40. /**
  41. * ID of the local participant.
  42. */
  43. _localParticipantId: ?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: 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. <SlidingView
  73. onHide = { this._onHideSideBar }
  74. position = 'left'
  75. show = { this.props._visible }
  76. style = { styles.sideBar } >
  77. <Header style = { styles.sideBarHeader }>
  78. <Avatar
  79. participantId = { this.props._localParticipantId }
  80. size = { SIDEBAR_AVATAR_SIZE } />
  81. <Text style = { styles.displayName }>
  82. { this.props._displayName }
  83. </Text>
  84. </Header>
  85. <SafeAreaView style = { styles.sideBarBody }>
  86. <ScrollView
  87. style = { styles.itemContainer }>
  88. <SideBarItem
  89. icon = { IconSettings }
  90. label = 'settings.title'
  91. onPress = { this._onOpenSettings } />
  92. <SideBarItem
  93. icon = { IconInfo }
  94. label = 'welcomepage.terms'
  95. url = { TERMS_URL } />
  96. <SideBarItem
  97. icon = { IconInfo }
  98. label = 'welcomepage.privacy'
  99. url = { PRIVACY_URL } />
  100. <SideBarItem
  101. icon = { IconInfo }
  102. label = 'welcomepage.sendFeedback'
  103. url = { SEND_FEEDBACK_URL } />
  104. </ScrollView>
  105. </SafeAreaView>
  106. </SlidingView>
  107. );
  108. }
  109. _onHideSideBar: () => void;
  110. /**
  111. * Invoked when the sidebar has closed itself (e.g. Overlay pressed).
  112. *
  113. * @private
  114. * @returns {void}
  115. */
  116. _onHideSideBar() {
  117. this.props.dispatch(setSideBarVisible(false));
  118. }
  119. _onOpenSettings: () => void;
  120. /**
  121. * Shows the {@link SettingsView}.
  122. *
  123. * @private
  124. * @returns {void}
  125. */
  126. _onOpenSettings() {
  127. const { dispatch } = this.props;
  128. dispatch(setSideBarVisible(false));
  129. dispatch(setSettingsViewVisible(true));
  130. }
  131. }
  132. /**
  133. * Maps (parts of) the redux state to the React {@code Component} props.
  134. *
  135. * @param {Object} state - The redux state.
  136. * @protected
  137. * @returns {Props}
  138. */
  139. function _mapStateToProps(state: Object) {
  140. const _localParticipant = getLocalParticipant(state);
  141. const _localParticipantId = _localParticipant?.id;
  142. const _displayName = _localParticipant && getParticipantDisplayName(state, _localParticipantId);
  143. return {
  144. _displayName,
  145. _localParticipantId,
  146. _visible: state['features/welcome'].sideBarVisible
  147. };
  148. }
  149. export default connect(_mapStateToProps)(WelcomePageSideBar);