@onekeyfe/react-native-native-overlay 6.8.0-alpha.514 → 6.8.0-alpha.539
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.
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayHost.kt +37 -5
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayPackage.kt +1 -1
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToastCardView.kt +869 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToastSpec.kt +327 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToasterView.kt +574 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToasterViewManager.kt +54 -0
- package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlayAccessibilityIsolationTest.kt +172 -0
- package/docs/SPEC.md +172 -11
- package/ios/NativeOverlayContainerView.swift +20 -4
- package/ios/NativeOverlayToastCardView.swift +572 -0
- package/ios/NativeOverlayToastSpec.swift +356 -0
- package/ios/NativeOverlayToasterView.swift +519 -0
- package/ios/RCTNativeOverlayToasterComponentView.h +11 -0
- package/ios/RCTNativeOverlayToasterComponentView.mm +85 -0
- package/lib/module/NativeOverlayToasterNativeComponent.ts +24 -0
- package/lib/module/OverlayStore.js +20 -3
- package/lib/module/OverlayStore.js.map +1 -1
- package/lib/module/OverlayView.web.js +9 -18
- package/lib/module/OverlayView.web.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/toast/OverlayToastHost.js +42 -0
- package/lib/module/toast/OverlayToastHost.js.map +1 -0
- package/lib/module/toast/OverlayToastHost.web.js +32 -0
- package/lib/module/toast/OverlayToastHost.web.js.map +1 -0
- package/lib/module/toast/OverlayToastStore.js +217 -0
- package/lib/module/toast/OverlayToastStore.js.map +1 -0
- package/lib/module/toast/toastBridge.js +65 -0
- package/lib/module/toast/toastBridge.js.map +1 -0
- package/lib/module/toast/toastDomContent.web.js +298 -0
- package/lib/module/toast/toastDomContent.web.js.map +1 -0
- package/lib/module/toast/toastDomRenderer.web.js +695 -0
- package/lib/module/toast/toastDomRenderer.web.js.map +1 -0
- package/lib/module/toast/toastStyles.web.js +97 -0
- package/lib/module/toast/toastStyles.web.js.map +1 -0
- package/lib/module/toast/types.js +2 -0
- package/lib/module/toast/types.js.map +1 -0
- package/lib/module/web/overlayLayers.js +82 -0
- package/lib/module/web/overlayLayers.js.map +1 -1
- package/lib/typescript/src/NativeOverlayToasterNativeComponent.d.ts +19 -0
- package/lib/typescript/src/NativeOverlayToasterNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/OverlayStore.d.ts +8 -1
- package/lib/typescript/src/OverlayStore.d.ts.map +1 -1
- package/lib/typescript/src/OverlayView.web.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/toast/OverlayToastHost.d.ts +6 -0
- package/lib/typescript/src/toast/OverlayToastHost.d.ts.map +1 -0
- package/lib/typescript/src/toast/OverlayToastHost.web.d.ts +6 -0
- package/lib/typescript/src/toast/OverlayToastHost.web.d.ts.map +1 -0
- package/lib/typescript/src/toast/OverlayToastStore.d.ts +47 -0
- package/lib/typescript/src/toast/OverlayToastStore.d.ts.map +1 -0
- package/lib/typescript/src/toast/toastBridge.d.ts +11 -0
- package/lib/typescript/src/toast/toastBridge.d.ts.map +1 -0
- package/lib/typescript/src/toast/toastDomContent.web.d.ts +15 -0
- package/lib/typescript/src/toast/toastDomContent.web.d.ts.map +1 -0
- package/lib/typescript/src/toast/toastDomRenderer.web.d.ts +8 -0
- package/lib/typescript/src/toast/toastDomRenderer.web.d.ts.map +1 -0
- package/lib/typescript/src/toast/toastStyles.web.d.ts +2 -0
- package/lib/typescript/src/toast/toastStyles.web.d.ts.map +1 -0
- package/lib/typescript/src/toast/types.d.ts +240 -0
- package/lib/typescript/src/toast/types.d.ts.map +1 -0
- package/lib/typescript/src/web/overlayLayers.d.ts +2 -0
- package/lib/typescript/src/web/overlayLayers.d.ts.map +1 -1
- package/package.json +3 -2
- package/react-native.config.js +1 -0
- package/src/NativeOverlayToasterNativeComponent.ts +24 -0
- package/src/OverlayStore.ts +35 -4
- package/src/OverlayView.web.tsx +10 -11
- package/src/index.ts +23 -0
- package/src/toast/OverlayToastHost.tsx +62 -0
- package/src/toast/OverlayToastHost.web.tsx +29 -0
- package/src/toast/OverlayToastStore.ts +254 -0
- package/src/toast/toastBridge.ts +62 -0
- package/src/toast/toastDomContent.web.ts +351 -0
- package/src/toast/toastDomRenderer.web.ts +856 -0
- package/src/toast/toastStyles.web.ts +97 -0
- package/src/toast/types.ts +251 -0
- package/src/web/overlayLayers.ts +114 -0
package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlayAccessibilityIsolationTest.kt
CHANGED
|
@@ -2,9 +2,17 @@ package com.onekey.nativeoverlay
|
|
|
2
2
|
|
|
3
3
|
import android.view.View
|
|
4
4
|
import android.widget.FrameLayout
|
|
5
|
+
import androidx.activity.ComponentActivity
|
|
6
|
+
import com.facebook.react.bridge.BridgeReactContext
|
|
7
|
+
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
|
+
import org.json.JSONObject
|
|
5
10
|
import org.junit.Assert.assertEquals
|
|
11
|
+
import org.junit.Assert.assertNotNull
|
|
12
|
+
import org.junit.Assert.assertTrue
|
|
6
13
|
import org.junit.Test
|
|
7
14
|
import org.junit.runner.RunWith
|
|
15
|
+
import org.robolectric.Robolectric
|
|
8
16
|
import org.robolectric.RobolectricTestRunner
|
|
9
17
|
import org.robolectric.RuntimeEnvironment
|
|
10
18
|
import org.robolectric.annotation.Config
|
|
@@ -109,4 +117,168 @@ class NativeOverlayAccessibilityIsolationTest {
|
|
|
109
117
|
assertEquals(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO, tree.blocker.importantForAccessibility)
|
|
110
118
|
assertEquals(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, tree.lower.importantForAccessibility)
|
|
111
119
|
}
|
|
120
|
+
|
|
121
|
+
@Test
|
|
122
|
+
fun lockBlockerIsolatesMessageToastLayerBothBeforeAndAfterLockOpens() {
|
|
123
|
+
val localAccessor = Class.forName(
|
|
124
|
+
"com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsLocalAccessor"
|
|
125
|
+
).getDeclaredConstructor().newInstance()
|
|
126
|
+
ReactNativeFeatureFlags::class.java.getDeclaredField("accessor").apply {
|
|
127
|
+
isAccessible = true
|
|
128
|
+
set(null, localAccessor)
|
|
129
|
+
}
|
|
130
|
+
val activity = Robolectric.buildActivity(ComponentActivity::class.java).setup().visible().get()
|
|
131
|
+
val reactContext = BridgeReactContext(activity)
|
|
132
|
+
reactContext.onHostResume(activity)
|
|
133
|
+
val themedContext = ThemedReactContext(reactContext, activity, "ToastIsolationTest", 1)
|
|
134
|
+
val host = NativeOverlayHost.of(activity)
|
|
135
|
+
val toastLayer = FrameLayout(activity)
|
|
136
|
+
host.attachToastLayer(toastLayer)
|
|
137
|
+
val modal = NativeOverlayEntryRootView(themedContext).apply {
|
|
138
|
+
blocking = true
|
|
139
|
+
isShownForInput = true
|
|
140
|
+
}
|
|
141
|
+
host.attach(modal, NativeOverlayLevel.MODAL)
|
|
142
|
+
assertEquals(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO, toastLayer.importantForAccessibility)
|
|
143
|
+
|
|
144
|
+
val lock = NativeOverlayEntryRootView(themedContext).apply {
|
|
145
|
+
blocking = true
|
|
146
|
+
isShownForInput = true
|
|
147
|
+
}
|
|
148
|
+
host.attach(lock, NativeOverlayLevel.LOCK)
|
|
149
|
+
assertEquals(
|
|
150
|
+
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS,
|
|
151
|
+
toastLayer.importantForAccessibility,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
val secondToastLayer = FrameLayout(activity)
|
|
155
|
+
host.detachToastLayer(toastLayer)
|
|
156
|
+
host.attachToastLayer(secondToastLayer)
|
|
157
|
+
assertEquals(
|
|
158
|
+
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS,
|
|
159
|
+
secondToastLayer.importantForAccessibility,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
host.detach(lock)
|
|
163
|
+
assertEquals(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO, secondToastLayer.importantForAccessibility)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@Test
|
|
167
|
+
@Config(sdk = [24, 26, 28])
|
|
168
|
+
fun toastFontAndPresenterSupportApi24Through28() {
|
|
169
|
+
assertNotNull(ToastFont.make(context, null, emptyMap(), "400"))
|
|
170
|
+
assertNotNull(ToastFont.make(context, null, emptyMap(), "700"))
|
|
171
|
+
val hostView = View(context)
|
|
172
|
+
val presenter = NativeOverlayToastPresenter(hostView)
|
|
173
|
+
presenter.sync(
|
|
174
|
+
ToastItem.parseList("""[{"spec":{"id":"a","layout":"message","duration":1000},"visible":true,"revision":0,"generation":0}]"""),
|
|
175
|
+
ToasterConfig.parse("{}"),
|
|
176
|
+
)
|
|
177
|
+
presenter.invalidate()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@Test
|
|
181
|
+
fun namedIconColorsNormalizeToStrictRgbaAcrossCssFormats() {
|
|
182
|
+
val strictPattern = Regex("""^rgba\(\d{1,3},\d{1,3},\d{1,3},(?:0(?:\.\d+)?|1(?:\.0+)?)\)$""")
|
|
183
|
+
val inputs = listOf(
|
|
184
|
+
"#ff0000" to "rgba(255,0,0,1)",
|
|
185
|
+
"#00ff0080" to "rgba(0,255,0,0.502)",
|
|
186
|
+
"rgb(12, 34, 56)" to "rgba(12,34,56,1)",
|
|
187
|
+
"rgba(255, 0, 128, 0.5)" to "rgba(255,0,128,0.502)",
|
|
188
|
+
"hsl(120, 100%, 50%)" to "rgba(0,255,0,1)",
|
|
189
|
+
"transparent" to "rgba(0,0,0,0)",
|
|
190
|
+
)
|
|
191
|
+
for ((raw, expected) in inputs) {
|
|
192
|
+
val icon = ToastIcon.parse(
|
|
193
|
+
JSONObject().put("kind", "icon").put("name", "DotVerSolid").put("color", raw).put("size", 20),
|
|
194
|
+
) as ToastIcon.Named
|
|
195
|
+
assertEquals(expected, icon.colorString)
|
|
196
|
+
assertTrue(strictPattern.matches(icon.colorString))
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@Test
|
|
201
|
+
fun rebuildingOrInvalidatingToastCardCancelsPendingImageLoads() {
|
|
202
|
+
val card = NativeOverlayToastCardView(context)
|
|
203
|
+
val spec = ToastSpec.parse(
|
|
204
|
+
JSONObject()
|
|
205
|
+
.put("id", "img-toast")
|
|
206
|
+
.put("layout", "notification")
|
|
207
|
+
.put("duration", 5000)
|
|
208
|
+
.put("icon", JSONObject().put("kind", "image").put("uri", "http://127.0.0.1:1/slow.png").put("size", 24))
|
|
209
|
+
.put("image", JSONObject().put("uri", "http://127.0.0.1:1/thumb.png").put("size", 40)),
|
|
210
|
+
)
|
|
211
|
+
repeat(10) {
|
|
212
|
+
card.apply(spec, 0xffffffff.toInt())
|
|
213
|
+
}
|
|
214
|
+
card.cancelLoads()
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@Test
|
|
218
|
+
fun pressableNotificationCardExposesAccessibilityClickActionSeparatelyFromButtons() {
|
|
219
|
+
val card = NativeOverlayToastCardView(context)
|
|
220
|
+
var pressed = 0
|
|
221
|
+
val actions = mutableListOf<String>()
|
|
222
|
+
card.onPress = { pressed += 1 }
|
|
223
|
+
card.onAction = { actions.add(it) }
|
|
224
|
+
val spec = ToastSpec.parse(
|
|
225
|
+
JSONObject()
|
|
226
|
+
.put("id", "press-notif")
|
|
227
|
+
.put("layout", "notification")
|
|
228
|
+
.put("duration", 5000)
|
|
229
|
+
.put("pressable", true)
|
|
230
|
+
.put("badgeSize", 36)
|
|
231
|
+
.put("badgeColor", "#eeeeee")
|
|
232
|
+
.put(
|
|
233
|
+
"title",
|
|
234
|
+
JSONObject()
|
|
235
|
+
.put("color", "#111111")
|
|
236
|
+
.put("fontSize", 14)
|
|
237
|
+
.put("lineHeight", 20)
|
|
238
|
+
.put("fontWeight", "600")
|
|
239
|
+
.put("paragraphs", org.json.JSONArray().put(org.json.JSONArray().put(JSONObject().put("text", "Hello")))),
|
|
240
|
+
)
|
|
241
|
+
.put(
|
|
242
|
+
"actions",
|
|
243
|
+
org.json.JSONArray().put(
|
|
244
|
+
JSONObject()
|
|
245
|
+
.put("id", "view")
|
|
246
|
+
.put("label", "View")
|
|
247
|
+
.put("color", "#ffffff")
|
|
248
|
+
.put("backgroundColor", "#000000")
|
|
249
|
+
.put("fontSize", 14)
|
|
250
|
+
.put("lineHeight", 20)
|
|
251
|
+
.put("fontWeight", "500")
|
|
252
|
+
.put("paddingHorizontal", 10)
|
|
253
|
+
.put("paddingVertical", 4)
|
|
254
|
+
.put("borderRadius", 8),
|
|
255
|
+
),
|
|
256
|
+
),
|
|
257
|
+
)
|
|
258
|
+
card.apply(spec, 0xffffffff.toInt())
|
|
259
|
+
val info = android.view.accessibility.AccessibilityNodeInfo.obtain()
|
|
260
|
+
card.onInitializeAccessibilityNodeInfo(info)
|
|
261
|
+
assertTrue(card.isClickable)
|
|
262
|
+
assertTrue(card.isFocusable)
|
|
263
|
+
assertTrue(info.isClickable)
|
|
264
|
+
assertEquals("Hello", info.contentDescription.toString())
|
|
265
|
+
assertTrue(card.performAccessibilityAction(android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK, null))
|
|
266
|
+
assertEquals(1, pressed)
|
|
267
|
+
assertTrue(card.performClick())
|
|
268
|
+
assertEquals(2, pressed)
|
|
269
|
+
assertTrue(
|
|
270
|
+
card.onKeyDown(
|
|
271
|
+
android.view.KeyEvent.KEYCODE_ENTER,
|
|
272
|
+
android.view.KeyEvent(android.view.KeyEvent.ACTION_DOWN, android.view.KeyEvent.KEYCODE_ENTER),
|
|
273
|
+
),
|
|
274
|
+
)
|
|
275
|
+
assertTrue(
|
|
276
|
+
card.onKeyUp(
|
|
277
|
+
android.view.KeyEvent.KEYCODE_ENTER,
|
|
278
|
+
android.view.KeyEvent(android.view.KeyEvent.ACTION_UP, android.view.KeyEvent.KEYCODE_ENTER),
|
|
279
|
+
),
|
|
280
|
+
)
|
|
281
|
+
assertEquals(3, pressed)
|
|
282
|
+
assertEquals(emptyList<String>(), actions)
|
|
283
|
+
}
|
|
112
284
|
}
|
package/docs/SPEC.md
CHANGED
|
@@ -70,8 +70,9 @@ password verify, DialogLoading, app lock, Spotlight, in-app notification.
|
|
|
70
70
|
|
|
71
71
|
Non-goals:
|
|
72
72
|
|
|
73
|
-
- Business UI. Titles, buttons, forms,
|
|
74
|
-
|
|
73
|
+
- Business UI. Titles, buttons, forms, the hardware stage morph and the lock
|
|
74
|
+
screen UI stay React content owned by components and kit. Message toast
|
|
75
|
+
cards are the exception: the platform draws them from data (§5.14).
|
|
75
76
|
- Navigation. Screens and navigation modals stay in react-navigation and
|
|
76
77
|
react-native-screens.
|
|
77
78
|
- Third-party windows such as RN `Modal`, WalletConnect, and system dialogs.
|
|
@@ -139,6 +140,10 @@ come only from props.
|
|
|
139
140
|
separate handler; the old removal cannot invoke or delete the new handler.
|
|
140
141
|
- `dismissAll({ scope, belowLevel, reason })`, `setPageVisible(ownerKey,
|
|
141
142
|
visible)`, `removePage(ownerKey)`.
|
|
143
|
+
- Web navigation calls `setFocusedPageHost(hostKey)` with a root-route host key.
|
|
144
|
+
`null` makes every page host inactive. The default `undefined` clears
|
|
145
|
+
the focus restriction, including when navigation unmounts.
|
|
146
|
+
`isPageHostFocused(hostKey)` reports whether a page host is eligible.
|
|
142
147
|
- `resolveBack(focusedHostKey?)` returns `dismiss(id)`, `block`, or `pass`.
|
|
143
148
|
- `getBlockingTop()` returns the entry that makes everything below it inert.
|
|
144
149
|
- `subscribe` and `getSnapshot` are compatible with `useSyncExternalStore`.
|
|
@@ -609,7 +614,15 @@ the first/last child respectively. With no tabbable children, focus stays on
|
|
|
609
614
|
the entry root. Disabled, negative-tabindex, hidden and inert subtrees are
|
|
610
615
|
excluded. Positive tabindex values precede ordinary DOM-order tab stops.
|
|
611
616
|
Non-blocking, lower, closing, suspended and parked entries MUST NOT run a
|
|
612
|
-
focus loop.
|
|
617
|
+
focus loop. When a page or global dialog becomes the top blocker, it takes
|
|
618
|
+
focus on its entry root if focus is currently outside the dialog.
|
|
619
|
+
Focus restoration starts after a dialog actually moves focus inside.
|
|
620
|
+
A dialog taking over from an exiting overlay keeps its saved
|
|
621
|
+
opener, or inherits the exiting overlay's restoration target when it has
|
|
622
|
+
none. On exit, focus can return through a chain of nested openers, skipping
|
|
623
|
+
closed overlays and detached targets, when focus is still inside the
|
|
624
|
+
dialog or has fallen back to the document body. An active control outside
|
|
625
|
+
the dialog keeps focus.
|
|
613
626
|
|
|
614
627
|
A Web backdrop with `dismissOnPress: true` MUST receive pointer events even
|
|
615
628
|
when its entry is non-blocking. This permits a transparent outside-click
|
|
@@ -705,6 +718,16 @@ until that owner resumes. Resuming an owner MUST NOT clear isolation imposed by
|
|
|
705
718
|
a higher blocking entry. Web page isolation compares level first, then request
|
|
706
719
|
order within that level; dismissal restores entries no longer below a blocker.
|
|
707
720
|
|
|
721
|
+
On Web, a covered root route can keep its page overlays visible. Its overlay
|
|
722
|
+
host is inert, and its entries cannot block the foreground route or consume
|
|
723
|
+
Escape. Switching focus restores eligibility without dismissing or remounting
|
|
724
|
+
entries. Host registration and unregistration recalculate DOM isolation. A
|
|
725
|
+
page entry requires a connected, registered host to block the DOM or consume
|
|
726
|
+
Escape. If its host detaches, the next eligible overlay takes precedence, or
|
|
727
|
+
the page becomes interactive if none remains. Global overlays remain eligible
|
|
728
|
+
regardless of the focused page host. iOS and Android use their native host
|
|
729
|
+
lifecycle for page visibility and back handling.
|
|
730
|
+
|
|
708
731
|
On Android, a blocking page entry MUST hide underlying page/navigation siblings
|
|
709
732
|
from accessibility while preserving the page host and the blocking entry. Entries
|
|
710
733
|
above it, including non-blocking global overlays, remain accessible. Global
|
|
@@ -828,7 +851,16 @@ Automated (P0):
|
|
|
828
851
|
verification pending.
|
|
829
852
|
- `src/__tests__/pageIsolation.web.test.ts` mounts a real React portal in a
|
|
830
853
|
DOM host and verifies late suspension, level ordering and restoration after
|
|
831
|
-
the blocking entry is removed.
|
|
854
|
+
the blocking entry is removed. It also verifies host isolation and Escape
|
|
855
|
+
handling when root-route focus changes or the top page host detaches.
|
|
856
|
+
- `tests/browser/pageIsolation.test.cjs` verifies in Chromium that removing a
|
|
857
|
+
host while its dialog stays visible restores page clicks and focus, and that
|
|
858
|
+
a dialog opened on a covered route regains focus and contains Tab when its
|
|
859
|
+
route returns. It also checks that closing a covered dialog preserves
|
|
860
|
+
foreground typing and that focus acquired after a route returns can be
|
|
861
|
+
restored on close. Stacked-dialog cases verify focus when a global dialog
|
|
862
|
+
becomes the top blocker and restoration after nested and concurrent exits.
|
|
863
|
+
It uses the same browser dependencies as the toast tests (§5.14).
|
|
832
864
|
- `NativeOverlayAccessibilityIsolationTest` runs six Robolectric cases against
|
|
833
865
|
Android views: page/navigation siblings, entries above the blocker, original
|
|
834
866
|
flags, global/page transitions, detached hosts and changing blockers. These
|
|
@@ -946,13 +978,16 @@ P2 sheet notes:
|
|
|
946
978
|
- `keepContentMounted` renders content while closed so callers can measure it
|
|
947
979
|
before opening (Popover waits for header / scroll measurements).
|
|
948
980
|
- `pan` dismissals cannot be vetoed; `onRequestDismiss('pan')` is informative.
|
|
981
|
+
- An active iOS NativeList reorder temporarily suppresses the enclosing page
|
|
982
|
+
sheet's dismiss pan. The sheet owns the latest `dismissOnPanDown` setting
|
|
983
|
+
throughout the suppression. Releasing the reorder restores eligibility
|
|
984
|
+
only when the current setting allows it.
|
|
949
985
|
|
|
950
986
|
P4a toast notes:
|
|
951
987
|
|
|
952
|
-
- Message toasts (`Toast.success` / `message` / `error` …)
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
entry (kit `ToastOverlayContainer`). The iOS raise tokens are gone.
|
|
988
|
+
- Message toasts (`Toast.success` / `message` / `error` …) are drawn by the
|
|
989
|
+
platform from data; see §5.14. The React toast libraries and the persistent
|
|
990
|
+
`toast`-level fullscreen entry that hosted them are gone.
|
|
956
991
|
- Custom toasts (`Toast.show` / `ShowCustom`) are their own `toast` entries:
|
|
957
992
|
transparent blocking backdrop (tap closes when `dismissOnOverlayPress`),
|
|
958
993
|
`scale 0.8 + offsetY -20 + fade` on `quick`, PanResponder swipe up to
|
|
@@ -1256,13 +1291,13 @@ Accepted limitations:
|
|
|
1256
1291
|
scroll views. Page sheets should keep scrollable content short or pass
|
|
1257
1292
|
`dismissOnPanDown={false}`.
|
|
1258
1293
|
- Custom toasts stack by request order and overlap at the top, as before;
|
|
1259
|
-
message toasts stack
|
|
1294
|
+
message toasts stack in the platform toaster (§5.14).
|
|
1260
1295
|
|
|
1261
1296
|
Future work (better to have):
|
|
1262
1297
|
|
|
1263
1298
|
- VoiceOver / TalkBack cross-window modality, verified on device.
|
|
1264
|
-
- Screen-reader toasts: the native
|
|
1265
|
-
|
|
1299
|
+
- Screen-reader toasts: the native toaster announces each card's text when
|
|
1300
|
+
it appears (§5.14); the lifetime is not yet extended, and the host should
|
|
1266
1301
|
its timer instead.
|
|
1267
1302
|
|
|
1268
1303
|
Known gaps:
|
|
@@ -1307,3 +1342,129 @@ staged version). Following the repository's verification guidance, the entire
|
|
|
1307
1342
|
batch advances to `3.0.162-alpha.270`. Existing versions are never overwritten.
|
|
1308
1343
|
The iOS lockfile failure was only local CocoaPods 1.17.0 versus the Gemfile's
|
|
1309
1344
|
locked 1.16.2; the actual CI lockfile was adopted, preserving semantic checks.
|
|
1345
|
+
|
|
1346
|
+
## 5.14 Message toasts
|
|
1347
|
+
|
|
1348
|
+
Message toasts are plain data. `overlayToastStore.show(spec, handlers)` takes
|
|
1349
|
+
an `IOverlayToastSpec` (`src/toast/types.ts`) and the platform draws the card:
|
|
1350
|
+
DOM on Web, UIKit on iOS, Android views on Android. React draws nothing; the
|
|
1351
|
+
only React piece is `OverlayToastHost`, which attaches the renderer.
|
|
1352
|
+
|
|
1353
|
+
### Contract
|
|
1354
|
+
|
|
1355
|
+
- A spec holds resolved values only: CSS colour strings, points, font sizes,
|
|
1356
|
+
icon names. The package carries no design tokens.
|
|
1357
|
+
- Two layouts: `message` (status icon, title, message, action row) and
|
|
1358
|
+
`notification` (round badge, clamped title and message, trailing image,
|
|
1359
|
+
pressable row).
|
|
1360
|
+
- Text is paragraphs of runs. A run may set colour, weight, size, underline
|
|
1361
|
+
and `link`; a link is opaque and comes back through `onLink`.
|
|
1362
|
+
- Actions are small buttons described by data and report `onAction(id)`.
|
|
1363
|
+
Pressing one does not dismiss the toast.
|
|
1364
|
+
- `show` with an id that is on screen updates that card and restarts its
|
|
1365
|
+
lifetime; `update` redraws it (theme or layout change) without restarting.
|
|
1366
|
+
- A toast leaves the list when its renderer reports `close`, after the exit.
|
|
1367
|
+
With no renderer attached a dismissal removes it at once. At most 20 toasts
|
|
1368
|
+
are kept; older ones are dropped without animation.
|
|
1369
|
+
- Events: `dismiss(reason)` when the card starts leaving (`timeout`, `swipe`,
|
|
1370
|
+
`close`, `programmatic`), `close(reason)` when it is gone, `action`,
|
|
1371
|
+
`link`, `press`.
|
|
1372
|
+
- `configure` sets toaster-wide values: position and theme (Web), card colour
|
|
1373
|
+
and content box (native), and the top obstruction the stack rests under.
|
|
1374
|
+
|
|
1375
|
+
### Bridge
|
|
1376
|
+
|
|
1377
|
+
iOS and Android use one zero-size Fabric component, `RNCNativeOverlayToaster`,
|
|
1378
|
+
with two string props (`toasts`, `config`: JSON) and one direct event
|
|
1379
|
+
(`onToastEvent { toastId, type, value }`). An infinite duration crosses as
|
|
1380
|
+
`-1`. The cards are not children of this view: iOS draws them in a `toast`
|
|
1381
|
+
level window from `NativeOverlayWindowManager`, Android in a layer at the
|
|
1382
|
+
bottom of the host's `toast` level container, so custom toast entries stay
|
|
1383
|
+
above them. Web has no bridge: the DOM renderer subscribes to the store.
|
|
1384
|
+
|
|
1385
|
+
Named icons come from `@onekeyfe/react-native-image`'s native registry,
|
|
1386
|
+
reached at runtime (Objective-C runtime on iOS, reflection on Android) so this
|
|
1387
|
+
package takes no dependency on it; without the registry an icon stays blank.
|
|
1388
|
+
On Android the lookup is `OneKeyNamedSVG.INSTANCE` plus its `request` (8
|
|
1389
|
+
arguments) and `cancel` methods; the image package's consumer R8 rules keep
|
|
1390
|
+
those names, since release app builds minify and would otherwise rename them.
|
|
1391
|
+
Web draws an SVG `<use>` of the `href` the caller supplies.
|
|
1392
|
+
|
|
1393
|
+
### Platform behaviour
|
|
1394
|
+
|
|
1395
|
+
Each platform keeps the look and motion of the renderer it replaced.
|
|
1396
|
+
|
|
1397
|
+
| Behaviour | Web | iOS / Android |
|
|
1398
|
+
| --- | --- | --- |
|
|
1399
|
+
| Position | Per toast or toaster; default bottom-right | Always top-centre |
|
|
1400
|
+
| Stack | Newest in front, 3 visible. Hover or tap to expand multiple cards. An outside press clears tap expansion. | Oldest at the top, newest under it, 8 pt apart, all visible |
|
|
1401
|
+
| Card | 356 px wide, 16 px padding, themed surface and border, close button | Content box from `contentWidth` plus 16 / 12 pt padding, 8 pt radius, shadow |
|
|
1402
|
+
| Enter / exit | 400 ms transform and opacity transition; exit 200 ms | 300 ms quadratic ease-in-out slide from above the top edge, with opacity |
|
|
1403
|
+
| `close` reported | 200 ms after the exit starts | 1000 ms after the exit starts |
|
|
1404
|
+
| Timer pause | While the stack is hovered, expanded, or has an active press. When the pause ends, timers restart with the full lifetime. | While a card is pressed; resuming continues the remaining time |
|
|
1405
|
+
| Swipe | Away from the anchored edge (down on bottom groups, up on top groups). Once a vertical swipe starts, only vertical displacement counts. Release dismisses at 20 px or above 0.11 px/ms. | Up; 32 pt, or 12 pt at 600 pt/s; dragging down moves a quarter as far |
|
|
1406
|
+
| Top obstruction | Inline `top` on top groups, 220 ms | The whole stack translates, 220 ms |
|
|
1407
|
+
| Reduced motion | Transitions off (media query) | Every animation is instant |
|
|
1408
|
+
|
|
1409
|
+
On Web, the card captures the pointer after recognizing a swipe. Ordinary
|
|
1410
|
+
clicks and taps activate the pressable row, buttons, or links through their
|
|
1411
|
+
own handlers. Each press ends independently on release or cancellation.
|
|
1412
|
+
Card removal, reuse, or repositioning clears its presses, and window blur
|
|
1413
|
+
clears all presses and expansion. A touch drag that did not dismiss the card
|
|
1414
|
+
ends the press without creating hover or tap expansion.
|
|
1415
|
+
|
|
1416
|
+
Divergences from the renderers replaced:
|
|
1417
|
+
|
|
1418
|
+
- Web measures a card's own height. The previous renderer could record a
|
|
1419
|
+
scaled height when several toasts arrived in one tick, which put about 4 px
|
|
1420
|
+
less between cards of an expanded stack.
|
|
1421
|
+
- Web starts the enter transition synchronously, so a toast shown while the
|
|
1422
|
+
page is hidden still appears.
|
|
1423
|
+
- Native shows toasts under a screen reader and announces their text; the
|
|
1424
|
+
previous renderer drew nothing while a screen reader was on.
|
|
1425
|
+
|
|
1426
|
+
### Verification
|
|
1427
|
+
|
|
1428
|
+
- Web: `src/__tests__/overlayToast.web.test.ts` covers the store and the DOM
|
|
1429
|
+
renderer. In app-monorepo, 13 scenarios in three captures (wide dark, narrow
|
|
1430
|
+
dark, wide light) matched the previous renderer's card boxes, text line
|
|
1431
|
+
rects, icon and button boxes and computed styles within 0.5 px.
|
|
1432
|
+
- Web pointer regression: `tests/browser/overlayToast.test.cjs` exercises
|
|
1433
|
+
browser-generated mouse clicks, touch taps, mixed input, and swipes in
|
|
1434
|
+
Chromium. Run from the package with `node --test tests/browser/overlayToast.test.cjs`.
|
|
1435
|
+
Make `esbuild` and `playwright-core` available via `NODE_PATH` or the local
|
|
1436
|
+
install, and set `CHROMIUM_EXECUTABLE_PATH` if using a system Chrome.
|
|
1437
|
+
- iOS: built into app-monorepo and run on an iPhone 17 Pro simulator (iOS
|
|
1438
|
+
26.0) beside the previous renderer. In 13 scenarios the card frames and
|
|
1439
|
+
every text line box matched to the pixel; the only differing pixels were
|
|
1440
|
+
corner anti-aliasing against a differently lit backdrop. Timeout, close
|
|
1441
|
+
callback, action press, notification press, swipe up, press-to-pause with
|
|
1442
|
+
resume, programmatic close, id de-duplication and dismiss by id were
|
|
1443
|
+
exercised with injected touches. Not exercised there: the top obstruction
|
|
1444
|
+
shift, the keyboard limit, dark theme, rotation, iPad and VoiceOver.
|
|
1445
|
+
- Android: built into app-monorepo and run on a Pixel 7 emulator (API 35,
|
|
1446
|
+
420 dpi) beside the previous renderer, both with the brand typeface. In 13
|
|
1447
|
+
scenarios, light and dark, every card, text, icon and button frame matched
|
|
1448
|
+
to the pixel; inside the cards the remaining pixel differences were at most
|
|
1449
|
+
12 of 255 (anti-aliasing), apart from the spinner's animation frame. The
|
|
1450
|
+
spinner box is 2 px shorter than before (53x52 against 53x54). Timeout and
|
|
1451
|
+
close callback, action press, notification press, swipe up, a short drag
|
|
1452
|
+
that settles back, press-to-pause with resume, programmatic close, id
|
|
1453
|
+
de-duplication, dismiss by id and stacking order were exercised with
|
|
1454
|
+
injected touches. Not exercised there: the top obstruction shift, the
|
|
1455
|
+
keyboard limit, rotation, tablets, foldables and TalkBack.
|
|
1456
|
+
|
|
1457
|
+
iOS text is laid out and drawn with TextKit (no font leading, glyphs centred
|
|
1458
|
+
in a fixed line box) because that is what the previous text engine did. Two
|
|
1459
|
+
of its habits are kept on purpose: a text box is one pixel taller than its
|
|
1460
|
+
lines, and an explicit letter spacing, zero included, turns the font's pair
|
|
1461
|
+
kerning off.
|
|
1462
|
+
|
|
1463
|
+
Android cards follow the previous layout engine's pixel rounding (Yoga): an
|
|
1464
|
+
offset from the parent is rounded half up, a text offset is floored, and a
|
|
1465
|
+
size is the difference of the rounded absolute edges, so the card keeps its
|
|
1466
|
+
unrounded window position. Text is drawn unhinted at subpixel positions with
|
|
1467
|
+
the font size and line height rounded up to whole pixels, underlines are
|
|
1468
|
+
stroked at baseline + thickness + 1 px, and a bordered pill's fill is inset
|
|
1469
|
+
by 0.8 px, all as React Native draws them. Named icons render at their
|
|
1470
|
+
rounded frame size.
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import React
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
|
+
final class NativeOverlayPageSheetPan: UIPanGestureRecognizer {
|
|
5
|
+
var dismissalAllowed = false {
|
|
6
|
+
didSet { updateAvailability() }
|
|
7
|
+
}
|
|
8
|
+
private var reorderSuppressions = 0
|
|
9
|
+
|
|
10
|
+
@objc func setOneKeyNativeListReorderSuppressed(_ suppressed: NSNumber) {
|
|
11
|
+
reorderSuppressions = max(0, reorderSuppressions + (suppressed.boolValue ? 1 : -1))
|
|
12
|
+
updateAvailability()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private func updateAvailability() {
|
|
16
|
+
isEnabled = dismissalAllowed && reorderSuppressions == 0
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
4
20
|
/// One overlay inside a level window: backdrop plus the reparented content.
|
|
5
21
|
final class NativeOverlayEntryView: UIView {
|
|
6
22
|
let backdropView = UIView()
|
|
@@ -22,7 +38,7 @@ final class NativeOverlayEntryView: UIView {
|
|
|
22
38
|
/// Page scope cannot use UIKit sheets (they always cover the window), so a
|
|
23
39
|
/// page sheet is this entry's content view pinned to the bottom.
|
|
24
40
|
private(set) var pageSheetHeight: CGFloat?
|
|
25
|
-
private var pageSheetPan:
|
|
41
|
+
private var pageSheetPan: NativeOverlayPageSheetPan?
|
|
26
42
|
|
|
27
43
|
override init(frame: CGRect) {
|
|
28
44
|
super.init(frame: frame)
|
|
@@ -93,12 +109,12 @@ final class NativeOverlayEntryView: UIView {
|
|
|
93
109
|
contentView.clipsToBounds = true
|
|
94
110
|
contentView.autoresizingMask = [.flexibleWidth, .flexibleTopMargin]
|
|
95
111
|
layoutPageSheet()
|
|
96
|
-
if
|
|
97
|
-
let pan =
|
|
112
|
+
if pageSheetPan == nil {
|
|
113
|
+
let pan = NativeOverlayPageSheetPan(target: self, action: #selector(handlePageSheetPan(_:)))
|
|
98
114
|
contentView.addGestureRecognizer(pan)
|
|
99
115
|
pageSheetPan = pan
|
|
100
116
|
}
|
|
101
|
-
pageSheetPan?.
|
|
117
|
+
pageSheetPan?.dismissalAllowed = draggable
|
|
102
118
|
}
|
|
103
119
|
|
|
104
120
|
/// Layout changed (rotation, page sheet height); the owner re-reports
|