Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iOS): push and pop transitions change after full screen back swipe #2234

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/test-examples/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import Test2069 from './src/Test2069';
import Test2118 from './src/Test2118';
import Test2184 from './src/Test2184';
import Test2223 from './src/Test2223';
import Test2227 from './src/Test2227';
import Test2229 from './src/Test2229';
import TestScreenAnimation from './src/TestScreenAnimation';
import TestHeader from './src/TestHeader';
Expand Down
57 changes: 57 additions & 0 deletions apps/test-examples/src/Test2227.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import * as React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {
createNativeStackNavigator,
NativeStackScreenProps,
} from '@react-navigation/native-stack';
import {Button, View, Text} from 'react-native';

type RootStackParamList = {
Home: undefined;
Details: undefined;
};

type HomeScreenProps = NativeStackScreenProps<RootStackParamList, 'Home'>;
type DetailsScreenProps = NativeStackScreenProps<RootStackParamList, 'Details'>;

const Stack = createNativeStackNavigator<RootStackParamList>();

function HomeScreen({navigation}: HomeScreenProps) {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text>Home Screen</Text>
<Button
title="Go to Details"
onPress={() => navigation.navigate('Details')}
/>
</View>
);
}

function DetailsScreen({navigation}: DetailsScreenProps) {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text>Details Screen</Text>
<Button
title="Go to Details Again"
onPress={() => navigation.push('Details')}
/>
<Button title="Go Back" onPress={() => navigation.goBack()} />
<Button title="Go to Home" onPress={() => navigation.navigate('Home')} />
</View>
);
}

export default function App() {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
fullScreenGestureEnabled: true,
}}>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Details" component={DetailsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
1 change: 1 addition & 0 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ - (void)handleSwipe:(UIPanGestureRecognizer *)gestureRecognizer
[_interactionController cancelInteractiveTransition];
}
_interactionController = nil;
_isFullWidthSwiping = NO;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so the main issue (change of transition style after popping a screen with swipe for the very first time) was caused by not properly reset state. Great finding!

}
default: {
break;
Expand Down
Loading