glacia-native 0.5.0 → 0.5.2

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.
Files changed (100) hide show
  1. package/LICENSE +29 -4
  2. package/README.md +27 -0
  3. package/lib/module/Bars.js +103 -9
  4. package/lib/module/Button.js +11 -8
  5. package/lib/module/Card.js +2 -2
  6. package/lib/module/Dialog.js +16 -17
  7. package/lib/module/Display.js +86 -8
  8. package/lib/module/Feedback.js +244 -21
  9. package/lib/module/Form.js +29 -33
  10. package/lib/module/Forms2.js +257 -13
  11. package/lib/module/Glass.js +2 -2
  12. package/lib/module/Input.js +12 -10
  13. package/lib/module/Message.js +84 -0
  14. package/lib/module/Overlays.js +195 -17
  15. package/lib/module/Pickers.js +16 -16
  16. package/lib/module/SegmentedControl.js +24 -11
  17. package/lib/module/Slider.js +24 -10
  18. package/lib/module/Switch.js +25 -10
  19. package/lib/module/TabBar.js +23 -13
  20. package/lib/module/Table.js +4 -3
  21. package/lib/module/Tabs.js +3 -2
  22. package/lib/module/ai.js +26 -18
  23. package/lib/module/charts/BarChart.js +11 -3
  24. package/lib/module/index.js +23 -2
  25. package/lib/module/internal/GlassContainer.js +54 -0
  26. package/lib/module/internal/GlassView.js +10 -2
  27. package/lib/module/internal/a11y.js +94 -0
  28. package/lib/module/internal/blur.js +78 -0
  29. package/lib/module/internal/fallback.js +120 -19
  30. package/lib/module/internal/glass-routing.js +7 -0
  31. package/lib/module/internal/glow.js +36 -0
  32. package/lib/module/internal/haptics.js +54 -0
  33. package/lib/module/internal/lens.js +70 -0
  34. package/lib/module/internal/material.js +64 -0
  35. package/lib/module/internal/motion.js +10 -1
  36. package/lib/module/internal/primitives.js +70 -4
  37. package/lib/module/internal/rim.js +35 -0
  38. package/lib/module/internal/tokens.js +80 -2
  39. package/lib/typescript/Bars.d.ts +67 -0
  40. package/lib/typescript/Display.d.ts +59 -0
  41. package/lib/typescript/Feedback.d.ts +58 -0
  42. package/lib/typescript/Forms2.d.ts +81 -0
  43. package/lib/typescript/Message.d.ts +67 -0
  44. package/lib/typescript/Overlays.d.ts +41 -0
  45. package/lib/typescript/SegmentedControl.d.ts +2 -0
  46. package/lib/typescript/Slider.d.ts +2 -0
  47. package/lib/typescript/Switch.d.ts +2 -0
  48. package/lib/typescript/TabBar.d.ts +2 -0
  49. package/lib/typescript/index.d.ts +9 -6
  50. package/lib/typescript/internal/GlassContainer.d.ts +37 -0
  51. package/lib/typescript/internal/GlassView.d.ts +21 -0
  52. package/lib/typescript/internal/a11y.d.ts +19 -0
  53. package/lib/typescript/internal/blur.d.ts +24 -0
  54. package/lib/typescript/internal/fallback.d.ts +32 -2
  55. package/lib/typescript/internal/glass-routing.d.ts +10 -0
  56. package/lib/typescript/internal/glow.d.ts +11 -0
  57. package/lib/typescript/internal/haptics.d.ts +7 -0
  58. package/lib/typescript/internal/lens.d.ts +47 -0
  59. package/lib/typescript/internal/material.d.ts +27 -0
  60. package/lib/typescript/internal/motion.d.ts +4 -0
  61. package/lib/typescript/internal/primitives.d.ts +23 -0
  62. package/lib/typescript/internal/rim.d.ts +16 -0
  63. package/lib/typescript/internal/tokens.d.ts +89 -0
  64. package/package.json +12 -3
  65. package/src/Bars.tsx +239 -2
  66. package/src/Button.tsx +16 -9
  67. package/src/Card.tsx +2 -2
  68. package/src/Dialog.tsx +37 -26
  69. package/src/Display.tsx +237 -6
  70. package/src/Feedback.tsx +448 -35
  71. package/src/Form.tsx +60 -40
  72. package/src/Forms2.tsx +455 -8
  73. package/src/Glass.tsx +4 -0
  74. package/src/Input.tsx +15 -11
  75. package/src/Message.tsx +218 -0
  76. package/src/Overlays.tsx +269 -39
  77. package/src/Pickers.tsx +11 -6
  78. package/src/SegmentedControl.tsx +39 -9
  79. package/src/Slider.tsx +26 -10
  80. package/src/Switch.tsx +29 -10
  81. package/src/TabBar.tsx +39 -12
  82. package/src/Table.tsx +4 -3
  83. package/src/Tabs.tsx +5 -0
  84. package/src/ai.tsx +37 -23
  85. package/src/charts/BarChart.tsx +41 -3
  86. package/src/index.ts +43 -1
  87. package/src/internal/GlassContainer.tsx +82 -0
  88. package/src/internal/GlassView.tsx +25 -0
  89. package/src/internal/a11y.ts +105 -0
  90. package/src/internal/blur.ts +90 -0
  91. package/src/internal/fallback.tsx +170 -15
  92. package/src/internal/glass-routing.ts +17 -0
  93. package/src/internal/glow.tsx +62 -0
  94. package/src/internal/haptics.ts +59 -0
  95. package/src/internal/lens.tsx +105 -0
  96. package/src/internal/material.ts +92 -0
  97. package/src/internal/motion.ts +10 -1
  98. package/src/internal/primitives.ts +83 -4
  99. package/src/internal/rim.tsx +79 -0
  100. package/src/internal/tokens.ts +82 -1
package/src/ai.tsx CHANGED
@@ -1,9 +1,12 @@
1
1
  import { useEffect, useState, type ReactNode } from "react";
2
2
  import type { StyleProp, ViewStyle } from "react-native";
3
3
 
4
+ import { Glass } from "./Glass";
4
5
  import { colors, radii } from "./internal/tokens";
5
6
  import { primitives } from "./internal/primitives";
6
7
  import { useIsDark } from "./internal/motion";
8
+ import { SelectedLens, lensFill } from "./internal/lens";
9
+ import { useReducedMotion } from "./internal/a11y";
7
10
 
8
11
  export interface NativePlanStep {
9
12
  id: string;
@@ -41,7 +44,7 @@ export function NativePlan({ title = "Plan", steps, isDark: isDarkProp, style }:
41
44
  : theme.muted;
42
45
 
43
46
  return (
44
- <View style={style}>
47
+ <Glass surface="panel" isDark={isDark} style={[{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: radii.lg }, style]}>
45
48
  <View
46
49
  style={{
47
50
  flexDirection: "row",
@@ -98,7 +101,7 @@ export function NativePlan({ title = "Plan", steps, isDark: isDarkProp, style }:
98
101
  </View>
99
102
  </View>
100
103
  ))}
101
- </View>
104
+ </Glass>
102
105
  );
103
106
  }
104
107
 
@@ -138,7 +141,7 @@ export function NativeSources({
138
141
  if (sources.length === 0) return null;
139
142
 
140
143
  return (
141
- <View style={style}>
144
+ <Glass surface="panel" isDark={isDark} style={[{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: radii.lg }, style]}>
142
145
  <Text style={{ fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }}>
143
146
  {title}
144
147
  </Text>
@@ -178,7 +181,7 @@ export function NativeSources({
178
181
  </View>
179
182
  </Pressable>
180
183
  ))}
181
- </View>
184
+ </Glass>
182
185
  );
183
186
  }
184
187
 
@@ -212,7 +215,7 @@ export function NativeResponse({
212
215
  const isStreaming = streaming ?? (revealed != null && revealed < text.length);
213
216
 
214
217
  return (
215
- <View style={style}>
218
+ <Glass surface="panel" isDark={isDark} style={[{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: radii.lg }, style]}>
216
219
  <Text
217
220
  accessibilityRole="text"
218
221
  accessibilityLabel={shown}
@@ -225,7 +228,7 @@ export function NativeResponse({
225
228
  <Text accessibilityRole="alert" style={{ height: 0, opacity: 0, fontSize: 0 }}>
226
229
  {isStreaming ? "Response streaming" : "Response complete"}
227
230
  </Text>
228
- </View>
231
+ </Glass>
229
232
  );
230
233
  }
231
234
 
@@ -254,7 +257,9 @@ export function NativeTask({ task, isDark: isDarkProp, style }: NativeTaskProps)
254
257
  status === "failed" ? theme.destructive : status === "done" ? "#34c759" : theme.fill;
255
258
 
256
259
  return (
257
- <View
260
+ <Glass
261
+ surface="panel"
262
+ isDark={isDark}
258
263
  accessibilityRole="progressbar"
259
264
  accessibilityLabel={task.label ?? "Task progress"}
260
265
  // Without the value, a screen reader only reads the label and never says
@@ -263,7 +268,7 @@ export function NativeTask({ task, isDark: isDarkProp, style }: NativeTaskProps)
263
268
  accessibilityState={{
264
269
  disabled: false,
265
270
  }}
266
- style={style as StyleProp<ViewStyle>}
271
+ style={[{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: radii.lg }, style as StyleProp<ViewStyle>]}
267
272
  >
268
273
  <View
269
274
  style={{ flexDirection: "row", justifyContent: "space-between", marginBottom: 6 }}
@@ -299,7 +304,7 @@ export function NativeTask({ task, isDark: isDarkProp, style }: NativeTaskProps)
299
304
  {task.detail && (
300
305
  <Text style={{ fontSize: 11, color: theme.muted, marginTop: 6 }}>{task.detail}</Text>
301
306
  )}
302
- </View>
307
+ </Glass>
303
308
  );
304
309
  }
305
310
 
@@ -390,15 +395,20 @@ export function NativeThinkingOrb({
390
395
  const isDark = useIsDark(isDarkProp);
391
396
  const theme = isDark ? colors.dark : colors.light;
392
397
  const { View, Text } = primitives();
398
+ const reducedMotion = useReducedMotion();
393
399
  const [tick, setTick] = useState(0);
394
400
 
401
+ // Reduce Motion: the orb stops pulsing and holds a steady size. The label is
402
+ // what carries the meaning, so nothing is lost by not moving.
403
+ const still = paused || reducedMotion;
404
+
395
405
  useEffect(() => {
396
- if (paused) return;
406
+ if (still) return;
397
407
  const timer = setInterval(() => setTick((value) => value + 1), 700);
398
408
  return () => clearInterval(timer);
399
- }, [paused]);
409
+ }, [still]);
400
410
 
401
- const scale = paused ? 1 : [1, 1.12, 1][tick % 3]!;
411
+ const scale = still ? 1 : [1, 1.12, 1][tick % 3]!;
402
412
 
403
413
  return (
404
414
  <View
@@ -455,7 +465,7 @@ export function NativePanelside({
455
465
  const { View, Text, Pressable } = primitives();
456
466
 
457
467
  return (
458
- <View style={style}>
468
+ <Glass surface="panel" isDark={isDark} style={[{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: radii.lg }, style]}>
459
469
  {title && (
460
470
  <Text style={{ fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }}>
461
471
  {title}
@@ -478,10 +488,11 @@ export function NativePanelside({
478
488
  paddingVertical: 9,
479
489
  paddingHorizontal: 11,
480
490
  borderRadius: radii.md,
481
- backgroundColor: isActive ? theme.glassActive : "transparent",
491
+ backgroundColor: "transparent",
482
492
  marginBottom: 2,
483
493
  }}
484
494
  >
495
+ {isActive ? <SelectedLens radius={radii.md} isDark={isDark} style={lensFill} /> : null}
485
496
  <Text
486
497
  style={{
487
498
  fontSize: 13,
@@ -497,7 +508,7 @@ export function NativePanelside({
497
508
  </Pressable>
498
509
  );
499
510
  })}
500
- </View>
511
+ </Glass>
501
512
  );
502
513
  }
503
514
 
@@ -557,16 +568,17 @@ export function NativeAIInput({
557
568
 
558
569
  return (
559
570
  <View style={style as StyleProp<ViewStyle>}>
560
- <View
571
+ <Glass
572
+ surface="field"
573
+ isDark={isDark}
561
574
  style={{
562
575
  flexDirection: "row",
563
576
  alignItems: "flex-end",
564
577
  gap: 8,
565
- padding: 8,
566
- borderRadius: radii.lg,
567
- borderWidth: 1,
568
- borderColor: theme.edge,
569
- backgroundColor: theme.glass,
578
+ paddingVertical: 6,
579
+ paddingRight: 6,
580
+ paddingLeft: 16,
581
+ borderRadius: radii.pill,
570
582
  opacity: disabled ? 0.5 : 1,
571
583
  }}
572
584
  >
@@ -612,8 +624,10 @@ export function NativeAIInput({
612
624
  disabled={!canSend}
613
625
  onPress={() => canSend && onSubmit?.()}
614
626
  style={{
615
- paddingVertical: 8,
627
+ height: 34,
616
628
  paddingHorizontal: 14,
629
+ alignItems: "center",
630
+ justifyContent: "center",
617
631
  borderRadius: radii.pill,
618
632
  backgroundColor: canSend ? theme.fill : theme.edge,
619
633
  }}
@@ -622,7 +636,7 @@ export function NativeAIInput({
622
636
  {busy ? "…" : sendLabel}
623
637
  </Text>
624
638
  </Pressable>
625
- </View>
639
+ </Glass>
626
640
 
627
641
  {footer}
628
642
  </View>
@@ -1,4 +1,4 @@
1
- import { useMemo, useState } from "react";
1
+ import { useId, useMemo, useState } from "react";
2
2
 
3
3
  import { colors } from "../internal/tokens";
4
4
  import { useIsDark } from "../internal/motion";
@@ -42,7 +42,19 @@ export function NativeBarChart({
42
42
  const [active, setActive] = useState<number | null>(null);
43
43
  const isDark = useIsDark(isDarkProp);
44
44
  const theme = isDark ? colors.dark : colors.light;
45
- const { View, Text, Pressable, Svg, G, Line, Rect, SvgText } = primitives();
45
+ const {
46
+ View,
47
+ Text,
48
+ Pressable,
49
+ Svg,
50
+ G,
51
+ Line,
52
+ Rect,
53
+ SvgText,
54
+ Defs,
55
+ LinearGradient,
56
+ Stop,
57
+ } = primitives();
46
58
 
47
59
  const plot = {
48
60
  x: PADDING.left,
@@ -64,6 +76,9 @@ export function NativeBarChart({
64
76
 
65
77
  const y = linearScale(domain, [bottom, plot.y], { nice: false });
66
78
  const bands = bandScale(labels.length, [plot.x, right], 0.32);
79
+ const seriesColors = series.map((s, si) => s.color ?? seriesColor(si, palette));
80
+ // One gradient per series, so the SVG can reference them by id.
81
+ const gradientKey = useId().replace(/[^a-zA-Z0-9_-]/g, "");
67
82
  const barWidth = stacked ? bands.width : bands.width / Math.max(1, series.length);
68
83
  const yTicks = ticks(domain, 4);
69
84
 
@@ -78,6 +93,25 @@ export function NativeBarChart({
78
93
  return (
79
94
  <View style={style}>
80
95
  <Svg width={width} height={height}>
96
+ <Defs>
97
+ {seriesColors.map((color, si) => (
98
+ // The web's bar fill runs from the series colour at the top to
99
+ // transparent at the base, so a bar reads as lit from above.
100
+ <LinearGradient
101
+ key={`grad-${si}`}
102
+ id={`bar-${gradientKey}-${si}`}
103
+ x1="0"
104
+ y1="0"
105
+ x2="0"
106
+ y2="1"
107
+ >
108
+ <Stop offset="0" stopColor={color} stopOpacity={1} />
109
+ <Stop offset="0.55" stopColor={color} stopOpacity={0.62} />
110
+ <Stop offset="1" stopColor={color} stopOpacity={0.04} />
111
+ </LinearGradient>
112
+ ))}
113
+ </Defs>
114
+
81
115
  {yTicks.map((tick, i) => (
82
116
  <Line
83
117
  key={`grid-${i}`}
@@ -117,7 +151,11 @@ export function NativeBarChart({
117
151
  width={w}
118
152
  height={barHeight}
119
153
  rx={Math.min(radius, w / 2)}
120
- fill={color}
154
+ fill={`url(#bar-${gradientKey}-${si})`}
155
+ // The inset edge the web draws inside every bar.
156
+ stroke={color}
157
+ strokeOpacity={0.35}
158
+ strokeWidth={0.5}
121
159
  opacity={active === null || active === i ? 1 : 0.45}
122
160
  />
123
161
  );
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Glass, type GlassProps } from "./Glass";
2
+ export type { SurfaceProfile } from "./internal/material";
2
3
  export { Button, type ButtonProps } from "./Button";
3
4
  export { Switch, type SwitchProps } from "./Switch";
4
5
  export { Slider, type SliderProps } from "./Slider";
@@ -105,6 +106,10 @@ export {
105
106
  type SpinnerSize,
106
107
  type ProgressProps,
107
108
  type ProgressVariant,
109
+ Rating,
110
+ type RatingProps,
111
+ NativeImage,
112
+ type NativeImageProps,
108
113
  } from "./Display";
109
114
  // Feedback and display.
110
115
  export {
@@ -114,11 +119,15 @@ export {
114
119
  ListItem,
115
120
  ListSection,
116
121
  Accordion,
122
+ ToastViewport,
117
123
  type ToastProps,
118
124
  type ToastAction,
125
+ type ToastItem,
126
+ type ToastViewportProps,
119
127
  type BannerProps,
120
128
  type ListProps,
121
129
  type ListItemProps,
130
+ type ListSwipeAction,
122
131
  type ListSectionProps,
123
132
  type AccordionProps,
124
133
  type AccordionSection,
@@ -136,6 +145,9 @@ export {
136
145
  type IconButtonProps,
137
146
  type AppBarProps,
138
147
  type AppBarAction,
148
+ FABGroup,
149
+ type FABGroupProps,
150
+ type FABGroupAction,
139
151
  } from "./Bars";
140
152
  // Overlays.
141
153
  export {
@@ -143,6 +155,8 @@ export {
143
155
  Sheet,
144
156
  Drawer,
145
157
  anchorPopover,
158
+ resolveSnapPoint,
159
+ nearestSnapPoint,
146
160
  type MenuProps,
147
161
  type MenuItem,
148
162
  type SheetProps,
@@ -169,6 +183,15 @@ export {
169
183
  type InputOTPProps,
170
184
  type ButtonGroupProps,
171
185
  type ButtonGroupItem,
186
+ ColorPicker,
187
+ DEFAULT_PALETTE,
188
+ hexToRgb,
189
+ rgbToHex,
190
+ hueGradientColors,
191
+ type ColorPickerProps,
192
+ Combobox,
193
+ type ComboboxProps,
194
+ type ComboboxOption,
172
195
  } from "./Forms2";
173
196
  export {
174
197
  Calendar,
@@ -186,5 +209,24 @@ export {
186
209
  type DatePickerProps,
187
210
  type TimePickerProps,
188
211
  } from "./Pickers";
212
+ // Chat. Bubbles are flat tints; the composer (NativeAIInput) is the glass.
213
+ export {
214
+ Message,
215
+ MessageBubble,
216
+ MessageAttachment,
217
+ type MessageProps,
218
+ type MessageBubbleProps,
219
+ type MessageAttachmentProps,
220
+ } from "./Message";
189
221
  export { isGlassSupported } from "./internal/GlassView";
190
- export { colors, radii, springs, typeScale, toneColor, type Tone } from "./internal/tokens";
222
+ export { GlassContainer, type NativeGlassContainerProps } from "./internal/GlassContainer";
223
+ export {
224
+ colors,
225
+ controlSizes,
226
+ palette,
227
+ radii,
228
+ springs,
229
+ typeScale,
230
+ toneColor,
231
+ type Tone,
232
+ } from "./internal/tokens";
@@ -0,0 +1,82 @@
1
+ import { forwardRef, type ReactNode } from "react";
2
+ import type { StyleProp, ViewStyle } from "react-native";
3
+
4
+ import { defaultRouter } from "./glass-routing";
5
+ import { primitives } from "./primitives";
6
+ import { useIsDark } from "./motion";
7
+
8
+ export interface NativeGlassContainerProps {
9
+ /**
10
+ * How close two glass surfaces must be before iOS 26 blends them into one
11
+ * connected liquid surface, in points. 0 merges only what touches.
12
+ */
13
+ spacing?: number;
14
+ style?: StyleProp<ViewStyle>;
15
+ children?: ReactNode;
16
+ isDark?: boolean;
17
+ testID?: string;
18
+ [prop: string]: any;
19
+ }
20
+
21
+ /**
22
+ * The installed module's routing decision, memoised so a container and the
23
+ * surfaces inside it always agree about which branch is rendering.
24
+ */
25
+ let cachedRouter: ReturnType<typeof defaultRouter> | null = null;
26
+
27
+ function router(): ReturnType<typeof defaultRouter> {
28
+ if (cachedRouter === null) cachedRouter = defaultRouter();
29
+ return cachedRouter;
30
+ }
31
+
32
+ /** Clears the memoised decision. Only tests call this, to drive both branches. */
33
+ export function resetGlassContainerRouter() {
34
+ cachedRouter = null;
35
+ }
36
+
37
+ /**
38
+ * Groups glass surfaces so iOS 26 can merge them into one surface.
39
+ *
40
+ * On iOS 26, Apple's Liquid Glass is a connected material: two glass elements
41
+ * placed close enough run together into a single shape with one shared edge,
42
+ * rather than reading as two separate panes. `GlassContainer` is the component
43
+ * that opts into that — a bar and the floating button above it, or a pair of
44
+ * adjacent buttons, become one piece of glass.
45
+ *
46
+ * **Merging is an iOS 26+ visual effect and a no-op everywhere else.** On
47
+ * older iOS, Android, Expo Go and the web preview this renders a plain wrapper
48
+ * with identical layout: the children are the same components, drawn at the
49
+ * same positions, they simply keep their own separate edges. Nothing changes
50
+ * shape or shifts, so a container costs nothing on the platforms that cannot
51
+ * blend.
52
+ *
53
+ * Use it only around surfaces that should read as one; glass inside glass is
54
+ * still forbidden, so a container's children are `Glass` surfaces placed side
55
+ * by side, not a panel wrapping another panel.
56
+ */
57
+ export const GlassContainer = forwardRef<any, NativeGlassContainerProps>(
58
+ function GlassContainer(
59
+ { spacing = 0, style, children, isDark: isDarkProp, testID, ...props },
60
+ ref,
61
+ ) {
62
+ const isDark = useIsDark(isDarkProp);
63
+ const decision = router();
64
+ const { View } = primitives();
65
+
66
+ if (decision.supported && decision.LiquidGlassContainerView) {
67
+ const ContentContainer = decision.LiquidGlassContainerView;
68
+ return (
69
+ <ContentContainer ref={ref} spacing={spacing} testID={testID} style={style} {...props}>
70
+ {children}
71
+ </ContentContainer>
72
+ );
73
+ }
74
+
75
+ // Unsupported: a wrapper with the same layout, so nothing shifts.
76
+ return (
77
+ <View ref={ref} testID={testID} style={style} {...props}>
78
+ {children}
79
+ </View>
80
+ );
81
+ },
82
+ );
@@ -3,12 +3,25 @@ import type { StyleProp, ViewStyle } from "react-native";
3
3
 
4
4
  import { FallbackGlassView } from "./fallback";
5
5
  import { defaultRouter } from "./glass-routing";
6
+ import type { SurfaceProfile } from "./material";
6
7
  import { useIsDark } from "./motion";
7
8
 
8
9
  export interface NativeGlassProps {
9
10
  effect?: "clear" | "regular" | "none";
10
11
  tintColor?: string;
11
12
  interactive?: boolean;
13
+ /**
14
+ * Which web surface profile this is (panel, control, field, overlay, hint,
15
+ * rail). The fallback uses it to pick blur, rim brightness and highlight —
16
+ * read by the fallback branch only; Apple's material replaces the stack on
17
+ * iOS 26, so the prop is not forwarded there.
18
+ */
19
+ surface?: SurfaceProfile;
20
+ /**
21
+ * True while the surface is held, so the fallback can fade its specular glow
22
+ * in. Not forwarded to Apple's view, which draws its own press effect.
23
+ */
24
+ pressed?: boolean;
12
25
  /** Passed to whichever surface renders, so tests can find the glass itself. */
13
26
  testID?: string;
14
27
  style?: StyleProp<ViewStyle>;
@@ -54,12 +67,22 @@ export const isGlassSupported = defaultRouter().supported;
54
67
  * Platform Glass View — the single place a glass surface is chosen:
55
68
  * - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
56
69
  * - iOS < 26 / Android / Expo Go: translucent tint View with identical layout
70
+ *
71
+ * Reduce Transparency is honoured on the fallback branch only: there the
72
+ * translucent tint is replaced by the theme's solid glass colour, with the same
73
+ * radius and the same hairline border, because a translucent surface is what
74
+ * the user asked the system to remove. On iOS 26 the system applies its own
75
+ * treatment to `UIGlassEffect` and this component does not second-guess it —
76
+ * overriding Apple's accessibility treatment would be worse than deferring to
77
+ * it, so the real glass is left exactly as the system renders it.
57
78
  */
58
79
  export const GlassView = forwardRef<any, NativeGlassProps>(function GlassView(
59
80
  {
60
81
  effect = "regular",
61
82
  tintColor,
62
83
  interactive = false,
84
+ surface = "panel",
85
+ pressed,
63
86
  testID,
64
87
  style,
65
88
  children,
@@ -92,6 +115,8 @@ export const GlassView = forwardRef<any, NativeGlassProps>(function GlassView(
92
115
  ref={ref}
93
116
  effect={effect}
94
117
  tintColor={tintColor}
118
+ surface={surface}
119
+ pressed={pressed}
95
120
  testID={testID}
96
121
  isDark={isDark}
97
122
  style={style}
@@ -0,0 +1,105 @@
1
+ // Accessibility preferences, as the platform reports them.
2
+ //
3
+ // Apple's HIG makes two of these part of wearing Liquid Glass faithfully:
4
+ // - Reduce Transparency: glass is replaced by a solid colour, because a
5
+ // translucent surface is exactly what the user asked the system to remove.
6
+ // - Reduce Motion: animation jumps to its end state instead of playing.
7
+ //
8
+ // React Native exposes both through AccessibilityInfo, but it is resolved at
9
+ // runtime like every other primitive, so the package stays importable where
10
+ // React Native is absent (jsdom tests, web preview). Where the API is missing
11
+ // the hooks answer `false`: the preference is treated as off, which is the
12
+ // behaviour those environments already had.
13
+
14
+ import { useEffect, useState } from "react";
15
+
16
+ import { primitives } from "./primitives";
17
+
18
+ /** Reads a boolean preference once, guarding against a missing or throwing API. */
19
+ function readPreference(
20
+ info: any,
21
+ method: "isReduceTransparencyEnabled" | "isReduceMotionEnabled",
22
+ ): Promise<boolean> {
23
+ try {
24
+ const result = info?.[method]?.();
25
+ // React Native returns a promise; anything unexpected is treated as "off".
26
+ if (result && typeof result.then === "function") {
27
+ return result.then(
28
+ (value: unknown) => Boolean(value),
29
+ () => false,
30
+ );
31
+ }
32
+ return Promise.resolve(Boolean(result));
33
+ } catch {
34
+ return Promise.resolve(false);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Subscribes to one AccessibilityInfo preference and keeps it in state.
40
+ *
41
+ * The initial read is async, so the hook starts `false` and corrects itself
42
+ * when the platform answers. The subscription is removed on unmount; a
43
+ * listener that outlives the component would leak on every navigation.
44
+ */
45
+ function useAccessibilityPreference(
46
+ method: "isReduceTransparencyEnabled" | "isReduceMotionEnabled",
47
+ event: "reduceTransparencyChanged" | "reduceMotionChanged",
48
+ ): boolean {
49
+ const { AccessibilityInfo } = primitives();
50
+ const [enabled, setEnabled] = useState(false);
51
+
52
+ useEffect(() => {
53
+ if (!AccessibilityInfo) return;
54
+ let cancelled = false;
55
+
56
+ readPreference(AccessibilityInfo, method).then((value) => {
57
+ if (!cancelled) setEnabled(value);
58
+ });
59
+
60
+ let subscription: any = null;
61
+ try {
62
+ subscription = AccessibilityInfo.addEventListener?.(event, (next: boolean) => {
63
+ setEnabled(Boolean(next));
64
+ });
65
+ } catch {
66
+ // An environment without the event still gets the initial read.
67
+ }
68
+
69
+ return () => {
70
+ cancelled = true;
71
+ try {
72
+ subscription?.remove?.();
73
+ } catch {
74
+ // Nothing to clean up if subscribing failed.
75
+ }
76
+ };
77
+ }, [AccessibilityInfo, method, event]);
78
+
79
+ return enabled;
80
+ }
81
+
82
+ /**
83
+ * Whether the user has asked the system to reduce transparency.
84
+ *
85
+ * When true, a glass surface must render a solid colour rather than a
86
+ * translucent one. `GlassView` honours this on the fallback branch; on iOS 26
87
+ * the system applies its own treatment to `UIGlassEffect` and is not
88
+ * second-guessed here.
89
+ *
90
+ * The change event is iOS-only in React Native, so on Android the initial
91
+ * read is the answer.
92
+ */
93
+ export function useReducedTransparency(): boolean {
94
+ return useAccessibilityPreference("isReduceTransparencyEnabled", "reduceTransparencyChanged");
95
+ }
96
+
97
+ /**
98
+ * Whether the user has asked the system to reduce motion.
99
+ *
100
+ * Glacia's own animations settle at their end state instead of playing when
101
+ * this is true.
102
+ */
103
+ export function useReducedMotion(): boolean {
104
+ return useAccessibilityPreference("isReduceMotionEnabled", "reduceMotionChanged");
105
+ }
@@ -0,0 +1,90 @@
1
+ // Backdrop blur for the fallback material.
2
+ //
3
+ // React Native has no backdrop blur of its own. The fallback's biggest missing
4
+ // layer is exactly that: without it a surface is a translucent rectangle, not
5
+ // glass. Two community backends provide a real native blur view, and the
6
+ // package accepts either:
7
+ //
8
+ // - `expo-blur` (Expo apps; also works on web through backdrop-filter)
9
+ // - `@react-native-community/blur` (bare React Native)
10
+ //
11
+ // They are optional peer dependencies, resolved at runtime like every other
12
+ // native module in this package: a project that installs neither still gets a
13
+ // working (unblurred) fallback instead of a crash, and the jsdom test run never
14
+ // touches a native module.
15
+
16
+ declare const require: any;
17
+
18
+ export type BlurKind = "expo" | "community";
19
+
20
+ interface ResolvedBlur {
21
+ kind: BlurKind;
22
+ View: any;
23
+ }
24
+
25
+ let resolved: ResolvedBlur | null | undefined;
26
+
27
+ /**
28
+ * The installed blur backend, or null when neither is available.
29
+ *
30
+ * Memoised: the answer is a property of the installed modules, not of the
31
+ * render, so resolving once keeps every surface on the same backend.
32
+ */
33
+ export function resolveBlurView(): ResolvedBlur | null {
34
+ if (resolved !== undefined) return resolved;
35
+
36
+ try {
37
+ const expo = require("expo-blur");
38
+ if (expo?.BlurView) {
39
+ resolved = { kind: "expo", View: expo.BlurView };
40
+ return resolved;
41
+ }
42
+ } catch {
43
+ // Not installed: try the bare-React-Native backend below.
44
+ }
45
+
46
+ try {
47
+ const community = require("@react-native-community/blur");
48
+ if (community?.BlurView) {
49
+ resolved = { kind: "community", View: community.BlurView };
50
+ return resolved;
51
+ }
52
+ } catch {
53
+ // Neither backend is installed; the fallback renders tint, rim and shadow.
54
+ }
55
+
56
+ resolved = null;
57
+ return resolved;
58
+ }
59
+
60
+ /** Clears the memoised backend. Only tests call this. */
61
+ export function resetBlurResolver() {
62
+ resolved = undefined;
63
+ }
64
+
65
+ /**
66
+ * The props one backend needs to blur a surface.
67
+ *
68
+ * The two libraries name the same idea differently — expo-blur takes a 0–100
69
+ * intensity and a tint, community-blur a 0–100 amount and a blur type — so the
70
+ * mapping lives here rather than in the fallback's render. Android needs an
71
+ * explicit method on expo-blur; Dimezis is its own real-time backdrop blur.
72
+ */
73
+ export function blurProps(
74
+ kind: BlurKind,
75
+ intensity: number,
76
+ isDark: boolean,
77
+ ): Record<string, any> {
78
+ if (kind === "expo") {
79
+ return {
80
+ intensity,
81
+ tint: isDark ? "dark" : "light",
82
+ experimentalBlurMethod: "dimezisBlurView",
83
+ };
84
+ }
85
+ return {
86
+ // Community blur amounts are coarser; the tint carries most of the read.
87
+ blurAmount: Math.max(1, Math.round(intensity / 1.6)),
88
+ blurType: isDark ? "dark" : "light",
89
+ };
90
+ }