( elevation: T, surfaceColor: string = MD2DarkTheme.colors?.surface )
| 9 | ): it is Animated.Value => it instanceof Animated.Value; |
| 10 | |
| 11 | export 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 | |
| 31 | function calculateColor(surfaceColor: string, elevation: number = 1) { |
| 32 | let overlayTransparency: number; |
no test coverage detected
searching dependent graphs…