@vvedantb/native-ui 0.27.0 → 0.28.0
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/dist/ai/message-context-menu.jsx +111 -113
- package/dist/entries/primitives.js +2 -0
- package/dist/media/ImageGallery.jsx +12 -15
- package/dist/primitives/window-layer.jsx +212 -0
- package/package.json +1 -1
- package/src/ai/message-context-menu.tsx +11 -10
- package/src/entries/primitives.ts +3 -0
- package/src/media/ImageGallery.tsx +6 -5
- package/src/primitives/window-layer.tsx +133 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Pressable, StyleSheet, Text, View, useWindowDimensions } from "react-native";
|
|
3
3
|
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
5
|
import { cn } from "../cn";
|
|
6
|
+
import { WindowLayer } from "../primitives/window-layer";
|
|
6
7
|
import { PANEL_SCALE_FROM, POPOVER_ENTER } from "../motion";
|
|
7
8
|
import { sizeStyle, typeStyle } from "../controlStyles";
|
|
8
9
|
import { palette, withAlpha } from "../palette";
|
|
9
10
|
import { useLargerText } from "../theme";
|
|
10
11
|
import { tokens } from "../tokens";
|
|
11
|
-
import { useReduceMotion } from "../useReduceMotion";
|
|
12
12
|
import { useScheme } from "../useScheme";
|
|
13
13
|
import { chatTextSize } from "./chat-text";
|
|
14
14
|
import { MESSAGE_MENU, messageContextMenuLayout } from "./message-menu-layout";
|
|
@@ -21,8 +21,9 @@ const LIFT_SCALE = 1.02;
|
|
|
21
21
|
* The iMessage hold menu for a chat message: the chat fades under a frosted
|
|
22
22
|
* wash of the screen colour, the held message stays in place,
|
|
23
23
|
* lifted, with the quick reactions in a pill above it and the actions in a
|
|
24
|
-
* card below it, label first and icon last. It
|
|
25
|
-
*
|
|
24
|
+
* card below it, label first and icon last. It draws in the app's window
|
|
25
|
+
* (`WindowLayer`) and fades in and out as one; with Reduce Motion on, it
|
|
26
|
+
* appears at once. As it fades
|
|
26
27
|
* in, the pill and the card grow into place from the message's side (0.96 to
|
|
27
28
|
* 1) and the held message lifts a little (to 1.02), in 150 ms; with Reduce
|
|
28
29
|
* Motion they are in place at once. A tap outside, Android back
|
|
@@ -30,7 +31,7 @@ const LIFT_SCALE = 1.02;
|
|
|
30
31
|
* runs. `Message` opens it with `menu`.
|
|
31
32
|
*/
|
|
32
33
|
export function MessageContextMenu(t0) {
|
|
33
|
-
const $ = _c(
|
|
34
|
+
const $ = _c(89);
|
|
34
35
|
const {
|
|
35
36
|
open,
|
|
36
37
|
onClose,
|
|
@@ -46,7 +47,6 @@ export function MessageContextMenu(t0) {
|
|
|
46
47
|
const window = useWindowDimensions();
|
|
47
48
|
const insets = useSafeAreaInsets();
|
|
48
49
|
const largerText = useLargerText();
|
|
49
|
-
const reduceMotion = useReduceMotion();
|
|
50
50
|
const rowHeight = largerText ? 56 : 48;
|
|
51
51
|
let t2;
|
|
52
52
|
if ($[0] !== largerText) {
|
|
@@ -151,57 +151,56 @@ export function MessageContextMenu(t0) {
|
|
|
151
151
|
}
|
|
152
152
|
const shadow = t9;
|
|
153
153
|
const pillWidth = Math.min(window.width - 2 * MESSAGE_MENU.edge, (menu.reactions?.items.length ?? 0) * 48 + 16);
|
|
154
|
-
|
|
155
|
-
let t11;
|
|
154
|
+
let t10;
|
|
156
155
|
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
157
|
-
|
|
156
|
+
t10 = {
|
|
158
157
|
flex: 1
|
|
159
158
|
};
|
|
160
|
-
$[18] =
|
|
159
|
+
$[18] = t10;
|
|
161
160
|
} else {
|
|
162
|
-
|
|
161
|
+
t10 = $[18];
|
|
163
162
|
}
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
let
|
|
167
|
-
if ($[19] !==
|
|
168
|
-
|
|
169
|
-
$[19] =
|
|
170
|
-
$[20] =
|
|
163
|
+
const t11 = `${testID}-backdrop`;
|
|
164
|
+
const t12 = tokens.color.background[scheme];
|
|
165
|
+
let t13;
|
|
166
|
+
if ($[19] !== t12) {
|
|
167
|
+
t13 = withAlpha(t12, 0.85);
|
|
168
|
+
$[19] = t12;
|
|
169
|
+
$[20] = t13;
|
|
171
170
|
} else {
|
|
172
|
-
|
|
171
|
+
t13 = $[20];
|
|
173
172
|
}
|
|
174
|
-
let
|
|
175
|
-
if ($[21] !==
|
|
176
|
-
|
|
177
|
-
backgroundColor:
|
|
173
|
+
let t14;
|
|
174
|
+
if ($[21] !== t13) {
|
|
175
|
+
t14 = [StyleSheet.absoluteFill, {
|
|
176
|
+
backgroundColor: t13
|
|
178
177
|
}];
|
|
179
|
-
$[21] =
|
|
180
|
-
$[22] =
|
|
178
|
+
$[21] = t13;
|
|
179
|
+
$[22] = t14;
|
|
181
180
|
} else {
|
|
182
|
-
|
|
181
|
+
t14 = $[22];
|
|
183
182
|
}
|
|
184
|
-
let
|
|
185
|
-
if ($[23] !== onClose || $[24] !==
|
|
186
|
-
|
|
183
|
+
let t15;
|
|
184
|
+
if ($[23] !== onClose || $[24] !== t11 || $[25] !== t14) {
|
|
185
|
+
t15 = <View style={StyleSheet.absoluteFill}><Pressable testID={t11} accessibilityRole="button" accessibilityLabel="Close menu" onPress={onClose} style={t14} /></View>;
|
|
187
186
|
$[23] = onClose;
|
|
188
|
-
$[24] =
|
|
189
|
-
$[25] =
|
|
190
|
-
$[26] =
|
|
187
|
+
$[24] = t11;
|
|
188
|
+
$[25] = t14;
|
|
189
|
+
$[26] = t15;
|
|
191
190
|
} else {
|
|
192
|
-
|
|
191
|
+
t15 = $[26];
|
|
193
192
|
}
|
|
194
|
-
const
|
|
195
|
-
let
|
|
196
|
-
if ($[27] !== anchor.width || $[28] !== anchor.x || $[29] !== layout.previewHeight || $[30] !== layout.previewTop || $[31] !==
|
|
197
|
-
|
|
193
|
+
const t16 = tokens.color.background[scheme];
|
|
194
|
+
let t17;
|
|
195
|
+
if ($[27] !== anchor.width || $[28] !== anchor.x || $[29] !== layout.previewHeight || $[30] !== layout.previewTop || $[31] !== t16) {
|
|
196
|
+
t17 = {
|
|
198
197
|
position: "absolute",
|
|
199
198
|
top: layout.previewTop,
|
|
200
199
|
left: anchor.x,
|
|
201
200
|
width: anchor.width,
|
|
202
201
|
height: layout.previewHeight,
|
|
203
202
|
overflow: "hidden",
|
|
204
|
-
backgroundColor:
|
|
203
|
+
backgroundColor: t16,
|
|
205
204
|
borderRadius: tokens.radius.card,
|
|
206
205
|
...shadow
|
|
207
206
|
};
|
|
@@ -209,32 +208,32 @@ export function MessageContextMenu(t0) {
|
|
|
209
208
|
$[28] = anchor.x;
|
|
210
209
|
$[29] = layout.previewHeight;
|
|
211
210
|
$[30] = layout.previewTop;
|
|
212
|
-
$[31] =
|
|
213
|
-
$[32] =
|
|
211
|
+
$[31] = t16;
|
|
212
|
+
$[32] = t17;
|
|
214
213
|
} else {
|
|
215
|
-
|
|
214
|
+
t17 = $[32];
|
|
216
215
|
}
|
|
217
|
-
let
|
|
218
|
-
if ($[33] !== liftStyle || $[34] !==
|
|
219
|
-
|
|
216
|
+
let t18;
|
|
217
|
+
if ($[33] !== liftStyle || $[34] !== t17) {
|
|
218
|
+
t18 = [t17, liftStyle];
|
|
220
219
|
$[33] = liftStyle;
|
|
221
|
-
$[34] =
|
|
222
|
-
$[35] =
|
|
220
|
+
$[34] = t17;
|
|
221
|
+
$[35] = t18;
|
|
223
222
|
} else {
|
|
224
|
-
|
|
223
|
+
t18 = $[35];
|
|
225
224
|
}
|
|
226
|
-
let
|
|
227
|
-
if ($[36] !== preview || $[37] !==
|
|
228
|
-
|
|
225
|
+
let t19;
|
|
226
|
+
if ($[36] !== preview || $[37] !== t18) {
|
|
227
|
+
t19 = <Animated.View pointerEvents="none" style={t18}>{preview}</Animated.View>;
|
|
229
228
|
$[36] = preview;
|
|
230
|
-
$[37] =
|
|
231
|
-
$[38] =
|
|
229
|
+
$[37] = t18;
|
|
230
|
+
$[38] = t19;
|
|
232
231
|
} else {
|
|
233
|
-
|
|
232
|
+
t19 = $[38];
|
|
234
233
|
}
|
|
235
|
-
let
|
|
234
|
+
let t20;
|
|
236
235
|
if ($[39] !== align || $[40] !== layout.pillTop || $[41] !== menu.reactions || $[42] !== pillWidth || $[43] !== popStyle || $[44] !== run || $[45] !== scheme || $[46] !== side || $[47] !== surface || $[48] !== testID) {
|
|
237
|
-
|
|
236
|
+
t20 = menu.reactions ? <Animated.View accessibilityRole="toolbar" style={[{
|
|
238
237
|
position: "absolute",
|
|
239
238
|
top: layout.pillTop,
|
|
240
239
|
...side(pillWidth),
|
|
@@ -265,113 +264,112 @@ export function MessageContextMenu(t0) {
|
|
|
265
264
|
$[46] = side;
|
|
266
265
|
$[47] = surface;
|
|
267
266
|
$[48] = testID;
|
|
268
|
-
$[49] =
|
|
267
|
+
$[49] = t20;
|
|
269
268
|
} else {
|
|
270
|
-
|
|
269
|
+
t20 = $[49];
|
|
271
270
|
}
|
|
272
|
-
const
|
|
273
|
-
let
|
|
271
|
+
const t21 = layout.menuTop;
|
|
272
|
+
let t22;
|
|
274
273
|
if ($[50] !== side) {
|
|
275
|
-
|
|
274
|
+
t22 = side(MESSAGE_MENU.menuWidth);
|
|
276
275
|
$[50] = side;
|
|
277
|
-
$[51] =
|
|
276
|
+
$[51] = t22;
|
|
278
277
|
} else {
|
|
279
|
-
|
|
278
|
+
t22 = $[51];
|
|
280
279
|
}
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
let
|
|
284
|
-
if ($[52] !== layout.menuTop || $[53] !== surface || $[54] !==
|
|
285
|
-
|
|
280
|
+
const t23 = window.width - 2 * MESSAGE_MENU.edge;
|
|
281
|
+
const t24 = align === "end" ? "right top" : "left top";
|
|
282
|
+
let t25;
|
|
283
|
+
if ($[52] !== layout.menuTop || $[53] !== surface || $[54] !== t22 || $[55] !== t23 || $[56] !== t24) {
|
|
284
|
+
t25 = {
|
|
286
285
|
position: "absolute",
|
|
287
|
-
top:
|
|
288
|
-
...
|
|
286
|
+
top: t21,
|
|
287
|
+
...t22,
|
|
289
288
|
width: MESSAGE_MENU.menuWidth,
|
|
290
|
-
maxWidth:
|
|
289
|
+
maxWidth: t23,
|
|
291
290
|
borderRadius: tokens.radius.card,
|
|
292
291
|
backgroundColor: surface,
|
|
293
292
|
overflow: "hidden",
|
|
294
|
-
transformOrigin:
|
|
293
|
+
transformOrigin: t24,
|
|
295
294
|
...shadow
|
|
296
295
|
};
|
|
297
296
|
$[52] = layout.menuTop;
|
|
298
297
|
$[53] = surface;
|
|
299
|
-
$[54] =
|
|
300
|
-
$[55] =
|
|
301
|
-
$[56] =
|
|
302
|
-
$[57] =
|
|
298
|
+
$[54] = t22;
|
|
299
|
+
$[55] = t23;
|
|
300
|
+
$[56] = t24;
|
|
301
|
+
$[57] = t25;
|
|
303
302
|
} else {
|
|
304
|
-
|
|
303
|
+
t25 = $[57];
|
|
305
304
|
}
|
|
306
|
-
let
|
|
307
|
-
if ($[58] !== popStyle || $[59] !==
|
|
308
|
-
|
|
305
|
+
let t26;
|
|
306
|
+
if ($[58] !== popStyle || $[59] !== t25) {
|
|
307
|
+
t26 = [t25, popStyle];
|
|
309
308
|
$[58] = popStyle;
|
|
310
|
-
$[59] =
|
|
311
|
-
$[60] =
|
|
309
|
+
$[59] = t25;
|
|
310
|
+
$[60] = t26;
|
|
312
311
|
} else {
|
|
313
|
-
|
|
312
|
+
t26 = $[60];
|
|
314
313
|
}
|
|
315
|
-
let
|
|
314
|
+
let t27;
|
|
316
315
|
if ($[61] !== body || $[62] !== largerText || $[63] !== menu.actions || $[64] !== rowHeight || $[65] !== run || $[66] !== testID) {
|
|
317
|
-
let
|
|
316
|
+
let t28;
|
|
318
317
|
if ($[68] !== body || $[69] !== largerText || $[70] !== rowHeight || $[71] !== run || $[72] !== testID) {
|
|
319
|
-
|
|
318
|
+
t28 = (action_0, index) => <MenuCardRow key={action_0.key} testID={`${testID}-action-${action_0.key}`} action={action_0} first={index === 0} rowHeight={rowHeight} body={body} iconSize={largerText ? 22 : 20} onPress={() => run(action_0.onPress)} />;
|
|
320
319
|
$[68] = body;
|
|
321
320
|
$[69] = largerText;
|
|
322
321
|
$[70] = rowHeight;
|
|
323
322
|
$[71] = run;
|
|
324
323
|
$[72] = testID;
|
|
325
|
-
$[73] =
|
|
324
|
+
$[73] = t28;
|
|
326
325
|
} else {
|
|
327
|
-
|
|
326
|
+
t28 = $[73];
|
|
328
327
|
}
|
|
329
|
-
|
|
328
|
+
t27 = menu.actions.map(t28);
|
|
330
329
|
$[61] = body;
|
|
331
330
|
$[62] = largerText;
|
|
332
331
|
$[63] = menu.actions;
|
|
333
332
|
$[64] = rowHeight;
|
|
334
333
|
$[65] = run;
|
|
335
334
|
$[66] = testID;
|
|
336
|
-
$[67] =
|
|
335
|
+
$[67] = t27;
|
|
337
336
|
} else {
|
|
338
|
-
|
|
337
|
+
t27 = $[67];
|
|
339
338
|
}
|
|
340
|
-
let
|
|
341
|
-
if ($[74] !==
|
|
342
|
-
|
|
343
|
-
$[74] =
|
|
344
|
-
$[75] =
|
|
345
|
-
$[76] =
|
|
339
|
+
let t28;
|
|
340
|
+
if ($[74] !== t26 || $[75] !== t27) {
|
|
341
|
+
t28 = <Animated.View accessibilityRole="menu" style={t26}>{t27}</Animated.View>;
|
|
342
|
+
$[74] = t26;
|
|
343
|
+
$[75] = t27;
|
|
344
|
+
$[76] = t28;
|
|
346
345
|
} else {
|
|
347
|
-
|
|
346
|
+
t28 = $[76];
|
|
348
347
|
}
|
|
349
|
-
let
|
|
350
|
-
if ($[77] !== appear || $[78] !== onClose || $[79] !==
|
|
351
|
-
|
|
348
|
+
let t29;
|
|
349
|
+
if ($[77] !== appear || $[78] !== onClose || $[79] !== t15 || $[80] !== t19 || $[81] !== t20 || $[82] !== t28 || $[83] !== testID) {
|
|
350
|
+
t29 = <View style={t10} testID={testID} accessibilityViewIsModal={true} onAccessibilityEscape={onClose} onLayout={appear}>{t15}{t19}{t20}{t28}</View>;
|
|
352
351
|
$[77] = appear;
|
|
353
352
|
$[78] = onClose;
|
|
354
|
-
$[79] =
|
|
355
|
-
$[80] =
|
|
356
|
-
$[81] =
|
|
357
|
-
$[82] =
|
|
353
|
+
$[79] = t15;
|
|
354
|
+
$[80] = t19;
|
|
355
|
+
$[81] = t20;
|
|
356
|
+
$[82] = t28;
|
|
358
357
|
$[83] = testID;
|
|
359
|
-
$[84] =
|
|
358
|
+
$[84] = t29;
|
|
360
359
|
} else {
|
|
361
|
-
|
|
360
|
+
t29 = $[84];
|
|
362
361
|
}
|
|
363
|
-
let
|
|
364
|
-
if ($[85] !== onClose || $[86] !== onDismissed || $[87] !==
|
|
365
|
-
|
|
362
|
+
let t30;
|
|
363
|
+
if ($[85] !== onClose || $[86] !== onDismissed || $[87] !== t29) {
|
|
364
|
+
t30 = <WindowLayer onRequestClose={onClose} onDismiss={onDismissed}>{t29}</WindowLayer>;
|
|
366
365
|
$[85] = onClose;
|
|
367
366
|
$[86] = onDismissed;
|
|
368
|
-
$[87] =
|
|
367
|
+
$[87] = t29;
|
|
369
368
|
$[88] = t30;
|
|
370
|
-
$[89] = t31;
|
|
371
369
|
} else {
|
|
372
|
-
|
|
370
|
+
t30 = $[88];
|
|
373
371
|
}
|
|
374
|
-
return
|
|
372
|
+
return t30;
|
|
375
373
|
}
|
|
376
374
|
|
|
377
375
|
/**
|
|
@@ -58,3 +58,5 @@ export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuLab
|
|
|
58
58
|
export { Sheet, SheetTrigger, SheetClose, SheetContent, SheetHandle, SheetHeader, SheetTitle, SheetDescription, SheetBody, SheetFooter } from "../Sheet";
|
|
59
59
|
export { Toaster } from "../Toast";
|
|
60
60
|
export { toast } from "../toastStore";
|
|
61
|
+
// Overlays in the app's window (the hold menu, the image viewer): wrap the navigator once.
|
|
62
|
+
export { WindowLayerHost } from "../primitives/window-layer";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { useContext, useState } from "react";
|
|
3
|
-
import { FlatList, Image,
|
|
3
|
+
import { FlatList, Image, Pressable, Text, View, useWindowDimensions } from "react-native";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
5
|
import { IconExternalLink, IconX } from "@tabler/icons-react-native";
|
|
6
6
|
import { typeStyle } from "../controlStyles";
|
|
7
|
+
import { WindowLayer } from "../primitives/window-layer";
|
|
7
8
|
import { IconButton } from "../IconButton";
|
|
8
9
|
import { withAlpha } from "../palette";
|
|
9
10
|
import { tokens } from "../tokens";
|
|
10
|
-
import { useReduceMotion } from "../useReduceMotion";
|
|
11
11
|
import { useScheme } from "../useScheme";
|
|
12
12
|
import { ZoomImageContext } from "./zoomImage";
|
|
13
13
|
import { imageAspect, imageGridTiles, imageViewerPage, MEDIA } from "./imageGrid";
|
|
@@ -346,7 +346,7 @@ function _temp(tile) {
|
|
|
346
346
|
* at once with Reduce Motion.
|
|
347
347
|
*/
|
|
348
348
|
export function ImageViewer(t0) {
|
|
349
|
-
const $ = _c(
|
|
349
|
+
const $ = _c(9);
|
|
350
350
|
const {
|
|
351
351
|
images,
|
|
352
352
|
index,
|
|
@@ -354,34 +354,31 @@ export function ImageViewer(t0) {
|
|
|
354
354
|
onClose,
|
|
355
355
|
onOpenImage
|
|
356
356
|
} = t0;
|
|
357
|
-
const reduceMotion = useReduceMotion();
|
|
358
357
|
if (index === null) {
|
|
359
358
|
return null;
|
|
360
359
|
}
|
|
361
|
-
|
|
362
|
-
let t2;
|
|
360
|
+
let t1;
|
|
363
361
|
if ($[0] !== images || $[1] !== index || $[2] !== onClose || $[3] !== onIndexChange || $[4] !== onOpenImage) {
|
|
364
|
-
|
|
362
|
+
t1 = <ViewerRoot><ViewerPages images={images} index={index} onIndexChange={onIndexChange} onClose={onClose} onOpenImage={onOpenImage} /></ViewerRoot>;
|
|
365
363
|
$[0] = images;
|
|
366
364
|
$[1] = index;
|
|
367
365
|
$[2] = onClose;
|
|
368
366
|
$[3] = onIndexChange;
|
|
369
367
|
$[4] = onOpenImage;
|
|
370
|
-
$[5] =
|
|
368
|
+
$[5] = t1;
|
|
371
369
|
} else {
|
|
372
|
-
|
|
370
|
+
t1 = $[5];
|
|
373
371
|
}
|
|
374
|
-
let
|
|
375
|
-
if ($[6] !== onClose || $[7] !== t1
|
|
376
|
-
|
|
372
|
+
let t2;
|
|
373
|
+
if ($[6] !== onClose || $[7] !== t1) {
|
|
374
|
+
t2 = <WindowLayer onRequestClose={onClose}>{t1}</WindowLayer>;
|
|
377
375
|
$[6] = onClose;
|
|
378
376
|
$[7] = t1;
|
|
379
377
|
$[8] = t2;
|
|
380
|
-
$[9] = t3;
|
|
381
378
|
} else {
|
|
382
|
-
|
|
379
|
+
t2 = $[8];
|
|
383
380
|
}
|
|
384
|
-
return
|
|
381
|
+
return t2;
|
|
385
382
|
}
|
|
386
383
|
|
|
387
384
|
/** The zoom parts' gesture root, when there are zoom parts. */
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { useId, useLayoutEffect, useSyncExternalStore } from "react";
|
|
3
|
+
import { BackHandler, Modal, StyleSheet, View } from "react-native";
|
|
4
|
+
import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
|
|
5
|
+
import { useReduceMotion } from "../useReduceMotion";
|
|
6
|
+
|
|
7
|
+
// Overlays drawn in the app's own window. A React Native `Modal` is a window
|
|
8
|
+
// of its own on Android: it takes the focus as it opens and hands it back as
|
|
9
|
+
// it closes, and each time `react-native-keyboard-controller`'s chat list
|
|
10
|
+
// scrolls to its newest message. A layer in `WindowLayerHost` is a view over
|
|
11
|
+
// the app instead, so the focus never moves. Without a host, `WindowLayer`
|
|
12
|
+
// falls back to a `Modal`, so an app that mounts none keeps working.
|
|
13
|
+
|
|
14
|
+
const EMPTY = [];
|
|
15
|
+
let layers = EMPTY;
|
|
16
|
+
let hosts = 0;
|
|
17
|
+
const listeners = new Set();
|
|
18
|
+
const emit = () => {
|
|
19
|
+
for (const listener of listeners) listener();
|
|
20
|
+
};
|
|
21
|
+
const subscribe = listener => {
|
|
22
|
+
listeners.add(listener);
|
|
23
|
+
return () => {
|
|
24
|
+
listeners.delete(listener);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const upsert = layer => {
|
|
28
|
+
const at = layers.findIndex(item => item.id === layer.id);
|
|
29
|
+
layers = at === -1 ? [...layers, layer] : layers.map((item, index) => index === at ? layer : item);
|
|
30
|
+
emit();
|
|
31
|
+
};
|
|
32
|
+
const remove = id => {
|
|
33
|
+
if (!layers.some(item => item.id === id)) return;
|
|
34
|
+
layers = layers.filter(item => item.id !== id);
|
|
35
|
+
emit();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Android back closes the newest layer, as a Modal's `onRequestClose`.
|
|
39
|
+
const onBack = () => {
|
|
40
|
+
const top = layers[layers.length - 1];
|
|
41
|
+
if (!top) return false;
|
|
42
|
+
top.onRequestClose();
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Mounted: the host is there, and it answers Android back for its layers. */
|
|
47
|
+
const hostRef = view => {
|
|
48
|
+
if (view === null) return undefined;
|
|
49
|
+
hosts += 1;
|
|
50
|
+
const back = BackHandler.addEventListener("hardwareBackPress", onBack);
|
|
51
|
+
emit();
|
|
52
|
+
return () => {
|
|
53
|
+
hosts -= 1;
|
|
54
|
+
back.remove();
|
|
55
|
+
emit();
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Wrap the app once (inside `NativeUiProvider`, around the navigator): the
|
|
61
|
+
* `WindowLayer`s draw over it, in the same window. While a layer shows, the
|
|
62
|
+
* app under it is hidden from TalkBack and VoiceOver, as under a Modal.
|
|
63
|
+
*/
|
|
64
|
+
export function WindowLayerHost(t0) {
|
|
65
|
+
const $ = _c(12);
|
|
66
|
+
const {
|
|
67
|
+
children
|
|
68
|
+
} = t0;
|
|
69
|
+
const shown = useSyncExternalStore(subscribe, _temp, _temp2);
|
|
70
|
+
let t1;
|
|
71
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
72
|
+
t1 = FadeIn.duration(200).reduceMotion(ReduceMotion.System);
|
|
73
|
+
$[0] = t1;
|
|
74
|
+
} else {
|
|
75
|
+
t1 = $[0];
|
|
76
|
+
}
|
|
77
|
+
const enter = t1;
|
|
78
|
+
let t2;
|
|
79
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
80
|
+
t2 = FadeOut.duration(150).reduceMotion(ReduceMotion.System);
|
|
81
|
+
$[1] = t2;
|
|
82
|
+
} else {
|
|
83
|
+
t2 = $[1];
|
|
84
|
+
}
|
|
85
|
+
const exit = t2;
|
|
86
|
+
const t3 = shown.length > 0 ? "no-hide-descendants" : "auto";
|
|
87
|
+
const t4 = shown.length > 0;
|
|
88
|
+
let t5;
|
|
89
|
+
if ($[2] !== children || $[3] !== t3 || $[4] !== t4) {
|
|
90
|
+
t5 = <View style={styles.fill} importantForAccessibility={t3} accessibilityElementsHidden={t4}>{children}</View>;
|
|
91
|
+
$[2] = children;
|
|
92
|
+
$[3] = t3;
|
|
93
|
+
$[4] = t4;
|
|
94
|
+
$[5] = t5;
|
|
95
|
+
} else {
|
|
96
|
+
t5 = $[5];
|
|
97
|
+
}
|
|
98
|
+
let t6;
|
|
99
|
+
if ($[6] !== shown) {
|
|
100
|
+
let t7;
|
|
101
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
102
|
+
t7 = layer => <Animated.View key={layer.id} entering={enter} exiting={exit} style={StyleSheet.absoluteFill} pointerEvents="box-none">{layer.node}</Animated.View>;
|
|
103
|
+
$[8] = t7;
|
|
104
|
+
} else {
|
|
105
|
+
t7 = $[8];
|
|
106
|
+
}
|
|
107
|
+
t6 = shown.map(t7);
|
|
108
|
+
$[6] = shown;
|
|
109
|
+
$[7] = t6;
|
|
110
|
+
} else {
|
|
111
|
+
t6 = $[7];
|
|
112
|
+
}
|
|
113
|
+
let t7;
|
|
114
|
+
if ($[9] !== t5 || $[10] !== t6) {
|
|
115
|
+
t7 = <View ref={hostRef} style={styles.fill}>{t5}{t6}</View>;
|
|
116
|
+
$[9] = t5;
|
|
117
|
+
$[10] = t6;
|
|
118
|
+
$[11] = t7;
|
|
119
|
+
} else {
|
|
120
|
+
t7 = $[11];
|
|
121
|
+
}
|
|
122
|
+
return t7;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* An overlay over the whole app, in its own window only when it must be: in
|
|
127
|
+
* `WindowLayerHost` when the app has one, else a transparent `Modal` (with
|
|
128
|
+
* `onDismiss` there). Render it only while the overlay shows. Android back
|
|
129
|
+
* calls `onRequestClose`. Its children keep the providers above the host, not
|
|
130
|
+
* those between the host and this element.
|
|
131
|
+
*/
|
|
132
|
+
function _temp2() {
|
|
133
|
+
return EMPTY;
|
|
134
|
+
}
|
|
135
|
+
function _temp() {
|
|
136
|
+
return layers;
|
|
137
|
+
}
|
|
138
|
+
export function WindowLayer(t0) {
|
|
139
|
+
const $ = _c(14);
|
|
140
|
+
const {
|
|
141
|
+
onRequestClose,
|
|
142
|
+
onDismiss,
|
|
143
|
+
children
|
|
144
|
+
} = t0;
|
|
145
|
+
const id = useId();
|
|
146
|
+
const reduceMotion = useReduceMotion();
|
|
147
|
+
const hosted = useSyncExternalStore(subscribe, _temp3, _temp4);
|
|
148
|
+
let t1;
|
|
149
|
+
let t2;
|
|
150
|
+
if ($[0] !== children || $[1] !== hosted || $[2] !== id || $[3] !== onRequestClose) {
|
|
151
|
+
t1 = () => {
|
|
152
|
+
if (hosted) {
|
|
153
|
+
upsert({
|
|
154
|
+
id,
|
|
155
|
+
node: children,
|
|
156
|
+
onRequestClose
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
t2 = [hosted, id, children, onRequestClose];
|
|
161
|
+
$[0] = children;
|
|
162
|
+
$[1] = hosted;
|
|
163
|
+
$[2] = id;
|
|
164
|
+
$[3] = onRequestClose;
|
|
165
|
+
$[4] = t1;
|
|
166
|
+
$[5] = t2;
|
|
167
|
+
} else {
|
|
168
|
+
t1 = $[4];
|
|
169
|
+
t2 = $[5];
|
|
170
|
+
}
|
|
171
|
+
useLayoutEffect(t1, t2);
|
|
172
|
+
let t3;
|
|
173
|
+
let t4;
|
|
174
|
+
if ($[6] !== id) {
|
|
175
|
+
t3 = () => () => remove(id);
|
|
176
|
+
t4 = [id];
|
|
177
|
+
$[6] = id;
|
|
178
|
+
$[7] = t3;
|
|
179
|
+
$[8] = t4;
|
|
180
|
+
} else {
|
|
181
|
+
t3 = $[7];
|
|
182
|
+
t4 = $[8];
|
|
183
|
+
}
|
|
184
|
+
useLayoutEffect(t3, t4);
|
|
185
|
+
if (hosted) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
const t5 = reduceMotion ? "none" : "fade";
|
|
189
|
+
let t6;
|
|
190
|
+
if ($[9] !== children || $[10] !== onDismiss || $[11] !== onRequestClose || $[12] !== t5) {
|
|
191
|
+
t6 = <Modal visible={true} transparent={true} statusBarTranslucent={true} animationType={t5} onRequestClose={onRequestClose} onDismiss={onDismiss}>{children}</Modal>;
|
|
192
|
+
$[9] = children;
|
|
193
|
+
$[10] = onDismiss;
|
|
194
|
+
$[11] = onRequestClose;
|
|
195
|
+
$[12] = t5;
|
|
196
|
+
$[13] = t6;
|
|
197
|
+
} else {
|
|
198
|
+
t6 = $[13];
|
|
199
|
+
}
|
|
200
|
+
return t6;
|
|
201
|
+
}
|
|
202
|
+
function _temp4() {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
function _temp3() {
|
|
206
|
+
return hosts > 0;
|
|
207
|
+
}
|
|
208
|
+
const styles = StyleSheet.create({
|
|
209
|
+
fill: {
|
|
210
|
+
flex: 1
|
|
211
|
+
}
|
|
212
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts, the family app marks, a NativeWind preset, the Expo web root and Clerk + Convex auth screens.",
|
|
6
6
|
"type": "module",
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Pressable, StyleSheet, Text, View, useWindowDimensions } from "react-native";
|
|
3
3
|
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
5
|
import { cn } from "../cn";
|
|
6
|
+
import { WindowLayer } from "../primitives/window-layer";
|
|
6
7
|
import { PANEL_SCALE_FROM, POPOVER_ENTER } from "../motion";
|
|
7
8
|
import { sizeStyle, typeStyle } from "../controlStyles";
|
|
8
9
|
import { palette, withAlpha } from "../palette";
|
|
9
10
|
import { useLargerText } from "../theme";
|
|
10
11
|
import { tokens } from "../tokens";
|
|
11
|
-
import { useReduceMotion } from "../useReduceMotion";
|
|
12
12
|
import { useScheme } from "../useScheme";
|
|
13
13
|
import { chatTextSize } from "./chat-text";
|
|
14
14
|
import { MESSAGE_MENU, messageContextMenuLayout, type MessageMenu, type MessageMenuRect } from "./message-menu-layout";
|
|
@@ -21,8 +21,9 @@ const LIFT_SCALE = 1.02;
|
|
|
21
21
|
* The iMessage hold menu for a chat message: the chat fades under a frosted
|
|
22
22
|
* wash of the screen colour, the held message stays in place,
|
|
23
23
|
* lifted, with the quick reactions in a pill above it and the actions in a
|
|
24
|
-
* card below it, label first and icon last. It
|
|
25
|
-
*
|
|
24
|
+
* card below it, label first and icon last. It draws in the app's window
|
|
25
|
+
* (`WindowLayer`) and fades in and out as one; with Reduce Motion on, it
|
|
26
|
+
* appears at once. As it fades
|
|
26
27
|
* in, the pill and the card grow into place from the message's side (0.96 to
|
|
27
28
|
* 1) and the held message lifts a little (to 1.02), in 150 ms; with Reduce
|
|
28
29
|
* Motion they are in place at once. A tap outside, Android back
|
|
@@ -56,11 +57,10 @@ export function MessageContextMenu({
|
|
|
56
57
|
const window = useWindowDimensions();
|
|
57
58
|
const insets = useSafeAreaInsets();
|
|
58
59
|
const largerText = useLargerText();
|
|
59
|
-
const reduceMotion = useReduceMotion();
|
|
60
60
|
const rowHeight = largerText ? 56 : 48;
|
|
61
61
|
const body = chatTextSize("body", largerText);
|
|
62
|
-
// 0 to 1 as the menu opens
|
|
63
|
-
// entering
|
|
62
|
+
// 0 to 1 as the menu opens, started from the menu's first layout: a shared value runs in a
|
|
63
|
+
// layer and in the fallback Modal alike (Reanimated's entering does not run inside a Modal on Android).
|
|
64
64
|
const shown = useSharedValue(0);
|
|
65
65
|
const popStyle = useAnimatedStyle(() => ({ transform: [{ scale: PANEL_SCALE_FROM + (1 - PANEL_SCALE_FROM) * shown.get() }] }));
|
|
66
66
|
const liftStyle = useAnimatedStyle(() => ({ transform: [{ scale: 1 + (LIFT_SCALE - 1) * shown.get() }] }));
|
|
@@ -92,8 +92,9 @@ export function MessageContextMenu({
|
|
|
92
92
|
const pillWidth = Math.min(window.width - 2 * MESSAGE_MENU.edge, (menu.reactions?.items.length ?? 0) * 48 + 16);
|
|
93
93
|
|
|
94
94
|
return (
|
|
95
|
-
//
|
|
96
|
-
|
|
95
|
+
// In the app's window (`WindowLayer`): a Modal's own window moved the focus on Android, and the chat
|
|
96
|
+
// list's keyboard handling scrolled to the newest message as it opened and closed.
|
|
97
|
+
<WindowLayer onRequestClose={onClose} onDismiss={onDismissed}>
|
|
97
98
|
<View style={{ flex: 1 }} testID={testID} accessibilityViewIsModal onAccessibilityEscape={onClose} onLayout={appear}>
|
|
98
99
|
<View style={StyleSheet.absoluteFill}>
|
|
99
100
|
<Pressable
|
|
@@ -191,7 +192,7 @@ export function MessageContextMenu({
|
|
|
191
192
|
))}
|
|
192
193
|
</Animated.View>
|
|
193
194
|
</View>
|
|
194
|
-
</
|
|
195
|
+
</WindowLayer>
|
|
195
196
|
);
|
|
196
197
|
}
|
|
197
198
|
|
|
@@ -168,3 +168,6 @@ export type { SheetProps, SheetContentProps } from "../Sheet";
|
|
|
168
168
|
export { Toaster } from "../Toast";
|
|
169
169
|
export { toast } from "../toastStore";
|
|
170
170
|
export type { ToastOptions, ToastVariant } from "../toastStore";
|
|
171
|
+
|
|
172
|
+
// Overlays in the app's window (the hold menu, the image viewer): wrap the navigator once.
|
|
173
|
+
export { WindowLayerHost } from "../primitives/window-layer";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useContext, useState, type ReactNode } from "react";
|
|
2
|
-
import { FlatList, Image,
|
|
2
|
+
import { FlatList, Image, Pressable, Text, View, useWindowDimensions } from "react-native";
|
|
3
3
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
4
|
import { IconExternalLink, IconX } from "@tabler/icons-react-native";
|
|
5
5
|
import { typeStyle } from "../controlStyles";
|
|
6
|
+
import { WindowLayer } from "../primitives/window-layer";
|
|
6
7
|
import { IconButton } from "../IconButton";
|
|
7
8
|
import { withAlpha } from "../palette";
|
|
8
9
|
import { tokens } from "../tokens";
|
|
9
|
-
import { useReduceMotion } from "../useReduceMotion";
|
|
10
10
|
import { useScheme } from "../useScheme";
|
|
11
11
|
import { ZoomImageContext } from "./zoomImage";
|
|
12
12
|
import { imageAspect, imageGridTiles, imageViewerPage, MEDIA, type GalleryImage, type ImageGridTile } from "./imageGrid";
|
|
@@ -156,14 +156,15 @@ export type ImageViewerProps = {
|
|
|
156
156
|
* at once with Reduce Motion.
|
|
157
157
|
*/
|
|
158
158
|
export function ImageViewer({ images, index, onIndexChange, onClose, onOpenImage }: ImageViewerProps) {
|
|
159
|
-
const reduceMotion = useReduceMotion();
|
|
160
159
|
if (index === null) return null;
|
|
161
160
|
return (
|
|
162
|
-
|
|
161
|
+
// In the app's window (`WindowLayer`): a Modal's own window moved the focus on Android, and a chat
|
|
162
|
+
// list under the viewer scrolled to its newest message as it opened and closed.
|
|
163
|
+
<WindowLayer onRequestClose={onClose}>
|
|
163
164
|
<ViewerRoot>
|
|
164
165
|
<ViewerPages images={images} index={index} onIndexChange={onIndexChange} onClose={onClose} onOpenImage={onOpenImage} />
|
|
165
166
|
</ViewerRoot>
|
|
166
|
-
</
|
|
167
|
+
</WindowLayer>
|
|
167
168
|
);
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useId, useLayoutEffect, useSyncExternalStore, type ReactNode } from "react";
|
|
2
|
+
import { BackHandler, Modal, StyleSheet, View } from "react-native";
|
|
3
|
+
import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
|
|
4
|
+
import { useReduceMotion } from "../useReduceMotion";
|
|
5
|
+
|
|
6
|
+
// Overlays drawn in the app's own window. A React Native `Modal` is a window
|
|
7
|
+
// of its own on Android: it takes the focus as it opens and hands it back as
|
|
8
|
+
// it closes, and each time `react-native-keyboard-controller`'s chat list
|
|
9
|
+
// scrolls to its newest message. A layer in `WindowLayerHost` is a view over
|
|
10
|
+
// the app instead, so the focus never moves. Without a host, `WindowLayer`
|
|
11
|
+
// falls back to a `Modal`, so an app that mounts none keeps working.
|
|
12
|
+
|
|
13
|
+
type Layer = { id: string; node: ReactNode; onRequestClose: () => void };
|
|
14
|
+
|
|
15
|
+
const EMPTY: readonly Layer[] = [];
|
|
16
|
+
let layers: readonly Layer[] = EMPTY;
|
|
17
|
+
let hosts = 0;
|
|
18
|
+
const listeners = new Set<() => void>();
|
|
19
|
+
|
|
20
|
+
const emit = () => {
|
|
21
|
+
for (const listener of listeners) listener();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const subscribe = (listener: () => void) => {
|
|
25
|
+
listeners.add(listener);
|
|
26
|
+
return () => {
|
|
27
|
+
listeners.delete(listener);
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const upsert = (layer: Layer) => {
|
|
32
|
+
const at = layers.findIndex((item) => item.id === layer.id);
|
|
33
|
+
layers = at === -1 ? [...layers, layer] : layers.map((item, index) => (index === at ? layer : item));
|
|
34
|
+
emit();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const remove = (id: string) => {
|
|
38
|
+
if (!layers.some((item) => item.id === id)) return;
|
|
39
|
+
layers = layers.filter((item) => item.id !== id);
|
|
40
|
+
emit();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Android back closes the newest layer, as a Modal's `onRequestClose`.
|
|
44
|
+
const onBack = () => {
|
|
45
|
+
const top = layers[layers.length - 1];
|
|
46
|
+
if (!top) return false;
|
|
47
|
+
top.onRequestClose();
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Mounted: the host is there, and it answers Android back for its layers. */
|
|
52
|
+
const hostRef = (view: View | null) => {
|
|
53
|
+
if (view === null) return undefined;
|
|
54
|
+
hosts += 1;
|
|
55
|
+
const back = BackHandler.addEventListener("hardwareBackPress", onBack);
|
|
56
|
+
emit();
|
|
57
|
+
return () => {
|
|
58
|
+
hosts -= 1;
|
|
59
|
+
back.remove();
|
|
60
|
+
emit();
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Wrap the app once (inside `NativeUiProvider`, around the navigator): the
|
|
66
|
+
* `WindowLayer`s draw over it, in the same window. While a layer shows, the
|
|
67
|
+
* app under it is hidden from TalkBack and VoiceOver, as under a Modal.
|
|
68
|
+
*/
|
|
69
|
+
export function WindowLayerHost({ children }: { children: ReactNode }) {
|
|
70
|
+
const shown = useSyncExternalStore(subscribe, () => layers, () => EMPTY);
|
|
71
|
+
// The layers fade in and out as a Modal's `fade`; with Reduce Motion they appear at once.
|
|
72
|
+
const enter = FadeIn.duration(200).reduceMotion(ReduceMotion.System);
|
|
73
|
+
const exit = FadeOut.duration(150).reduceMotion(ReduceMotion.System);
|
|
74
|
+
return (
|
|
75
|
+
<View ref={hostRef} style={styles.fill}>
|
|
76
|
+
<View
|
|
77
|
+
style={styles.fill}
|
|
78
|
+
importantForAccessibility={shown.length > 0 ? "no-hide-descendants" : "auto"}
|
|
79
|
+
accessibilityElementsHidden={shown.length > 0}
|
|
80
|
+
>
|
|
81
|
+
{children}
|
|
82
|
+
</View>
|
|
83
|
+
{shown.map((layer) => (
|
|
84
|
+
<Animated.View key={layer.id} entering={enter} exiting={exit} style={StyleSheet.absoluteFill} pointerEvents="box-none">
|
|
85
|
+
{layer.node}
|
|
86
|
+
</Animated.View>
|
|
87
|
+
))}
|
|
88
|
+
</View>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* An overlay over the whole app, in its own window only when it must be: in
|
|
94
|
+
* `WindowLayerHost` when the app has one, else a transparent `Modal` (with
|
|
95
|
+
* `onDismiss` there). Render it only while the overlay shows. Android back
|
|
96
|
+
* calls `onRequestClose`. Its children keep the providers above the host, not
|
|
97
|
+
* those between the host and this element.
|
|
98
|
+
*/
|
|
99
|
+
export function WindowLayer({
|
|
100
|
+
onRequestClose,
|
|
101
|
+
onDismiss,
|
|
102
|
+
children,
|
|
103
|
+
}: {
|
|
104
|
+
onRequestClose: () => void;
|
|
105
|
+
/** The fallback Modal's dismiss (iOS); a layer is gone as it unmounts. */
|
|
106
|
+
onDismiss?: () => void;
|
|
107
|
+
children: ReactNode;
|
|
108
|
+
}) {
|
|
109
|
+
const id = useId();
|
|
110
|
+
const reduceMotion = useReduceMotion();
|
|
111
|
+
const hosted = useSyncExternalStore(subscribe, () => hosts > 0, () => false);
|
|
112
|
+
// A portal has to hand the host its children after each render: an external
|
|
113
|
+
// store fed from an effect, the one sync React offers for it.
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
if (hosted) upsert({ id, node: children, onRequestClose });
|
|
116
|
+
}, [hosted, id, children, onRequestClose]);
|
|
117
|
+
useLayoutEffect(() => () => remove(id), [id]);
|
|
118
|
+
if (hosted) return null;
|
|
119
|
+
return (
|
|
120
|
+
<Modal
|
|
121
|
+
visible
|
|
122
|
+
transparent
|
|
123
|
+
statusBarTranslucent
|
|
124
|
+
animationType={reduceMotion ? "none" : "fade"}
|
|
125
|
+
onRequestClose={onRequestClose}
|
|
126
|
+
onDismiss={onDismiss}
|
|
127
|
+
>
|
|
128
|
+
{children}
|
|
129
|
+
</Modal>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const styles = StyleSheet.create({ fill: { flex: 1 } });
|