forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-native+0.75.2+023+modal-navigation-bar-translucent.patch
214 lines (204 loc) · 8.95 KB
/
react-native+0.75.2+023+modal-navigation-bar-translucent.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
diff --git a/node_modules/react-native/Libraries/Modal/Modal.d.ts b/node_modules/react-native/Libraries/Modal/Modal.d.ts
index 4cc2df2..a501b27 100644
--- a/node_modules/react-native/Libraries/Modal/Modal.d.ts
+++ b/node_modules/react-native/Libraries/Modal/Modal.d.ts
@@ -94,6 +94,11 @@ export interface ModalPropsAndroid {
* Determines whether your modal should go under the system statusbar.
*/
statusBarTranslucent?: boolean | undefined;
+
+ /**
+ * Determines whether your modal should go under the system navigationbar.
+ */
+ navigationBarTranslucent?: boolean | undefined;
}
export type ModalProps = ModalBaseProps &
diff --git a/node_modules/react-native/Libraries/Modal/Modal.js b/node_modules/react-native/Libraries/Modal/Modal.js
index 1942d9e..1ffbe4c 100644
--- a/node_modules/react-native/Libraries/Modal/Modal.js
+++ b/node_modules/react-native/Libraries/Modal/Modal.js
@@ -95,6 +95,14 @@ export type Props = $ReadOnly<{|
*/
statusBarTranslucent?: ?boolean,
+ /**
+ * The `navigationBarTranslucent` prop determines whether your modal should go under
+ * the system navigationbar.
+ *
+ * See https://reactnative.dev/docs/modal.html#navigationbartranslucent-android
+ */
+ navigationBarTranslucent?: ?boolean,
+
/**
* The `hardwareAccelerated` prop controls whether to force hardware
* acceleration for the underlying window.
@@ -170,6 +178,14 @@ function confirmProps(props: Props) {
`Modal with '${props.presentationStyle}' presentation style and 'transparent' value is not supported.`,
);
}
+ if (
+ props.navigationBarTranslucent === true &&
+ props.statusBarTranslucent !== true
+ ) {
+ console.warn(
+ 'Modal with translucent navigation bar and without translucent status bar is not supported.',
+ );
+ }
}
}
@@ -291,6 +307,7 @@ class Modal extends React.Component<Props, State> {
onDismiss={onDismiss}
visible={this.props.visible}
statusBarTranslucent={this.props.statusBarTranslucent}
+ navigationBarTranslucent={this.props.navigationBarTranslucent}
identifier={this._identifier}
style={styles.modal}
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
diff --git a/node_modules/react-native/React/Views/RCTModalHostView.h b/node_modules/react-native/React/Views/RCTModalHostView.h
index 2fcdcae..0469c23 100644
--- a/node_modules/react-native/React/Views/RCTModalHostView.h
+++ b/node_modules/react-native/React/Views/RCTModalHostView.h
@@ -27,6 +27,7 @@
// Android only
@property (nonatomic, assign) BOOL statusBarTranslucent;
+@property (nonatomic, assign) BOOL navigationBarTranslucent;
@property (nonatomic, assign) BOOL hardwareAccelerated;
@property (nonatomic, assign) BOOL animated;
diff --git a/node_modules/react-native/React/Views/RCTModalHostViewManager.m b/node_modules/react-native/React/Views/RCTModalHostViewManager.m
index e2ae7e2..a694008 100644
--- a/node_modules/react-native/React/Views/RCTModalHostViewManager.m
+++ b/node_modules/react-native/React/Views/RCTModalHostViewManager.m
@@ -118,6 +118,7 @@ - (void)invalidate
RCT_EXPORT_VIEW_PROPERTY(presentationStyle, UIModalPresentationStyle)
RCT_EXPORT_VIEW_PROPERTY(transparent, BOOL)
RCT_EXPORT_VIEW_PROPERTY(statusBarTranslucent, BOOL)
+RCT_EXPORT_VIEW_PROPERTY(navigationBarTranslucent, BOOL)
RCT_EXPORT_VIEW_PROPERTY(hardwareAccelerated, BOOL)
RCT_EXPORT_VIEW_PROPERTY(animated, BOOL)
RCT_EXPORT_VIEW_PROPERTY(onShow, RCTDirectEventBlock)
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.kt b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.kt
index d5e053c..fddda45 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.kt
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.kt
@@ -59,6 +59,15 @@ public class ReactModalHostManager :
view.statusBarTranslucent = statusBarTranslucent
}
+
+ @ReactProp(name = "navigationBarTranslucent")
+ public override fun setNavigationBarTranslucent(
+ view: ReactModalHostView,
+ navigationBarTranslucent: Boolean
+ ) {
+ view.navigationBarTranslucent = navigationBarTranslucent
+ }
+
@ReactProp(name = "hardwareAccelerated")
public override fun setHardwareAccelerated(
view: ReactModalHostView,
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt
index f6e0d82..03380cb 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt
@@ -46,6 +46,7 @@ import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.events.EventDispatcher
import com.facebook.react.views.common.ContextUtils
import com.facebook.react.views.view.ReactViewGroup
+import com.facebook.react.views.view.setSystemBarsTranslucency
import java.util.Objects
import kotlin.math.abs
@@ -78,6 +79,12 @@ public class ReactModalHostView(context: ThemedReactContext) :
createNewDialog = true
}
+ public var navigationBarTranslucent: Boolean = false
+ set(value) {
+ field = value
+ createNewDialog = true
+ }
+
public var animationType: String? = null
set(value) {
field = value
@@ -296,6 +303,7 @@ public class ReactModalHostView(context: ThemedReactContext) :
} else {
frameLayout.fitsSystemWindows = true
}
+ dialog?.window?.setSystemBarsTranslucency(navigationBarTranslucent)
return frameLayout
}
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/WindowUtil.kt b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/WindowUtil.kt
new file mode 100644
index 0000000..24057c4
--- /dev/null
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/WindowUtil.kt
@@ -0,0 +1,53 @@
+/*
+ * 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.view
+
+import android.content.res.Configuration
+import android.graphics.Color
+import android.os.Build
+import android.view.Window
+import android.view.WindowManager
+import androidx.core.view.ViewCompat
+import androidx.core.view.WindowCompat
+import androidx.core.view.WindowInsetsControllerCompat
+
+@Suppress("DEPRECATION")
+public fun Window.setSystemBarsTranslucency(isTranslucent: Boolean) {
+ WindowCompat.setDecorFitsSystemWindows(this, !isTranslucent)
+
+ if (isTranslucent) {
+ val isDarkMode =
+ context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK ==
+ Configuration.UI_MODE_NIGHT_YES
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ isStatusBarContrastEnforced = false
+ isNavigationBarContrastEnforced = true
+ }
+
+ statusBarColor = Color.TRANSPARENT
+ navigationBarColor = when {
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> Color.TRANSPARENT
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !isDarkMode ->
+ Color.argb(0xe6, 0xFF, 0xFF, 0xFF)
+ else -> Color.argb(0x80, 0x1b, 0x1b, 0x1b)
+ }
+
+ WindowInsetsControllerCompat(this, this.decorView).run {
+ isAppearanceLightNavigationBars = !isDarkMode
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ attributes.layoutInDisplayCutoutMode = when {
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.R ->
+ WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
+ else -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/node_modules/react-native/src/private/specs/components/RCTModalHostViewNativeComponent.js b/node_modules/react-native/src/private/specs/components/RCTModalHostViewNativeComponent.js
index 86bf895..58ec294 100644
--- a/node_modules/react-native/src/private/specs/components/RCTModalHostViewNativeComponent.js
+++ b/node_modules/react-native/src/private/specs/components/RCTModalHostViewNativeComponent.js
@@ -58,6 +58,14 @@ type NativeProps = $ReadOnly<{|
*/
statusBarTranslucent?: WithDefault<boolean, false>,
+ /**
+ * The `navigationBarTranslucent` prop determines whether your modal should go under
+ * the system navigationbar.
+ *
+ * See https://reactnative.dev/docs/modal#navigationBarTranslucent
+ */
+ navigationBarTranslucent?: WithDefault<boolean, false>,
+
/**
* The `hardwareAccelerated` prop controls whether to force hardware
* acceleration for the underlying window.