-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserCard.tsx
More file actions
36 lines (32 loc) · 959 Bytes
/
Copy pathUserCard.tsx
File metadata and controls
36 lines (32 loc) · 959 Bytes
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
32
33
34
35
36
import { Image, Text, View } from "react-native";
interface UserCardProps {
name: string;
avatar?: string;
}
export default function UserCard({ name, avatar }: UserCardProps) {
// Get the initials from the name for the avatar fallback
const initials = name
.split(" ")
.map((word) => word[0])
.join("")
.toUpperCase()
.substring(0, 2);
return (
<View className="flex-row items-center bg-[#23293a] rounded-lg p-4 m-2">
{avatar ? (
<Image
source={{ uri: avatar }}
className="w-12 h-12 rounded-full bg-gray-700"
/>
) : (
<View className="w-12 h-12 rounded-full bg-gray-700 items-center justify-center">
<Text className="text-white font-bold text-lg">{initials}</Text>
</View>
)}
{/* User Name */}
<View className="ml-4 flex-1">
<Text className="text-white font-medium text-lg">{name}</Text>
</View>
</View>
);
}