import {useAnimatedScrollHandler} from 'react-native-reanimated';

import {useAnimatedValue} from './useAnimatedValueContext';

export const useAnimatedTabs = () => {
  const animatedValue = useAnimatedValue();

  const scrollHandler = useAnimatedScrollHandler(event => {
    if (animatedValue && 'value' in animatedValue) {
      animatedValue.value = event.contentOffset.y;
    }
  });

  return {
    animatedValue,
    scrollHandler,
  };
};
