forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreact-native+0.73.4+004+AndroidModalSize.patch
142 lines (140 loc) · 6.46 KB
/
react-native+0.73.4+004+AndroidModalSize.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ModalHostHelper.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ModalHostHelper.java
deleted file mode 100644
index 3a226c0..0000000
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ModalHostHelper.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-package com.facebook.react.views.modal;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.Point;
-import android.view.Display;
-import android.view.WindowManager;
-import com.facebook.infer.annotation.Assertions;
-
-/** Helper class for Modals. */
-/*package*/ class ModalHostHelper {
-
- private static final Point MIN_POINT = new Point();
- private static final Point MAX_POINT = new Point();
- private static final Point SIZE_POINT = new Point();
-
- /**
- * To get the size of the screen, we use information from the WindowManager and default Display.
- * We don't use DisplayMetricsHolder, or Display#getSize() because they return values that include
- * the status bar. We only want the values of what will actually be shown on screen. We use
- * Display#getSize() to determine if the screen is in portrait or landscape. We don't use
- * getRotation because the 'natural' rotation will be portrait on phones and landscape on tablets.
- * This should only be called on the native modules/shadow nodes thread.
- */
- public static Point getModalHostSize(Context context) {
- WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- Display display = Assertions.assertNotNull(wm).getDefaultDisplay();
- // getCurrentSizeRange will return the min and max width and height that the window can be
- display.getCurrentSizeRange(MIN_POINT, MAX_POINT);
- // getSize will return the dimensions of the screen in its current orientation
- display.getSize(SIZE_POINT);
-
- int[] attrs = {android.R.attr.windowFullscreen};
- Resources.Theme theme = context.getTheme();
- TypedArray ta = theme.obtainStyledAttributes(attrs);
- boolean windowFullscreen = ta.getBoolean(0, false);
-
- // We need to add the status bar height to the height if we have a fullscreen window,
- // because Display.getCurrentSizeRange doesn't include it.
- Resources resources = context.getResources();
- int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android");
- int statusBarHeight = 0;
- if (windowFullscreen && statusBarId > 0) {
- statusBarHeight = (int) resources.getDimension(statusBarId);
- }
-
- if (SIZE_POINT.x < SIZE_POINT.y) {
- // If we are vertical the width value comes from min width and height comes from max height
- return new Point(MIN_POINT.x, MAX_POINT.y + statusBarHeight);
- } else {
- // If we are horizontal the width value comes from max width and height comes from min height
- return new Point(MAX_POINT.x, MIN_POINT.y + statusBarHeight);
- }
- }
-}
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ModalHostShadowNode.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ModalHostShadowNode.java
deleted file mode 100644
index 7288fe0..0000000
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ModalHostShadowNode.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-package com.facebook.react.views.modal;
-
-import android.graphics.Point;
-import com.facebook.react.uimanager.LayoutShadowNode;
-import com.facebook.react.uimanager.ReactShadowNodeImpl;
-
-/**
- * We implement the Modal by using an Android Dialog. That will fill the entire window of the
- * application. To get layout to work properly, we need to layout all the elements within the
- * Modal's inner content view as if they can fill the entire window. To do that, we need to
- * explicitly set the styleWidth and styleHeight on the LayoutShadowNode of the child of this node
- * to be the window size. This will then cause the children of the Modal to layout as if they can
- * fill the window.
- */
-class ModalHostShadowNode extends LayoutShadowNode {
-
- public ModalHostShadowNode() {}
-
- /**
- * We need to set the styleWidth and styleHeight of the one child (represented by the <View/>
- * within the <RCTModalHostView/> in Modal.js. This needs to fill the entire window.
- */
- @Override
- public void addChildAt(ReactShadowNodeImpl child, int i) {
- super.addChildAt(child, i);
- Point modalSize = ModalHostHelper.getModalHostSize(getThemedContext());
- child.setStyleWidth(modalSize.x);
- child.setStyleHeight(modalSize.y);
- }
-}
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java
index 74c6b8e..0d447e5 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java
@@ -50,16 +50,6 @@ public class ReactModalHostManager extends ViewGroupManager<ReactModalHostView>
return new ReactModalHostView(reactContext);
}
- @Override
- public LayoutShadowNode createShadowNodeInstance() {
- return new ModalHostShadowNode();
- }
-
- @Override
- public Class<? extends LayoutShadowNode> getShadowNodeClass() {
- return ModalHostShadowNode.class;
- }
-
@Override
public void onDropViewInstance(ReactModalHostView view) {
super.onDropViewInstance(view);
@@ -168,8 +158,6 @@ public class ReactModalHostManager extends ViewGroupManager<ReactModalHostView>
public Object updateState(
ReactModalHostView view, ReactStylesDiffMap props, StateWrapper stateWrapper) {
view.setStateWrapper(stateWrapper);
- Point modalSize = ModalHostHelper.getModalHostSize(view.getContext());
- view.updateState(modalSize.x, modalSize.y);
return null;
}