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: disable gestures in native stack on Android #496

Merged
merged 1 commit into from May 12, 2020

Conversation

WoLewicki
Copy link
Member

@WoLewicki WoLewicki commented May 6, 2020

If ScreenStacks of native-stack navigators have the same FragmentManager (because each of them is not under a different Screen component), changing a screen in one of the stacks pops one screen in the other stack because of the https://github.com/software-mansion/react-native-screens/blob/master/android/src/main/java/com/swmansion/rnscreens/ScreenStack.java#L34 being called in both ScreenStacks by the FragmentManager. The workaround is to set gestureEnabled to false in createNativeStackNavigator on Android since React-Navigation handles hw back button and setting it will make the https://github.com/software-mansion/react-native-screens/blob/master/android/src/main/java/com/swmansion/rnscreens/ScreenStack.java#L283 not to be called because the screen is not dismissable without gestureEnabled set to true. Should fix #402. PR also fixes some indentations since the file was not indented properly.

@@ -46,7 +46,7 @@ export default function NativeStackView({
<Screen
key={route.key}
style={StyleSheet.absoluteFill}
gestureEnabled={gestureEnabled}
gestureEnabled={Platform.OS === 'android' ? false : gestureEnabled}
Copy link
Contributor

Choose a reason for hiding this comment

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

swipe gestures are common on android these days tho. there will be no way to have them on android with this change, yeah?

Copy link
Member Author

Choose a reason for hiding this comment

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

gestureEnabled prop on Android handles dismissing screen by clicking hw back button and there are no swipe gestures supported by RNScreens on Android for now.

@WoLewicki WoLewicki merged commit 13cfd2c into master May 12, 2020
@WoLewicki WoLewicki deleted the @wolewcki/disable-gestures-android branch May 12, 2020 11:54
@ku8ar
Copy link

ku8ar commented Jul 16, 2021

@WoLewicki Can you tell me why property gestureEnabled exists on the native side if it is always false in JS? Maybe we should just remove this property in java code?

@WoLewicki
Copy link
Member Author

It is there e.g. for people who would like to make their own implementation of JS side of react-native-screens, with different handling of hw back button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android: Navigation resets to first tab in nested navigations
4 participants