- 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 (
<View
key={item.id}
@ -142,17 +146,43 @@ const GroceryItem = ({
<View height={0.7} backgroundColor="#e7e7e7" width={"98%"} />
</View>
<View paddingL-0 paddingT-12 flexS row centerV>
<ImageBackground
{profileData?.pfp ? <ImageBackground
source={require("../../../assets/images/child-picture.png")}
style={{
width: 22.36,
height: 24.64,
aspectRatio: 1,
borderRadius: 50,
backgroundColor: "red",
marginRight: 10,
borderRadius: 22,
overflow: "hidden",
}}
source={require("../../../assets/images/child-picture.png")}
/>
/> : <View
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}>
Requested by {itemCreator?.firstName}
</Text>