Skip to content

Commit

Permalink
ModalHostView's child view can not fill screen (#18615)
Browse files Browse the repository at this point in the history
Summary:
Signed-off-by: yukai <[email protected]>

In some Android device such as Samsung S8, the ModalHostView's child view can't fill the screen.
before:
![before](https://user-images.githubusercontent.com/1514899/38024961-3e756f8e-32b9-11e8-9555-50a7cf778288.jpeg)
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: #18615

Differential Revision: D14206830

Pulled By: cpojer

fbshipit-source-id: abe35ce1ab253aa1472d2c798543b515218be445
  • Loading branch information
yukai1 authored and facebook-github-bot committed Feb 25, 2019
1 parent a8449c1 commit b2d3052
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
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

0 comments on commit b2d3052

Please sign in to comment.