aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/Avatar.tsx
blob: 86ebedf3cf69a172d5950295fc2a24499b982dfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React, {FC} from 'react';
import {Image, ImageStyle, StyleProp, ImageBackground} from 'react-native';

type AvatarProps = {
  style: StyleProp<ImageStyle>;
  uri: string | undefined;
  loading: boolean;
  loadingStyle: StyleProp<ImageStyle> | undefined;
};
const Avatar: FC<AvatarProps> = ({
  style,
  uri,
  loading = false,
  loadingStyle,
}) => {
  return (
    <ImageBackground
      style={style}
      defaultSource={require('../../assets/images/avatar-placeholder.png')}
      source={{uri, cache: 'reload'}}>
      {loading && (
        <Image
          source={require('../../assets/gifs/loading-animation.gif')}
          style={loadingStyle}
        />
      )}
    </ImageBackground>
  );
};

export default Avatar;