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

Supported DrawerLayoutAndroid component from react native #530

Merged
merged 1 commit into from
Sep 8, 2021
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.navigation.reactnative;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.facebook.react.bridge.ReactContext;
Expand All @@ -19,6 +20,28 @@ public SceneView(Context context) {
super(context);
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
View child = getChildAt(0);
if (child != null && child.getClass().getSimpleName().contains("DrawerLayout")) {
child.requestLayout();
post(measureAndLayoutDrawer);
}
}

private final Runnable measureAndLayoutDrawer = new Runnable() {
@Override
public void run() {
View drawer = getChildAt(0);
if (drawer == null) return;
drawer.measure(
MeasureSpec.makeMeasureSpec(drawer.getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(drawer.getHeight(), MeasureSpec.EXACTLY));
drawer.layout(drawer.getLeft(), drawer.getTop(), drawer.getRight(), drawer.getBottom());
}
};

protected void popped() {
ReactContext reactContext = (ReactContext) getContext();
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(getId(),"onPopped", null);
Expand Down