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

Ensured openDrawer of DrawerLayoutAndroid works on all screens #266

Merged
merged 1 commit into from
Jul 16, 2019

Conversation

grahammendick
Copy link
Owner

Fixes #264

Calling openDrawer only worked on the first screen, but not any subsequent ones.

The DrawerLayout on Android expects the layout to be done after it’s attached to the window. If it’s done before then it doesn’t open.

When navigating to a second screen React Native renders and does the layout first and then I start a new Activity and set the content. That’s the wrong order for the DrawerLayout. I fixed this by doing a second layout pass for the DrawerLayout after it’s attached to the window. I got the idea from the ViewPager component.

To avoid importing an androidx namespace I checked for DrawerLayout using a string. This means it works in both React Native 0.59 and 0.60. Unfortunately couldn’t check for ReactDrawerLayout because it’s not public.

If there's a Drawer then it the layout needs to happen after it's attached to the window
@grahammendick grahammendick merged commit 24e2572 into master Jul 16, 2019
@grahammendick grahammendick deleted the issue-264 branch July 16, 2019 11:26
grahammendick added a commit that referenced this pull request Sep 8, 2021
Applied the fix from over 2 years ago to the SceneView again and it works, #266!
Not sure why it didn't work for Fragments back then but it does now, #264 (comment)?
grahammendick added a commit that referenced this pull request Jul 16, 2024
I checked back and this seemed to be for handling activities - apparently drawer didn't open on second activity (#266). This seems to be a good time to remove this old code
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.

Integration issues with react-native-gesture-handler on Android
1 participant