From a13dcb5110245bb554d79e779c4942e6f5aaf18a Mon Sep 17 00:00:00 2001
From: Ivan Chen <ivan@tagg.id>
Date: Tue, 27 Apr 2021 10:46:17 -0400
Subject: refactored avatar

---
 src/components/profile/TaggAvatar.tsx | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 src/components/profile/TaggAvatar.tsx

(limited to 'src/components/profile/TaggAvatar.tsx')

diff --git a/src/components/profile/TaggAvatar.tsx b/src/components/profile/TaggAvatar.tsx
new file mode 100644
index 00000000..ea0bdb65
--- /dev/null
+++ b/src/components/profile/TaggAvatar.tsx
@@ -0,0 +1,35 @@
+import React from 'react';
+import {StyleSheet} from 'react-native';
+import {useSelector} from 'react-redux';
+import {RootState} from '../../store/rootreducer';
+import {ScreenType} from '../../types';
+import {Avatar} from '../common';
+
+const PROFILE_DIM = 100;
+
+interface TaggAvatarProps {
+  style?: object;
+  userXId: string | undefined;
+  screenType: ScreenType;
+}
+const TaggAvatar: React.FC<TaggAvatarProps> = ({
+  style,
+  screenType,
+  userXId,
+}) => {
+  const {avatar} = useSelector((state: RootState) =>
+    userXId ? state.userX[screenType][userXId] : state.user,
+  );
+
+  return <Avatar style={[styles.image, style]} uri={avatar} />;
+};
+
+const styles = StyleSheet.create({
+  image: {
+    height: PROFILE_DIM,
+    width: PROFILE_DIM,
+    borderRadius: PROFILE_DIM / 2,
+  },
+});
+
+export default TaggAvatar;
-- 
cgit v1.2.3-70-g09d2

