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

Function v2Shadow

src/styles/shadow.tsx:18–71  ·  view source on GitHub ↗
(elevation: number | Animated.Value = 0)

Source from the content-addressed store, hash-verified

16}
17
18function v2Shadow(elevation: number | Animated.Value = 0) {
19 if (elevation instanceof Animated.Value) {
20 const inputRange = [0, 1, 2, 3, 8, 24];
21
22 return {
23 shadowColor: SHADOW_COLOR,
24 shadowOffset: {
25 width: new Animated.Value(0),
26 height: elevation.interpolate({
27 inputRange,
28 outputRange: [0, 0.5, 0.75, 2, 7, 23],
29 }),
30 },
31 shadowOpacity: elevation.interpolate({
32 inputRange: [0, 1],
33 outputRange: [0, SHADOW_OPACITY],
34 extrapolate: 'clamp',
35 }),
36 shadowRadius: elevation.interpolate({
37 inputRange,
38 outputRange: [0, 0.75, 1.5, 3, 8, 24],
39 }),
40 };
41 } else {
42 if (elevation === 0) {
43 return {};
44 }
45
46 let height, radius;
47 switch (elevation) {
48 case 1:
49 height = 0.5;
50 radius = 0.75;
51 break;
52 case 2:
53 height = 0.75;
54 radius = 1.5;
55 break;
56 default:
57 height = elevation - 1;
58 radius = elevation;
59 }
60
61 return {
62 shadowColor: SHADOW_COLOR,
63 shadowOffset: {
64 width: 0,
65 height,
66 },
67 shadowOpacity: SHADOW_OPACITY,
68 shadowRadius: radius,
69 };
70 }
71}
72
73function v3Shadow(elevation: number | Animated.Value = 0) {
74 const inputRange = [0, 1, 2, 3, 4, 5];

Callers 1

shadowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…