Skip to content

Commit 59703e1

Browse files
authored
chore: Bump react-navigation and update Test2560 to cover sheetResizeAnimationEnabled (#3581)
## Description Follow-up to #3484 - after upgrading `react-navigation/native-stack` to 7.11, we can update the example to test both scenarios with default and custom animations dynamically. ## Changes - Upgraded `react-navigation` to cover `native-stack` release containing `sheetResizeAnimationEnabled` - Updated Test2560 ## Before & after - visual documentation https://github.com/user-attachments/assets/bcd780ec-ddfd-4a19-acb7-d84636a943bb ## Test plan No regression observed in Test2560. ## Checklist - [x] Included code example that can be used to test this change. - [ ] Updated / created local changelog entries in relevant test files. - [x] For visual changes, included screenshots / GIFs / recordings documenting the change. - [ ] For API changes, updated relevant public types. - [x] Ensured that CI passes
1 parent 1c28f52 commit 59703e1

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

apps/src/tests/Test2560.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,37 @@ import {
1515
import Colors from '../shared/styling/Colors';
1616
import PressableWithFeedback from '../shared/PressableWithFeedback';
1717

18-
const USE_ANIMATED_COMPONENT = false;
19-
2018
type StackParamList = {
2119
Home: undefined;
22-
FormSheet: undefined;
20+
FormSheet: { useAnimated: boolean };
2321
};
2422

2523
const Stack = createNativeStackNavigator<StackParamList>();
2624

27-
const HomeScreen = ({ navigation }: NativeStackScreenProps<StackParamList>) => (
28-
<View style={styles.screen}>
29-
<Text style={styles.title}>Home Screen</Text>
30-
<Button
31-
title="Open Form Sheet"
32-
onPress={() => navigation.navigate('FormSheet')}
33-
/>
34-
</View>
35-
);
25+
const HomeScreen = ({ navigation }: NativeStackScreenProps<StackParamList>) => {
26+
const [useAnimated, setUseAnimated] = useState(false);
27+
28+
return (
29+
<View style={styles.screen}>
30+
<Text style={styles.title}>Home Screen</Text>
31+
<Button
32+
title="Open Form Sheet"
33+
onPress={() => navigation.navigate('FormSheet', { useAnimated })}
34+
/>
35+
<Button
36+
title={`Using custom animation: ${useAnimated ? 'YES' : 'NO'}`}
37+
onPress={() => setUseAnimated(prev => !prev)}
38+
/>
39+
</View>
40+
);
41+
};
3642

3743
const FormSheetScreen = ({
3844
navigation,
39-
}: NativeStackScreenProps<StackParamList>) => {
45+
route,
46+
}: NativeStackScreenProps<StackParamList, 'FormSheet'>) => {
47+
const { useAnimated } = route.params;
48+
4049
const [showTopView, setShowTopView] = useState(false);
4150
const [showBottomView, setShowBottomView] = useState(false);
4251
const [rectangleHeight, setRectangleHeight] = useState(200);
@@ -71,7 +80,7 @@ const FormSheetScreen = ({
7180
</View>
7281
)}
7382
<Text style={styles.formSheetTitle}>Form Sheet Content</Text>
74-
{USE_ANIMATED_COMPONENT ? (
83+
{useAnimated ? (
7584
<Animated.View
7685
style={[styles.rectangle, { height: animatedRectangleHeight }]}
7786
/>
@@ -83,7 +92,7 @@ const FormSheetScreen = ({
8392
title={showTopView ? 'Hide Top View' : 'Show Top View'}
8493
onPress={toggleTopView}
8594
/>
86-
{USE_ANIMATED_COMPONENT ? (
95+
{useAnimated ? (
8796
<Button
8897
title={`Toggle Animated Rectangle Height (Current: ${currentAnimatedRectangleHeight.current}px)`}
8998
onPress={toggleAnimatedRectangleHeight}
@@ -118,14 +127,14 @@ export default function App() {
118127
<Stack.Screen
119128
name="FormSheet"
120129
component={FormSheetScreen}
121-
options={{
130+
options={({ route }) => ({
122131
presentation: 'formSheet',
123132
sheetAllowedDetents: 'fitToContents',
124133
contentStyle: {
125134
backgroundColor: Colors.YellowLight40,
126135
},
127-
// TODO(@t0maboro) - add `sheetDefaultResizeAnimationEnabled` prop here when possible
128-
}}
136+
sheetResizeAnimationEnabled: !route.params.useAnimated,
137+
})}
129138
/>
130139
</Stack.Navigator>
131140
</NavigationContainer>

0 commit comments

Comments
 (0)