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

Function getBackgroundColor

src/components/IconButton/utils.ts:34–78  ·  view source on GitHub ↗
({
  theme,
  isMode,
  disabled,
  selected,
  customContainerColor,
}: BaseProps & { customContainerColor?: string })

Source from the content-addressed store, hash-verified

32};
33
34const getBackgroundColor = ({
35 theme,
36 isMode,
37 disabled,
38 selected,
39 customContainerColor,
40}: BaseProps & { customContainerColor?: string }) => {
41 if (theme.isV3) {
42 if (disabled) {
43 if (isMode('contained') || isMode('contained-tonal')) {
44 return theme.colors.surfaceDisabled;
45 }
46 }
47
48 if (typeof customContainerColor !== 'undefined') {
49 return customContainerColor;
50 }
51
52 if (isMode('contained')) {
53 if (selected) {
54 return theme.colors.primary;
55 }
56 return theme.colors.surfaceVariant;
57 }
58
59 if (isMode('contained-tonal')) {
60 if (selected) {
61 return theme.colors.secondaryContainer;
62 }
63 return theme.colors.surfaceVariant;
64 }
65
66 if (isMode('outlined')) {
67 if (selected) {
68 return theme.colors.inverseSurface;
69 }
70 }
71 }
72
73 if (typeof customContainerColor !== 'undefined') {
74 return customContainerColor;
75 }
76
77 return undefined;
78};
79
80const getIconColor = ({
81 theme,

Callers 1

getIconButtonColorFunction · 0.70

Calls 1

isModeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…