glacia-native 0.4.0 → 0.5.1

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 (73) hide show
  1. package/lib/module/Bars.js +269 -0
  2. package/lib/module/Carousel.js +103 -0
  3. package/lib/module/Display.js +317 -0
  4. package/lib/module/Feedback.js +386 -0
  5. package/lib/module/Forms2.js +454 -0
  6. package/lib/module/Message.js +88 -0
  7. package/lib/module/Overlays.js +328 -0
  8. package/lib/module/Pickers.js +243 -0
  9. package/lib/module/SegmentedControl.js +5 -1
  10. package/lib/module/Slider.js +6 -1
  11. package/lib/module/Switch.js +4 -1
  12. package/lib/module/TabBar.js +5 -1
  13. package/lib/module/Text.js +37 -0
  14. package/lib/module/ai.js +8 -3
  15. package/lib/module/index.js +79 -1
  16. package/lib/module/internal/GlassContainer.js +54 -0
  17. package/lib/module/internal/GlassView.js +31 -7
  18. package/lib/module/internal/a11y.js +94 -0
  19. package/lib/module/internal/fallback.js +19 -8
  20. package/lib/module/internal/glass-routing.js +7 -0
  21. package/lib/module/internal/haptics.js +54 -0
  22. package/lib/module/internal/motion.js +10 -1
  23. package/lib/module/internal/primitives.js +73 -3
  24. package/lib/module/internal/tokens.js +101 -1
  25. package/lib/typescript/Bars.d.ts +188 -0
  26. package/lib/typescript/Carousel.d.ts +47 -0
  27. package/lib/typescript/Display.d.ts +178 -0
  28. package/lib/typescript/Feedback.d.ts +196 -0
  29. package/lib/typescript/Forms2.d.ts +209 -0
  30. package/lib/typescript/Glass.d.ts +1 -1
  31. package/lib/typescript/Message.d.ts +71 -0
  32. package/lib/typescript/Overlays.d.ts +146 -0
  33. package/lib/typescript/Pickers.d.ts +105 -0
  34. package/lib/typescript/SegmentedControl.d.ts +2 -0
  35. package/lib/typescript/Slider.d.ts +2 -0
  36. package/lib/typescript/Switch.d.ts +2 -0
  37. package/lib/typescript/TabBar.d.ts +2 -0
  38. package/lib/typescript/Text.d.ts +28 -0
  39. package/lib/typescript/index.d.ts +11 -1
  40. package/lib/typescript/internal/GlassContainer.d.ts +37 -0
  41. package/lib/typescript/internal/GlassView.d.ts +18 -1
  42. package/lib/typescript/internal/a11y.d.ts +19 -0
  43. package/lib/typescript/internal/fallback.d.ts +5 -0
  44. package/lib/typescript/internal/glass-routing.d.ts +10 -0
  45. package/lib/typescript/internal/haptics.d.ts +7 -0
  46. package/lib/typescript/internal/motion.d.ts +4 -0
  47. package/lib/typescript/internal/primitives.d.ts +21 -0
  48. package/lib/typescript/internal/tokens.d.ts +114 -0
  49. package/package.json +2 -2
  50. package/src/Bars.tsx +797 -0
  51. package/src/Carousel.tsx +233 -0
  52. package/src/Display.tsx +778 -0
  53. package/src/Feedback.tsx +969 -0
  54. package/src/Forms2.tsx +1014 -0
  55. package/src/Message.tsx +219 -0
  56. package/src/Overlays.tsx +685 -0
  57. package/src/Pickers.tsx +590 -0
  58. package/src/SegmentedControl.tsx +6 -0
  59. package/src/Slider.tsx +7 -0
  60. package/src/Switch.tsx +5 -0
  61. package/src/TabBar.tsx +6 -0
  62. package/src/Text.tsx +83 -0
  63. package/src/ai.tsx +9 -3
  64. package/src/index.ts +142 -1
  65. package/src/internal/GlassContainer.tsx +82 -0
  66. package/src/internal/GlassView.tsx +37 -7
  67. package/src/internal/a11y.ts +105 -0
  68. package/src/internal/fallback.tsx +19 -2
  69. package/src/internal/glass-routing.ts +17 -0
  70. package/src/internal/haptics.ts +59 -0
  71. package/src/internal/motion.ts +10 -1
  72. package/src/internal/primitives.ts +84 -3
  73. package/src/internal/tokens.ts +110 -0
package/src/TabBar.tsx CHANGED
@@ -5,6 +5,7 @@ import { Glass } from "./Glass";
5
5
  import { colors, radii } from "./internal/tokens";
6
6
  import { primitives } from "./internal/primitives";
7
7
  import { useIsDark, useSpring } from "./internal/motion";
8
+ import { hapticSelection } from "./internal/haptics";
8
9
 
9
10
  export interface TabBarItem {
10
11
  id: string;
@@ -17,6 +18,8 @@ export interface TabBarProps {
17
18
  activeId?: string;
18
19
  defaultActiveId?: string;
19
20
  onTabChange?: (id: string) => void;
21
+ /** One selection tick when the tab changes. `false` opts out. */
22
+ haptics?: boolean;
20
23
  style?: StyleProp<ViewStyle>;
21
24
  isDark?: boolean;
22
25
  /** Passed through to the bar so it is testable. */
@@ -40,6 +43,7 @@ export const TabBar = forwardRef<any, TabBarProps>(function TabBar(
40
43
  activeId: activeProp,
41
44
  defaultActiveId,
42
45
  onTabChange,
46
+ haptics = true,
43
47
  style,
44
48
  isDark: isDarkProp,
45
49
  testID,
@@ -62,6 +66,8 @@ export const TabBar = forwardRef<any, TabBarProps>(function TabBar(
62
66
  const { value: slide, animated } = useSpring(activeIndex, "snappy");
63
67
 
64
68
  const handleSelect = (id: string) => {
69
+ // Selecting the tab already active is not a change, so it does not tick.
70
+ if (haptics && id !== activeId) hapticSelection();
65
71
  if (activeProp === undefined) setInternalId(id);
66
72
  onTabChange?.(id);
67
73
  };
package/src/Text.tsx ADDED
@@ -0,0 +1,83 @@
1
+ import { forwardRef, type ReactNode } from "react";
2
+ import type { StyleProp, TextStyle } from "react-native";
3
+
4
+ import { colors, typeScale } from "./internal/tokens";
5
+ import { primitives } from "./internal/primitives";
6
+ import { useIsDark } from "./internal/motion";
7
+
8
+ export type TextVariant = "title" | "heading" | "body" | "caption" | "label";
9
+
10
+ export interface TextProps {
11
+ /**
12
+ * The type step. The names come from the package's type scale, so a title in
13
+ * one app reads the same as a title in another.
14
+ */
15
+ variant?: TextVariant;
16
+ /** Secondary text: descriptions, hints, timestamps. */
17
+ muted?: boolean;
18
+ /** Renders the text in the destructive tone (errors, danger). */
19
+ destructive?: boolean;
20
+ /** Number of lines before truncating. */
21
+ numberOfLines?: number;
22
+ children?: ReactNode;
23
+ style?: StyleProp<TextStyle>;
24
+ isDark?: boolean;
25
+ testID?: string;
26
+ }
27
+
28
+ /** The accessibility role each variant announces. */
29
+ const roles: Record<TextVariant, "heading" | "text"> = {
30
+ title: "heading",
31
+ heading: "heading",
32
+ body: "text",
33
+ caption: "text",
34
+ label: "text",
35
+ };
36
+
37
+ /**
38
+ * Themed text.
39
+ *
40
+ * Every Glacia component that renders words uses this, so type, colour and
41
+ * contrast come from one place. It wraps the resolver's `Text`, which is React
42
+ * Native's own on a device.
43
+ */
44
+ export const Text = forwardRef<any, TextProps>(function Text(
45
+ {
46
+ variant = "body",
47
+ muted = false,
48
+ destructive = false,
49
+ numberOfLines,
50
+ children,
51
+ style,
52
+ isDark: isDarkProp,
53
+ testID,
54
+ ...props
55
+ },
56
+ ref,
57
+ ) {
58
+ const isDark = useIsDark(isDarkProp);
59
+ const theme = isDark ? colors.dark : colors.light;
60
+ const { Text: RNText } = primitives();
61
+ const scale = typeScale[variant];
62
+
63
+ const textStyle: TextStyle = {
64
+ fontSize: scale.fontSize,
65
+ lineHeight: scale.lineHeight,
66
+ fontWeight: scale.fontWeight,
67
+ color: destructive ? theme.destructive : muted ? theme.muted : theme.foreground,
68
+ ...(style as TextStyle),
69
+ };
70
+
71
+ return (
72
+ <RNText
73
+ ref={ref}
74
+ testID={testID}
75
+ accessibilityRole={roles[variant]}
76
+ numberOfLines={numberOfLines}
77
+ style={textStyle}
78
+ {...props}
79
+ >
80
+ {children}
81
+ </RNText>
82
+ );
83
+ });
package/src/ai.tsx CHANGED
@@ -4,6 +4,7 @@ import type { StyleProp, ViewStyle } from "react-native";
4
4
  import { colors, radii } from "./internal/tokens";
5
5
  import { primitives } from "./internal/primitives";
6
6
  import { useIsDark } from "./internal/motion";
7
+ import { useReducedMotion } from "./internal/a11y";
7
8
 
8
9
  export interface NativePlanStep {
9
10
  id: string;
@@ -390,15 +391,20 @@ export function NativeThinkingOrb({
390
391
  const isDark = useIsDark(isDarkProp);
391
392
  const theme = isDark ? colors.dark : colors.light;
392
393
  const { View, Text } = primitives();
394
+ const reducedMotion = useReducedMotion();
393
395
  const [tick, setTick] = useState(0);
394
396
 
397
+ // Reduce Motion: the orb stops pulsing and holds a steady size. The label is
398
+ // what carries the meaning, so nothing is lost by not moving.
399
+ const still = paused || reducedMotion;
400
+
395
401
  useEffect(() => {
396
- if (paused) return;
402
+ if (still) return;
397
403
  const timer = setInterval(() => setTick((value) => value + 1), 700);
398
404
  return () => clearInterval(timer);
399
- }, [paused]);
405
+ }, [still]);
400
406
 
401
- const scale = paused ? 1 : [1, 1.12, 1][tick % 3]!;
407
+ const scale = still ? 1 : [1, 1.12, 1][tick % 3]!;
402
408
 
403
409
  return (
404
410
  <View
package/src/index.ts CHANGED
@@ -86,5 +86,146 @@ export {
86
86
  } from "./Table";
87
87
  // Charts, drawn with react-native-svg using the same maths as the web package.
88
88
  export * from "./charts";
89
+ // Basics.
90
+ export { Text, type TextProps, type TextVariant } from "./Text";
91
+ export {
92
+ Avatar,
93
+ Badge,
94
+ Separator,
95
+ Skeleton,
96
+ Spinner,
97
+ Progress,
98
+ initialsOf,
99
+ type AvatarProps,
100
+ type AvatarSize,
101
+ type BadgeProps,
102
+ type SeparatorProps,
103
+ type SkeletonProps,
104
+ type SpinnerProps,
105
+ type SpinnerSize,
106
+ type ProgressProps,
107
+ type ProgressVariant,
108
+ Rating,
109
+ type RatingProps,
110
+ NativeImage,
111
+ type NativeImageProps,
112
+ } from "./Display";
113
+ // Feedback and display.
114
+ export {
115
+ Toast,
116
+ Banner,
117
+ List,
118
+ ListItem,
119
+ ListSection,
120
+ Accordion,
121
+ ToastViewport,
122
+ type ToastProps,
123
+ type ToastAction,
124
+ type ToastItem,
125
+ type ToastViewportProps,
126
+ type BannerProps,
127
+ type ListProps,
128
+ type ListItemProps,
129
+ type ListSwipeAction,
130
+ type ListSectionProps,
131
+ type AccordionProps,
132
+ type AccordionSection,
133
+ } from "./Feedback";
134
+ // Bars, buttons and navigation.
135
+ export {
136
+ SearchBar,
137
+ Chip,
138
+ FAB,
139
+ IconButton,
140
+ AppBar,
141
+ type SearchBarProps,
142
+ type ChipProps,
143
+ type FABProps,
144
+ type IconButtonProps,
145
+ type AppBarProps,
146
+ type AppBarAction,
147
+ FABGroup,
148
+ type FABGroupProps,
149
+ type FABGroupAction,
150
+ } from "./Bars";
151
+ // Overlays.
152
+ export {
153
+ Menu,
154
+ Sheet,
155
+ Drawer,
156
+ anchorPopover,
157
+ resolveSnapPoint,
158
+ nearestSnapPoint,
159
+ type MenuProps,
160
+ type MenuItem,
161
+ type SheetProps,
162
+ type DrawerProps,
163
+ } from "./Overlays";
164
+ // Carousel.
165
+ export {
166
+ Carousel,
167
+ PageControl,
168
+ type CarouselProps,
169
+ type PageControlProps,
170
+ } from "./Carousel";
171
+ // Forms and pickers.
172
+ export {
173
+ Stepper,
174
+ Toggle,
175
+ ToggleGroup,
176
+ InputOTP,
177
+ ButtonGroup,
178
+ type StepperProps,
179
+ type ToggleProps,
180
+ type ToggleGroupProps,
181
+ type ToggleGroupItem,
182
+ type InputOTPProps,
183
+ type ButtonGroupProps,
184
+ type ButtonGroupItem,
185
+ ColorPicker,
186
+ DEFAULT_PALETTE,
187
+ hexToRgb,
188
+ rgbToHex,
189
+ hueGradientColors,
190
+ type ColorPickerProps,
191
+ Combobox,
192
+ type ComboboxProps,
193
+ type ComboboxOption,
194
+ } from "./Forms2";
195
+ export {
196
+ Calendar,
197
+ DatePicker,
198
+ TimePicker,
199
+ monthGrid,
200
+ startOfDay,
201
+ sameDay,
202
+ parseTime,
203
+ formatTime,
204
+ WEEKDAYS,
205
+ MONTHS,
206
+ type CalendarProps,
207
+ type CalendarCell,
208
+ type DatePickerProps,
209
+ type TimePickerProps,
210
+ } from "./Pickers";
211
+ // Chat. Bubbles are flat tints; the composer (NativeAIInput) is the glass.
212
+ export {
213
+ Message,
214
+ MessageBubble,
215
+ MessageAttachment,
216
+ type MessageProps,
217
+ type MessageBubbleProps,
218
+ type MessageAttachmentProps,
219
+ } from "./Message";
89
220
  export { isGlassSupported } from "./internal/GlassView";
90
- export { colors, radii, springs } from "./internal/tokens";
221
+ export { GlassContainer, type NativeGlassContainerProps } from "./internal/GlassContainer";
222
+ export {
223
+ colors,
224
+ controlSizes,
225
+ palette,
226
+ radii,
227
+ springs,
228
+ typeScale,
229
+ toneColor,
230
+ type Tone,
231
+ } 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
+ );
@@ -18,21 +18,50 @@ export interface NativeGlassProps {
18
18
  * colour scheme decides, so developers never thread this prop themselves.
19
19
  */
20
20
  isDark?: boolean;
21
+ /**
22
+ * Any further React Native view prop (accessibility, onLayout, pointer
23
+ * events, …) is passed straight through to whichever surface renders, so a
24
+ * component can put its own accessibility contract on the glass itself.
25
+ */
26
+ [prop: string]: any;
21
27
  }
22
28
 
23
29
  /**
24
- * The installed `@callstack/liquid-glass` module, resolved once at load.
25
- * `isLiquidGlassSupported` is true only on iOS 26+; false on older iOS,
26
- * Android and Expo Go.
30
+ * The installed `@callstack/liquid-glass` module's routing decision.
31
+ *
32
+ * Resolved lazily and memoised on first use, rather than at module load, so the
33
+ * decision is taken when a surface first renders. On a device that is the same
34
+ * answer either way — `isLiquidGlassSupported` is a constant of the installed
35
+ * build — but it keeps the choice a property of the module rather than of
36
+ * import order, which is what makes both branches reachable in tests.
27
37
  */
28
- const router = defaultRouter();
38
+ let cachedRouter: ReturnType<typeof defaultRouter> | null = null;
39
+
40
+ function router(): ReturnType<typeof defaultRouter> {
41
+ if (cachedRouter === null) cachedRouter = defaultRouter();
42
+ return cachedRouter;
43
+ }
44
+
45
+ /** Clears the memoised decision. Only tests call this, to drive both branches. */
46
+ export function resetGlassRouter() {
47
+ cachedRouter = null;
48
+ }
29
49
 
30
- export const isGlassSupported = router.supported;
50
+ /** Whether this build renders Apple's glass. */
51
+ export const isGlassSupported = defaultRouter().supported;
31
52
 
32
53
  /**
33
54
  * Platform Glass View — the single place a glass surface is chosen:
34
55
  * - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
35
56
  * - iOS < 26 / Android / Expo Go: translucent tint View with identical layout
57
+ *
58
+ * Reduce Transparency is honoured on the fallback branch only: there the
59
+ * translucent tint is replaced by the theme's solid glass colour, with the same
60
+ * radius and the same hairline border, because a translucent surface is what
61
+ * the user asked the system to remove. On iOS 26 the system applies its own
62
+ * treatment to `UIGlassEffect` and this component does not second-guess it —
63
+ * overriding Apple's accessibility treatment would be worse than deferring to
64
+ * it, so the real glass is left exactly as the system renders it.
36
65
  */
37
66
  export const GlassView = forwardRef<any, NativeGlassProps>(function GlassView(
38
67
  {
@@ -48,8 +77,9 @@ export const GlassView = forwardRef<any, NativeGlassProps>(function GlassView(
48
77
  ref,
49
78
  ) {
50
79
  const isDark = useIsDark(isDarkProp);
51
- if (router.supported && router.LiquidGlassView) {
52
- const LiquidGlassView = router.LiquidGlassView;
80
+ const decision = router();
81
+ if (decision.supported && decision.LiquidGlassView) {
82
+ const LiquidGlassView = decision.LiquidGlassView;
53
83
  return (
54
84
  <LiquidGlassView
55
85
  ref={ref}
@@ -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
+ }
@@ -3,6 +3,7 @@ import type { StyleProp, ViewStyle } from "react-native";
3
3
 
4
4
  import { colors, radii } from "./tokens";
5
5
  import { primitives } from "./primitives";
6
+ import { useReducedTransparency } from "./a11y";
6
7
 
7
8
  export interface FallbackGlassProps {
8
9
  effect?: "clear" | "regular" | "none";
@@ -11,6 +12,11 @@ export interface FallbackGlassProps {
11
12
  style?: StyleProp<ViewStyle>;
12
13
  children?: ReactNode;
13
14
  isDark?: boolean;
15
+ /**
16
+ * Force the solid treatment. Normally read from the system's Reduce
17
+ * Transparency preference; this exists so a test can pin it.
18
+ */
19
+ reducedTransparency?: boolean;
14
20
  }
15
21
 
16
22
  /**
@@ -28,6 +34,7 @@ export const FallbackGlassView = forwardRef<any, FallbackGlassProps>(function Fa
28
34
  style,
29
35
  children,
30
36
  isDark = false,
37
+ reducedTransparency,
31
38
  ...props
32
39
  },
33
40
  ref,
@@ -35,8 +42,18 @@ export const FallbackGlassView = forwardRef<any, FallbackGlassProps>(function Fa
35
42
  const themeColors = isDark ? colors.dark : colors.light;
36
43
  const { View } = primitives();
37
44
 
38
- const bg =
39
- effect === "none"
45
+ // Reduce Transparency means the translucent material is replaced by a solid
46
+ // colour — the point of the preference is to remove see-through surfaces.
47
+ const systemReduced = useReducedTransparency();
48
+ const solid = reducedTransparency ?? systemReduced;
49
+
50
+ const bg = solid
51
+ ? effect === "none"
52
+ ? "transparent"
53
+ : tintColor && effect === "clear"
54
+ ? tintColor
55
+ : themeColors.glassSolid
56
+ : effect === "none"
40
57
  ? "transparent"
41
58
  : effect === "clear"
42
59
  ? isDark
@@ -16,6 +16,11 @@ declare const require: any;
16
16
 
17
17
  export interface LiquidGlassModule {
18
18
  LiquidGlassView?: any;
19
+ /**
20
+ * The container that merges nearby glass elements into one connected
21
+ * surface. Exported by `@callstack/liquid-glass` alongside the view.
22
+ */
23
+ LiquidGlassContainerView?: any;
19
24
  isLiquidGlassSupported?: boolean;
20
25
  }
21
26
 
@@ -25,6 +30,11 @@ export interface GlassRouter {
25
30
  supported: boolean;
26
31
  /** Apple's `LiquidGlassView`, or null when the fallback renders instead. */
27
32
  LiquidGlassView: any;
33
+ /**
34
+ * Apple's `LiquidGlassContainerView` — the surface that merges neighbouring
35
+ * glass — or null when the fallback wrapper renders instead.
36
+ */
37
+ LiquidGlassContainerView: any;
28
38
  }
29
39
 
30
40
  /**
@@ -35,9 +45,16 @@ export interface GlassRouter {
35
45
  */
36
46
  export function routerFor(module: LiquidGlassModule | null | undefined): GlassRouter {
37
47
  const view = module?.LiquidGlassView ?? null;
48
+ const container = module?.LiquidGlassContainerView ?? null;
38
49
  return {
50
+ // A module that reports support but lacks the container still renders real
51
+ // glass; the container is only needed by GlassContainer, which falls back
52
+ // when it is missing.
39
53
  supported: Boolean(module?.isLiquidGlassSupported) && Boolean(view),
40
54
  LiquidGlassView: view,
55
+ // The container merges only when the material itself is available; a
56
+ // container without the view would have nothing to merge.
57
+ LiquidGlassContainerView: container,
41
58
  };
42
59
  }
43
60