import React, { useState, useRef } from 'react'; import { InteractionManager } from 'react-native'; // import { TransitioningView } from 'react-native-reanimated'; import { useSharedValue, withTiming } from 'react-native-reanimated'; import { useFocusEffect } from '@react-navigation/native'; export const useAfterInteractions = () => { const [interactionsComplete, setInteractionsComplete] = useState(false); const [interactionTimeout, setInteractionsTimeOut] = useState(200); const opacity = useSharedValue(0); // const subscriptionRef = useRef(null); // const transitionRef = useRef(null); useFocusEffect( React.useCallback(() => { // Do something when the screen is focused const interactionPromise = InteractionManager.runAfterInteractions(() => { // Simulate some asynchronous task setTimeout(() => { // Start the animation opacity.value = withTiming(1, { duration: 500 }); setInteractionsComplete(true); }, interactionTimeout); }); return () => { // Do something when the screen is unfocused // Useful for cleanup functions interactionPromise?.cancel(); setInteractionsComplete(false); }; }, [interactionTimeout]), ); // useFocusEffect( // React.useCallback(() => { // // Do something when the screen is focused // subscriptionRef.current = InteractionManager.runAfterInteractions(() => { // transitionRef.current?.animateNextTransition(); // setInteractionsComplete(true); // subscriptionRef.current = null; // }); // return () => { // // Do something when the screen is unfocused // // Useful for cleanup functions // setInteractionsComplete(false); // subscriptionRef.current?.cancel(); // }; // }, []), // ); return { interactionsComplete, opacity, setInteractionsTimeOut, }; };