({
icon,
size = defaultSize,
style,
theme: themeOverrides,
...rest
}: Props)
| 43 | * ``` |
| 44 | */ |
| 45 | const Avatar = ({ |
| 46 | icon, |
| 47 | size = defaultSize, |
| 48 | style, |
| 49 | theme: themeOverrides, |
| 50 | ...rest |
| 51 | }: Props) => { |
| 52 | const theme = useInternalTheme(themeOverrides); |
| 53 | const { backgroundColor = theme.colors?.primary, ...restStyle } = |
| 54 | StyleSheet.flatten(style) || {}; |
| 55 | const textColor = |
| 56 | rest.color ?? |
| 57 | getContrastingColor(backgroundColor, white, 'rgba(0, 0, 0, .54)'); |
| 58 | |
| 59 | return ( |
| 60 | <View |
| 61 | style={[ |
| 62 | { |
| 63 | width: size, |
| 64 | height: size, |
| 65 | borderRadius: size / 2, |
| 66 | backgroundColor, |
| 67 | }, |
| 68 | styles.container, |
| 69 | restStyle, |
| 70 | ]} |
| 71 | {...rest} |
| 72 | > |
| 73 | <Icon source={icon} color={textColor} size={size * 0.6} /> |
| 74 | </View> |
| 75 | ); |
| 76 | }; |
| 77 | |
| 78 | Avatar.displayName = 'Avatar.Icon'; |
| 79 |
nothing calls this directly
no test coverage detected
searching dependent graphs…