MCPcopy Create free account
hub / github.com/callstack/react-native-paper / AvatarImage

Function AvatarImage

src/components/Avatar/AvatarImage.tsx:77–124  ·  view source on GitHub ↗
({
  size = defaultSize,
  source,
  style,
  onError,
  onLayout,
  onLoad,
  onLoadEnd,
  onLoadStart,
  onProgress,
  theme: themeOverrides,
  testID,
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

75 * ```
76 */
77const AvatarImage = ({
78 size = defaultSize,
79 source,
80 style,
81 onError,
82 onLayout,
83 onLoad,
84 onLoadEnd,
85 onLoadStart,
86 onProgress,
87 theme: themeOverrides,
88 testID,
89 ...rest
90}: Props) => {
91 const { colors } = useInternalTheme(themeOverrides);
92 const { backgroundColor = colors?.primary } = StyleSheet.flatten(style) || {};
93
94 return (
95 <View
96 style={[
97 {
98 width: size,
99 height: size,
100 borderRadius: size / 2,
101 backgroundColor,
102 },
103 style,
104 ]}
105 {...rest}
106 >
107 {typeof source === 'function' && source({ size })}
108 {typeof source !== 'function' && (
109 <Image
110 testID={testID}
111 source={source}
112 style={{ width: size, height: size, borderRadius: size / 2 }}
113 onError={onError}
114 onLayout={onLayout}
115 onLoad={onLoad}
116 onLoadEnd={onLoadEnd}
117 onLoadStart={onLoadStart}
118 onProgress={onProgress}
119 accessibilityIgnoresInvertColors
120 />
121 )}
122 </View>
123 );
124};
125
126AvatarImage.displayName = 'Avatar.Image';
127

Callers

nothing calls this directly

Calls 2

useInternalThemeFunction · 0.90
sourceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…