Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

CustomDrawerContent.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @flow
  2. import { DrawerItemList } from '@react-navigation/drawer';
  3. import React from 'react';
  4. import { ScrollView, Text, View } from 'react-native';
  5. import { SafeAreaView } from 'react-native-safe-area-context';
  6. import { Avatar } from '../../base/avatar';
  7. import {
  8. getLocalParticipant, getParticipantDisplayName
  9. } from '../../base/participants';
  10. import { connect } from '../../base/redux';
  11. import styles, { DRAWER_AVATAR_SIZE } from './styles';
  12. type Props = {
  13. /**
  14. * Local participant name to be displayed.
  15. */
  16. displayName: string,
  17. /**
  18. * The ID of the local participant.
  19. */
  20. localParticipantId: string
  21. };
  22. const CustomDrawerContent = (props: Props) => (
  23. <ScrollView bounces = { false }>
  24. <View style = { styles.drawerHeader }>
  25. <Avatar
  26. participantId = { props.localParticipantId }
  27. size = { DRAWER_AVATAR_SIZE } />
  28. <Text style = { styles.displayName }>
  29. { props.displayName }
  30. </Text>
  31. </View>
  32. <SafeAreaView
  33. edges = { [
  34. 'left',
  35. 'right'
  36. ] }>
  37. <DrawerItemList { ...props } />
  38. </SafeAreaView>
  39. </ScrollView>
  40. );
  41. /**
  42. * Maps (parts of) the redux state to the React {@code Component} props.
  43. *
  44. * @param {Object} state - The redux state.
  45. * @protected
  46. * @returns {Props}
  47. */
  48. function mapStateToProps(state: Object) {
  49. const localParticipant = getLocalParticipant(state);
  50. const localParticipantId = localParticipant?.id;
  51. const displayName = localParticipant && getParticipantDisplayName(state, localParticipantId);
  52. return {
  53. displayName,
  54. localParticipantId
  55. };
  56. }
  57. export default connect(mapStateToProps)(CustomDrawerContent);