'use client'; import React from 'react'; import { createAvatar } from '@gluestack-ui/avatar'; import { View, Text, Image, Platform } from 'react-native'; import { tva } from '@gluestack-ui/nativewind-utils/tva'; import { withStyleContext, useStyleContext, } from '@gluestack-ui/nativewind-utils/withStyleContext'; const SCOPE = 'AVATAR'; import type { VariantProps } from '@gluestack-ui/nativewind-utils'; const UIAvatar = createAvatar({ Root: withStyleContext(View, SCOPE), Badge: View, Group: View, Image: Image, FallbackText: Text, }); const avatarStyle = tva({ base: 'rounded-full justify-center items-center relative bg-primary-600 group-[.avatar-group]/avatar-group:-ml-2.5', variants: { size: { 'xs': 'w-6 h-6', 'sm': 'w-8 h-8', 'md': 'w-12 h-12', 'lg': 'w-16 h-16', 'xl': 'w-24 h-24', '2xl': 'w-32 h-32', }, }, }); const avatarFallbackTextStyle = tva({ base: 'text-typography-0 font-semibold overflow-hidden text-transform:uppercase web:cursor-default', parentVariants: { size: { 'xs': 'text-2xs', 'sm': 'text-xs', 'md': 'text-base', 'lg': 'text-xl', 'xl': 'text-3xl', '2xl': 'text-5xl', }, }, }); const avatarGroupStyle = tva({ base: 'group/avatar-group flex-row-reverse relative avatar-group', }); const avatarBadgeStyle = tva({ base: 'w-5 h-5 bg-success-500 rounded-full absolute right-0 bottom-0 border-background-0 border-2', parentVariants: { size: { 'xs': 'w-2 h-2', 'sm': 'w-2 h-2', 'md': 'w-3 h-3', 'lg': 'w-4 h-4', 'xl': 'w-6 h-6', '2xl': 'w-8 h-8', }, }, }); const avatarImageStyle = tva({ base: 'h-full w-full rounded-full absolute', }); type IAvatarProps = Omit< React.ComponentPropsWithoutRef, 'context' > & VariantProps; const Avatar = React.forwardRef< React.ElementRef, IAvatarProps >(({ className, size = 'md', ...props }, ref) => { return ( ); }); type IAvatarBadgeProps = React.ComponentPropsWithoutRef & VariantProps; const AvatarBadge = React.forwardRef< React.ElementRef, IAvatarBadgeProps >(({ className, size, ...props }, ref) => { const { size: parentSize } = useStyleContext(SCOPE); return ( ); }); type IAvatarFallbackTextProps = React.ComponentPropsWithoutRef< typeof UIAvatar.FallbackText > & VariantProps; const AvatarFallbackText = React.forwardRef< React.ElementRef, IAvatarFallbackTextProps >(({ className, size, ...props }, ref) => { const { size: parentSize } = useStyleContext(SCOPE); return ( ); }); type IAvatarImageProps = React.ComponentPropsWithoutRef & VariantProps; const AvatarImage = React.forwardRef< React.ElementRef, IAvatarImageProps >(({ className, ...props }, ref) => { return ( ); }); type IAvatarGroupProps = React.ComponentPropsWithoutRef & VariantProps; const AvatarGroup = React.forwardRef< React.ElementRef, IAvatarGroupProps >(({ className, ...props }, ref) => { return ( ); }); export { Avatar, AvatarBadge, AvatarFallbackText, AvatarImage, AvatarGroup };