mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-19 21:41:52 +08:00
ModalHostView's child view can not fill screen (#18615)
Summary: Signed-off-by: yukai <yk3372@gmail.com> In some Android device such as Samsung S8, the ModalHostView's child view can't fill the screen. before:  The JS ModalHostView can't fill the bottom, the area is device's navigation bar. In class ModalHostShadowNode, follow code calculate is error: `Point modalSize = ModalHostHelper.getModalHostSize(getThemedContext());` This way not care the device's navigation bar, so the height is smaller than real. For Samsung S8, real height is 2220 and modalSize.y is 2076. Pull Request resolved: https://github.com/facebook/react-native/pull/18615 Differential Revision: D14206830 Pulled By: cpojer fbshipit-source-id: abe35ce1ab253aa1472d2c798543b515218be445
This commit is contained in:
committed by
Facebook Github Bot
parent
a8449c14ac
commit
b2d3052de7
@@ -327,6 +327,9 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
||||
* 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);
|
||||
|
||||
@@ -337,7 +340,14 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
||||
@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(
|
||||
@@ -345,9 +355,19 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user