@plexui/react-native 0.2.18 → 0.2.20
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/es/components/Menu/Menu.js +10 -3
- package/dist/es/components/TabBar/TabBar.js +8 -2
- package/dist/es/internal/Glass.js +53 -7
- package/dist/es/internal/Overlay.js +5 -1
- package/package.json +1 -1
- package/src/components/Menu/Menu.tsx +10 -2
- package/src/components/TabBar/TabBar.tsx +9 -2
- package/src/internal/Glass.tsx +65 -7
- package/src/internal/Overlay.tsx +7 -0
|
@@ -178,10 +178,14 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
178
178
|
const [subHeight, setSubHeight] = useState(null);
|
|
179
179
|
const [step] = useState(() => new Animated.Value(0));
|
|
180
180
|
const [wasOpen, setWasOpen] = useState(open);
|
|
181
|
+
// Each opening lays the panel out anew: a menu opened again while it still leaves keeps its view, whose size does
|
|
182
|
+
// not change, so it would report no layout and stay where it is measured, off the screen
|
|
183
|
+
const [openings, setOpenings] = useState(0);
|
|
181
184
|
if (wasOpen !== open) {
|
|
182
185
|
setWasOpen(open);
|
|
183
186
|
// Each opening measures again: its items may have changed, and it opens at the menu, not at a submenu
|
|
184
187
|
if (open) {
|
|
188
|
+
setOpenings((count) => count + 1);
|
|
185
189
|
setSize(null);
|
|
186
190
|
setSub(null);
|
|
187
191
|
// A menu closed over its submenu comes back whole
|
|
@@ -334,7 +338,7 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
334
338
|
// With reduced motion it fades in place
|
|
335
339
|
transform: scale ? [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [0.8, 1] }) }] : undefined,
|
|
336
340
|
},
|
|
337
|
-
], children: _jsxs(Animated.View, { style: [styles.shrink, scale ? stepBack : null], children: [_jsx(Glass, { ...glass, style: [styles.shrink, { padding: gutter }, !scale && web && !theme.reducedMotion ? stepBack : null], children: _jsx(ScrollView, { style: styles.scroll, bounces: false, children: _jsx(Animated.View, { pointerEvents: sub ? "none" : "auto", style: { opacity: step.interpolate({ inputRange: [0, 1], outputRange: [1, 0.5] }) }, children: content }) }) }), sub ? _jsx(View, { style: StyleSheet.absoluteFill, onStartShouldSetResponder: () => true, onResponderRelease: collapse }) : null] }) }), sub ? (_jsx(Animated.View, { ref: subPanel, ...(web ? { tabIndex: -1 } : null), accessibilityRole: "menu", "aria-label": textOf(sub.label) || undefined, ...keysOf(subPanel), onLayout: (event) => setSubHeight(event.nativeEvent.layout.height), style: [
|
|
341
|
+
], children: _jsxs(Animated.View, { style: [styles.shrink, scale ? stepBack : null], children: [_jsx(Glass, { ...glass, style: [styles.shrink, { padding: gutter }, !scale && web && !theme.reducedMotion ? stepBack : null], children: _jsx(ScrollView, { style: styles.scroll, bounces: false, children: _jsx(Animated.View, { pointerEvents: sub ? "none" : "auto", style: { opacity: step.interpolate({ inputRange: [0, 1], outputRange: [1, 0.5] }) }, children: content }) }) }), sub ? _jsx(View, { style: StyleSheet.absoluteFill, onStartShouldSetResponder: () => true, onResponderRelease: collapse }) : null] }) }, openings), sub ? (_jsx(Animated.View, { ref: subPanel, ...(web ? { tabIndex: -1 } : null), accessibilityRole: "menu", "aria-label": textOf(sub.label) || undefined, ...keysOf(subPanel), onLayout: (event) => setSubHeight(event.nativeEvent.layout.height), style: [
|
|
338
342
|
styles.surface,
|
|
339
343
|
horizontal,
|
|
340
344
|
{
|
|
@@ -456,11 +460,14 @@ function AndroidMenuSurface({ open, anchor, row, header = false, onClose, align
|
|
|
456
460
|
const [clock] = useState(() => new Animated.Value(0));
|
|
457
461
|
const [revealed, setRevealed] = useState(false);
|
|
458
462
|
const pending = useRef(false);
|
|
463
|
+
const [openings, setOpenings] = useState(0);
|
|
459
464
|
const [wasOpen, setWasOpen] = useState(open);
|
|
460
465
|
if (wasOpen !== open) {
|
|
461
466
|
setWasOpen(open);
|
|
462
|
-
// Each opening measures again and opens at the menu
|
|
467
|
+
// Each opening measures again and opens at the menu, its page laid out anew (a page kept from a menu that still
|
|
468
|
+
// leaves would report no layout)
|
|
463
469
|
if (open) {
|
|
470
|
+
setOpenings((count) => count + 1);
|
|
464
471
|
setSize(null);
|
|
465
472
|
setSub(null);
|
|
466
473
|
setSubSize(null);
|
|
@@ -694,7 +701,7 @@ function AndroidMenuSurface({ open, anchor, row, header = false, onClose, align
|
|
|
694
701
|
? [{ translateY: Animated.multiply(drop, -1) }]
|
|
695
702
|
: undefined,
|
|
696
703
|
},
|
|
697
|
-
], children: [_jsx(CascadeContext.Provider, { value: cascade, children: _jsx(AndroidPage, { width: morphing ? size.width : width, minWidth: minWidth, maxWidth: maxWidth, maxHeight: maxHeight, onSize: (measured) => setSize(sameSize(measured)), style: header ? styles.androidHeaderPage : undefined, children: _jsx(SurfaceContext.Provider, { value: surface, children: children }) }) }), sub ? _jsx(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { backgroundColor: "#000000", opacity: swipe.interpolate({ inputRange: [0, 1], outputRange: [0, 0.25] }) }] }) : null] }), sub ? (
|
|
704
|
+
], children: [_jsx(CascadeContext.Provider, { value: cascade, children: _jsx(AndroidPage, { width: morphing ? size.width : width, minWidth: minWidth, maxWidth: maxWidth, maxHeight: maxHeight, onSize: (measured) => setSize(sameSize(measured)), style: header ? styles.androidHeaderPage : undefined, children: _jsx(SurfaceContext.Provider, { value: surface, children: children }) }, openings) }), sub ? _jsx(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { backgroundColor: "#000000", opacity: swipe.interpolate({ inputRange: [0, 1], outputRange: [0, 0.25] }) }] }) : null] }), sub ? (
|
|
698
705
|
// As wide as the widest page may be, so the submenu takes its own width, not the menu's
|
|
699
706
|
_jsx(Animated.View, { ref: subPage, ...swipeBack.responder.panHandlers, pointerEvents: "box-none", style: [styles.androidSubPage, startEdge, { width: maxWidth, transform: [{ translateX: swipe.interpolate({ inputRange: [0, 1], outputRange: [span || window.width, 0] }) }] }], children: _jsx(AndroidPage, { width: width, minWidth: minWidth, maxWidth: maxWidth, maxHeight: maxHeight, onSize: onSubSize, style: [{ backgroundColor: background }, header ? styles.androidHeaderPage : null], children: subItems }) })) : null] })] })] }));
|
|
700
707
|
} }));
|
|
@@ -12,7 +12,7 @@ import { Glass } from "../../internal/Glass";
|
|
|
12
12
|
import { curves } from "../../internal/motion";
|
|
13
13
|
import { useTabKeys } from "../../internal/tabKeys";
|
|
14
14
|
import { barSurface, mix, stateLayer, withAlpha } from "../../theme/material";
|
|
15
|
-
import { useTheme } from "../../theme/ThemeProvider";
|
|
15
|
+
import { useTheme, useThemeOverrides } from "../../theme/ThemeProvider";
|
|
16
16
|
import { IconDefaultsProvider } from "../Icon/createIcon";
|
|
17
17
|
import { Text, textStyle } from "../Text/Text";
|
|
18
18
|
const TabBarContext = createContext(null);
|
|
@@ -382,6 +382,12 @@ function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, pro
|
|
|
382
382
|
slidingPill: pillFrame ? value : undefined,
|
|
383
383
|
};
|
|
384
384
|
const pillOutset = theme.length("--tab-bar-pill-outset", 6);
|
|
385
|
+
// The web's selected pill in the dark is a shade of the glass, deeper at its top and lifting toward its bottom, as
|
|
386
|
+
// iOS 26 draws it; a brand that sets the pill's token keeps its color
|
|
387
|
+
const overrides = useThemeOverrides();
|
|
388
|
+
const webPill = theme.scheme === "dark" && overrides?.["--tab-bar-item-background-selected"] == null
|
|
389
|
+
? { backgroundColor: "transparent", backgroundImage: "linear-gradient(to bottom, rgb(0 0 0 / 22%), rgb(255 255 255 / 8%))" }
|
|
390
|
+
: { backgroundColor: theme.color("--tab-bar-item-background-selected") };
|
|
385
391
|
const [pillX] = useState(() => new Animated.Value(0));
|
|
386
392
|
const [pillWidth] = useState(() => new Animated.Value(0));
|
|
387
393
|
const pillShown = useRef(false);
|
|
@@ -444,7 +450,7 @@ function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, pro
|
|
|
444
450
|
], children: [backdrop, accessory ? (_jsx(Glass, { radius: accessoryHeight / 2, elevation: "raised", style: [styles.accessory, accessoryPlace], children: accessory }, "accessory")) : null, _jsxs(View, { style: [styles.iosRow, { gap: theme.length("--tab-bar-gap", 8), justifyContent: circle || minimized ? "space-between" : "center" }], children: [_jsxs(Glass, { radius: 999, elevation: "raised", style: [styles.capsule, minimized ? { padding: capsulePadding } : { paddingVertical: capsulePadding, paddingHorizontal: theme.length("--tab-bar-capsule-padding-inline", 10) }], children: [pillFrame && Platform.OS === "web" ? (
|
|
445
451
|
// The web slides the pill in CSS, off the JavaScript thread, so a screen mounting under the new tab
|
|
446
452
|
// does not stop it
|
|
447
|
-
_jsx(CssSlide, { x: pillLeft, width: pillSpan, side: "start", duration: 300, easing: "cubic-bezier(0.25, 0.1, 0.25, 1)", still: theme.reducedMotion, style: [styles.pill, { top: pillFrame.y, height: pillFrame.height,
|
|
453
|
+
_jsx(CssSlide, { x: pillLeft, width: pillSpan, side: "start", duration: 300, easing: "cubic-bezier(0.25, 0.1, 0.25, 1)", still: theme.reducedMotion, style: [styles.pill, { top: pillFrame.y, height: pillFrame.height }, webPill] })) : pillFrame ? (_jsx(Animated.View, { pointerEvents: "none", style: [
|
|
448
454
|
styles.pill,
|
|
449
455
|
{ top: pillFrame.y, height: pillFrame.height, start: pillX, width: pillWidth, backgroundColor: theme.color("--tab-bar-item-background-selected") },
|
|
450
456
|
] })) : null, visible.map((tab) => (_jsx(Tab, { ...tab, context: context }, tab.value)))] }), circle ? (_jsx(Glass, { radius: circleSize / 2, elevation: "raised", style: { width: circleSize, height: circleSize }, children: _jsx(Tab, { ...circle, context: { ...context, minimized: false }, kind: "circle", hideLabel: true }) })) : null] })] }) }));
|
|
@@ -12,18 +12,18 @@ import { useReduceTransparency } from "./reduceTransparency";
|
|
|
12
12
|
const WEB_DENSE = {
|
|
13
13
|
"--mobile-glass-background": {
|
|
14
14
|
fill: "--mobile-glass-web-background",
|
|
15
|
-
light: "rgba(
|
|
16
|
-
dark: "rgba(
|
|
15
|
+
light: "rgba(250, 250, 252, 0.62)",
|
|
16
|
+
dark: "rgba(52, 52, 56, 0.74)",
|
|
17
17
|
filter: "--mobile-glass-web-backdrop-filter",
|
|
18
|
-
blur: "blur(
|
|
18
|
+
blur: "blur(8px) saturate(180%)",
|
|
19
19
|
},
|
|
20
20
|
// Pressed, a step deeper, as the shared tokens step from 55% to 75%
|
|
21
21
|
"--mobile-glass-background-active": {
|
|
22
22
|
fill: "--mobile-glass-web-background-active",
|
|
23
|
-
light: "rgba(
|
|
24
|
-
dark: "rgba(
|
|
23
|
+
light: "rgba(238, 238, 242, 0.8)",
|
|
24
|
+
dark: "rgba(72, 72, 76, 0.84)",
|
|
25
25
|
filter: "--mobile-glass-web-backdrop-filter",
|
|
26
|
-
blur: "blur(
|
|
26
|
+
blur: "blur(8px) saturate(180%)",
|
|
27
27
|
},
|
|
28
28
|
"--menu-mobile-background": {
|
|
29
29
|
fill: "--menu-mobile-web-background",
|
|
@@ -33,6 +33,29 @@ const WEB_DENSE = {
|
|
|
33
33
|
blur: "blur(30px)",
|
|
34
34
|
},
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* The web's plain glass drawn as iOS 26's Liquid Glass reads (measured on its tab bars and bar buttons): a lighter fill
|
|
38
|
+
* than a tint of white in the dark, a sheen down the glass (a shade under its top edge in the light, a lift toward its
|
|
39
|
+
* bottom in the dark), a bright rim on every side, and a lens at the edge, where what is under the glass is blurred and
|
|
40
|
+
* lit more, as Liquid Glass bends it there (a browser cannot bend it). Each part a token a theme may set.
|
|
41
|
+
*/
|
|
42
|
+
const WEB_LIQUID = {
|
|
43
|
+
sheen: { token: "--mobile-glass-web-sheen", light: "linear-gradient(to bottom, rgb(0 0 0 / 3.5%), rgb(0 0 0 / 0) 35%)", dark: "linear-gradient(to bottom, rgb(255 255 255 / 0), rgb(255 255 255 / 5%))" },
|
|
44
|
+
shadow: {
|
|
45
|
+
token: "--mobile-glass-web-shadow",
|
|
46
|
+
light: "0 8px 24px rgb(0 0 0 / 6%), 0 0 0 0.5px rgb(0 0 0 / 12%), inset 0 1px 0 rgb(255 255 255), inset 0 -1px 0 rgb(255 255 255 / 90%), inset 1px 0 0 rgb(255 255 255 / 70%), inset -1px 0 0 rgb(255 255 255 / 70%)",
|
|
47
|
+
dark: "0 8px 24px rgb(0 0 0 / 25%), inset 0 1px 0 rgb(255 255 255 / 36%), inset 0 -1px 0 rgb(255 255 255 / 20%), inset 1px 0 0 rgb(255 255 255 / 12%), inset -1px 0 0 rgb(255 255 255 / 12%)",
|
|
48
|
+
},
|
|
49
|
+
shadowRaised: {
|
|
50
|
+
token: "--mobile-glass-web-shadow-raised",
|
|
51
|
+
light: "0 8px 40px rgb(0 0 0 / 12%), 0 0 0 0.5px rgb(0 0 0 / 12%), inset 0 1px 0 rgb(255 255 255), inset 0 -1px 0 rgb(255 255 255 / 90%), inset 1px 0 0 rgb(255 255 255 / 70%), inset -1px 0 0 rgb(255 255 255 / 70%)",
|
|
52
|
+
dark: "0 8px 40px rgb(0 0 0 / 30%), inset 0 1px 0 rgb(255 255 255 / 36%), inset 0 -1px 0 rgb(255 255 255 / 20%), inset 1px 0 0 rgb(255 255 255 / 12%), inset -1px 0 0 rgb(255 255 255 / 12%)",
|
|
53
|
+
},
|
|
54
|
+
lens: { token: "--mobile-glass-web-lens-filter", value: "blur(3px) brightness(1.12) saturate(200%)" },
|
|
55
|
+
};
|
|
56
|
+
// The lens: the glass's edge only, 14 in from its sides and 9 from its top and bottom (a small glass keeps a third)
|
|
57
|
+
const lensMask = (inline, block) => `linear-gradient(to right, #000 0, transparent ${inline}px, transparent calc(100% - ${inline}px), #000 100%), ` +
|
|
58
|
+
`linear-gradient(to bottom, #000 0, transparent ${block}px, transparent calc(100% - ${block}px), #000 100%)`;
|
|
36
59
|
/** The filter and the shadow of the glass surfaces of the phone layer, by their fill (mobile-materials.css, touch.css). */
|
|
37
60
|
const SURFACES = {
|
|
38
61
|
"--menu-mobile-background": { filter: "--menu-mobile-backdrop-filter", shadow: "--menu-shadow" },
|
|
@@ -81,8 +104,31 @@ export function Glass({ radius = 0, elevation = "regular", tint, interactive, fi
|
|
|
81
104
|
const module = web || Platform.OS !== "ios" ? null : blurModule();
|
|
82
105
|
const opaque = reduceTransparency || (!web && module == null);
|
|
83
106
|
if (web && !opaque) {
|
|
107
|
+
// The plain glass (bars, bar buttons, the tab bar, the large segmented control) reads as Liquid Glass; menus,
|
|
108
|
+
// toasts and alerts keep their frosted panels
|
|
109
|
+
const liquid = !theme.isAndroid && (fillName === "--mobile-glass-background" || fillName === "--mobile-glass-background-active" || plainFilter);
|
|
110
|
+
const scheme = theme.scheme === "dark" ? "dark" : "light";
|
|
111
|
+
const own = (part) => {
|
|
112
|
+
const value = theme.token(part.token);
|
|
113
|
+
return typeof value === "string" ? value : part[scheme];
|
|
114
|
+
};
|
|
115
|
+
const ownShadow = shadowToken == null && surface == null && overrides?.["--mobile-glass-shadow"] == null && overrides?.["--mobile-glass-shadow-raised"] == null;
|
|
116
|
+
const liquidShadow = liquid && ownShadow ? own(elevation === "raised" ? WEB_LIQUID.shadowRaised : WEB_LIQUID.shadow) : boxShadow;
|
|
117
|
+
const sheen = liquid && tint == null ? own(WEB_LIQUID.sheen) : undefined;
|
|
118
|
+
const lensToken = theme.token(WEB_LIQUID.lens.token);
|
|
119
|
+
const lensFilter = typeof lensToken === "string" ? lensToken : WEB_LIQUID.lens.value;
|
|
120
|
+
const mask = lensMask(Math.min(14, radius > 0 ? radius / 2 : 14), Math.min(9, radius > 0 ? radius / 3 : 9));
|
|
84
121
|
// An Animated.View, so a panel can move its own glass (a transform above the blur would stop it)
|
|
85
|
-
return (
|
|
122
|
+
return (_jsxs(Animated.View, { ...rest, style: [
|
|
123
|
+
shape,
|
|
124
|
+
{ backgroundColor: fill, boxShadow: liquidShadow },
|
|
125
|
+
{ backdropFilter: filter, WebkitBackdropFilter: filter, backgroundImage: sheen },
|
|
126
|
+
style,
|
|
127
|
+
], children: [liquid && lensFilter !== "none" ? (_jsx(View, { pointerEvents: "none", "aria-hidden": true, style: [
|
|
128
|
+
StyleSheet.absoluteFill,
|
|
129
|
+
shape,
|
|
130
|
+
{ backdropFilter: lensFilter, WebkitBackdropFilter: lensFilter, maskImage: mask, WebkitMaskImage: mask },
|
|
131
|
+
] })) : null, children] }));
|
|
86
132
|
}
|
|
87
133
|
const radiusPx = Number(/blur\(\s*([\d.]+)px\s*\)/.exec(filter)?.[1] ?? 12);
|
|
88
134
|
return (_jsxs(View, { ...rest, style: [shape, { boxShadow }, style], children: [_jsxs(View, { style: [StyleSheet.absoluteFill, shape, { overflow: "hidden" }], pointerEvents: "none", children: [opaque ? (_jsx(View, { style: [StyleSheet.absoluteFill, { backgroundColor: theme.color("--mobile-surface-elevated-plain-primary", theme.colors.surfaceElevated) }] })) : module ? (_jsx(module.BlurView, { intensity: intensityOf(radiusPx), tint: theme.scheme === "dark" ? "systemChromeMaterialDark" : "systemChromeMaterialLight", style: StyleSheet.absoluteFill })) : null, _jsx(View, { style: [StyleSheet.absoluteFill, { backgroundColor: fill }] })] }), children] }));
|
|
@@ -195,9 +195,13 @@ export function Overlay({ open, onDismiss, scrim = "transparent", dismissible =
|
|
|
195
195
|
// action (Android's `setCancelable(false)`)
|
|
196
196
|
_jsx(Modal, { visible: mounted, transparent: true, animationType: "none", onRequestClose: dismissible ? onDismiss : ignore, onDismiss: ios ? () => setPresented(false) : undefined, statusBarTranslucent: true, navigationBarTranslucent: true, supportedOrientations: ORIENTATIONS, children: mounted ? (
|
|
197
197
|
// A closing overlay takes no more touches: an action cannot run twice while it fades
|
|
198
|
-
_jsxs(View, { style: StyleSheet.absoluteFill, pointerEvents: show ? "box-none" : "none", onAccessibilityEscape: dismissible && show ? onDismiss : undefined, testID: testID, children: [_jsx(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { backgroundColor: scrim, opacity: scrimOpacity ? scrimOpacity(progress, show) : progress }] }), _jsx(View, { importantForAccessibility: "no", "aria-hidden": true, style: StyleSheet.absoluteFill, onStartShouldSetResponder: dismissible && show ? yes : undefined, onResponderRelease: dismissible && show ? onDismiss : undefined, testID: testID ? `${testID}-scrim` : undefined }), children(progress, show, focus)] })) : null }));
|
|
198
|
+
_jsxs(View, { style: StyleSheet.absoluteFill, pointerEvents: show ? "box-none" : "none", onAccessibilityEscape: dismissible && show ? onDismiss : undefined, testID: testID, children: [_jsx(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { backgroundColor: scrim, opacity: scrimOpacity ? scrimOpacity(progress, show) : progress }] }), _jsx(View, { importantForAccessibility: "no", "aria-hidden": true, style: StyleSheet.absoluteFill, onStartShouldSetResponder: dismissible && show ? yes : undefined, onResponderRelease: dismissible && show ? onDismiss : undefined, ...(Platform.OS === "web" ? { onTouchEnd: endTouch } : null), testID: testID ? `${testID}-scrim` : undefined }), children(progress, show, focus)] })) : null }));
|
|
199
199
|
}
|
|
200
200
|
const ignore = () => { };
|
|
201
|
+
const endTouch = (event) => {
|
|
202
|
+
if (event.cancelable !== false && event.nativeEvent?.cancelable !== false)
|
|
203
|
+
event.preventDefault?.();
|
|
204
|
+
};
|
|
201
205
|
const yes = () => true;
|
|
202
206
|
const NO_FOCUS = {};
|
|
203
207
|
const styles = StyleSheet.create({
|
package/package.json
CHANGED
|
@@ -245,10 +245,14 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
245
245
|
const [subHeight, setSubHeight] = useState<number | null>(null)
|
|
246
246
|
const [step] = useState(() => new Animated.Value(0))
|
|
247
247
|
const [wasOpen, setWasOpen] = useState(open)
|
|
248
|
+
// Each opening lays the panel out anew: a menu opened again while it still leaves keeps its view, whose size does
|
|
249
|
+
// not change, so it would report no layout and stay where it is measured, off the screen
|
|
250
|
+
const [openings, setOpenings] = useState(0)
|
|
248
251
|
if (wasOpen !== open) {
|
|
249
252
|
setWasOpen(open)
|
|
250
253
|
// Each opening measures again: its items may have changed, and it opens at the menu, not at a submenu
|
|
251
254
|
if (open) {
|
|
255
|
+
setOpenings((count) => count + 1)
|
|
252
256
|
setSize(null)
|
|
253
257
|
setSub(null)
|
|
254
258
|
// A menu closed over its submenu comes back whole
|
|
@@ -408,6 +412,7 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
408
412
|
</>
|
|
409
413
|
) : null}
|
|
410
414
|
<Animated.View
|
|
415
|
+
key={openings}
|
|
411
416
|
ref={panel as never}
|
|
412
417
|
// The panel takes the focus of a menu opened by a pointer (the web), with no ring of its own
|
|
413
418
|
{...(web ? { tabIndex: -1 as const } : null)}
|
|
@@ -645,11 +650,14 @@ function AndroidMenuSurface({ open, anchor, row, header = false, onClose, align
|
|
|
645
650
|
const [clock] = useState(() => new Animated.Value(0))
|
|
646
651
|
const [revealed, setRevealed] = useState(false)
|
|
647
652
|
const pending = useRef(false)
|
|
653
|
+
const [openings, setOpenings] = useState(0)
|
|
648
654
|
const [wasOpen, setWasOpen] = useState(open)
|
|
649
655
|
if (wasOpen !== open) {
|
|
650
656
|
setWasOpen(open)
|
|
651
|
-
// Each opening measures again and opens at the menu
|
|
657
|
+
// Each opening measures again and opens at the menu, its page laid out anew (a page kept from a menu that still
|
|
658
|
+
// leaves would report no layout)
|
|
652
659
|
if (open) {
|
|
660
|
+
setOpenings((count) => count + 1)
|
|
653
661
|
setSize(null)
|
|
654
662
|
setSub(null)
|
|
655
663
|
setSubSize(null)
|
|
@@ -914,7 +922,7 @@ function AndroidMenuSurface({ open, anchor, row, header = false, onClose, align
|
|
|
914
922
|
]}
|
|
915
923
|
>
|
|
916
924
|
<CascadeContext.Provider value={cascade}>
|
|
917
|
-
<AndroidPage width={morphing ? size.width : width} minWidth={minWidth} maxWidth={maxWidth} maxHeight={maxHeight} onSize={(measured) => setSize(sameSize(measured))} style={header ? styles.androidHeaderPage : undefined}>
|
|
925
|
+
<AndroidPage key={openings} width={morphing ? size.width : width} minWidth={minWidth} maxWidth={maxWidth} maxHeight={maxHeight} onSize={(measured) => setSize(sameSize(measured))} style={header ? styles.androidHeaderPage : undefined}>
|
|
918
926
|
<SurfaceContext.Provider value={surface}>{children}</SurfaceContext.Provider>
|
|
919
927
|
</AndroidPage>
|
|
920
928
|
</CascadeContext.Provider>
|
|
@@ -11,7 +11,7 @@ import { Glass } from "../../internal/Glass"
|
|
|
11
11
|
import { curves } from "../../internal/motion"
|
|
12
12
|
import { useTabKeys } from "../../internal/tabKeys"
|
|
13
13
|
import { barSurface, mix, stateLayer, withAlpha } from "../../theme/material"
|
|
14
|
-
import { useTheme } from "../../theme/ThemeProvider"
|
|
14
|
+
import { useTheme, useThemeOverrides } from "../../theme/ThemeProvider"
|
|
15
15
|
import type { Theme } from "../../theme/types"
|
|
16
16
|
import { IconDefaultsProvider } from "../Icon/createIcon"
|
|
17
17
|
import { Text, textStyle } from "../Text/Text"
|
|
@@ -732,6 +732,13 @@ function TabBarRoot({
|
|
|
732
732
|
slidingPill: pillFrame ? value : undefined,
|
|
733
733
|
}
|
|
734
734
|
const pillOutset = theme.length("--tab-bar-pill-outset", 6)
|
|
735
|
+
// The web's selected pill in the dark is a shade of the glass, deeper at its top and lifting toward its bottom, as
|
|
736
|
+
// iOS 26 draws it; a brand that sets the pill's token keeps its color
|
|
737
|
+
const overrides = useThemeOverrides()
|
|
738
|
+
const webPill: ViewStyle =
|
|
739
|
+
theme.scheme === "dark" && overrides?.["--tab-bar-item-background-selected"] == null
|
|
740
|
+
? ({ backgroundColor: "transparent", backgroundImage: "linear-gradient(to bottom, rgb(0 0 0 / 22%), rgb(255 255 255 / 8%))" } as ViewStyle)
|
|
741
|
+
: { backgroundColor: theme.color("--tab-bar-item-background-selected") }
|
|
735
742
|
const [pillX] = useState(() => new Animated.Value(0))
|
|
736
743
|
const [pillWidth] = useState(() => new Animated.Value(0))
|
|
737
744
|
const pillShown = useRef(false)
|
|
@@ -845,7 +852,7 @@ function TabBarRoot({
|
|
|
845
852
|
duration={300}
|
|
846
853
|
easing="cubic-bezier(0.25, 0.1, 0.25, 1)"
|
|
847
854
|
still={theme.reducedMotion}
|
|
848
|
-
style={[styles.pill, { top: pillFrame.y, height: pillFrame.height,
|
|
855
|
+
style={[styles.pill, { top: pillFrame.y, height: pillFrame.height }, webPill]}
|
|
849
856
|
/>
|
|
850
857
|
) : pillFrame ? (
|
|
851
858
|
<Animated.View
|
package/src/internal/Glass.tsx
CHANGED
|
@@ -38,18 +38,18 @@ export type GlassProps = ViewProps & {
|
|
|
38
38
|
const WEB_DENSE: Record<string, { fill: string; light: string; dark: string; filter: string; blur: string }> = {
|
|
39
39
|
"--mobile-glass-background": {
|
|
40
40
|
fill: "--mobile-glass-web-background",
|
|
41
|
-
light: "rgba(
|
|
42
|
-
dark: "rgba(
|
|
41
|
+
light: "rgba(250, 250, 252, 0.62)",
|
|
42
|
+
dark: "rgba(52, 52, 56, 0.74)",
|
|
43
43
|
filter: "--mobile-glass-web-backdrop-filter",
|
|
44
|
-
blur: "blur(
|
|
44
|
+
blur: "blur(8px) saturate(180%)",
|
|
45
45
|
},
|
|
46
46
|
// Pressed, a step deeper, as the shared tokens step from 55% to 75%
|
|
47
47
|
"--mobile-glass-background-active": {
|
|
48
48
|
fill: "--mobile-glass-web-background-active",
|
|
49
|
-
light: "rgba(
|
|
50
|
-
dark: "rgba(
|
|
49
|
+
light: "rgba(238, 238, 242, 0.8)",
|
|
50
|
+
dark: "rgba(72, 72, 76, 0.84)",
|
|
51
51
|
filter: "--mobile-glass-web-backdrop-filter",
|
|
52
|
-
blur: "blur(
|
|
52
|
+
blur: "blur(8px) saturate(180%)",
|
|
53
53
|
},
|
|
54
54
|
"--menu-mobile-background": {
|
|
55
55
|
fill: "--menu-mobile-web-background",
|
|
@@ -60,6 +60,34 @@ const WEB_DENSE: Record<string, { fill: string; light: string; dark: string; fil
|
|
|
60
60
|
},
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The web's plain glass drawn as iOS 26's Liquid Glass reads (measured on its tab bars and bar buttons): a lighter fill
|
|
65
|
+
* than a tint of white in the dark, a sheen down the glass (a shade under its top edge in the light, a lift toward its
|
|
66
|
+
* bottom in the dark), a bright rim on every side, and a lens at the edge, where what is under the glass is blurred and
|
|
67
|
+
* lit more, as Liquid Glass bends it there (a browser cannot bend it). Each part a token a theme may set.
|
|
68
|
+
*/
|
|
69
|
+
const WEB_LIQUID = {
|
|
70
|
+
sheen: { token: "--mobile-glass-web-sheen", light: "linear-gradient(to bottom, rgb(0 0 0 / 3.5%), rgb(0 0 0 / 0) 35%)", dark: "linear-gradient(to bottom, rgb(255 255 255 / 0), rgb(255 255 255 / 5%))" },
|
|
71
|
+
shadow: {
|
|
72
|
+
token: "--mobile-glass-web-shadow",
|
|
73
|
+
light:
|
|
74
|
+
"0 8px 24px rgb(0 0 0 / 6%), 0 0 0 0.5px rgb(0 0 0 / 12%), inset 0 1px 0 rgb(255 255 255), inset 0 -1px 0 rgb(255 255 255 / 90%), inset 1px 0 0 rgb(255 255 255 / 70%), inset -1px 0 0 rgb(255 255 255 / 70%)",
|
|
75
|
+
dark: "0 8px 24px rgb(0 0 0 / 25%), inset 0 1px 0 rgb(255 255 255 / 36%), inset 0 -1px 0 rgb(255 255 255 / 20%), inset 1px 0 0 rgb(255 255 255 / 12%), inset -1px 0 0 rgb(255 255 255 / 12%)",
|
|
76
|
+
},
|
|
77
|
+
shadowRaised: {
|
|
78
|
+
token: "--mobile-glass-web-shadow-raised",
|
|
79
|
+
light:
|
|
80
|
+
"0 8px 40px rgb(0 0 0 / 12%), 0 0 0 0.5px rgb(0 0 0 / 12%), inset 0 1px 0 rgb(255 255 255), inset 0 -1px 0 rgb(255 255 255 / 90%), inset 1px 0 0 rgb(255 255 255 / 70%), inset -1px 0 0 rgb(255 255 255 / 70%)",
|
|
81
|
+
dark: "0 8px 40px rgb(0 0 0 / 30%), inset 0 1px 0 rgb(255 255 255 / 36%), inset 0 -1px 0 rgb(255 255 255 / 20%), inset 1px 0 0 rgb(255 255 255 / 12%), inset -1px 0 0 rgb(255 255 255 / 12%)",
|
|
82
|
+
},
|
|
83
|
+
lens: { token: "--mobile-glass-web-lens-filter", value: "blur(3px) brightness(1.12) saturate(200%)" },
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// The lens: the glass's edge only, 14 in from its sides and 9 from its top and bottom (a small glass keeps a third)
|
|
87
|
+
const lensMask = (inline: number, block: number) =>
|
|
88
|
+
`linear-gradient(to right, #000 0, transparent ${inline}px, transparent calc(100% - ${inline}px), #000 100%), ` +
|
|
89
|
+
`linear-gradient(to bottom, #000 0, transparent ${block}px, transparent calc(100% - ${block}px), #000 100%)`
|
|
90
|
+
|
|
63
91
|
/** The filter and the shadow of the glass surfaces of the phone layer, by their fill (mobile-materials.css, touch.css). */
|
|
64
92
|
const SURFACES: Record<string, { filter: string; shadow: string }> = {
|
|
65
93
|
"--menu-mobile-background": { filter: "--menu-mobile-backdrop-filter", shadow: "--menu-shadow" },
|
|
@@ -133,12 +161,42 @@ export function Glass({
|
|
|
133
161
|
const module = web || Platform.OS !== "ios" ? null : blurModule()
|
|
134
162
|
const opaque = reduceTransparency || (!web && module == null)
|
|
135
163
|
if (web && !opaque) {
|
|
164
|
+
// The plain glass (bars, bar buttons, the tab bar, the large segmented control) reads as Liquid Glass; menus,
|
|
165
|
+
// toasts and alerts keep their frosted panels
|
|
166
|
+
const liquid = !theme.isAndroid && (fillName === "--mobile-glass-background" || fillName === "--mobile-glass-background-active" || plainFilter)
|
|
167
|
+
const scheme = theme.scheme === "dark" ? "dark" : "light"
|
|
168
|
+
const own = (part: { token: string; light: string; dark: string }) => {
|
|
169
|
+
const value = theme.token(part.token)
|
|
170
|
+
return typeof value === "string" ? value : part[scheme]
|
|
171
|
+
}
|
|
172
|
+
const ownShadow = shadowToken == null && surface == null && overrides?.["--mobile-glass-shadow"] == null && overrides?.["--mobile-glass-shadow-raised"] == null
|
|
173
|
+
const liquidShadow = liquid && ownShadow ? own(elevation === "raised" ? WEB_LIQUID.shadowRaised : WEB_LIQUID.shadow) : boxShadow
|
|
174
|
+
const sheen = liquid && tint == null ? own(WEB_LIQUID.sheen) : undefined
|
|
175
|
+
const lensToken = theme.token(WEB_LIQUID.lens.token)
|
|
176
|
+
const lensFilter = typeof lensToken === "string" ? lensToken : WEB_LIQUID.lens.value
|
|
177
|
+
const mask = lensMask(Math.min(14, radius > 0 ? radius / 2 : 14), Math.min(9, radius > 0 ? radius / 3 : 9))
|
|
136
178
|
// An Animated.View, so a panel can move its own glass (a transform above the blur would stop it)
|
|
137
179
|
return (
|
|
138
180
|
<Animated.View
|
|
139
181
|
{...rest}
|
|
140
|
-
style={[
|
|
182
|
+
style={[
|
|
183
|
+
shape,
|
|
184
|
+
{ backgroundColor: fill, boxShadow: liquidShadow },
|
|
185
|
+
{ backdropFilter: filter, WebkitBackdropFilter: filter, backgroundImage: sheen } as ViewStyle,
|
|
186
|
+
style,
|
|
187
|
+
]}
|
|
141
188
|
>
|
|
189
|
+
{liquid && lensFilter !== "none" ? (
|
|
190
|
+
<View
|
|
191
|
+
pointerEvents="none"
|
|
192
|
+
aria-hidden
|
|
193
|
+
style={[
|
|
194
|
+
StyleSheet.absoluteFill,
|
|
195
|
+
shape,
|
|
196
|
+
{ backdropFilter: lensFilter, WebkitBackdropFilter: lensFilter, maskImage: mask, WebkitMaskImage: mask } as ViewStyle,
|
|
197
|
+
]}
|
|
198
|
+
/>
|
|
199
|
+
) : null}
|
|
142
200
|
{children}
|
|
143
201
|
</Animated.View>
|
|
144
202
|
)
|
package/src/internal/Overlay.tsx
CHANGED
|
@@ -269,6 +269,10 @@ export function Overlay({ open, onDismiss, scrim = "transparent", dismissible =
|
|
|
269
269
|
style={StyleSheet.absoluteFill}
|
|
270
270
|
onStartShouldSetResponder={dismissible && show ? yes : undefined}
|
|
271
271
|
onResponderRelease={dismissible && show ? onDismiss : undefined}
|
|
272
|
+
// A tap on the web is followed by the browser's own mouse events and click at its point, which land on what
|
|
273
|
+
// is under the overlay once it closes (a sheet's row that opens the same menu again): the scrim's touch
|
|
274
|
+
// ends without them
|
|
275
|
+
{...(Platform.OS === "web" ? { onTouchEnd: endTouch as never } : null)}
|
|
272
276
|
testID={testID ? `${testID}-scrim` : undefined}
|
|
273
277
|
/>
|
|
274
278
|
{children(progress, show, focus)}
|
|
@@ -279,6 +283,9 @@ export function Overlay({ open, onDismiss, scrim = "transparent", dismissible =
|
|
|
279
283
|
}
|
|
280
284
|
|
|
281
285
|
const ignore = () => {}
|
|
286
|
+
const endTouch = (event: { cancelable?: boolean; preventDefault?: () => void; nativeEvent?: { cancelable?: boolean } }) => {
|
|
287
|
+
if (event.cancelable !== false && event.nativeEvent?.cancelable !== false) event.preventDefault?.()
|
|
288
|
+
}
|
|
282
289
|
const yes = () => true
|
|
283
290
|
const NO_FOCUS: OverlayFocus = {}
|
|
284
291
|
|