import React from 'react' import Svg, {Circle, Text, Defs, LinearGradient, Stop} from 'react-native-svg' import {getGradient} from '../../lib/asset-gen' export function UserAvatar({ size, displayName, handle, }: { size: number displayName: string | undefined handle: string }) { const initials = getInitials(displayName || handle) const gradient = getGradient(handle) return ( {initials} ) } function getInitials(str: string): string { const tokens = str .toLowerCase() .replace(/[^a-z]/g, '') .split(' ') .filter(Boolean) .map(v => v.trim()) if (tokens.length >= 2 && tokens[0][0] && tokens[0][1]) { return tokens[0][0].toUpperCase() + tokens[1][0].toUpperCase() } if (tokens.length === 1 && tokens[0][0]) { return tokens[0][0].toUpperCase() } return 'X' }