Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default ({
name,
radius,
isActive,
index,
currentIndex
}: ChannelIconProps) => {
const clock = new Clock();
const value = new Value(0);
useCode(
block([
cond(and(not(isActive), approximates(index, currentIndex)), [
set(value, runSpring(clock, 0, 1)),
cond(not(clockRunning(clock)), set(isActive, 0))
]),
cond(isActive, [stopClock(clock), set(value, 0)])
]),
[]
);
const backgroundColor = interpolateColor(
value,
{
inputRange: [0, 1],
outputRange: [nonActiveColor, activeColor]
},
"rgb"
);
return (
() => ({
onGestureEvent: gestureEvent({
translationX,
velocityX,
state
}),
translateX: spring(
translationX,
state,
snapPoint(translationX, velocityX, snapPoints)
)
}),
[state, translationX, velocityX]
);
useCode(
cond(approximates(abs(translateX), EXTREMITY, 10), call([], closeTab)),
[translateX, closeTab]
);
return (
<img style="{styles.image}">
);
};