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

chore: migrate to screens v4 and navigation v7 #6622

Merged
merged 12 commits into from
Nov 14, 2024
Prev Previous commit
Next Next commit
migrated navigate to popTo method
  • Loading branch information
alduzy committed Oct 22, 2024
commit 59573828c8b36a0d758fdae2f5efb1a372752e85
2 changes: 1 addition & 1 deletion apps/common-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function BackButton(props: HeaderBackButtonProps) {
const navigation = useNavigation<NavigationProp<RootStackParamList>>();

return (
<HeaderBackButton {...props} onPress={() => navigation.navigate('Home')} />
<HeaderBackButton {...props} onPress={() => navigation.popTo('Home')} />
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const App = ({
</Pressable>
<Pressable
style={[styles.button, styles.buttonOpen]}
onPress={() => navigation.navigate('Home')}>
onPress={() => navigation.popTo('Home')}>
<Text style={styles.textStyle}>Go back</Text>
</Pressable>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Screen1({ navigation }: NativeStackScreenProps<ParamListBase>) {
function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
return (
<View style={styles.flexOne}>
<Button title="go back" onPress={() => navigation.navigate('Screen1')} />
<Button title="go back" onPress={() => navigation.popTo('Screen1')} />
<Animated.View
style={styles.greenBoxScreenTwo}
sharedTransitionTag="tag"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
/>
<Button
title="go to Screen1"
onPress={() => navigation.navigate('Screen1')}
onPress={() => navigation.popTo('Screen1')}
/>
</View>
);
Expand Down Expand Up @@ -266,12 +266,12 @@ function Screen3({ navigation }: NativeStackScreenProps<ParamListBase>) {
</Animated.Text>
</Animated.View>
<Button
onPress={() => navigation.navigate('Screen1')}
onPress={() => navigation.popTo('Screen1')}
title="go to screen1"
/>
<Button
title="go to Screen2"
onPress={() => navigation.navigate('Screen2')}
onPress={() => navigation.popTo('Screen2')}
/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
sharedTransitionTag="tag"
sharedTransitionStyle={transition}
/>
<Button title="go back" onPress={() => navigation.navigate('Screen1')} />
<Button title="go back" onPress={() => navigation.popTo('Screen1')} />
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function Screen2({
}: NativeStackScreenProps<ParamList, 'Screen2'>) {
return (
<View style={styles.flexOne}>
<Button title="go back" onPress={() => navigation.navigate('Screen1')} />
<Button title="go back" onPress={() => navigation.popTo('Screen1')} />
<Animated.Image
sharedTransitionTag={route.params.sharedTransitionTag + 'image'}
source={photo}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
<Animated.View entering={SlideInLeft.delay(1000)} exiting={SlideOutLeft}>
<Button
title="go back"
onPress={() => navigation.navigate('Screen1')}
onPress={() => navigation.popTo('Screen1')}
/>
</Animated.View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
return (
<View style={styles.container}>
<Animated.View style={styles.greenBox} sharedTransitionTag="tag1" />
<Button title="Screen1" onPress={() => navigation.navigate('Screen1')} />
<Button title="Screen1" onPress={() => navigation.popTo('Screen1')} />
<Button title="Screen3" onPress={() => navigation.navigate('Screen3')} />
</View>
);
Expand All @@ -31,8 +31,8 @@ function Screen3({ navigation }: NativeStackScreenProps<ParamListBase>) {
return (
<View style={styles.flexOne}>
<Animated.View style={styles.blueBox} sharedTransitionTag="tag1" />
<Button title="Screen1" onPress={() => navigation.navigate('Screen1')} />
<Button title="Screen2" onPress={() => navigation.navigate('Screen2')} />
<Button title="Screen1" onPress={() => navigation.popTo('Screen1')} />
<Button title="Screen2" onPress={() => navigation.popTo('Screen2')} />
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
sharedTransitionTag="placeholder1"
style={styles.greenBoxScreenTwo}
/>
<Button title="go back" onPress={() => navigation.navigate('Screen1')} />
<Button title="go back" onPress={() => navigation.popTo('Screen1')} />
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function Screen2({
const { title, sharedTransitionTag } = route.params;

const goNext = () => {
navigation.navigate('Screen1', {
navigation.popTo('Screen1', {
title,
sharedTransitionTag,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
/>
</Animated.View>
</Animated.View>
<Button title="go back" onPress={() => navigation.navigate('Screen1')} />
<Button title="go back" onPress={() => navigation.popTo('Screen1')} />
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
return (
<View style={styles.container}>
<Animated.View style={styles.greenBox} sharedTransitionTag="tag1" />
<Button title="Screen1" onPress={() => navigation.navigate('Screen1')} />
<Button title="Screen1" onPress={() => navigation.popTo('Screen1')} />
<Button title="Screen3" onPress={() => navigation.navigate('Screen3')} />
</View>
);
Expand All @@ -31,8 +31,8 @@ function Screen3({ navigation }: NativeStackScreenProps<ParamListBase>) {
return (
<View style={styles.flexOne}>
<Animated.View style={styles.blueBox} sharedTransitionTag="tag1" />
<Button title="Screen1" onPress={() => navigation.navigate('Screen1')} />
<Button title="Screen2" onPress={() => navigation.navigate('Screen2')} />
<Button title="Screen1" onPress={() => navigation.popTo('Screen1')} />
<Button title="Screen2" onPress={() => navigation.popTo('Screen2')} />
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
</Animated.Text>
</Animated.View>
))}
<Button title="go back" onPress={() => navigation.navigate('Screen1')} />
<Button title="go back" onPress={() => navigation.popTo('Screen1')} />
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ function Screen3({ navigation }: NativeStackScreenProps<ParamListBase>) {
<View style={styles.container}>
<Button
title="go to screen1"
onPress={() => navigation.navigate('Screen1')}
onPress={() => navigation.popTo('Screen1')}
/>
<Button
title="go to screen2"
onPress={() => navigation.navigate('Screen2')}
onPress={() => navigation.popTo('Screen2')}
/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Screen2({ navigation }: NativeStackScreenProps<ParamListBase>) {
title="1 -> 2"
onPress={() => navigationSequence(navigation, 'Screen1', 'Screen2')}
/>
<Button title="Screen1" onPress={() => navigation.navigate('Screen1')} />
<Button title="Screen1" onPress={() => navigation.popTo('Screen1')} />
<Button title="Screen3" onPress={() => navigation.navigate('Screen3')} />
</View>
);
Expand All @@ -78,8 +78,8 @@ function Screen3({ navigation }: NativeStackScreenProps<ParamListBase>) {
<View style={styles.flexOne}>
<SharedView style={styles.blueBox} />
<SharedViewWithAnimation style={styles.blueBox} />
<Button title="Screen1" onPress={() => navigation.navigate('Screen1')} />
<Button title="Screen2" onPress={() => navigation.navigate('Screen2')} />
<Button title="Screen1" onPress={() => navigation.popTo('Screen1')} />
<Button title="Screen2" onPress={() => navigation.popTo('Screen2')} />
</View>
);
}
Expand Down