MCPcopy Index your code
hub / github.com/callstack/react-native-paper / getForegroundColor

Function getForegroundColor

src/components/FAB/utils.ts:210–259  ·  view source on GitHub ↗
({
  theme,
  isVariant,
  disabled,
  backgroundColor,
  customColor,
}: BaseProps & { backgroundColor: string; customColor?: string })

Source from the content-addressed store, hash-verified

208};
209
210const getForegroundColor = ({
211 theme,
212 isVariant,
213 disabled,
214 backgroundColor,
215 customColor,
216}: BaseProps & { backgroundColor: string; customColor?: string }) => {
217 if (typeof customColor !== 'undefined' && !disabled) {
218 return customColor;
219 }
220
221 if (theme.isV3) {
222 if (disabled) {
223 return theme.colors.onSurfaceDisabled;
224 }
225
226 if (isVariant('primary')) {
227 return theme.colors.onPrimaryContainer;
228 }
229
230 if (isVariant('secondary')) {
231 return theme.colors.onSecondaryContainer;
232 }
233
234 if (isVariant('tertiary')) {
235 return theme.colors.onTertiaryContainer;
236 }
237
238 if (isVariant('surface')) {
239 return theme.colors.primary;
240 }
241 }
242
243 if (disabled) {
244 if (theme.dark) {
245 return color(white).alpha(0.32).rgb().string();
246 }
247 return color(black).alpha(0.32).rgb().string();
248 }
249
250 if (backgroundColor) {
251 return getContrastingColor(
252 backgroundColor || white,
253 white,
254 'rgba(0, 0, 0, .54)'
255 );
256 }
257
258 return getContrastingColor(white, white, 'rgba(0, 0, 0, .54)');
259};
260
261export const getFABColors = ({
262 theme,

Callers 1

getFABColorsFunction · 0.85

Calls 2

isVariantFunction · 0.85
getContrastingColorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…