@onekeyfe/react-native-native-overlay 6.8.0-4 → 6.8.0-5
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 +871 -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 +120 -9
- 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/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 +629 -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 +5 -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/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.map +1 -1
- package/package.json +3 -2
- package/react-native.config.js +1 -0
- package/src/NativeOverlayToasterNativeComponent.ts +24 -0
- 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 +748 -0
- package/src/toast/toastStyles.web.ts +97 -0
- package/src/toast/types.ts +251 -0
- package/src/web/overlayLayers.ts +7 -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.
|
|
@@ -949,10 +950,9 @@ P2 sheet notes:
|
|
|
949
950
|
|
|
950
951
|
P4a toast notes:
|
|
951
952
|
|
|
952
|
-
- Message toasts (`Toast.success` / `message` / `error` …)
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
entry (kit `ToastOverlayContainer`). The iOS raise tokens are gone.
|
|
953
|
+
- Message toasts (`Toast.success` / `message` / `error` …) are drawn by the
|
|
954
|
+
platform from data; see §5.14. The React toast libraries and the persistent
|
|
955
|
+
`toast`-level fullscreen entry that hosted them are gone.
|
|
956
956
|
- Custom toasts (`Toast.show` / `ShowCustom`) are their own `toast` entries:
|
|
957
957
|
transparent blocking backdrop (tap closes when `dismissOnOverlayPress`),
|
|
958
958
|
`scale 0.8 + offsetY -20 + fade` on `quick`, PanResponder swipe up to
|
|
@@ -1256,13 +1256,13 @@ Accepted limitations:
|
|
|
1256
1256
|
scroll views. Page sheets should keep scrollable content short or pass
|
|
1257
1257
|
`dismissOnPanDown={false}`.
|
|
1258
1258
|
- Custom toasts stack by request order and overlap at the top, as before;
|
|
1259
|
-
message toasts stack
|
|
1259
|
+
message toasts stack in the platform toaster (§5.14).
|
|
1260
1260
|
|
|
1261
1261
|
Future work (better to have):
|
|
1262
1262
|
|
|
1263
1263
|
- VoiceOver / TalkBack cross-window modality, verified on device.
|
|
1264
|
-
- Screen-reader toasts: the native
|
|
1265
|
-
|
|
1264
|
+
- Screen-reader toasts: the native toaster announces each card's text when
|
|
1265
|
+
it appears (§5.14); the lifetime is not yet extended, and the host should
|
|
1266
1266
|
its timer instead.
|
|
1267
1267
|
|
|
1268
1268
|
Known gaps:
|
|
@@ -1307,3 +1307,114 @@ staged version). Following the repository's verification guidance, the entire
|
|
|
1307
1307
|
batch advances to `3.0.162-alpha.270`. Existing versions are never overwritten.
|
|
1308
1308
|
The iOS lockfile failure was only local CocoaPods 1.17.0 versus the Gemfile's
|
|
1309
1309
|
locked 1.16.2; the actual CI lockfile was adopted, preserving semantic checks.
|
|
1310
|
+
|
|
1311
|
+
## 5.14 Message toasts
|
|
1312
|
+
|
|
1313
|
+
Message toasts are plain data. `overlayToastStore.show(spec, handlers)` takes
|
|
1314
|
+
an `IOverlayToastSpec` (`src/toast/types.ts`) and the platform draws the card:
|
|
1315
|
+
DOM on Web, UIKit on iOS, Android views on Android. React draws nothing; the
|
|
1316
|
+
only React piece is `OverlayToastHost`, which attaches the renderer.
|
|
1317
|
+
|
|
1318
|
+
### Contract
|
|
1319
|
+
|
|
1320
|
+
- A spec holds resolved values only: CSS colour strings, points, font sizes,
|
|
1321
|
+
icon names. The package carries no design tokens.
|
|
1322
|
+
- Two layouts: `message` (status icon, title, message, action row) and
|
|
1323
|
+
`notification` (round badge, clamped title and message, trailing image,
|
|
1324
|
+
pressable row).
|
|
1325
|
+
- Text is paragraphs of runs. A run may set colour, weight, size, underline
|
|
1326
|
+
and `link`; a link is opaque and comes back through `onLink`.
|
|
1327
|
+
- Actions are small buttons described by data and report `onAction(id)`.
|
|
1328
|
+
Pressing one does not dismiss the toast.
|
|
1329
|
+
- `show` with an id that is on screen updates that card and restarts its
|
|
1330
|
+
lifetime; `update` redraws it (theme or layout change) without restarting.
|
|
1331
|
+
- A toast leaves the list when its renderer reports `close`, after the exit.
|
|
1332
|
+
With no renderer attached a dismissal removes it at once. At most 20 toasts
|
|
1333
|
+
are kept; older ones are dropped without animation.
|
|
1334
|
+
- Events: `dismiss(reason)` when the card starts leaving (`timeout`, `swipe`,
|
|
1335
|
+
`close`, `programmatic`), `close(reason)` when it is gone, `action`,
|
|
1336
|
+
`link`, `press`.
|
|
1337
|
+
- `configure` sets toaster-wide values: position and theme (Web), card colour
|
|
1338
|
+
and content box (native), and the top obstruction the stack rests under.
|
|
1339
|
+
|
|
1340
|
+
### Bridge
|
|
1341
|
+
|
|
1342
|
+
iOS and Android use one zero-size Fabric component, `RNCNativeOverlayToaster`,
|
|
1343
|
+
with two string props (`toasts`, `config`: JSON) and one direct event
|
|
1344
|
+
(`onToastEvent { toastId, type, value }`). An infinite duration crosses as
|
|
1345
|
+
`-1`. The cards are not children of this view: iOS draws them in a `toast`
|
|
1346
|
+
level window from `NativeOverlayWindowManager`, Android in a layer at the
|
|
1347
|
+
bottom of the host's `toast` level container, so custom toast entries stay
|
|
1348
|
+
above them. Web has no bridge: the DOM renderer subscribes to the store.
|
|
1349
|
+
|
|
1350
|
+
Named icons come from `@onekeyfe/react-native-image`'s native registry,
|
|
1351
|
+
reached at runtime (Objective-C runtime on iOS, reflection on Android) so this
|
|
1352
|
+
package takes no dependency on it; without the registry an icon stays blank.
|
|
1353
|
+
Web draws an SVG `<use>` of the `href` the caller supplies.
|
|
1354
|
+
|
|
1355
|
+
### Platform behaviour
|
|
1356
|
+
|
|
1357
|
+
Each platform keeps the look and motion of the renderer it replaced.
|
|
1358
|
+
|
|
1359
|
+
| Behaviour | Web | iOS / Android |
|
|
1360
|
+
| --- | --- | --- |
|
|
1361
|
+
| Position | Per toast or toaster; default bottom-right | Always top-centre |
|
|
1362
|
+
| Stack | Newest in front, 3 visible, collapsed until hovered | Oldest at the top, newest under it, 8 pt apart, all visible |
|
|
1363
|
+
| 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 |
|
|
1364
|
+
| 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 |
|
|
1365
|
+
| `close` reported | 200 ms after the exit starts | 1000 ms after the exit starts |
|
|
1366
|
+
| Timer pause | While the stack is hovered or pressed; resuming restarts the full lifetime | While a card is pressed; resuming continues the remaining time |
|
|
1367
|
+
| Swipe | Away from the anchored edge; 20 px or 0.11 px/ms | Up; 32 pt, or 12 pt at 600 pt/s; dragging down moves a quarter as far |
|
|
1368
|
+
| Top obstruction | Inline `top` on top groups, 220 ms | The whole stack translates, 220 ms |
|
|
1369
|
+
| Reduced motion | Transitions off (media query) | Every animation is instant |
|
|
1370
|
+
|
|
1371
|
+
Divergences from the renderers replaced:
|
|
1372
|
+
|
|
1373
|
+
- Web measures a card's own height. The previous renderer could record a
|
|
1374
|
+
scaled height when several toasts arrived in one tick, which put about 4 px
|
|
1375
|
+
less between cards of an expanded stack.
|
|
1376
|
+
- Web starts the enter transition synchronously, so a toast shown while the
|
|
1377
|
+
page is hidden still appears.
|
|
1378
|
+
- Native shows toasts under a screen reader and announces their text; the
|
|
1379
|
+
previous renderer drew nothing while a screen reader was on.
|
|
1380
|
+
|
|
1381
|
+
### Verification
|
|
1382
|
+
|
|
1383
|
+
- Web: `src/__tests__/overlayToast.web.test.ts` covers the store and the DOM
|
|
1384
|
+
renderer. In app-monorepo, 13 scenarios in three captures (wide dark, narrow
|
|
1385
|
+
dark, wide light) matched the previous renderer's card boxes, text line
|
|
1386
|
+
rects, icon and button boxes and computed styles within 0.5 px.
|
|
1387
|
+
- iOS: built into app-monorepo and run on an iPhone 17 Pro simulator (iOS
|
|
1388
|
+
26.0) beside the previous renderer. In 13 scenarios the card frames and
|
|
1389
|
+
every text line box matched to the pixel; the only differing pixels were
|
|
1390
|
+
corner anti-aliasing against a differently lit backdrop. Timeout, close
|
|
1391
|
+
callback, action press, notification press, swipe up, press-to-pause with
|
|
1392
|
+
resume, programmatic close, id de-duplication and dismiss by id were
|
|
1393
|
+
exercised with injected touches. Not exercised there: the top obstruction
|
|
1394
|
+
shift, the keyboard limit, dark theme, rotation, iPad and VoiceOver.
|
|
1395
|
+
- Android: built into app-monorepo and run on a Pixel 7 emulator (API 35,
|
|
1396
|
+
420 dpi) beside the previous renderer, both with the brand typeface. In 13
|
|
1397
|
+
scenarios, light and dark, every card, text, icon and button frame matched
|
|
1398
|
+
to the pixel; inside the cards the remaining pixel differences were at most
|
|
1399
|
+
12 of 255 (anti-aliasing), apart from the spinner's animation frame. The
|
|
1400
|
+
spinner box is 2 px shorter than before (53x52 against 53x54). Timeout and
|
|
1401
|
+
close callback, action press, notification press, swipe up, a short drag
|
|
1402
|
+
that settles back, press-to-pause with resume, programmatic close, id
|
|
1403
|
+
de-duplication, dismiss by id and stacking order were exercised with
|
|
1404
|
+
injected touches. Not exercised there: the top obstruction shift, the
|
|
1405
|
+
keyboard limit, rotation, tablets, foldables and TalkBack.
|
|
1406
|
+
|
|
1407
|
+
iOS text is laid out and drawn with TextKit (no font leading, glyphs centred
|
|
1408
|
+
in a fixed line box) because that is what the previous text engine did. Two
|
|
1409
|
+
of its habits are kept on purpose: a text box is one pixel taller than its
|
|
1410
|
+
lines, and an explicit letter spacing, zero included, turns the font's pair
|
|
1411
|
+
kerning off.
|
|
1412
|
+
|
|
1413
|
+
Android cards follow the previous layout engine's pixel rounding (Yoga): an
|
|
1414
|
+
offset from the parent is rounded half up, a text offset is floored, and a
|
|
1415
|
+
size is the difference of the rounded absolute edges, so the card keeps its
|
|
1416
|
+
unrounded window position. Text is drawn unhinted at subpixel positions with
|
|
1417
|
+
the font size and line height rounded up to whole pixels, underlines are
|
|
1418
|
+
stroked at baseline + thickness + 1 px, and a bordered pill's fill is inset
|
|
1419
|
+
by 0.8 px, all as React Native draws them. Named icons render at their
|
|
1420
|
+
rounded frame size.
|