CastModal Back gesture fix

This commit is contained in:
tapframe 2025-09-17 13:12:09 +05:30
parent 5143917117
commit a0626e8f8a

View file

@ -8,6 +8,7 @@ import {
Dimensions,
TouchableOpacity,
InteractionManager,
BackHandler,
} from 'react-native';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { useRoute, useNavigation, useFocusEffect } from '@react-navigation/native';
@ -206,7 +207,7 @@ const MetadataScreen: React.FC = () => {
useFocusEffect(
useCallback(() => {
setIsScreenFocused(true);
// Delay secondary data loading until interactions are complete
const timer = setTimeout(() => {
if (!interactionComplete.current) {
@ -224,6 +225,21 @@ const MetadataScreen: React.FC = () => {
}, [])
);
// Handle back button press - close modal if open, otherwise navigate back
useFocusEffect(
useCallback(() => {
const backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
if (showCastModal) {
setShowCastModal(false);
return true; // Prevent default back behavior
}
return false; // Allow default back behavior (navigate back)
});
return () => backHandler.remove();
}, [showCastModal])
);
// Optimize secondary data loading
useEffect(() => {
if (metadata && isScreenFocused && !shouldLoadSecondaryData) {