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

ModalHostView's child view can not fill screen #18615

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -327,6 +327,9 @@ private void updateProperties() {
* UIManagerModule, and will then cause the children to layout as if they can fill the window.
*/
static class DialogRootViewGroup extends ReactViewGroup implements RootView {
private boolean hasAdjustedSize = false;
private int viewWidth;
private int viewHeight;

private final JSTouchDispatcher mJSTouchDispatcher = new JSTouchDispatcher(this);

Expand All @@ -337,17 +340,34 @@ public DialogRootViewGroup(Context context) {
@Override
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
viewWidth = w;
viewHeight = h;
updateFirstChildView();
}

private void updateFirstChildView() {
if (getChildCount() > 0) {
hasAdjustedSize = false;
final int viewTag = getChildAt(0).getId();
ReactContext reactContext = getReactContext();
reactContext.runOnNativeModulesQueueThread(
new GuardedRunnable(reactContext) {
@Override
public void runGuarded() {
(getReactContext()).getNativeModule(UIManagerModule.class)
.updateNodeSize(viewTag, w, h);
.updateNodeSize(viewTag, viewWidth, viewHeight);
}
});
} else {
hasAdjustedSize = true;
}
}

@Override
public void addView(View child, int index, LayoutParams params) {
super.addView(child, index, params);
if (hasAdjustedSize) {
updateFirstChildView();
}
}

Expand Down