您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

WelcomePageSideBar.native.js 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { SafeAreaView, ScrollView, Text } from 'react-native';
  4. import {
  5. Avatar,
  6. getAvatarURL,
  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. * The avatar URL to be rendered.
  38. */
  39. _avatarURL: 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: 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. size = { SIDEBAR_AVATAR_SIZE }
  80. style = { styles.avatar }
  81. uri = { this.props._avatarURL } />
  82. <Text style = { styles.displayName }>
  83. { this.props._displayName }
  84. </Text>
  85. </Header>
  86. <SafeAreaView style = { styles.sideBarBody }>
  87. <ScrollView
  88. style = { styles.itemContainer }>
  89. <SideBarItem
  90. icon = 'settings'
  91. label = 'settings.title'
  92. onPress = { this._onOpenSettings } />
  93. <SideBarItem
  94. icon = 'info'
  95. label = 'welcomepage.terms'
  96. url = { TERMS_URL } />
  97. <SideBarItem
  98. icon = 'info'
  99. label = 'welcomepage.privacy'
  100. url = { PRIVACY_URL } />
  101. <SideBarItem
  102. icon = 'info'
  103. label = 'welcomepage.sendFeedback'
  104. url = { SEND_FEEDBACK_URL } />
  105. </ScrollView>
  106. </SafeAreaView>
  107. </SlidingView>
  108. );
  109. }
  110. _onHideSideBar: () => void;
  111. /**
  112. * Invoked when the sidebar has closed itself (e.g. Overlay pressed).
  113. *
  114. * @private
  115. * @returns {void}
  116. */
  117. _onHideSideBar() {
  118. this.props.dispatch(setSideBarVisible(false));
  119. }
  120. _onOpenSettings: () => void;
  121. /**
  122. * Shows the {@link SettingsView}.
  123. *
  124. * @private
  125. * @returns {void}
  126. */
  127. _onOpenSettings() {
  128. const { dispatch } = this.props;
  129. dispatch(setSideBarVisible(false));
  130. dispatch(setSettingsViewVisible(true));
  131. }
  132. }
  133. /**
  134. * Maps (parts of) the redux state to the React {@code Component} props.
  135. *
  136. * @param {Object} state - The redux state.
  137. * @protected
  138. * @returns {{
  139. * _avatarURL: string,
  140. * _displayName: string,
  141. * _visible: boolean
  142. * }}
  143. */
  144. function _mapStateToProps(state: Object) {
  145. const localParticipant = getLocalParticipant(state);
  146. return {
  147. _avatarURL: getAvatarURL(localParticipant),
  148. _displayName: getParticipantDisplayName(state, localParticipant.id),
  149. _visible: state['features/welcome'].sideBarVisible
  150. };
  151. }
  152. export default connect(_mapStateToProps)(WelcomePageSideBar);