@onekeyfe/react-native-native-overlay 6.7.0-28 → 6.7.0-30
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.
|
@@ -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(
|
|
99
|
+
post(runnable)
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
private fun layoutEntries() {
|
|
102
|
-
|
|
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) {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
package com.onekey.nativeoverlay
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import android.os.Looper
|
|
5
|
+
import android.view.View
|
|
6
|
+
import androidx.activity.ComponentActivity
|
|
7
|
+
import com.facebook.react.bridge.BridgeReactContext
|
|
8
|
+
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
|
|
9
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
10
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
11
|
+
import org.junit.Assert.assertEquals
|
|
12
|
+
import org.junit.Assert.assertFalse
|
|
13
|
+
import org.junit.Test
|
|
14
|
+
import org.junit.runner.RunWith
|
|
15
|
+
import org.robolectric.Robolectric
|
|
16
|
+
import org.robolectric.RobolectricTestRunner
|
|
17
|
+
import org.robolectric.Shadows
|
|
18
|
+
import org.robolectric.annotation.Config
|
|
19
|
+
import java.time.Duration
|
|
20
|
+
|
|
21
|
+
@RunWith(RobolectricTestRunner::class)
|
|
22
|
+
@Config(sdk = [34])
|
|
23
|
+
class NativeOverlayPageHostLayoutTest {
|
|
24
|
+
@Test
|
|
25
|
+
fun pageSheetTracksHeightChangesAfterAttachInsideFabricParent() {
|
|
26
|
+
ReactNativeFeatureFlagsForTests.setUp()
|
|
27
|
+
val activity = Robolectric.buildActivity(ComponentActivity::class.java).setup().visible().get()
|
|
28
|
+
val reactContext = BridgeReactContext(activity)
|
|
29
|
+
val context = ThemedReactContext(reactContext, activity, "PageHostLayoutTest", 1)
|
|
30
|
+
val parent = ReactViewGroup(context)
|
|
31
|
+
val host = NativeOverlayPageHostView(context)
|
|
32
|
+
parent.addView(host)
|
|
33
|
+
activity.setContentView(parent)
|
|
34
|
+
val widthSpec = View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.EXACTLY)
|
|
35
|
+
val heightSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY)
|
|
36
|
+
host.measure(widthSpec, heightSpec)
|
|
37
|
+
host.layout(0, 0, 400, 1000)
|
|
38
|
+
val entry = NativeOverlayEntryRootView(context)
|
|
39
|
+
entry.configureSheet(200, 24f, Color.WHITE, false, true)
|
|
40
|
+
|
|
41
|
+
host.attach(entry)
|
|
42
|
+
Shadows.shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(100))
|
|
43
|
+
val sheet = entry.sheetView!!
|
|
44
|
+
assertEquals(entry.sheetHeightPx(), sheet.height)
|
|
45
|
+
assertEquals(1000 - entry.sheetHeightPx(), sheet.top)
|
|
46
|
+
|
|
47
|
+
entry.configureSheet(600, 24f, Color.WHITE, false, true)
|
|
48
|
+
Shadows.shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(100))
|
|
49
|
+
assertEquals(entry.sheetHeightPx(), sheet.height)
|
|
50
|
+
assertEquals(1000 - entry.sheetHeightPx(), sheet.top)
|
|
51
|
+
assertFalse(host.isLayoutRequested)
|
|
52
|
+
|
|
53
|
+
entry.configureSheet(320, 24f, Color.WHITE, false, true)
|
|
54
|
+
Shadows.shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(100))
|
|
55
|
+
assertEquals(entry.sheetHeightPx(), sheet.height)
|
|
56
|
+
assertEquals(1000 - entry.sheetHeightPx(), sheet.top)
|
|
57
|
+
}
|
|
58
|
+
}
|
package/docs/SPEC.md
CHANGED
|
@@ -670,6 +670,10 @@ Automated (P0):
|
|
|
670
670
|
old-parent transition completion after the move, and reopen during exit.
|
|
671
671
|
It also covers Fabric removal of staged content and replacement of presented
|
|
672
672
|
content during a transition, including layout-listener cleanup.
|
|
673
|
+
- `NativeOverlayPageHostLayoutTest` places the Android page host below an
|
|
674
|
+
actual `ReactViewGroup` and checks a sheet at 200, 600 and 320 px after
|
|
675
|
+
attachment. Height changes MUST relayout and bottom-pin the sheet without
|
|
676
|
+
a Fabric host-size update, and leave no pending host layout flag.
|
|
673
677
|
- `src/__tests__/pageIsolation.web.test.ts` mounts a real React portal in a
|
|
674
678
|
DOM host and verifies late suspension, level ordering and restoration after
|
|
675
679
|
the blocking entry is removed.
|
|
@@ -740,6 +744,15 @@ P3 page scope notes:
|
|
|
740
744
|
- iOS page sheets are drawn by the entry (bottom-pinned content view, pan to
|
|
741
745
|
close) because UIKit sheets always cover the window. Android and Web reuse
|
|
742
746
|
their global sheet implementation inside the page host.
|
|
747
|
+
- Android page hosts MUST complete their own measure/layout lifecycle after
|
|
748
|
+
native child layout requests. This clears the pending host layout flag so
|
|
749
|
+
later descendant requests can reach the host through Fabric-managed parents.
|
|
750
|
+
Scheduling MUST remain available when View construction requests layout
|
|
751
|
+
before the callback is initialized. Fitted sheets follow settled content
|
|
752
|
+
height changes in both directions. Runtime verified in app-monorepo 6.7.0
|
|
753
|
+
with a locally rebuilt shell on a Pixel 10 Pro API 37 emulator: the referral
|
|
754
|
+
form and Apply button remain visible after loading, error text grows the
|
|
755
|
+
sheet, and clearing the error restores its height.
|
|
743
756
|
- Android back also resolves page entries: global overlays first, then the
|
|
744
757
|
topmost visible page overlay.
|
|
745
758
|
- A declarative page overlay waits for a resolvable host and owner; it never
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-native-overlay",
|
|
3
|
-
"version": "6.7.0-
|
|
3
|
+
"version": "6.7.0-30",
|
|
4
4
|
"description": "Native and Web overlay hosts with ordered levels, page scope and Fabric measurement",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|