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.

RemoteAvatar.js 1023B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { Image } from 'react-native';
  4. import styles from './styles';
  5. export const DEFAULT_AVATAR = require('../../../../../../images/avatar.png');
  6. type Props = {
  7. /**
  8. * Callback for load errors.
  9. */
  10. onError: Function,
  11. /**
  12. * Size of the avatar.
  13. */
  14. size: number,
  15. /**
  16. * URI of the avatar to load.
  17. */
  18. uri: string
  19. };
  20. /**
  21. * Implements a private class that is used to fetch and render remote avatars based on an URI.
  22. */
  23. export default class RemoteAvatar extends PureComponent<Props> {
  24. /**
  25. * Implements {@code Component#render}.
  26. *
  27. * @inheritdoc
  28. */
  29. render() {
  30. const { onError, size, uri } = this.props;
  31. return (
  32. <Image
  33. defaultSource = { DEFAULT_AVATAR }
  34. onError = { onError }
  35. resizeMode = 'cover'
  36. source = {{ uri }}
  37. style = { styles.avatarContent(size) } />
  38. );
  39. }
  40. }