@marktiderman/genesis-ui-native 2.2.0 → 2.3.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 (79) hide show
  1. package/README.md +82 -0
  2. package/dist/chunk-7PCWEY6R.js +27 -0
  3. package/dist/chunk-7PCWEY6R.js.map +1 -0
  4. package/dist/chunk-D5RKSPMH.js +24 -0
  5. package/dist/chunk-D5RKSPMH.js.map +1 -0
  6. package/dist/{chunk-5HRGIA6F.js → chunk-EFXCJ5AN.js} +76 -3
  7. package/dist/chunk-EFXCJ5AN.js.map +1 -0
  8. package/dist/{chunk-2WCXMJL6.js → chunk-FIITITXO.js} +67 -108
  9. package/dist/chunk-FIITITXO.js.map +1 -0
  10. package/dist/chunk-H4Q7COTI.js +1587 -0
  11. package/dist/chunk-H4Q7COTI.js.map +1 -0
  12. package/dist/{chunk-TXJT55JC.js → chunk-Q445I7WO.js} +715 -324
  13. package/dist/chunk-Q445I7WO.js.map +1 -0
  14. package/dist/{chunk-ULS7I6ZS.js → chunk-W2UBJ56D.js} +99 -12
  15. package/dist/chunk-W2UBJ56D.js.map +1 -0
  16. package/dist/components/index.d.ts +146 -18
  17. package/dist/components/index.js +6 -4
  18. package/dist/data/index.d.ts +7 -1
  19. package/dist/data/index.js +31 -6
  20. package/dist/data/index.js.map +1 -1
  21. package/dist/hooks/index.js +2 -1
  22. package/dist/icons/lucide.d.ts +7 -0
  23. package/dist/icons/lucide.js +60 -0
  24. package/dist/icons/lucide.js.map +1 -0
  25. package/dist/index.d.ts +3 -2
  26. package/dist/index.js +7 -6
  27. package/dist/layouts/index.d.ts +329 -4
  28. package/dist/layouts/index.js +3 -3
  29. package/dist/native-modules-BGO2MnFF.d.ts +219 -0
  30. package/package.json +34 -5
  31. package/src/__tests__/fake-modules.tsx +134 -0
  32. package/src/__tests__/native-modules-lists.test.tsx +71 -0
  33. package/src/__tests__/native-modules.test.tsx +631 -0
  34. package/src/components/__tests__/refresh-control.test.tsx +35 -0
  35. package/src/components/__tests__/sheet.test.tsx +193 -0
  36. package/src/components/__tests__/toast.test.tsx +15 -0
  37. package/src/components/avatar.tsx +69 -16
  38. package/src/components/date-time-picker.tsx +128 -10
  39. package/src/components/drawer.tsx +158 -68
  40. package/src/components/dropdown-menu.tsx +7 -6
  41. package/src/components/glass-surface.tsx +150 -0
  42. package/src/components/icon.tsx +66 -0
  43. package/src/components/image.tsx +89 -0
  44. package/src/components/index.ts +33 -2
  45. package/src/components/list-item.tsx +29 -9
  46. package/src/components/popover.tsx +12 -9
  47. package/src/components/refresh-control.tsx +11 -45
  48. package/src/components/segmented-control.tsx +7 -1
  49. package/src/components/sheet.tsx +276 -133
  50. package/src/components/skeleton.tsx +75 -53
  51. package/src/components/toast.tsx +185 -87
  52. package/src/data/NativeResourcePage.tsx +48 -3
  53. package/src/data/__tests__/resource-page-offline.test.tsx +47 -0
  54. package/src/hooks/use-reduced-motion.ts +24 -10
  55. package/src/icon-names.ts +62 -0
  56. package/src/icons/lucide.ts +114 -0
  57. package/src/layouts/__tests__/google-sign-in.test.tsx +26 -0
  58. package/src/layouts/__tests__/inbox-page.test.tsx +200 -0
  59. package/src/layouts/__tests__/keyboard-scroll.test.tsx +42 -1
  60. package/src/layouts/__tests__/settings-page-native-look.test.tsx +142 -0
  61. package/src/layouts/__tests__/thread-page.test.tsx +128 -0
  62. package/src/layouts/auth-screen.tsx +6 -3
  63. package/src/layouts/google-sign-in.tsx +42 -0
  64. package/src/layouts/inbox-page.tsx +455 -0
  65. package/src/layouts/index.ts +37 -2
  66. package/src/layouts/keyboard.tsx +61 -9
  67. package/src/layouts/notifications-page.tsx +133 -16
  68. package/src/layouts/settings-page.tsx +117 -14
  69. package/src/layouts/settings-sub-page.tsx +9 -3
  70. package/src/layouts/thread-page.tsx +444 -0
  71. package/src/native-modules.tsx +186 -0
  72. package/dist/chunk-2WCXMJL6.js.map +0 -1
  73. package/dist/chunk-5HRGIA6F.js.map +0 -1
  74. package/dist/chunk-F2TGDKOO.js +0 -43
  75. package/dist/chunk-F2TGDKOO.js.map +0 -1
  76. package/dist/chunk-FZTUSM56.js +0 -935
  77. package/dist/chunk-FZTUSM56.js.map +0 -1
  78. package/dist/chunk-TXJT55JC.js.map +0 -1
  79. package/dist/chunk-ULS7I6ZS.js.map +0 -1
@@ -1,27 +1,41 @@
1
1
  /**
2
2
  * useReducedMotion — subscribe to the OS reduce-motion preference.
3
3
  *
4
- * Returns `true` when the user has enabled reduce-motion at the OS level.
5
- * Components that animate (Sheet, Drawer, Toast, etc.) honor this hook by
6
- * skipping non-essential transitions and snapping into final state.
4
+ * Returns `true` when the user has enabled reduce-motion at the OS level,
5
+ * and follows the setting while the app runs (Reanimated's own hook reads it
6
+ * once at launch). Components that animate (Sheet, Drawer, Toast, Skeleton)
7
+ * honor it by skipping non-essential transitions and snapping into the
8
+ * final state.
7
9
  *
8
10
  * @stability Beta
9
11
  */
10
12
  import { useEffect, useState } from "react";
11
13
  import { AccessibilityInfo } from "react-native";
12
14
 
15
+ // The last answer anyone got: a component mounting later (a toast, an open
16
+ // drawer) starts from it instead of animating for a frame before it hears.
17
+ let lastKnown = false;
18
+
19
+ /** Tests only: forget the last answer. Not exported from the package. */
20
+ export function __resetReducedMotion() {
21
+ lastKnown = false;
22
+ }
23
+
13
24
  export function useReducedMotion(): boolean {
14
- const [reduced, setReduced] = useState(false);
25
+ const [reduced, setReduced] = useState(lastKnown);
15
26
 
16
27
  useEffect(() => {
17
28
  let mounted = true;
18
- AccessibilityInfo.isReduceMotionEnabled().then((v) => {
29
+ const set = (v: boolean) => {
30
+ lastKnown = v;
19
31
  if (mounted) setReduced(v);
20
- });
21
- const sub = AccessibilityInfo.addEventListener(
22
- "reduceMotionChanged",
23
- (v: boolean) => setReduced(v),
24
- );
32
+ };
33
+ AccessibilityInfo.isReduceMotionEnabled()
34
+ .then(set)
35
+ // Some runtimes (web, older Android) reject when the accessibility
36
+ // manager isn't wired up: treat that as "no preference".
37
+ .catch(() => {});
38
+ const sub = AccessibilityInfo.addEventListener("reduceMotionChanged", set);
25
39
  return () => {
26
40
  mounted = false;
27
41
  sub?.remove?.();
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The semantic icon names Genesis components ask for, and the SF Symbol each
3
+ * one draws on iOS. Components say "settings" or "bell", never a library's
4
+ * own name; `lucideIcons` (`/icons/lucide`) maps the same names for Android,
5
+ * web and the SF Symbol fallback.
6
+ *
7
+ * @stability Beta
8
+ */
9
+ export const SF_SYMBOLS = {
10
+ "arrow-left": "arrow.left",
11
+ "arrow-up": "arrow.up",
12
+ bell: "bell",
13
+ calendar: "calendar",
14
+ camera: "camera",
15
+ check: "checkmark",
16
+ "chevron-down": "chevron.down",
17
+ "chevron-left": "chevron.left",
18
+ "chevron-right": "chevron.right",
19
+ "chevron-up": "chevron.up",
20
+ clock: "clock",
21
+ close: "xmark",
22
+ compose: "square.and.pencil",
23
+ copy: "doc.on.doc",
24
+ edit: "pencil",
25
+ error: "xmark.circle",
26
+ "external-link": "arrow.up.right.square",
27
+ file: "doc",
28
+ filter: "line.3.horizontal.decrease",
29
+ heart: "heart",
30
+ home: "house",
31
+ image: "photo",
32
+ info: "info.circle",
33
+ lock: "lock",
34
+ "log-out": "rectangle.portrait.and.arrow.right",
35
+ mail: "envelope",
36
+ menu: "line.3.horizontal",
37
+ message: "bubble.left",
38
+ mic: "mic",
39
+ minus: "minus",
40
+ more: "ellipsis",
41
+ paperclip: "paperclip",
42
+ pause: "pause.fill",
43
+ pin: "pin",
44
+ play: "play.fill",
45
+ plus: "plus",
46
+ refresh: "arrow.clockwise",
47
+ reply: "arrowshape.turn.up.left",
48
+ search: "magnifyingglass",
49
+ settings: "gearshape",
50
+ share: "square.and.arrow.up",
51
+ star: "star",
52
+ success: "checkmark.circle",
53
+ trash: "trash",
54
+ user: "person",
55
+ warning: "exclamationmark.triangle",
56
+ } as const;
57
+
58
+ /** A semantic icon name: what the icon is for. */
59
+ export type NativeIconName = keyof typeof SF_SYMBOLS;
60
+
61
+ /** Every semantic icon name. */
62
+ export const NATIVE_ICON_NAMES = Object.keys(SF_SYMBOLS) as NativeIconName[];
@@ -0,0 +1,114 @@
1
+ /**
2
+ * `lucideIcons` — the lucide-react-native icon for every semantic name, the
3
+ * icon set `NativeIcon` draws on Android and web (and on iOS when an SF
4
+ * Symbol can't be drawn). Opt in by importing this subpath and passing it as
5
+ * `modules.icons`; the rest of the package never imports lucide.
6
+ *
7
+ * Needs lucide-react-native 0.475 or later (the names below).
8
+ *
9
+ * @stability Beta
10
+ */
11
+ import {
12
+ ArrowLeft,
13
+ ArrowUp,
14
+ Bell,
15
+ Calendar,
16
+ Camera,
17
+ Check,
18
+ ChevronDown,
19
+ ChevronLeft,
20
+ ChevronRight,
21
+ ChevronUp,
22
+ CircleCheck,
23
+ CircleX,
24
+ Clock,
25
+ Copy,
26
+ Ellipsis,
27
+ ExternalLink,
28
+ File,
29
+ Funnel,
30
+ Heart,
31
+ House,
32
+ Image,
33
+ Info,
34
+ Lock,
35
+ LogOut,
36
+ Mail,
37
+ Menu,
38
+ MessageCircle,
39
+ Mic,
40
+ Minus,
41
+ Paperclip,
42
+ Pause,
43
+ Pencil,
44
+ Pin,
45
+ Play,
46
+ Plus,
47
+ RefreshCw,
48
+ Reply,
49
+ Search,
50
+ Settings,
51
+ Share,
52
+ SquarePen,
53
+ Star,
54
+ Trash2,
55
+ TriangleAlert,
56
+ User,
57
+ X,
58
+ } from "lucide-react-native";
59
+ import type { NativeIconName } from "../icon-names";
60
+ import type { GenesisIconComponent } from "../native-modules";
61
+
62
+ export const lucideIcons: Record<NativeIconName, GenesisIconComponent> = {
63
+ "arrow-left": ArrowLeft,
64
+ "arrow-up": ArrowUp,
65
+ bell: Bell,
66
+ calendar: Calendar,
67
+ camera: Camera,
68
+ check: Check,
69
+ "chevron-down": ChevronDown,
70
+ "chevron-left": ChevronLeft,
71
+ "chevron-right": ChevronRight,
72
+ "chevron-up": ChevronUp,
73
+ clock: Clock,
74
+ close: X,
75
+ compose: SquarePen,
76
+ copy: Copy,
77
+ edit: Pencil,
78
+ error: CircleX,
79
+ "external-link": ExternalLink,
80
+ file: File,
81
+ filter: Funnel,
82
+ heart: Heart,
83
+ home: House,
84
+ image: Image,
85
+ info: Info,
86
+ lock: Lock,
87
+ "log-out": LogOut,
88
+ mail: Mail,
89
+ menu: Menu,
90
+ message: MessageCircle,
91
+ mic: Mic,
92
+ minus: Minus,
93
+ more: Ellipsis,
94
+ paperclip: Paperclip,
95
+ pause: Pause,
96
+ pin: Pin,
97
+ play: Play,
98
+ plus: Plus,
99
+ refresh: RefreshCw,
100
+ reply: Reply,
101
+ search: Search,
102
+ settings: Settings,
103
+ share: Share,
104
+ star: Star,
105
+ success: CircleCheck,
106
+ trash: Trash2,
107
+ user: User,
108
+ warning: TriangleAlert,
109
+ // The cast widens lucide's declared `color: string` to `ColorValue`. On iOS
110
+ // NativeIcon passes theme roles as `PlatformColor` objects; lucide hands
111
+ // `color` to react-native-svg's stroke, whose extractBrush resolves
112
+ // PlatformColor and DynamicColorIOS objects (react-native-svg 15,
113
+ // src/lib/extract/extractBrush.ts).
114
+ } as Record<NativeIconName, GenesisIconComponent>;
@@ -0,0 +1,26 @@
1
+ // @feat:account
2
+ import { fireEvent, render, screen } from "@testing-library/react";
3
+ import { describe, expect, it, vi } from "vitest";
4
+ import { AuthScreen } from "../auth-screen";
5
+ import { googleProvider } from "../google-sign-in";
6
+
7
+ const form = { onSubmit: vi.fn() };
8
+
9
+ describe("googleProvider", () => {
10
+ it("is a provider with Google's wording that AuthScreen draws and presses", () => {
11
+ const onPress = vi.fn();
12
+ vi.spyOn(console, "warn").mockImplementation(() => {});
13
+ render(<AuthScreen form={form} providers={[googleProvider({ onPress, icon: <span>G</span> })]} />);
14
+ const button = screen.getByTestId("auth-screen-social-google");
15
+ expect(button.textContent).toContain("Continue with Google");
16
+ expect(button.textContent).toContain("G");
17
+ fireEvent.click(button);
18
+ expect(onPress).toHaveBeenCalledTimes(1);
19
+ vi.restoreAllMocks();
20
+ });
21
+
22
+ it("is null when switched off, so the list takes it as is", () => {
23
+ expect(googleProvider({ onPress: () => {}, enabled: false })).toBeNull();
24
+ expect(googleProvider({ onPress: () => {}, label: "Sign in with Google" })?.label).toBe("Sign in with Google");
25
+ });
26
+ });
@@ -0,0 +1,200 @@
1
+ // @feat:inbox-thread
2
+ import type { ReactNode } from "react";
3
+ import { fireEvent, render, screen } from "@testing-library/react";
4
+ import { afterEach, describe, expect, it, vi } from "vitest";
5
+ import { Alert, Platform, StyleSheet } from "react-native";
6
+ import { InboxPage, formatInboxTime, getInboxPageStackOptions, type InboxItem } from "../inbox-page";
7
+
8
+ const NOW = new Date(2026, 9, 24, 15, 0);
9
+ const now = () => NOW;
10
+
11
+ function styleOf(el: Element): Record<string, unknown> {
12
+ return StyleSheet.flatten(JSON.parse((el as HTMLElement).dataset.style ?? "null"));
13
+ }
14
+
15
+ const os = Platform.OS;
16
+ afterEach(() => {
17
+ Platform.OS = os;
18
+ vi.mocked(Alert.alert).mockClear();
19
+ });
20
+
21
+ const items: InboxItem[] = [
22
+ { id: "a", title: "Save button does nothing", preview: "Thanks, we're on it.", timestamp: new Date(2026, 9, 24, 9, 41), unreadCount: 2, meta: "In progress", onPress: vi.fn() },
23
+ { id: "b", title: "Dark mode", preview: "You: please", timestamp: new Date(2026, 9, 23, 12, 0), unread: true },
24
+ { id: "c", title: "Old one", timestamp: new Date(2026, 8, 1) },
25
+ ];
26
+
27
+ describe("formatInboxTime", () => {
28
+ it("reads as a time today, Yesterday, a weekday this week, then a date", () => {
29
+ expect(formatInboxTime(new Date(2026, 9, 24, 9, 41), NOW)).toMatch(/9:41/);
30
+ expect(formatInboxTime(new Date(2026, 9, 23, 9, 41), NOW)).toBe("Yesterday");
31
+ expect(formatInboxTime(new Date(2026, 9, 20, 9, 41), NOW)).toBe(new Date(2026, 9, 20).toLocaleDateString(undefined, { weekday: "long" }));
32
+ expect(formatInboxTime(new Date(2026, 8, 1), NOW)).not.toMatch(/2026/);
33
+ expect(formatInboxTime(new Date(2025, 8, 1), NOW)).toMatch(/2025/);
34
+ });
35
+ });
36
+
37
+ describe("InboxPage", () => {
38
+ it("shows the empty state, with its action, when there are no items", () => {
39
+ const onEmptyAction = vi.fn();
40
+ render(<InboxPage testID="inbox" items={[]} emptyTitle="No reports" emptyBody="Send one" emptyActionLabel="Send feedback" onEmptyAction={onEmptyAction} />);
41
+ expect(screen.getByTestId("inbox-empty").textContent).toContain("No reports");
42
+ fireEvent.click(screen.getByTestId("inbox-empty-action"));
43
+ expect(onEmptyAction).toHaveBeenCalled();
44
+ });
45
+
46
+ it("shows a spinner while the first page loads, and an error (with Try again) when the read failed", () => {
47
+ const onRefresh = vi.fn();
48
+ const { unmount } = render(<InboxPage testID="inbox" items={[]} loading emptyTitle="No reports" />);
49
+ expect(screen.getByTestId("inbox-loading")).toBeTruthy();
50
+ expect(screen.queryByTestId("inbox-empty")).toBeNull();
51
+ unmount();
52
+ render(<InboxPage testID="inbox" items={[]} error errorTitle="Couldn't load" onRefresh={onRefresh} />);
53
+ expect(screen.getByTestId("inbox-error").textContent).toContain("Couldn't load");
54
+ fireEvent.click(screen.getByTestId("inbox-error-action"));
55
+ expect(onRefresh).toHaveBeenCalled();
56
+ });
57
+
58
+ it("lets a tap in the header (a text field's button) land while the keyboard is up", () => {
59
+ render(<InboxPage testID="inbox" items={items} now={now} />);
60
+ expect(screen.getByTestId("inbox-list").dataset.keyboardShouldPersistTaps).toBe("handled");
61
+ });
62
+
63
+ it("renders every row with its time, preview and status, newest first as given", () => {
64
+ render(<InboxPage testID="inbox" items={items} now={now} />);
65
+ const rows = ["a", "b", "c"].map((id) => screen.getByTestId(`inbox-row-${id}`));
66
+ expect(rows).toHaveLength(3);
67
+ expect(screen.getByTestId("inbox-row-b-time").textContent).toBe("Yesterday");
68
+ expect(screen.getByTestId("inbox-row-a-meta").textContent).toBe("In progress");
69
+ });
70
+
71
+ it("shows unread as a count or a dot, and says it to VoiceOver", () => {
72
+ render(<InboxPage testID="inbox" items={items} now={now} />);
73
+ expect(screen.getByTestId("inbox-row-a-count").textContent).toBe("2");
74
+ expect(screen.getByTestId("inbox-row-a").getAttribute("aria-label")).toMatch(/^2 unread, Save button does nothing/);
75
+ expect(styleOf(screen.getByTestId("inbox-row-b-unread")).borderRadius).toBe(5);
76
+ expect(screen.getByTestId("inbox-row-b").getAttribute("aria-label")).toMatch(/^Unread, Dark mode/);
77
+ expect(styleOf(screen.getByTestId("inbox-row-c-unread")).borderRadius).toBeUndefined();
78
+ });
79
+
80
+ it("opens a row on press", () => {
81
+ render(<InboxPage testID="inbox" items={items} now={now} />);
82
+ fireEvent.click(screen.getByTestId("inbox-row-a"));
83
+ expect(items[0]!.onPress).toHaveBeenCalled();
84
+ });
85
+
86
+ it("offers swipe actions as accessibility actions and on long press, without a gesture library", () => {
87
+ const remove = vi.fn();
88
+ const markRead = vi.fn();
89
+ render(
90
+ <InboxPage
91
+ testID="inbox"
92
+ now={now}
93
+ items={[{ id: "x", title: "Thread", swipeActions: [{ id: "read", label: "Mark read", onPress: markRead }, { id: "delete", label: "Delete", destructive: true, onPress: remove }] }]}
94
+ />,
95
+ );
96
+ const row = screen.getByTestId("inbox-row-x");
97
+ expect(row.getAttribute("data-a11y-actions")).toBe("read,delete");
98
+ row.dispatchEvent(new CustomEvent("accessibilityaction", { detail: "delete" }));
99
+ expect(remove).toHaveBeenCalledTimes(1);
100
+ fireEvent.contextMenu(row);
101
+ const [title, , buttons] = vi.mocked(Alert.alert).mock.calls[0]!;
102
+ expect(title).toBe("Thread");
103
+ expect(buttons?.map((b) => [b.text, b.style])).toEqual([["Mark read", "default"], ["Delete", "destructive"], ["Cancel", "cancel"]]);
104
+ buttons?.[0]?.onPress?.();
105
+ expect(markRead).toHaveBeenCalled();
106
+ });
107
+
108
+ it("wraps rows with actions in the swipeable slot, and a null slot leaves them bare", () => {
109
+ function Swipe({ actions, children, testID }: { actions: { id: string }[]; children?: ReactNode; testID: string }) {
110
+ return (
111
+ <div data-testid={testID} data-actions={actions.map((a) => a.id).join(",")}>
112
+ {children}
113
+ </div>
114
+ );
115
+ }
116
+ const withActions = [{ id: "x", title: "T", swipeActions: [{ id: "delete", label: "Delete", onPress: () => {} }] }];
117
+ const { unmount } = render(<InboxPage testID="inbox" items={withActions} slots={{ swipeable: Swipe }} />);
118
+ expect(screen.getByTestId("inbox-row-x-swipe").getAttribute("data-actions")).toBe("delete");
119
+ expect(screen.getByTestId("inbox-row-x-swipe").querySelector('[data-testid="inbox-row-x"]')).toBeTruthy();
120
+ unmount();
121
+ render(<InboxPage testID="inbox" items={withActions} slots={{ swipeable: null }} />);
122
+ expect(screen.queryByTestId("inbox-row-x-swipe")).toBeNull();
123
+ expect(screen.getByTestId("inbox-row-x")).toBeTruthy();
124
+ });
125
+
126
+ it("on iOS, draws one inset rounded group of cells, like SettingsPage", () => {
127
+ Platform.OS = "ios";
128
+ render(<InboxPage testID="inbox" items={items} now={now} />);
129
+ const first = styleOf(screen.getByTestId("inbox-row-a-cell"));
130
+ const middle = styleOf(screen.getByTestId("inbox-row-b-cell"));
131
+ const last = styleOf(screen.getByTestId("inbox-row-c-cell"));
132
+ expect(first).toMatchObject({ marginHorizontal: 16, borderTopLeftRadius: 10, borderBottomLeftRadius: 0, backgroundColor: { semantic: ["secondarySystemGroupedBackground"] } });
133
+ expect(middle).toMatchObject({ borderTopLeftRadius: 0, borderBottomLeftRadius: 0 });
134
+ expect(last).toMatchObject({ borderTopLeftRadius: 0, borderBottomLeftRadius: 10 });
135
+ expect(screen.queryByTestId("inbox-row-c-separator-line")).toBeNull();
136
+ expect(screen.getByTestId("inbox-row-a-separator-line")).toBeTruthy();
137
+ });
138
+
139
+ it("on Android, rows are full width", () => {
140
+ Platform.OS = "android";
141
+ render(<InboxPage testID="inbox" items={items} now={now} />);
142
+ expect(styleOf(screen.getByTestId("inbox-row-a-cell")).marginHorizontal).toBeUndefined();
143
+ });
144
+
145
+ it("shows the paging spinner while more load, and the header and section title", () => {
146
+ render(<InboxPage testID="inbox" items={items} now={now} loadingMore header={<span data-testid="filter" />} sectionTitle="Your reports" />);
147
+ expect(screen.getByTestId("inbox-footer")).toBeTruthy();
148
+ expect(screen.getByTestId("filter")).toBeTruthy();
149
+ expect(screen.getByTestId("inbox-section-title").textContent).toBe("Your reports");
150
+ });
151
+
152
+ it("composes a large-title header by default", () => {
153
+ expect(getInboxPageStackOptions({ headerTitle: "Help" })).toMatchObject({ title: "Help", headerLargeTitle: true });
154
+ });
155
+
156
+ it("puts the empty state in a scroll view that insets below a large-title header, with pull to refresh", () => {
157
+ const onRefresh = vi.fn();
158
+ render(<InboxPage testID="inbox" items={[]} emptyTitle="No messages" onRefresh={onRefresh} />);
159
+ const scroll = screen.getByTestId("inbox-empty-scroll");
160
+ expect(scroll.getAttribute("contentInsetAdjustmentBehavior")).toBe("automatic");
161
+ expect(scroll.contains(screen.getByTestId("inbox-empty"))).toBe(true);
162
+ fireEvent.click(screen.getByTestId("inbox-refresh"));
163
+ expect(onRefresh).toHaveBeenCalled();
164
+ });
165
+
166
+ it("uses the themed refresh control (safe under the native app shell) on the list", () => {
167
+ render(<InboxPage testID="inbox" items={items} now={now} refreshing onRefresh={() => {}} />);
168
+ expect(screen.getByTestId("inbox-refresh").dataset.refreshing).toBe("true");
169
+ expect(screen.getByTestId("inbox-refresh").dataset.tintColor).toBeTruthy();
170
+ });
171
+
172
+ it("has room for an avatar beside the unread dot or count, and starts the separator at the text", () => {
173
+ const withAvatars: InboxItem[] = [
174
+ { ...items[0]!, avatar: <span data-testid="avatar-a" /> },
175
+ { ...items[1]!, avatar: <span data-testid="avatar-b" /> },
176
+ items[2]!,
177
+ ];
178
+ render(<InboxPage testID="inbox" items={withAvatars} now={now} />);
179
+ // Count and avatar together; dot and avatar together.
180
+ expect(screen.getByTestId("inbox-row-a-count").textContent).toBe("2");
181
+ expect(screen.getByTestId("inbox-row-a-avatar").contains(screen.getByTestId("avatar-a"))).toBe(true);
182
+ expect(styleOf(screen.getByTestId("inbox-row-b-unread")).borderRadius).toBe(5);
183
+ expect(screen.getByTestId("avatar-b")).toBeTruthy();
184
+ // The avatar isn't read out twice: the row's label already names it.
185
+ expect(screen.getByTestId("inbox-row-a-avatar").getAttribute("aria-hidden")).toBe("true");
186
+ // 16 padding + 18 dot column + 40 avatar + 12 gap; without an avatar, 34 as before.
187
+ expect(styleOf(screen.getByTestId("inbox-row-a-separator-inset")).width).toBe(86);
188
+ expect(screen.queryByTestId("inbox-row-c-avatar")).toBeNull();
189
+ });
190
+
191
+ it("reads who an avatar shows when the title doesn't name them", () => {
192
+ const rows: InboxItem[] = [
193
+ { ...items[0]!, title: "Morning crew", avatar: <span />, avatarLabel: "Sam" },
194
+ { ...items[1]!, avatarLabel: "Ignored without an avatar" },
195
+ ];
196
+ render(<InboxPage testID="inbox" items={rows} now={now} />);
197
+ expect(screen.getByTestId("inbox-row-a").getAttribute("aria-label")).toMatch(/^2 unread, Sam, Morning crew/);
198
+ expect(screen.getByTestId("inbox-row-b").getAttribute("aria-label")).not.toContain("Ignored");
199
+ });
200
+ });
@@ -4,7 +4,7 @@ import { describe, expect, it, vi } from "vitest";
4
4
  import { View } from "react-native";
5
5
  import { AuthScreen } from "../auth-screen";
6
6
  import { SettingsSubPage } from "../settings-sub-page";
7
- import { KeyboardScrollProvider, type KeyboardScrollProps } from "../keyboard";
7
+ import { KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, useKeyboardToolbar, type KeyboardScrollProps } from "../keyboard";
8
8
 
9
9
  const Aware = ({ children, testID }: KeyboardScrollProps) => <View testID={testID}>{children}</View>;
10
10
 
@@ -32,3 +32,44 @@ describe("KeyboardScrollProvider", () => {
32
32
  expect(screen.getByTestId("sub-kav")).toBeTruthy();
33
33
  });
34
34
  });
35
+
36
+ describe("KeyboardScrollProvider toolbar", () => {
37
+ const Toolbar = () => <View testID="toolbar" />;
38
+ const Spy = vi.fn(({ children, testID, bottomOffset }: KeyboardScrollProps) => (
39
+ <View testID={testID} accessibilityLabel={`offset ${bottomOffset}`}>
40
+ {children}
41
+ </View>
42
+ ));
43
+
44
+ it("adds the previous / next / done bar to AuthScreen and SettingsSubPage, and keeps the focused field clear of it", () => {
45
+ render(
46
+ <KeyboardScrollProvider component={Spy} toolbar={Toolbar}>
47
+ <AuthScreen form={{ onSubmit: vi.fn() }} />
48
+ <SettingsSubPage testID="sub">{null}</SettingsSubPage>
49
+ </KeyboardScrollProvider>,
50
+ );
51
+ // One bar each, beside (not inside) the scroll view.
52
+ expect(screen.getAllByTestId("toolbar")).toHaveLength(2);
53
+ expect(screen.getByTestId("auth-screen-keyboard").querySelector("[data-testid=toolbar]")).toBeNull();
54
+ expect(screen.getByTestId("auth-screen").querySelector("[data-testid=toolbar]")).not.toBeNull();
55
+ expect(screen.getByTestId("auth-screen-keyboard").getAttribute("aria-label")).toBe(`offset ${24 + KEYBOARD_TOOLBAR_HEIGHT}`);
56
+ });
57
+
58
+ it("draws no bar without one", () => {
59
+ render(
60
+ <KeyboardScrollProvider component={Spy}>
61
+ <AuthScreen form={{ onSubmit: vi.fn() }} />
62
+ </KeyboardScrollProvider>,
63
+ );
64
+ expect(screen.queryByTestId("toolbar")).toBeNull();
65
+ expect(screen.getByTestId("auth-screen-keyboard").getAttribute("aria-label")).toBe("offset 24");
66
+ });
67
+
68
+ it("reports no toolbar outside a provider", () => {
69
+ function Probe() {
70
+ return <span data-testid="probe">{String(useKeyboardToolbar())}</span>;
71
+ }
72
+ render(<Probe />);
73
+ expect(screen.getByTestId("probe").textContent).toBe("null");
74
+ });
75
+ });
@@ -0,0 +1,142 @@
1
+ // @feat:native-layouts
2
+ import { render, screen } from "@testing-library/react";
3
+ import { afterEach, describe, expect, it } from "vitest";
4
+ import { Platform, StyleSheet, Text } from "react-native";
5
+ import { SettingsPage } from "../settings-page";
6
+
7
+ const sections = [
8
+ {
9
+ id: "account",
10
+ title: "Account",
11
+ footnote: "Only you see this.",
12
+ rows: [
13
+ { id: "name", title: "Name", leading: <Text>icon</Text> },
14
+ { id: "email", title: "Email" },
15
+ { id: "phone", title: "Phone" },
16
+ ],
17
+ },
18
+ ];
19
+
20
+ function styleOf(el: Element): Record<string, unknown> {
21
+ return StyleSheet.flatten(JSON.parse((el as HTMLElement).dataset.style ?? "null"));
22
+ }
23
+
24
+ const os = Platform.OS;
25
+ const version = Platform.Version;
26
+ afterEach(() => {
27
+ Platform.OS = os;
28
+ Platform.Version = version;
29
+ });
30
+
31
+ describe("SettingsPage on iOS (inset grouped)", () => {
32
+ it("renders the header as an uppercase footnote in secondaryLabel, read as written, with no band or rule", () => {
33
+ render(<SettingsPage testID="s" sections={sections} />);
34
+ const header = screen.getByTestId("s-section-account-header");
35
+ expect(header.getAttribute("role")).toBe("header");
36
+ expect(header.getAttribute("aria-label")).toBe("Account");
37
+ expect(header.textContent).toBe("Account");
38
+ const style = styleOf(header);
39
+ expect(style).toMatchObject({
40
+ color: { semantic: ["secondaryLabel"] },
41
+ fontSize: 13,
42
+ textTransform: "uppercase",
43
+ marginHorizontal: 16,
44
+ });
45
+ expect(style.backgroundColor).toBeUndefined();
46
+ expect(style.borderBottomWidth).toBeUndefined();
47
+ expect(header.className).not.toMatch(/\bbg-|\bborder/);
48
+ });
49
+
50
+ it("aligns the header with the cell text: the group's margin, then the cell's padding", () => {
51
+ render(<SettingsPage testID="s" sections={sections} />);
52
+ const header = screen.getByTestId("s-section-account-header");
53
+ const group = screen.getByTestId("s-section-account-group");
54
+ expect(styleOf(header).marginHorizontal).toBe(styleOf(group).marginHorizontal);
55
+ expect(header.className).toContain("px-4");
56
+ expect(screen.getByTestId("s-row-email").className).toContain("px-4");
57
+ });
58
+
59
+ it("puts rows in a rounded group on secondarySystemGroupedBackground", () => {
60
+ Platform.Version = "18.4";
61
+ const { unmount } = render(<SettingsPage testID="s" sections={sections} />);
62
+ const group = screen.getByTestId("s-section-account-group");
63
+ expect(group.className).toContain("overflow-hidden");
64
+ expect(styleOf(group)).toMatchObject({
65
+ backgroundColor: { semantic: ["secondarySystemGroupedBackground"] },
66
+ borderRadius: 10,
67
+ });
68
+ unmount();
69
+ Platform.Version = "26.0";
70
+ render(<SettingsPage testID="s" sections={sections} />);
71
+ expect(styleOf(screen.getByTestId("s-section-account-group")).borderRadius).toBe(26);
72
+ });
73
+
74
+ it("draws hairline separators between cells only, inset to the cell text and hidden from screen readers", () => {
75
+ render(<SettingsPage testID="s" sections={sections} />);
76
+ expect(screen.queryByTestId("s-row-phone-separator")).toBeNull();
77
+ const separator = screen.getByTestId("s-row-email-separator");
78
+ expect(separator.getAttribute("aria-hidden")).toBe("true");
79
+ expect(styleOf(separator).height).toBe(StyleSheet.hairlineWidth);
80
+ // The leading spacer is the cell's `px-4`, so the line starts where the text does.
81
+ const [inset, line] = Array.from(separator.children);
82
+ expect(inset!.className).toBe("w-4");
83
+ expect(styleOf(screen.getByTestId("s-row-email-separator-line")).backgroundColor).toEqual({
84
+ semantic: ["separator"],
85
+ });
86
+ expect(line).toBe(screen.getByTestId("s-row-email-separator-line"));
87
+ });
88
+
89
+ it("insets a separator past a leading icon by the icon and the cell's gap", () => {
90
+ render(<SettingsPage testID="s" sections={sections} />);
91
+ const children = Array.from(screen.getByTestId("s-row-name-separator").children);
92
+ expect(children.map((c) => c.className)).toEqual(expect.arrayContaining(["w-4", "mr-3"]));
93
+ expect(children[1]!.className).toBe("mr-3");
94
+ expect(styleOf(children[1]!)).toHaveProperty("width");
95
+ });
96
+
97
+ it("stops separators short of the trailing edge from iOS 26", () => {
98
+ Platform.Version = "18.4";
99
+ const { unmount } = render(<SettingsPage testID="s" sections={sections} />);
100
+ expect(screen.getByTestId("s-row-email-separator").children).toHaveLength(2);
101
+ unmount();
102
+ Platform.Version = "26.0";
103
+ render(<SettingsPage testID="s" sections={sections} />);
104
+ expect(screen.getByTestId("s-row-email-separator").children).toHaveLength(3);
105
+ });
106
+
107
+ it("puts the footnote under the group in secondaryLabel, aligned like the header", () => {
108
+ render(<SettingsPage testID="s" sections={sections} />);
109
+ const footnote = screen.getByText("Only you see this.");
110
+ expect(styleOf(footnote)).toMatchObject({
111
+ color: { semantic: ["secondaryLabel"] },
112
+ fontSize: 13,
113
+ marginHorizontal: 16,
114
+ });
115
+ expect(footnote.className).toContain("px-4");
116
+ const group = screen.getByTestId("s-section-account-group");
117
+ expect(group.compareDocumentPosition(footnote) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
118
+ });
119
+ });
120
+
121
+ describe("SettingsPage on Android (Material)", () => {
122
+ it("renders the header as a primary-colored subheader, not uppercase, with no band", () => {
123
+ Platform.OS = "android";
124
+ render(<SettingsPage testID="s" sections={sections} />);
125
+ const header = screen.getByTestId("s-section-account-header");
126
+ expect(header.getAttribute("role")).toBe("header");
127
+ expect(header.className).toContain("text-primary");
128
+ expect(header.className).not.toMatch(/\bbg-|\bborder/);
129
+ const style = styleOf(header);
130
+ expect(style.textTransform).toBeUndefined();
131
+ expect(style.backgroundColor).toBeUndefined();
132
+ });
133
+
134
+ it("keeps full-width cells and colors the footnote from the theme roles", () => {
135
+ Platform.OS = "android";
136
+ render(<SettingsPage testID="s" sections={sections} />);
137
+ const group = screen.getByTestId("s-section-account-group");
138
+ expect(styleOf(group).borderRadius).toBeUndefined();
139
+ expect(group.className).toContain("border-y");
140
+ expect(typeof styleOf(screen.getByText("Only you see this.")).color).toBe("string");
141
+ });
142
+ });