import { View, Text } from "react-native";
import { Image } from "expo-image";
import { useTheme } from "../theme";
interface AvatarProps {
uri?: string | null;
name: string;
size?: number;
borderColor?: string;
}
export function Avatar({ uri, name, size = 48, borderColor }: AvatarProps) {
const theme = useTheme();
const initials = name
.split(" ")
.map((w) => w[0])
.join("")
.toUpperCase()
.slice(0, 2);
const baseStyle = {
width: size,
height: size,
borderRadius: size / 2,
borderWidth: borderColor ? 2 : 0,
borderColor: borderColor || "transparent",
};
if (uri) {
return (
);
}
return (
{initials}
);
}