import * as React from 'react'; import { Platform, StyleSheet, View } from 'react-native'; type Props = { focused: boolean; animated: boolean; isNextScreenTransparent: boolean; detachCurrentScreen: boolean; children: React.ReactNode; }; export type CardA11yWrapperRef = { setInert: (value: boolean) => void }; export const CardA11yWrapper = React.forwardRef( ( { focused, animated, isNextScreenTransparent, detachCurrentScreen, children, }: Props, ref: React.Ref ) => { // Manage this in separate component to avoid re-rendering card during gestures // Otherwise the gesture animation will be interrupted as state hasn't updated yet const [inert, setInert] = React.useState(false); React.useImperativeHandle(ref, () => ({ setInert }), []); const isHidden = !animated && isNextScreenTransparent === false && detachCurrentScreen !== false && !focused; return ( {children} ); } ); CardA11yWrapper.displayName = 'CardA11yWrapper';