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

Function Icon

src/components/Icon.tsx:103–168  ·  view source on GitHub ↗
({
  source,
  color,
  size,
  theme: themeOverrides,
  testID,
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

101 */
102
103const Icon = ({
104 source,
105 color,
106 size,
107 theme: themeOverrides,
108 testID,
109 ...rest
110}: Props) => {
111 const theme = useInternalTheme(themeOverrides);
112 const direction =
113 typeof source === 'object' && source.direction && source.source
114 ? source.direction === 'auto'
115 ? I18nManager.getConstants().isRTL
116 ? 'rtl'
117 : 'ltr'
118 : source.direction
119 : null;
120
121 const s =
122 typeof source === 'object' && source.direction && source.source
123 ? source.source
124 : source;
125 const iconColor =
126 color || (theme.isV3 ? theme.colors.onSurface : theme.colors.text);
127
128 if (isImageSource(s)) {
129 return (
130 <Image
131 {...rest}
132 testID={testID}
133 source={s}
134 style={[
135 {
136 transform: [{ scaleX: direction === 'rtl' ? -1 : 1 }],
137 },
138 {
139 width: size,
140 height: size,
141 tintColor: color,
142 resizeMode: `contain`,
143 },
144 ]}
145 {...accessibilityProps}
146 accessibilityIgnoresInvertColors
147 />
148 );
149 } else if (typeof s === 'string') {
150 return (
151 <SettingsConsumer>
152 {({ icon }) => {
153 return icon?.({
154 name: s,
155 color: iconColor,
156 size,
157 direction,
158 testID,
159 });
160 }}

Callers

nothing calls this directly

Calls 3

useInternalThemeFunction · 0.90
isImageSourceFunction · 0.85
sFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…