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): restore old header animation to prevent content jump #2563

Merged
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
104 changes: 104 additions & 0 deletions apps/src/tests/TestAnimation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { NavigationContainer, RouteProp } from '@react-navigation/native';
import { NativeStackNavigationProp, createNativeStackNavigator } from '@react-navigation/native-stack';
import React from 'react';
import { View } from 'react-native';
import { Button, Square } from '../shared';

type ParamList = {
Home: undefined;
Second: undefined;
Third: undefined;
Fourth: undefined;
Fifth: undefined;
}

type RoutePropBase<RouteName extends keyof ParamList> = {
navigation: NativeStackNavigationProp<ParamList>,
route: RouteProp<ParamList, RouteName>;
}

const Stack = createNativeStackNavigator<ParamList>();

function Contents(): React.ReactNode {
return (
<View>
<Square size={200} color="lightblue" />
</View>
);
}

function Home({ navigation }: RoutePropBase<'Home'>): React.ReactNode {
return (
<View style={{ flex: 1, backgroundColor: 'lightgreen', justifyContent: 'center', alignItems: 'center' }}>
<View style={{ width: '100%', height: 20, backgroundColor: 'red' }} />
<Button title="Go Second" onPress={() => navigation.navigate('Second')} />
<Contents />
</View>
);
}


function Second({ navigation }: RoutePropBase<'Second'>): React.ReactNode {
return (
<View style={{ flex: 1, backgroundColor: 'lightseagreen', justifyContent: 'center', alignItems: 'center' }}>
<Button title="Go Third" onPress={() => navigation.navigate('Third')} />
<Button title="Go back" onPress={() => navigation.popTo('Home')} />
<Contents />
</View>
);
}

function Third({ navigation }: RoutePropBase<'Third'>): React.ReactNode {
return (
<View style={{ flex: 1, backgroundColor: 'lightcoral', justifyContent: 'center', alignItems: 'center' }}>
<Button title="Go Fourth" onPress={() => navigation.navigate('Fourth')} />
<Button title="Go back" onPress={() => navigation.popTo('Second')} />
<Contents />
</View>
);
}

function Fourth({ navigation }: RoutePropBase<'Fourth'>): React.ReactNode {
return (
<View style={{ flex: 1, backgroundColor: 'orange', justifyContent: 'center', alignItems: 'center' }}>
<Button title="Go Fifth" onPress={() => navigation.navigate('Fifth')} />
<Button title="Go back" onPress={() => navigation.popTo('Second')} />
<Contents />
</View>
);
}

function Fifth({ navigation }: RoutePropBase<'Fifth'>): React.ReactNode {
return (
<View style={{ flex: 1, backgroundColor: 'pink', justifyContent: 'center', alignItems: 'center' }}>
<Button title="Go back" onPress={() => navigation.popTo('Fourth')} />
<Contents />
</View>
);
}

export default function App() {
return (
<NavigationContainer>
<Stack.Navigator screenOptions={{
fullScreenGestureEnabled: true,
animation: 'simple_push',
//animationMatchesGesture: true,
}}>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="Second" component={Second} options={{
headerShown: true,
}}/>
<Stack.Screen name="Third" component={Third} options={{
headerShown: true,
}} />
<Stack.Screen name="Fourth" component={Fourth} options={{
headerShown: false,
}} />
<Stack.Screen name="Fifth" component={Fifth} options={{
headerShown: true,
}} />
</Stack.Navigator>
</NavigationContainer>
);
}
1 change: 1 addition & 0 deletions apps/src/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,5 @@ export { default as TestModalNavigation } from './TestModalNavigation';
export { default as TestMemoryLeak } from './TestMemoryLeak';
export { default as TestFormSheet } from './TestFormSheet';
export { default as TestAndroidTransitions } from './TestAndroidTransitions';
export { default as TestAnimation } from './TestAnimation';

10 changes: 5 additions & 5 deletions ios/RNSScreenStackAnimator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)t
return _transitionDuration;
}

- (id<UIViewImplicitlyAnimating>)interruptibleAnimatorForTransition:
(id<UIViewControllerContextTransitioning>)transitionContext
{
return _inFlightAnimator;
}
//- (id<UIViewImplicitlyAnimating>)interruptibleAnimatorForTransition:
// (id<UIViewControllerContextTransitioning>)transitionContext
//{
// return _inFlightAnimator;
//}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
Expand Down
Loading