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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { SafeAreaView, ScrollView, Text } from 'react-native';
  4. import { Avatar } from '../../base/avatar';
  5. import {
  6. getLocalParticipant,
  7. getParticipantDisplayName
  8. } from '../../base/participants';
  9. import {
  10. Header,
  11. SlidingView
  12. } from '../../base/react';
  13. import { connect } from '../../base/redux';
  14. import { setSettingsViewVisible } from '../../settings';
  15. import { setSideBarVisible } from '../actions';
  16. import SideBarItem from './SideBarItem';
  17. import styles, { SIDEBAR_AVATAR_SIZE } from './styles';
  18. /**
  19. * The URL at which the privacy policy is available to the user.
  20. */
  21. const PRIVACY_URL = 'https://jitsi.org/meet/privacy';
  22. /**
  23. * The URL at which the user may send feedback.
  24. */
  25. const SEND_FEEDBACK_URL = 'mailto:support@jitsi.org';
  26. /**
  27. * The URL at which the terms (of service/use) are available to the user.
  28. */
  29. const TERMS_URL = 'https://jitsi.org/meet/terms';
  30. type Props = {
  31. /**
  32. * Redux dispatch action
  33. */
  34. dispatch: Function,
  35. /**
  36. * Display name of the local participant.
  37. */
  38. _displayName: string,
  39. /**
  40. * ID of the local participant.
  41. */
  42. _localParticipantId: string,
  43. /**
  44. * Sets the side bar visible or hidden.
  45. */
  46. _visible: boolean
  47. };
  48. /**
  49. * A component rendering a welcome page sidebar.
  50. */
  51. class WelcomePageSideBar extends Component<Props> {
  52. /**
  53. * Constructs a new SideBar instance.
  54. *
  55. * @inheritdoc
  56. */
  57. constructor(props: Props) {
  58. super(props);
  59. // Bind event handlers so they are only bound once per instance.
  60. this._onHideSideBar = this._onHideSideBar.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 = '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. </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. _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 {Props}
  137. */
  138. function _mapStateToProps(state: Object) {
  139. const _localParticipant = getLocalParticipant(state);
  140. return {
  141. _displayName: getParticipantDisplayName(state, _localParticipant.id),
  142. _localParticipantId: _localParticipant.id,
  143. _visible: state['features/welcome'].sideBarVisible
  144. };
  145. }
  146. export default connect(_mapStateToProps)(WelcomePageSideBar);