@onekeyfe/react-native-native-overlay 6.7.0-alpha.466 → 6.8.0-10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +119 -21
  2. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayEntryRootView.kt +60 -0
  3. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayHost.kt +37 -5
  4. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayPackage.kt +1 -1
  5. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayPageHostView.kt +14 -3
  6. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToastCardView.kt +869 -0
  7. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToastSpec.kt +327 -0
  8. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToasterView.kt +574 -0
  9. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToasterViewManager.kt +54 -0
  10. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayView.kt +12 -0
  11. package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayViewManager.kt +8 -0
  12. package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlayAccessibilityIsolationTest.kt +172 -0
  13. package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlayMotionTest.kt +42 -0
  14. package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlayPageHostLayoutTest.kt +58 -0
  15. package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlaySheetInsetTest.kt +78 -0
  16. package/docs/SPEC.md +337 -33
  17. package/ios/NativeOverlayContainerView.swift +6 -0
  18. package/ios/NativeOverlayToastCardView.swift +572 -0
  19. package/ios/NativeOverlayToastSpec.swift +356 -0
  20. package/ios/NativeOverlayToasterView.swift +519 -0
  21. package/ios/NativeOverlayWindowManager.swift +244 -7
  22. package/ios/RCTNativeOverlayToasterComponentView.h +11 -0
  23. package/ios/RCTNativeOverlayToasterComponentView.mm +85 -0
  24. package/lib/module/NativeOverlayNativeComponent.ts +13 -0
  25. package/lib/module/NativeOverlayToasterNativeComponent.ts +24 -0
  26. package/lib/module/OverlayView.js +7 -1
  27. package/lib/module/OverlayView.js.map +1 -1
  28. package/lib/module/animation/anchoredOrigin.js +26 -0
  29. package/lib/module/animation/anchoredOrigin.js.map +1 -0
  30. package/lib/module/animation/resolveAnimation.js +26 -4
  31. package/lib/module/animation/resolveAnimation.js.map +1 -1
  32. package/lib/module/index.js +3 -0
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/module/toast/OverlayToastHost.js +42 -0
  35. package/lib/module/toast/OverlayToastHost.js.map +1 -0
  36. package/lib/module/toast/OverlayToastHost.web.js +32 -0
  37. package/lib/module/toast/OverlayToastHost.web.js.map +1 -0
  38. package/lib/module/toast/OverlayToastStore.js +217 -0
  39. package/lib/module/toast/OverlayToastStore.js.map +1 -0
  40. package/lib/module/toast/toastBridge.js +65 -0
  41. package/lib/module/toast/toastBridge.js.map +1 -0
  42. package/lib/module/toast/toastDomContent.web.js +298 -0
  43. package/lib/module/toast/toastDomContent.web.js.map +1 -0
  44. package/lib/module/toast/toastDomRenderer.web.js +695 -0
  45. package/lib/module/toast/toastDomRenderer.web.js.map +1 -0
  46. package/lib/module/toast/toastStyles.web.js +97 -0
  47. package/lib/module/toast/toastStyles.web.js.map +1 -0
  48. package/lib/module/toast/types.js +2 -0
  49. package/lib/module/toast/types.js.map +1 -0
  50. package/lib/module/web/animateTransition.js +38 -12
  51. package/lib/module/web/animateTransition.js.map +1 -1
  52. package/lib/module/web/overlayLayers.js +5 -0
  53. package/lib/module/web/overlayLayers.js.map +1 -1
  54. package/lib/typescript/src/NativeOverlayNativeComponent.d.ts +13 -0
  55. package/lib/typescript/src/NativeOverlayNativeComponent.d.ts.map +1 -1
  56. package/lib/typescript/src/NativeOverlayToasterNativeComponent.d.ts +19 -0
  57. package/lib/typescript/src/NativeOverlayToasterNativeComponent.d.ts.map +1 -0
  58. package/lib/typescript/src/OverlayView.d.ts.map +1 -1
  59. package/lib/typescript/src/animation/anchoredOrigin.d.ts +7 -0
  60. package/lib/typescript/src/animation/anchoredOrigin.d.ts.map +1 -0
  61. package/lib/typescript/src/animation/resolveAnimation.d.ts +9 -3
  62. package/lib/typescript/src/animation/resolveAnimation.d.ts.map +1 -1
  63. package/lib/typescript/src/animation/types.d.ts +5 -1
  64. package/lib/typescript/src/animation/types.d.ts.map +1 -1
  65. package/lib/typescript/src/index.d.ts +5 -0
  66. package/lib/typescript/src/index.d.ts.map +1 -1
  67. package/lib/typescript/src/toast/OverlayToastHost.d.ts +6 -0
  68. package/lib/typescript/src/toast/OverlayToastHost.d.ts.map +1 -0
  69. package/lib/typescript/src/toast/OverlayToastHost.web.d.ts +6 -0
  70. package/lib/typescript/src/toast/OverlayToastHost.web.d.ts.map +1 -0
  71. package/lib/typescript/src/toast/OverlayToastStore.d.ts +47 -0
  72. package/lib/typescript/src/toast/OverlayToastStore.d.ts.map +1 -0
  73. package/lib/typescript/src/toast/toastBridge.d.ts +11 -0
  74. package/lib/typescript/src/toast/toastBridge.d.ts.map +1 -0
  75. package/lib/typescript/src/toast/toastDomContent.web.d.ts +15 -0
  76. package/lib/typescript/src/toast/toastDomContent.web.d.ts.map +1 -0
  77. package/lib/typescript/src/toast/toastDomRenderer.web.d.ts +8 -0
  78. package/lib/typescript/src/toast/toastDomRenderer.web.d.ts.map +1 -0
  79. package/lib/typescript/src/toast/toastStyles.web.d.ts +2 -0
  80. package/lib/typescript/src/toast/toastStyles.web.d.ts.map +1 -0
  81. package/lib/typescript/src/toast/types.d.ts +240 -0
  82. package/lib/typescript/src/toast/types.d.ts.map +1 -0
  83. package/lib/typescript/src/web/animateTransition.d.ts +12 -0
  84. package/lib/typescript/src/web/animateTransition.d.ts.map +1 -1
  85. package/lib/typescript/src/web/overlayLayers.d.ts.map +1 -1
  86. package/package.json +3 -2
  87. package/react-native.config.js +1 -0
  88. package/src/NativeOverlayNativeComponent.ts +13 -0
  89. package/src/NativeOverlayToasterNativeComponent.ts +24 -0
  90. package/src/OverlayView.tsx +7 -0
  91. package/src/animation/anchoredOrigin.ts +35 -0
  92. package/src/animation/resolveAnimation.ts +28 -7
  93. package/src/animation/types.ts +5 -1
  94. package/src/index.ts +24 -0
  95. package/src/toast/OverlayToastHost.tsx +62 -0
  96. package/src/toast/OverlayToastHost.web.tsx +29 -0
  97. package/src/toast/OverlayToastStore.ts +254 -0
  98. package/src/toast/toastBridge.ts +62 -0
  99. package/src/toast/toastDomContent.web.ts +351 -0
  100. package/src/toast/toastDomRenderer.web.ts +856 -0
  101. package/src/toast/toastStyles.web.ts +97 -0
  102. package/src/toast/types.ts +251 -0
  103. package/src/web/animateTransition.ts +54 -14
  104. package/src/web/overlayLayers.ts +7 -0
package/README.md CHANGED
@@ -1,35 +1,133 @@
1
+ <div align="center">
2
+
1
3
  # @onekeyfe/react-native-native-overlay
2
4
 
3
- Native and Web overlay hosts with ordered levels, page scope, lifecycle events,
4
- keyboard avoidance and Fabric measurement. See [SPEC](docs/SPEC.md) for the
5
- behavioral contract, platform differences and outstanding runtime acceptance.
5
+ **Overlay hosts that draw above the app on iOS, Android and Web while keeping the caller's React subtree and hit testing intact.**
6
+
7
+ [![npm](https://img.shields.io/npm/v/%40onekeyfe%2Freact-native-native-overlay?label=npm&color=4D6BFE)](https://www.npmjs.com/package/@onekeyfe/react-native-native-overlay)
8
+ [![license](https://img.shields.io/npm/l/%40onekeyfe%2Freact-native-native-overlay?label=license&color=4D6BFE)](LICENSE)
9
+ ![iOS](https://img.shields.io/badge/iOS-000000?logo=apple&logoColor=white)
10
+ ![Android](https://img.shields.io/badge/Android-3DDC84?logo=android&logoColor=white)
11
+ ![Web](https://img.shields.io/badge/Web-4285F4?logo=googlechrome&logoColor=white)
12
+ ![Fabric](https://img.shields.io/badge/Fabric-4D6BFE)
13
+
14
+ </div>
15
+
16
+ Owns where an overlay is drawn, which overlay is on top and how it enters and
17
+ exits. Levels are fixed (`modal`, `hardware`, `secure`, `toast`, `lock`,
18
+ `debug`), each entry picks a `global` or `page` scope and a lane strategy, and
19
+ the native host reparents the caller's content so React context, refs and
20
+ `measureInWindow` keep working. Sheet, center, fullscreen, toast and anchored
21
+ presentations are available; the application owns the content and business UI.
22
+
23
+ ## Features
24
+
25
+ - **Predictable ordering** — every page entry renders below every global entry,
26
+ and inside a scope entries sort by level and then by request order.
27
+ - **Lane strategies** — `stack`, `queue` and `replace` apply per
28
+ (scope, host, level) lane, with `priority`, `replaceKey` and de-duplicated ids.
29
+ - **Preserved React identity** — the overlay view stays where the caller
30
+ rendered it; native code moves its content into the host, so there is no
31
+ portal that drops context.
32
+ - **Page scope that covers chrome** — `OverlayPageHost` as the last child of a
33
+ root route lets page overlays cover native headers and the tab bar.
34
+ - **Native presentation and motion** — sheet drag, back handling, keyboard
35
+ avoidance, status bar styling and configurable enter/exit animations.
36
+ - **Web parity** — the Web implementation portals into z-indexed level layers
37
+ with a focus trap and page isolation.
38
+
39
+ ## Installation
40
+
41
+ ```sh
42
+ yarn add @onekeyfe/react-native-native-overlay
43
+ ```
44
+
45
+ The native hosts are React Native Fabric codegen components, not Nitro views.
46
+ Install the app's iOS pods and rebuild the native application after adding the
47
+ package. Web additionally needs `react-dom`; it is declared as an optional peer
48
+ dependency.
49
+
50
+ ## Usage
6
51
 
7
52
  ```tsx
8
- import { OverlayView } from '@onekeyfe/react-native-native-overlay';
53
+ import { useState } from 'react';
54
+ import {
55
+ OverlayPageHost,
56
+ OverlayView,
57
+ } from '@onekeyfe/react-native-native-overlay';
9
58
 
10
- <OverlayView open={open} presentation="sheet" level="modal">
11
- {content}
12
- </OverlayView>;
59
+ function MainRoute() {
60
+ const [visible, setVisible] = useState(false);
61
+ return (
62
+ <>
63
+ {screen}
64
+ <OverlayView
65
+ visible={visible}
66
+ presentation="sheet"
67
+ level="modal"
68
+ sheet={{ dismissOnPanDown: true, cornerRadius: 24 }}
69
+ onRequestDismiss={() => setVisible(false)}
70
+ >
71
+ {content}
72
+ </OverlayView>
73
+ {/* Last child of the root route, after its navigator. */}
74
+ <OverlayPageHost hostKey="main" />
75
+ </>
76
+ );
77
+ }
13
78
  ```
14
79
 
15
- Global levels are ordered modal, hardware, secure, toast, lock, then debug.
16
- React context stays attached to the original subtree while the native host
17
- reparents its contents. Page overlays use `OverlayPageHost` and
18
- `OverlayPageHostScope` / `OverlayPageOwnerScope`. Android and iOS require the React Native new
19
- architecture; Web additionally requires `react-dom`.
80
+ The application still owns `visible` and the content. `scope="page"` resolves
81
+ `hostKey`/`ownerKey` from the nearest `OverlayPageHostScope` and
82
+ `OverlayPageOwnerScope` providers.
83
+
84
+ ## API
85
+
86
+ | Export | Shape | Description | Platforms |
87
+ | --- | --- | --- | :-: |
88
+ | `OverlayView` | component | Declarative overlay: `visible`, `scope`, `level`, `strategy`, `priority`, `replaceKey`, `presentation`, `sheet`, `animation`, `backdrop`, `blocking`, `keepContentMounted`, `statusBarStyle`, `contentSize`, dismiss/present callbacks. | iOS, Android, Web |
89
+ | `OverlayPageHost` | component | Renders the page-scope overlays of one root route from `hostKey`. | iOS, Android, Web |
90
+ | `OverlayPageHostScope`, `OverlayPageOwnerScope` | providers | Supply `hostKey` per root route and `ownerKey` per page. | iOS, Android, Web |
91
+ | `overlayStore` | store | Imperative `request`, `dismiss`, `finalize`, `reopen`, `dismissAll`, `setPageVisible`, `removePage`, `resolveBack`. | iOS, Android, Web |
92
+ | `OverlayRequestError` | error class | Thrown for invalid requests such as a page entry without keys. | iOS, Android, Web |
93
+ | `OVERLAY_LEVELS`, `OVERLAY_LEVEL_ORDER` | constants | The level list and their numeric order. | iOS, Android, Web |
94
+ | `resolveOverlayAnimation`, `OVERLAY_MOTION_PRESETS`, `NATIVE_MOTION_PRESETS`, `WEB_MOTION_PRESETS` | helpers | Resolve animation configs per platform. | iOS, Android, Web |
95
+
96
+ `presentation` accepts `sheet`, `center`, `fullscreen`, `toast` and `anchored`.
97
+ `strategy` accepts `stack`, `queue` and `replace`. See
98
+ [`docs/SPEC.md`](docs/SPEC.md) for the ownership model, platform differences and
99
+ acceptance record.
100
+
101
+ ## Platform support
102
+
103
+ | Capability | iOS | Android | Web |
104
+ | --- | :-: | :-: | :-: |
105
+ | Global overlays and level ordering | ✅ | ✅ | ✅ |
106
+ | Page scope via `OverlayPageHost` | ✅ | ✅ | ✅ |
107
+ | Sheet presentation | ✅ | ✅ | ✅ |
108
+ | Keyboard avoidance | ✅ | ✅ | ✅ |
109
+ | `windowOffsetRequest` for modal-relative anchors | ✅ | — | — |
110
+ | `contentSize` for pre-rotation layout | ✅ | ✅ | — |
111
+ | Status bar styling | ✅ | ✅ | — |
112
+
113
+ ## Caveats
20
114
 
21
- ## Development
115
+ > [!IMPORTANT]
116
+ > Page-scope entries need both `hostKey` and `ownerKey`. A declarative
117
+ > `OverlayView` waits until the nearest scope providers supply them, but a
118
+ > direct `overlayStore.request` with a missing key throws `OverlayRequestError`.
22
119
 
23
- Run `yarn typecheck`, `yarn lint`, `yarn test --runInBand`, and `yarn prepare`.
24
- This package was initialized from the repository view template and retains
25
- Fabric rather than Nitro under the explicit exception recorded in the SPEC.
120
+ > [!NOTE]
121
+ > The `windowOffsetRequest`/`onWindowOffset` and `contentSize` props are
122
+ > native-only layout aids; they do nothing on Web. On Web the overlay portals
123
+ > into a level layer and relies on `react-dom`.
26
124
 
27
- ## Release
125
+ ## References
28
126
 
29
- Use the repository `package-publish` CI workflow. This branch's synchronized
30
- 42-package batch is `3.0.162-alpha.270`, published under `next`; no PR merge or
31
- stable-tag change is required. Consumers must pin the exact verified version.
127
+ - [Package spec](docs/SPEC.md)
128
+ - [Public exports](src/index.ts)
129
+ - [Changelog](../../CHANGELOG.md)
32
130
 
33
131
  ## License
34
132
 
35
- MIT
133
+ MIT. See [LICENSE](LICENSE).
@@ -103,6 +103,9 @@ internal class NativeOverlayEntryRootView(
103
103
  private var imeBottom = 0
104
104
  private var safeTop = 0
105
105
  private var sheetBottomPadding = 0
106
+ /** Paints the platform sheet's navigation-bar inset strip. */
107
+ internal var sheetBottomInsetPaintView: View? = null
108
+ private set
106
109
  private var keyboardAnimating = false
107
110
 
108
111
  /** `sheet` presentation: the draggable surface; otherwise null. */
@@ -156,6 +159,8 @@ internal class NativeOverlayEntryRootView(
156
159
  backgroundColor: Int,
157
160
  showHandle: Boolean,
158
161
  draggable: Boolean,
162
+ bottomInsetColor: Int? = null,
163
+ bottomInsetHorizontalPx: Float = 0f,
159
164
  ) {
160
165
  val sheet = sheetView ?: createSheet()
161
166
  (sheet.background as? GradientDrawable)?.apply {
@@ -178,6 +183,60 @@ internal class NativeOverlayEntryRootView(
178
183
  params.height = targetHeight
179
184
  sheet.layoutParams = params
180
185
  }
186
+ updateSheetBottomInsetPaint(sheetBottomPadding, bottomInsetColor, bottomInsetHorizontalPx)
187
+ }
188
+
189
+ /**
190
+ * `sheet` presentation: the sheet pads its content by the navigation-bar
191
+ * inset so the content sits above the system bar. When JS draws the surface
192
+ * the platform sheet stays transparent, and the JS safe-area tail cannot
193
+ * paint this strip on Android: it hangs below the React content root, which
194
+ * Android does not composite outside its bounds. Paint the strip natively
195
+ * with the drawn surface color instead. A null color keeps it transparent
196
+ * for platform-painted sheets.
197
+ */
198
+ internal fun updateSheetBottomInsetPaint(
199
+ insetPx: Int,
200
+ color: Int?,
201
+ horizontalInsetPx: Float,
202
+ ) {
203
+ val sheet = sheetView ?: return
204
+ if (color == null || insetPx <= 0) {
205
+ sheetBottomInsetPaintView?.let { paint ->
206
+ sheet.removeView(paint)
207
+ sheetBottomInsetPaintView = null
208
+ }
209
+ return
210
+ }
211
+ val paint = sheetBottomInsetPaintView ?: View(reactContext).apply {
212
+ isClickable = false
213
+ isFocusable = false
214
+ importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_NO
215
+ // Index 0 keeps the strip behind the sheet content.
216
+ sheet.addView(
217
+ this,
218
+ 0,
219
+ LayoutParams(LayoutParams.MATCH_PARENT, 0).apply { gravity = Gravity.BOTTOM },
220
+ )
221
+ sheetBottomInsetPaintView = this
222
+ }
223
+ paint.setBackgroundColor(color)
224
+ // The content height can be fractional; overlap it by a couple of points so
225
+ // rounding cannot leave an unpainted row above the strip. Both views share
226
+ // the same surface color, so the overlap is invisible.
227
+ val height = insetPx + (2 * resources.displayMetrics.density).toInt()
228
+ val horizontal = horizontalInsetPx.toInt().coerceAtLeast(0)
229
+ val params = paint.layoutParams as LayoutParams
230
+ if (
231
+ params.height != height ||
232
+ params.leftMargin != horizontal ||
233
+ params.rightMargin != horizontal
234
+ ) {
235
+ params.height = height
236
+ params.leftMargin = horizontal
237
+ params.rightMargin = horizontal
238
+ paint.layoutParams = params
239
+ }
181
240
  }
182
241
 
183
242
  /** The sheet's full height, navigation bar padding included. */
@@ -242,6 +301,7 @@ internal class NativeOverlayEntryRootView(
242
301
  sheetAnimationView = coordinator
243
302
  sheetBehavior = behavior
244
303
  handleView = handle
304
+ sheetBottomInsetPaintView = null
245
305
  return sheet
246
306
  }
247
307
 
@@ -2,6 +2,7 @@ package com.onekey.nativeoverlay
2
2
 
3
3
  import android.app.Activity
4
4
  import android.view.KeyEvent
5
+ import android.view.View
5
6
  import android.view.ViewGroup
6
7
  import android.view.Window
7
8
  import android.widget.FrameLayout
@@ -103,6 +104,32 @@ internal class NativeOverlayHost private constructor(
103
104
  onEntriesChanged()
104
105
  }
105
106
 
107
+ /**
108
+ * Adds the message-toast layer under every entry of the `toast` level: the
109
+ * cards are plain views, drawn by the platform rather than hosted React
110
+ * content, and custom toast entries stay above them.
111
+ */
112
+ fun attachToastLayer(layer: View) {
113
+ val content = activity.findViewById<ViewGroup>(android.R.id.content) ?: return
114
+ if (parent !== content) {
115
+ (parent as? ViewGroup)?.removeView(this)
116
+ content.addView(this, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
117
+ } else if (content.getChildAt(content.childCount - 1) !== this) {
118
+ bringToFront()
119
+ }
120
+ val container = levelContainer(NativeOverlayLevel.TOAST)
121
+ if (layer.parent !== container) {
122
+ (layer.parent as? ViewGroup)?.removeView(layer)
123
+ container.addView(layer, 0, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
124
+ }
125
+ updateAccessibility()
126
+ }
127
+
128
+ fun detachToastLayer(layer: View) {
129
+ (layer.parent as? ViewGroup)?.removeView(layer)
130
+ updateAccessibility()
131
+ }
132
+
106
133
  fun detach(entry: NativeOverlayEntryRootView) {
107
134
  (entry.parent as? ViewGroup)?.removeView(entry)
108
135
  onEntriesChanged()
@@ -128,11 +155,14 @@ internal class NativeOverlayHost private constructor(
128
155
  container
129
156
  }
130
157
 
131
- private fun orderedEntries(): List<NativeOverlayEntryRootView> =
158
+ private fun orderedViews(): List<View> =
132
159
  levelContainers.values.flatMap { container ->
133
- (0 until container.childCount).mapNotNull { container.getChildAt(it) as? NativeOverlayEntryRootView }
160
+ (0 until container.childCount).map { container.getChildAt(it) }
134
161
  }
135
162
 
163
+ private fun orderedEntries(): List<NativeOverlayEntryRootView> =
164
+ orderedViews().filterIsInstance<NativeOverlayEntryRootView>()
165
+
136
166
  /** Global overlays win; otherwise the topmost visible page overlay. */
137
167
  private fun topBackEntry(): NativeOverlayEntryRootView? =
138
168
  orderedEntries().lastOrNull {
@@ -149,11 +179,13 @@ internal class NativeOverlayHost private constructor(
149
179
 
150
180
  /** TalkBack only reads the topmost blocking overlay and what is above it. */
151
181
  private fun updateAccessibility() {
152
- val entries = orderedEntries()
153
- val topIndex = entries.indexOfLast { it.blocking && it.isShownForInput }
182
+ val views = orderedViews()
183
+ val topIndex = views.indexOfLast {
184
+ it is NativeOverlayEntryRootView && it.blocking && it.isShownForInput
185
+ }
154
186
  val content = activity.findViewById<ViewGroup>(android.R.id.content) ?: return
155
187
  if (topIndex >= 0) {
156
- accessibilityIsolation.update(content, this, entries.take(topIndex), this)
188
+ accessibilityIsolation.update(content, this, views.take(topIndex), this)
157
189
  return
158
190
  }
159
191
  val pageEntry = shownPageHosts().flatMap { it.shownEntries() }.lastOrNull { it.blocking }
@@ -8,7 +8,7 @@ import com.facebook.react.uimanager.ViewManager
8
8
  class NativeOverlayPackage : ReactPackage {
9
9
  override fun createViewManagers(
10
10
  reactContext: ReactApplicationContext,
11
- ): List<ViewManager<*, *>> = listOf(NativeOverlayViewManager(), NativeOverlayPageHostViewManager())
11
+ ): List<ViewManager<*, *>> = listOf(NativeOverlayViewManager(), NativeOverlayPageHostViewManager(), NativeOverlayToasterViewManager())
12
12
 
13
13
  override fun createNativeModules(
14
14
  reactContext: ReactApplicationContext,
@@ -80,7 +80,7 @@ class NativeOverlayPageHostView(context: Context) : ViewGroup(context), ReactPoi
80
80
  }
81
81
 
82
82
  private var layoutScheduled = false
83
- private val layoutRunnable = Runnable {
83
+ private val layoutRunnable: Runnable? = Runnable {
84
84
  layoutScheduled = false
85
85
  layoutEntries()
86
86
  }
@@ -92,14 +92,25 @@ class NativeOverlayPageHostView(context: Context) : ViewGroup(context), ReactPoi
92
92
  */
93
93
  override fun requestLayout() {
94
94
  super.requestLayout()
95
+ // View construction can request layout before this callback is initialized.
96
+ val runnable = layoutRunnable ?: return
95
97
  if (!layoutScheduled) {
96
98
  layoutScheduled = true
97
- post(layoutRunnable)
99
+ post(runnable)
98
100
  }
99
101
  }
100
102
 
101
103
  private fun layoutEntries() {
102
- onLayout(false, left, top, right, bottom)
104
+ if (width <= 0 || height <= 0) return
105
+ // Run the host's layout lifecycle to clear FORCE_LAYOUT, so later child
106
+ // requests can reach this host through a Fabric-managed parent.
107
+ // Force another pass even when attach() reuses an existing child.
108
+ forceLayout()
109
+ measure(
110
+ MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
111
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
112
+ )
113
+ layout(left, top, right, bottom)
103
114
  }
104
115
 
105
116
  override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {