glacia-native 0.3.5 → 0.4.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.
Files changed (91) hide show
  1. package/lib/module/Button.js +15 -2
  2. package/lib/module/Card.js +29 -14
  3. package/lib/module/Dialog.js +43 -32
  4. package/lib/module/Form.js +51 -12
  5. package/lib/module/Glass.js +11 -2
  6. package/lib/module/Input.js +19 -7
  7. package/lib/module/SegmentedControl.js +65 -21
  8. package/lib/module/Slider.js +121 -25
  9. package/lib/module/Switch.js +33 -15
  10. package/lib/module/TabBar.js +63 -25
  11. package/lib/module/Table.js +24 -6
  12. package/lib/module/Tabs.js +55 -33
  13. package/lib/module/ai.js +49 -20
  14. package/lib/module/charts/BarChart.js +4 -2
  15. package/lib/module/charts/FunnelChart.js +4 -2
  16. package/lib/module/charts/HeatmapChart.js +4 -2
  17. package/lib/module/charts/LineChart.js +4 -2
  18. package/lib/module/charts/PlotChart.js +11 -3
  19. package/lib/module/charts/RadarChart.js +4 -2
  20. package/lib/module/charts/RingChart.js +4 -2
  21. package/lib/module/charts/ScatterChart.js +20 -3
  22. package/lib/module/charts/WaterfallChart.js +12 -3
  23. package/lib/module/charts/advanced.js +12 -6
  24. package/lib/module/charts/extra.js +6 -3
  25. package/lib/module/internal/GlassView.js +17 -19
  26. package/lib/module/internal/fallback.js +14 -3
  27. package/lib/module/internal/glass-routing.js +56 -0
  28. package/lib/module/internal/motion.js +55 -0
  29. package/lib/module/internal/primitives.js +408 -0
  30. package/lib/typescript/Button.d.ts +11 -1
  31. package/lib/typescript/Card.d.ts +20 -8
  32. package/lib/typescript/Dialog.d.ts +19 -6
  33. package/lib/typescript/Form.d.ts +27 -11
  34. package/lib/typescript/Glass.d.ts +9 -0
  35. package/lib/typescript/Input.d.ts +11 -1
  36. package/lib/typescript/SegmentedControl.d.ts +11 -1
  37. package/lib/typescript/Slider.d.ts +13 -1
  38. package/lib/typescript/Switch.d.ts +12 -1
  39. package/lib/typescript/TabBar.d.ts +13 -1
  40. package/lib/typescript/Table.d.ts +14 -5
  41. package/lib/typescript/Tabs.d.ts +8 -5
  42. package/lib/typescript/ai.d.ts +12 -9
  43. package/lib/typescript/charts/BarChart.d.ts +1 -1
  44. package/lib/typescript/charts/FunnelChart.d.ts +1 -1
  45. package/lib/typescript/charts/HeatmapChart.d.ts +1 -1
  46. package/lib/typescript/charts/LineChart.d.ts +1 -1
  47. package/lib/typescript/charts/PlotChart.d.ts +1 -1
  48. package/lib/typescript/charts/RadarChart.d.ts +1 -1
  49. package/lib/typescript/charts/RingChart.d.ts +1 -1
  50. package/lib/typescript/charts/ScatterChart.d.ts +1 -1
  51. package/lib/typescript/charts/WaterfallChart.d.ts +1 -1
  52. package/lib/typescript/charts/advanced.d.ts +5 -5
  53. package/lib/typescript/charts/extra.d.ts +2 -2
  54. package/lib/typescript/internal/GlassView.d.ts +11 -3
  55. package/lib/typescript/internal/fallback.d.ts +10 -1
  56. package/lib/typescript/internal/glass-routing.d.ts +30 -0
  57. package/lib/typescript/internal/motion.d.ts +19 -0
  58. package/lib/typescript/internal/primitives.d.ts +41 -0
  59. package/package.json +2 -2
  60. package/src/Button.tsx +47 -22
  61. package/src/Card.tsx +52 -31
  62. package/src/Dialog.tsx +99 -64
  63. package/src/Form.tsx +90 -25
  64. package/src/Glass.tsx +24 -1
  65. package/src/Input.tsx +33 -12
  66. package/src/SegmentedControl.tsx +104 -32
  67. package/src/Slider.tsx +151 -47
  68. package/src/Switch.tsx +56 -32
  69. package/src/TabBar.tsx +100 -30
  70. package/src/Table.tsx +38 -14
  71. package/src/Tabs.tsx +85 -32
  72. package/src/ai.tsx +77 -31
  73. package/src/charts/BarChart.tsx +4 -2
  74. package/src/charts/FunnelChart.tsx +4 -2
  75. package/src/charts/HeatmapChart.tsx +4 -2
  76. package/src/charts/LineChart.tsx +4 -2
  77. package/src/charts/PlotChart.tsx +23 -3
  78. package/src/charts/RadarChart.tsx +4 -2
  79. package/src/charts/RingChart.tsx +4 -2
  80. package/src/charts/ScatterChart.tsx +24 -3
  81. package/src/charts/WaterfallChart.tsx +21 -3
  82. package/src/charts/advanced.tsx +12 -6
  83. package/src/charts/extra.tsx +6 -3
  84. package/src/internal/GlassView.tsx +31 -21
  85. package/src/internal/fallback.tsx +23 -8
  86. package/src/internal/glass-routing.ts +68 -0
  87. package/src/internal/motion.ts +60 -0
  88. package/src/internal/primitives.ts +477 -0
  89. package/lib/module/charts/primitives.js +0 -212
  90. package/lib/typescript/charts/primitives.d.ts +0 -23
  91. package/src/charts/primitives.ts +0 -262
@@ -0,0 +1,19 @@
1
+ import { springs } from "./tokens";
2
+ /**
3
+ * Resolves the theme. An explicit `isDark` always wins; otherwise the phone's
4
+ * colour scheme decides, defaulting to light when it is unknown.
5
+ */
6
+ export declare function useIsDark(isDark?: boolean): boolean;
7
+ export type SpringName = keyof typeof springs;
8
+ /**
9
+ * A value that springs towards `target` whenever it changes.
10
+ *
11
+ * Returns the `Animated.Value` to put in a style, plus whether motion is real
12
+ * on this platform. A caller that gets `animated === false` renders the target
13
+ * directly, so the DOM preview and tests show the settled state rather than an
14
+ * animation the environment cannot advance.
15
+ */
16
+ export declare function useSpring(target: number, spring?: SpringName): {
17
+ value: any;
18
+ animated: boolean;
19
+ };
@@ -0,0 +1,41 @@
1
+ /** Minimal shapes of the React Native primitives the package uses. */
2
+ export interface RNPrimitives {
3
+ View: any;
4
+ Text: any;
5
+ Pressable: any;
6
+ Svg: any;
7
+ G: any;
8
+ Line: any;
9
+ Path: any;
10
+ Circle: any;
11
+ Rect: any;
12
+ Polygon: any;
13
+ SvgText: any;
14
+ TextInput: any;
15
+ Modal: any;
16
+ Image: any;
17
+ /** React Native's Animated API, or a no-op animation shim off-device. */
18
+ Animated: any;
19
+ /** React Native's Easing curves, used with Animated.spring. */
20
+ Easing: any;
21
+ /** React Native's ScrollView, or null when it is unavailable. */
22
+ getScrollView: () => any;
23
+ /** React Native's BackHandler, or null outside a native runtime. */
24
+ getBackHandler: () => any;
25
+ /** True when the returned primitives are React Native's own. */
26
+ isNative: boolean;
27
+ /** React Native's PanResponder, or a DOM stand-in off-device. */
28
+ PanResponder: any;
29
+ /** React Native's useColorScheme, or null outside a native runtime. */
30
+ useColorScheme: (() => "light" | "dark" | null | undefined) | null;
31
+ }
32
+ /**
33
+ * Records an element's width for gesture maths when the environment has no
34
+ * layout events (the DOM preview). A device never needs it: React Native
35
+ * reports width through `onLayout`.
36
+ */
37
+ export declare function measurePreviewWidth(node: any, widthRef: {
38
+ current: number;
39
+ }): void;
40
+ /** The resolved primitives, computed once per process. */
41
+ export declare function primitives(): RNPrimitives;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glacia-native",
3
- "version": "0.3.5",
3
+ "version": "0.4.0",
4
4
  "description": "Liquid Glass UI components for React Native — real iOS 26 glass, with a clean fallback on Android and older iOS.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "react-native-svg": ">=13"
28
28
  },
29
29
  "dependencies": {
30
- "glacia-tokens": "0.3.5"
30
+ "glacia-tokens": "0.4.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@testing-library/react": "^16.3.3",
package/src/Button.tsx CHANGED
@@ -1,6 +1,10 @@
1
1
  import { forwardRef, type ReactNode } from "react";
2
+ import type { StyleProp, TextStyle, ViewStyle } from "react-native";
3
+
2
4
  import { Glass } from "./Glass";
3
- import { colors, radii } from "./internal/tokens";
5
+ import { colors } from "./internal/tokens";
6
+ import { primitives } from "./internal/primitives";
7
+ import { useIsDark } from "./internal/motion";
4
8
 
5
9
  export interface ButtonProps {
6
10
  variant?: "glass" | "filled" | "ghost";
@@ -10,9 +14,11 @@ export interface ButtonProps {
10
14
  accessibilityLabel: string;
11
15
  icon?: ReactNode;
12
16
  children?: ReactNode;
13
- style?: any;
17
+ style?: StyleProp<ViewStyle>;
14
18
  tint?: string;
15
19
  isDark?: boolean;
20
+ /** Passed through to the pressable root so the button is testable. */
21
+ testID?: string;
16
22
  }
17
23
 
18
24
  const sizeHeights = {
@@ -21,6 +27,13 @@ const sizeHeights = {
21
27
  lg: 48,
22
28
  };
23
29
 
30
+ /**
31
+ * A pressable button on Glacia's glass.
32
+ *
33
+ * The root is a Pressable so it gets the platform's own press semantics
34
+ * (focus, screen-reader activation, pressed feedback) while the material —
35
+ * Apple's glass on iOS 26+, Glacia's tint elsewhere — comes from `Glass`.
36
+ */
24
37
  export const Button = forwardRef<any, ButtonProps>(function Button(
25
38
  {
26
39
  variant = "glass",
@@ -32,56 +45,68 @@ export const Button = forwardRef<any, ButtonProps>(function Button(
32
45
  children,
33
46
  style,
34
47
  tint,
35
- isDark = false,
48
+ isDark: isDarkProp,
49
+ testID,
36
50
  ...props
37
51
  },
38
52
  ref,
39
53
  ) {
54
+ const isDark = useIsDark(isDarkProp);
40
55
  const themeColors = isDark ? colors.dark : colors.light;
56
+ const { Pressable, View, Text } = primitives();
41
57
  const height = sizeHeights[size];
42
58
 
43
- const buttonStyle = {
59
+ const buttonStyle: ViewStyle = {
44
60
  height,
45
61
  borderRadius: height / 2,
46
- flexDirection: "row" as const,
47
- alignItems: "center" as const,
48
- justifyContent: "center" as const,
62
+ flexDirection: "row",
63
+ alignItems: "center",
64
+ justifyContent: "center",
49
65
  paddingHorizontal: size === "sm" ? 12 : size === "lg" ? 22 : 16,
50
66
  opacity: disabled ? 0.38 : 1,
51
67
  backgroundColor:
52
68
  variant === "filled"
53
69
  ? tint || themeColors.fill
54
70
  : variant === "ghost"
55
- ? "transparent"
56
- : undefined,
57
- ...style,
71
+ ? "transparent"
72
+ : undefined,
73
+ ...(style as ViewStyle),
58
74
  };
59
75
 
60
- const textStyle = {
76
+ const textStyle: TextStyle = {
61
77
  color: variant === "filled" ? "#FFFFFF" : tint || themeColors.foreground,
62
78
  fontSize: size === "sm" ? 13 : size === "lg" ? 16 : 14,
63
- fontWeight: "500" as const,
79
+ fontWeight: "500",
64
80
  };
65
81
 
66
82
  return (
67
- <div
83
+ <Pressable
68
84
  ref={ref}
69
- role="button"
70
- tabIndex={disabled ? -1 : 0}
71
- aria-label={accessibilityLabel}
72
- aria-disabled={disabled}
73
- onClick={disabled ? undefined : onPress}
74
- style={{ display: "inline-block", cursor: disabled ? "default" : "pointer" }}
85
+ testID={testID}
86
+ accessibilityRole="button"
87
+ accessibilityLabel={accessibilityLabel}
88
+ accessibilityState={{ disabled }}
89
+ disabled={disabled}
90
+ onPress={disabled ? undefined : onPress}
91
+ style={({ pressed }: { pressed: boolean }) => ({ opacity: pressed && !disabled ? 0.85 : 1 })}
75
92
  {...props}
76
93
  >
77
94
  <Glass
78
95
  effect={variant === "ghost" ? "none" : "regular"}
79
96
  interactive={!disabled}
97
+ isDark={isDark}
80
98
  style={buttonStyle}
81
99
  >
82
- {icon && <span style={{ marginRight: children ? 8 : 0 }}>{icon}</span>}
83
- {typeof children === "string" ? <span style={textStyle}>{children}</span> : children}
100
+ {icon ? <View style={{ marginRight: children ? 8 : 0 }}>{icon}</View> : null}
101
+ {typeof children === "string" ? (
102
+ // A string label is text: it needs Text to inherit font and colour.
103
+ <Text style={textStyle} numberOfLines={1}>
104
+ {children}
105
+ </Text>
106
+ ) : (
107
+ children
108
+ )}
84
109
  </Glass>
85
- </div>
110
+ </Pressable>
86
111
  );
87
112
  });
package/src/Card.tsx CHANGED
@@ -1,120 +1,141 @@
1
1
  import { forwardRef, type ReactNode } from "react";
2
+ import type { StyleProp, TextStyle, ViewStyle } from "react-native";
3
+
2
4
  import { Glass } from "./Glass";
3
5
  import { colors, radii } from "./internal/tokens";
6
+ import { primitives } from "./internal/primitives";
7
+ import { useIsDark } from "./internal/motion";
4
8
 
5
9
  export interface CardProps {
6
10
  effect?: "clear" | "regular" | "none";
7
- style?: any;
11
+ style?: StyleProp<ViewStyle>;
8
12
  children?: ReactNode;
9
13
  isDark?: boolean;
14
+ /** Passed through to the card's glass so it is testable. */
15
+ testID?: string;
10
16
  }
11
17
 
18
+ /**
19
+ * A content panel on Glacia's glass: Apple's material on iOS 26+, Glacia's
20
+ * tint elsewhere. The padding, radius and stacking are ours on every platform.
21
+ */
12
22
  export const Card = forwardRef<any, CardProps>(function Card(
13
- { effect = "regular", style, children, isDark = false, ...props },
23
+ { effect = "regular", style, children, isDark: isDarkProp, testID, ...props },
14
24
  ref,
15
25
  ) {
16
- const cardStyle = {
26
+ const isDark = useIsDark(isDarkProp);
27
+
28
+ const cardStyle: ViewStyle = {
17
29
  padding: 20,
18
30
  borderRadius: radii.lg,
19
- display: "flex" as const,
20
- flexDirection: "column" as const,
31
+ flexDirection: "column",
21
32
  gap: 12,
22
- ...style,
33
+ ...(style as ViewStyle),
23
34
  };
24
35
 
25
36
  return (
26
- <Glass ref={ref} effect={effect} style={cardStyle} {...props}>
37
+ <Glass ref={ref} effect={effect} isDark={isDark} style={cardStyle} testID={testID} {...props}>
27
38
  {children}
28
39
  </Glass>
29
40
  );
30
41
  });
31
42
 
32
- export function CardHeader({ style, children, ...props }: { style?: any; children?: ReactNode }) {
43
+ /** The block holding a card's title and description. */
44
+ export function CardHeader({ style, children, ...props }: { style?: StyleProp<ViewStyle>; children?: ReactNode }) {
45
+ const { View } = primitives();
33
46
  return (
34
- <div style={{ display: "flex", flexDirection: "column", gap: 4, ...style }} {...props}>
47
+ <View style={{ flexDirection: "column", gap: 4, ...(style as ViewStyle) }} {...props}>
35
48
  {children}
36
- </div>
49
+ </View>
37
50
  );
38
51
  }
39
52
 
53
+ /** A card's heading, announced as a heading by screen readers. */
40
54
  export function CardTitle({
41
55
  style,
42
56
  children,
43
- isDark = false,
57
+ isDark: isDarkProp,
44
58
  ...props
45
59
  }: {
46
- style?: any;
60
+ style?: StyleProp<TextStyle>;
47
61
  children?: ReactNode;
48
62
  isDark?: boolean;
49
63
  }) {
64
+ const isDark = useIsDark(isDarkProp);
50
65
  const themeColors = isDark ? colors.dark : colors.light;
66
+ const { Text } = primitives();
51
67
  return (
52
- <h3
68
+ <Text
69
+ accessibilityRole="heading"
53
70
  style={{
54
- margin: 0,
55
71
  fontSize: 18,
56
- fontWeight: 600,
72
+ fontWeight: "600",
57
73
  color: themeColors.foreground,
58
- ...style,
74
+ ...(style as TextStyle),
59
75
  }}
60
76
  {...props}
61
77
  >
62
78
  {children}
63
- </h3>
79
+ </Text>
64
80
  );
65
81
  }
66
82
 
83
+ /** Supporting text under a card's title. */
67
84
  export function CardDescription({
68
85
  style,
69
86
  children,
70
- isDark = false,
87
+ isDark: isDarkProp,
71
88
  ...props
72
89
  }: {
73
- style?: any;
90
+ style?: StyleProp<TextStyle>;
74
91
  children?: ReactNode;
75
92
  isDark?: boolean;
76
93
  }) {
94
+ const isDark = useIsDark(isDarkProp);
77
95
  const themeColors = isDark ? colors.dark : colors.light;
96
+ const { Text } = primitives();
78
97
  return (
79
- <p
98
+ <Text
80
99
  style={{
81
- margin: 0,
82
100
  fontSize: 13,
83
101
  color: themeColors.muted,
84
- ...style,
102
+ ...(style as TextStyle),
85
103
  }}
86
104
  {...props}
87
105
  >
88
106
  {children}
89
- </p>
107
+ </Text>
90
108
  );
91
109
  }
92
110
 
93
- export function CardContent({ style, children, ...props }: { style?: any; children?: ReactNode }) {
111
+ /** The card's body. */
112
+ export function CardContent({ style, children, ...props }: { style?: StyleProp<ViewStyle>; children?: ReactNode }) {
113
+ const { View } = primitives();
94
114
  return (
95
- <div style={{ display: "flex", flexDirection: "column", gap: 8, ...style }} {...props}>
115
+ <View style={{ flexDirection: "column", gap: 8, ...(style as ViewStyle) }} {...props}>
96
116
  {children}
97
- </div>
117
+ </View>
98
118
  );
99
119
  }
100
120
 
101
121
  export const CardBody = CardContent;
102
122
 
103
- export function CardFooter({ style, children, ...props }: { style?: any; children?: ReactNode }) {
123
+ /** The card's action row. */
124
+ export function CardFooter({ style, children, ...props }: { style?: StyleProp<ViewStyle>; children?: ReactNode }) {
125
+ const { View } = primitives();
104
126
  return (
105
- <div
127
+ <View
106
128
  style={{
107
- display: "flex",
108
129
  flexDirection: "row",
109
130
  alignItems: "center",
110
131
  justifyContent: "flex-end",
111
132
  gap: 8,
112
133
  paddingTop: 8,
113
- ...style,
134
+ ...(style as ViewStyle),
114
135
  }}
115
136
  {...props}
116
137
  >
117
138
  {children}
118
- </div>
139
+ </View>
119
140
  );
120
141
  }
package/src/Dialog.tsx CHANGED
@@ -1,11 +1,14 @@
1
1
  import { useCallback, useEffect, useState, type ReactNode } from "react";
2
+ import type { StyleProp, ViewStyle } from "react-native";
2
3
 
3
4
  import { colors, radii } from "./internal/tokens";
4
- import { primitives } from "./charts/primitives";
5
+ import { primitives } from "./internal/primitives";
6
+ import { useIsDark } from "./internal/motion";
7
+ import { Glass } from "./Glass";
5
8
  import { Button } from "./Button";
6
9
 
7
10
  export interface DialogProps {
8
- /** Controlled visibility. Omit to use `trigger` and uncontrolled state. */
11
+ /** Controlled visibility. Omit it and the dialog keeps its own state. */
9
12
  open?: boolean;
10
13
  onOpenChange?: (open: boolean) => void;
11
14
  title?: string;
@@ -15,16 +18,24 @@ export interface DialogProps {
15
18
  /** Tapping the backdrop dismisses. Off for destructive confirmations. */
16
19
  dismissOnBackdropPress?: boolean;
17
20
  isDark?: boolean;
18
- style?: any;
21
+ style?: StyleProp<ViewStyle>;
22
+ /** Passed through to the dialog panel so it is testable. */
23
+ testID?: string;
19
24
  }
20
25
 
21
26
  /**
22
- * A centred modal surface above a dimmed backdrop.
27
+ * A centred modal panel above a dimmed backdrop.
28
+ *
29
+ * The panel is a glass surface, so it is Apple's real Liquid Glass on iOS 26+
30
+ * and Glacia's translucent tint elsewhere; the text sits on it with the
31
+ * theme's foreground colour, so contrast holds either way.
23
32
  *
24
33
  * React Native has no built-in focus trap, so this component covers what the
25
34
  * platform can actually do: `Modal` blocks touches behind it, Android's back
26
35
  * button routes to `onOpenChange(false)`, and the heading is marked as such so
27
36
  * screen readers announce the dialog as it appears.
37
+ *
38
+ * To open a dialog from a button, use `DialogTrigger`.
28
39
  */
29
40
  export function Dialog({
30
41
  open: controlledOpen,
@@ -34,9 +45,11 @@ export function Dialog({
34
45
  children,
35
46
  footer,
36
47
  dismissOnBackdropPress = true,
37
- isDark = false,
48
+ isDark: isDarkProp,
38
49
  style,
50
+ testID,
39
51
  }: DialogProps) {
52
+ const isDark = useIsDark(isDarkProp);
40
53
  const theme = isDark ? colors.dark : colors.light;
41
54
  const { View, Text, Pressable, Modal, getBackHandler } = primitives();
42
55
 
@@ -86,34 +99,38 @@ export function Dialog({
86
99
  <Pressable
87
100
  accessibilityRole="none"
88
101
  onPress={() => {}}
89
- style={{
90
- width: "100%",
91
- maxWidth: 380,
92
- borderRadius: radii.lg,
93
- borderWidth: 1,
94
- borderColor: theme.edge,
95
- backgroundColor: isDark ? "#1c1c1e" : "#ffffff",
96
- padding: 20,
97
- gap: 8,
98
- ...style,
99
- }}
102
+ style={{ width: "100%", maxWidth: 380 }}
100
103
  >
101
- {title && (
102
- <Text
103
- accessibilityRole="heading"
104
- style={{ fontSize: 17, fontWeight: "600", color: theme.foreground }}
105
- >
106
- {title}
107
- </Text>
108
- )}
104
+ <Glass
105
+ effect="regular"
106
+ isDark={isDark}
107
+ testID={testID}
108
+ style={{
109
+ borderRadius: radii.lg,
110
+ borderWidth: 1,
111
+ borderColor: theme.edge,
112
+ padding: 20,
113
+ gap: 8,
114
+ ...(style as ViewStyle),
115
+ }}
116
+ >
117
+ {title && (
118
+ <Text
119
+ accessibilityRole="heading"
120
+ style={{ fontSize: 17, fontWeight: "600", color: theme.foreground }}
121
+ >
122
+ {title}
123
+ </Text>
124
+ )}
109
125
 
110
- {description && (
111
- <Text style={{ fontSize: 13, color: theme.muted, lineHeight: 18 }}>{description}</Text>
112
- )}
126
+ {description && (
127
+ <Text style={{ fontSize: 13, color: theme.muted, lineHeight: 18 }}>{description}</Text>
128
+ )}
113
129
 
114
- {children}
130
+ {children}
115
131
 
116
- {footer && <View style={{ marginTop: 12, gap: 8 }}>{footer}</View>}
132
+ {footer && <View style={{ marginTop: 12, gap: 8 }}>{footer}</View>}
133
+ </Glass>
117
134
  </Pressable>
118
135
  </Pressable>
119
136
  </Modal>
@@ -150,6 +167,8 @@ export interface AlertDialogProps {
150
167
  onConfirm?: () => void;
151
168
  onCancel?: () => void;
152
169
  isDark?: boolean;
170
+ /** Passed through to the dialog panel so it is testable. */
171
+ testID?: string;
153
172
  }
154
173
 
155
174
  /**
@@ -169,8 +188,10 @@ export function AlertDialog({
169
188
  destructive = false,
170
189
  onConfirm,
171
190
  onCancel,
172
- isDark = false,
191
+ isDark: isDarkProp,
192
+ testID,
173
193
  }: AlertDialogProps) {
194
+ const isDark = useIsDark(isDarkProp);
174
195
  const theme = isDark ? colors.dark : colors.light;
175
196
  const { View } = primitives();
176
197
  const [uncontrolled, setUncontrolled] = useState(false);
@@ -181,24 +202,31 @@ export function AlertDialog({
181
202
  onOpenChange?.(next);
182
203
  };
183
204
 
205
+ const cancel = () => {
206
+ onCancel?.();
207
+ close(false);
208
+ };
209
+
184
210
  return (
185
211
  <Dialog
186
212
  open={open}
187
- onOpenChange={close}
213
+ testID={testID}
214
+ // Android's back button routes here as a dismissal, and a dismissal of a
215
+ // confirmation question is a cancellation, so onCancel fires too.
216
+ onOpenChange={(next) => {
217
+ if (!next) {
218
+ cancel();
219
+ return;
220
+ }
221
+ close(true);
222
+ }}
188
223
  title={title}
189
224
  description={description}
190
225
  dismissOnBackdropPress={false}
191
226
  isDark={isDark}
192
227
  footer={
193
228
  <View style={{ flexDirection: "row", gap: 8, justifyContent: "flex-end" }}>
194
- <Button
195
- accessibilityLabel={cancelLabel}
196
- variant="ghost"
197
- onPress={() => {
198
- onCancel?.();
199
- close(false);
200
- }}
201
- >
229
+ <Button accessibilityLabel={cancelLabel} variant="ghost" onPress={cancel}>
202
230
  {cancelLabel}
203
231
  </Button>
204
232
  <Button
@@ -233,6 +261,8 @@ export interface ActionSheetProps {
233
261
  options: ActionSheetOption[];
234
262
  cancelLabel?: string;
235
263
  isDark?: boolean;
264
+ /** Passed through to the sheet so it is testable. */
265
+ testID?: string;
236
266
  }
237
267
 
238
268
  /**
@@ -248,10 +278,14 @@ export function ActionSheet({
248
278
  message,
249
279
  options,
250
280
  cancelLabel = "Cancel",
251
- isDark = false,
281
+ isDark: isDarkProp,
282
+ testID,
252
283
  }: ActionSheetProps) {
284
+ const isDark = useIsDark(isDarkProp);
253
285
  const theme = isDark ? colors.dark : colors.light;
254
- const { View, Text, Pressable, Modal, getBackHandler } = primitives();
286
+ // Android's back button is handled by Modal's onRequestClose, so no
287
+ // BackHandler subscription is needed here.
288
+ const { View, Text, Pressable, Modal } = primitives();
255
289
  const [uncontrolled, setUncontrolled] = useState(false);
256
290
  const open = controlledOpen ?? uncontrolled;
257
291
 
@@ -261,7 +295,13 @@ export function ActionSheet({
261
295
  };
262
296
 
263
297
  return (
264
- <Modal visible={open} transparent animationType="slide" onRequestClose={close}>
298
+ <Modal
299
+ visible={open}
300
+ transparent
301
+ animationType="slide"
302
+ onRequestClose={close}
303
+ testID={testID}
304
+ >
265
305
  <Pressable
266
306
  accessibilityRole="button"
267
307
  accessibilityLabel="Dismiss actions"
@@ -273,12 +313,10 @@ export function ActionSheet({
273
313
  onPress={() => {}}
274
314
  style={{ padding: 10, gap: 8 }}
275
315
  >
276
- <View
277
- style={{
278
- borderRadius: radii.lg,
279
- overflow: "hidden",
280
- backgroundColor: isDark ? "#1c1c1e" : "#ffffff",
281
- }}
316
+ <Glass
317
+ effect="regular"
318
+ isDark={isDark}
319
+ style={{ borderRadius: radii.lg, overflow: "hidden" }}
282
320
  >
283
321
  {(title || message) && (
284
322
  <View style={{ paddingVertical: 12, paddingHorizontal: 16, alignItems: "center" }}>
@@ -321,23 +359,20 @@ export function ActionSheet({
321
359
  </Text>
322
360
  </Pressable>
323
361
  ))}
324
- </View>
362
+ </Glass>
325
363
 
326
- <Pressable
327
- accessibilityRole="button"
328
- accessibilityLabel={cancelLabel}
329
- onPress={close}
330
- style={{
331
- paddingVertical: 14,
332
- alignItems: "center",
333
- borderRadius: radii.lg,
334
- backgroundColor: isDark ? "#1c1c1e" : "#ffffff",
335
- }}
336
- >
337
- <Text style={{ fontSize: 16, fontWeight: "600", color: theme.foreground }}>
338
- {cancelLabel}
339
- </Text>
340
- </Pressable>
364
+ <Glass effect="regular" isDark={isDark} style={{ borderRadius: radii.lg }}>
365
+ <Pressable
366
+ accessibilityRole="button"
367
+ accessibilityLabel={cancelLabel}
368
+ onPress={close}
369
+ style={{ paddingVertical: 14, alignItems: "center" }}
370
+ >
371
+ <Text style={{ fontSize: 16, fontWeight: "600", color: theme.foreground }}>
372
+ {cancelLabel}
373
+ </Text>
374
+ </Pressable>
375
+ </Glass>
341
376
  </Pressable>
342
377
  </Pressable>
343
378
  </Modal>