"use strict";

import { Extrapolation, interpolate, interpolateColor, useAnimatedStyle } from "react-native-reanimated";
import { useIOTheme } from "../context";
import { hexToRgba, IOColors, IOScaleEffect } from "../core";
import { useSpringPressProgressValue } from "../utils/hooks";
export const useListItemAnimation = () => {
  const {
    progress,
    onPressIn,
    onPressOut
  } = useSpringPressProgressValue("button");
  const theme = useIOTheme();
  const mapBackgroundStates = {
    default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
    pressed: IOColors[theme["listItem-pressed"]]
  };

  // Interpolate animation values from `isPressed` values
  const scaleAnimatedStyle = useAnimatedStyle(() => ({
    transform: [{
      scale: interpolate(progress.value, [0, 1], [1, IOScaleEffect.slight], Extrapolation.CLAMP)
    }]
  }));
  const backgroundAnimatedStyle = useAnimatedStyle(() => ({
    backgroundColor: interpolateColor(progress.value, [0, 1], [mapBackgroundStates.default, mapBackgroundStates.pressed])
  }));
  return {
    progress,
    onPressIn,
    onPressOut,
    scaleAnimatedStyle,
    backgroundAnimatedStyle
  };
};
//# sourceMappingURL=useListItemAnimation.js.map