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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { SafeAreaView, ScrollView, Text } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import SideBarItem from './SideBarItem';
  6. import styles from './styles';
  7. import { setSideBarVisibility } from '../actions';
  8. import { showAppSettings } from '../../app-settings';
  9. import {
  10. Avatar,
  11. getAvatarURL,
  12. getLocalParticipant,
  13. getParticipantDisplayName
  14. } from '../../base/participants';
  15. import {
  16. Header,
  17. SideBar
  18. } from '../../base/react';
  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. _avatar: 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. 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. <SideBar
  72. onHide = { this._onHideSideBar }
  73. show = { this.props._visible }>
  74. <Header style = { styles.sideBarHeader }>
  75. <Avatar
  76. style = { styles.avatar }
  77. uri = { this.props._avatar } />
  78. <Text style = { styles.displayName }>
  79. { this.props._displayName }
  80. </Text>
  81. </Header>
  82. <SafeAreaView style = { styles.sideBarBody }>
  83. <ScrollView
  84. style = { styles.itemContainer }>
  85. <SideBarItem
  86. i18Label = 'settings.title'
  87. icon = 'settings'
  88. onPress = { this._onOpenSettings } />
  89. <SideBarItem
  90. i18Label = 'welcomepage.terms'
  91. icon = 'info'
  92. url = { TERMS_URL } />
  93. <SideBarItem
  94. i18Label = 'welcomepage.privacy'
  95. icon = 'info'
  96. url = { PRIVACY_URL } />
  97. <SideBarItem
  98. i18Label = 'welcomepage.sendFeedback'
  99. icon = 'info'
  100. url = { SEND_FEEDBACK_URL } />
  101. </ScrollView>
  102. </SafeAreaView>
  103. </SideBar>
  104. );
  105. }
  106. _onHideSideBar: () => void;
  107. /**
  108. * Invoked when the sidebar has closed itslef (e.g. overlay pressed).
  109. *
  110. * @private
  111. * @returns {void}
  112. */
  113. _onHideSideBar() {
  114. this.props.dispatch(setSideBarVisibility(false));
  115. }
  116. _onOpenSettings: () => void;
  117. /**
  118. * Opens the settings screen.
  119. *
  120. * @private
  121. * @returns {void}
  122. */
  123. _onOpenSettings() {
  124. const { dispatch } = this.props;
  125. dispatch(setSideBarVisibility(false));
  126. dispatch(showAppSettings());
  127. }
  128. }
  129. /**
  130. * Maps (parts of) the redux state to the React {@code Component} props.
  131. *
  132. * @param {Object} state - The redux state.
  133. * @protected
  134. * @returns {Object}
  135. */
  136. function _mapStateToProps(state: Object) {
  137. const _localParticipant = getLocalParticipant(state);
  138. return {
  139. _avatar: getAvatarURL(_localParticipant),
  140. _displayName: getParticipantDisplayName(state, _localParticipant.id),
  141. _visible: state['features/welcome'].sideBarVisible
  142. };
  143. }
  144. export default connect(_mapStateToProps)(WelcomePageSideBar);