aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/Avatar.tsx
diff options
context:
space:
mode:
authorBrian Kim <brian@tagg.id>2021-05-14 19:33:03 -0700
committerBrian Kim <brian@tagg.id>2021-05-14 19:33:03 -0700
commit37b37f296a59aea43e73f615ae6cb042b2242e87 (patch)
tree843caf5c4c79ce41fa2a2837bf6075e4abed9533 /src/components/common/Avatar.tsx
parente884ad25b4f2358406eee8a2766890291538a518 (diff)
Bug fixes
Diffstat (limited to 'src/components/common/Avatar.tsx')
-rw-r--r--src/components/common/Avatar.tsx23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/components/common/Avatar.tsx b/src/components/common/Avatar.tsx
index 831cf906..86ebedf3 100644
--- a/src/components/common/Avatar.tsx
+++ b/src/components/common/Avatar.tsx
@@ -1,17 +1,30 @@
import React, {FC} from 'react';
-import {Image, ImageStyle, StyleProp} from 'react-native';
+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}) => {
+const Avatar: FC<AvatarProps> = ({
+ style,
+ uri,
+ loading = false,
+ loadingStyle,
+}) => {
return (
- <Image
+ <ImageBackground
style={style}
defaultSource={require('../../assets/images/avatar-placeholder.png')}
- source={{uri, cache: 'reload'}}
- />
+ source={{uri, cache: 'reload'}}>
+ {loading && (
+ <Image
+ source={require('../../assets/gifs/loading-animation.gif')}
+ style={loadingStyle}
+ />
+ )}
+ </ImageBackground>
);
};