- Added the profile image or the initials if profile picture is missing to the grocery item

This commit is contained in:
Dejan
2024-10-26 14:58:44 +02:00
parent c7e2dcfdf9
commit 731af8a3b8

View File

@ -56,6 +56,10 @@ const GroceryItem = ({
} }
}; };
const getInitials = (firstName: string, lastName: string) => {
return `${firstName.charAt(0)}${lastName.charAt(0)}`;
};
return ( return (
<View <View
key={item.id} key={item.id}
@ -142,17 +146,43 @@ const GroceryItem = ({
<View height={0.7} backgroundColor="#e7e7e7" width={"98%"} /> <View height={0.7} backgroundColor="#e7e7e7" width={"98%"} />
</View> </View>
<View paddingL-0 paddingT-12 flexS row centerV> <View paddingL-0 paddingT-12 flexS row centerV>
<ImageBackground {profileData?.pfp ? <ImageBackground
style={{ source={require("../../../assets/images/child-picture.png")}
width: 22.36, style={{
aspectRatio: 1, height: 24.64,
borderRadius: 50, aspectRatio: 1,
backgroundColor: "red", borderRadius: 22,
marginRight: 10, overflow: "hidden",
overflow: "hidden", }}
}} /> : <View
source={require("../../../assets/images/child-picture.png")} style={{
/> position: "relative",
width: 24.64,
aspectRatio: 1,
marginRight: 4
}}
>
<View
style={{
backgroundColor: "#ccc",
justifyContent: "center",
alignItems: "center",
borderRadius: 100, // Circular shape
width: "100%",
height: "100%",
}}
>
<Text
style={{
color: "#fff",
fontSize: 12,
fontWeight: "bold",
}}
>
{getInitials(itemCreator.firstName, itemCreator.lastName ?? "")}
</Text>
</View>
</View>}
<Text color="#858585" style={styles.authorTxt}> <Text color="#858585" style={styles.authorTxt}>
Requested by {itemCreator?.firstName} Requested by {itemCreator?.firstName}
</Text> </Text>