MCPcopy
hub / github.com/callstack/react-native-paper / Avatar

Function Avatar

src/components/Avatar/AvatarIcon.tsx:45–76  ·  view source on GitHub ↗
({
  icon,
  size = defaultSize,
  style,
  theme: themeOverrides,
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

43 * ```
44 */
45const 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
78Avatar.displayName = 'Avatar.Icon';
79

Callers

nothing calls this directly

Calls 2

useInternalThemeFunction · 0.90
getContrastingColorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…