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

Function overlay

src/styles/overlay.tsx:11–29  ·  view source on GitHub ↗
(
  elevation: T,
  surfaceColor: string = MD2DarkTheme.colors?.surface
)

Source from the content-addressed store, hash-verified

9): it is Animated.Value => it instanceof Animated.Value;
10
11export default function overlay<T extends Animated.Value | number>(
12 elevation: T,
13 surfaceColor: string = MD2DarkTheme.colors?.surface
14): T extends number ? string : Animated.AnimatedInterpolation<number | string> {
15 if (isAnimatedValue(elevation)) {
16 const inputRange = [0, 1, 2, 3, 8, 24];
17
18 // @ts-expect-error: TS doesn't seem to refine the type correctly
19 return elevation.interpolate({
20 inputRange,
21 outputRange: inputRange.map((elevation) => {
22 return calculateColor(surfaceColor, elevation);
23 }),
24 });
25 }
26
27 // @ts-expect-error: TS doesn't seem to refine the type correctly
28 return calculateColor(surfaceColor, elevation);
29}
30
31function calculateColor(surfaceColor: string, elevation: number = 1) {
32 let overlayTransparency: number;

Callers 5

Surface.tsxFile · 0.85
DialogFunction · 0.85
getAppbarBackgroundColorFunction · 0.85
Appbar.test.tsxFile · 0.85
BottomNavigationBarFunction · 0.85

Calls 2

isAnimatedValueFunction · 0.85
calculateColorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…