@marktiderman/genesis-ui-native 2.2.0 → 2.3.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 (77) 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-ULS7I6ZS.js → chunk-ERHGCWTY.js} +81 -12
  9. package/dist/chunk-ERHGCWTY.js.map +1 -0
  10. package/dist/{chunk-2WCXMJL6.js → chunk-FIITITXO.js} +67 -108
  11. package/dist/chunk-FIITITXO.js.map +1 -0
  12. package/dist/chunk-FZY2IXOX.js +1559 -0
  13. package/dist/chunk-FZY2IXOX.js.map +1 -0
  14. package/dist/{chunk-TXJT55JC.js → chunk-W7BK3ARU.js} +715 -293
  15. package/dist/chunk-W7BK3ARU.js.map +1 -0
  16. package/dist/components/index.d.ts +142 -17
  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 +47 -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 +320 -4
  28. package/dist/layouts/index.js +3 -3
  29. package/dist/native-modules-BSVaEb3D.d.ts +206 -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 +70 -0
  33. package/src/__tests__/native-modules.test.tsx +631 -0
  34. package/src/components/__tests__/sheet.test.tsx +193 -0
  35. package/src/components/__tests__/toast.test.tsx +15 -0
  36. package/src/components/avatar.tsx +69 -16
  37. package/src/components/date-time-picker.tsx +128 -10
  38. package/src/components/drawer.tsx +158 -68
  39. package/src/components/dropdown-menu.tsx +7 -6
  40. package/src/components/glass-surface.tsx +150 -0
  41. package/src/components/icon.tsx +66 -0
  42. package/src/components/image.tsx +89 -0
  43. package/src/components/index.ts +33 -2
  44. package/src/components/list-item.tsx +29 -9
  45. package/src/components/popover.tsx +12 -9
  46. package/src/components/segmented-control.tsx +7 -1
  47. package/src/components/sheet.tsx +276 -133
  48. package/src/components/skeleton.tsx +75 -53
  49. package/src/components/toast.tsx +185 -87
  50. package/src/data/NativeResourcePage.tsx +48 -3
  51. package/src/data/__tests__/resource-page-offline.test.tsx +47 -0
  52. package/src/hooks/use-reduced-motion.ts +24 -10
  53. package/src/icon-names.ts +49 -0
  54. package/src/icons/lucide.ts +88 -0
  55. package/src/layouts/__tests__/google-sign-in.test.tsx +26 -0
  56. package/src/layouts/__tests__/inbox-page.test.tsx +155 -0
  57. package/src/layouts/__tests__/keyboard-scroll.test.tsx +42 -1
  58. package/src/layouts/__tests__/settings-page-native-look.test.tsx +142 -0
  59. package/src/layouts/__tests__/thread-page.test.tsx +128 -0
  60. package/src/layouts/auth-screen.tsx +6 -3
  61. package/src/layouts/google-sign-in.tsx +42 -0
  62. package/src/layouts/inbox-page.tsx +408 -0
  63. package/src/layouts/index.ts +37 -2
  64. package/src/layouts/keyboard.tsx +61 -9
  65. package/src/layouts/notifications-page.tsx +133 -16
  66. package/src/layouts/settings-page.tsx +117 -14
  67. package/src/layouts/settings-sub-page.tsx +9 -3
  68. package/src/layouts/thread-page.tsx +444 -0
  69. package/src/native-modules.tsx +186 -0
  70. package/dist/chunk-2WCXMJL6.js.map +0 -1
  71. package/dist/chunk-5HRGIA6F.js.map +0 -1
  72. package/dist/chunk-F2TGDKOO.js +0 -43
  73. package/dist/chunk-F2TGDKOO.js.map +0 -1
  74. package/dist/chunk-FZTUSM56.js +0 -935
  75. package/dist/chunk-FZTUSM56.js.map +0 -1
  76. package/dist/chunk-TXJT55JC.js.map +0 -1
  77. package/dist/chunk-ULS7I6ZS.js.map +0 -1
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Layer-2 primitive: ScreenContainer (composable chrome).
5
5
  * Layer-3/4 layouts: SettingsPage, SettingsSubPage, NotificationsPage,
6
- * AuthScreen (assembled from AuthForm + SocialAuthRow + AuthBranding).
6
+ * InboxPage, ThreadPage, AuthScreen (assembled from AuthForm +
7
+ * SocialAuthRow + AuthBranding).
7
8
  *
8
9
  * See standards/usage-doctrine.md for the Layer 1-4 progression.
9
10
  */
@@ -46,11 +47,36 @@ export {
46
47
  export {
47
48
  NotificationsPage,
48
49
  getNotificationsPageStackOptions,
50
+ defaultStickyHeaderOffset,
51
+ iosCompactNavigationBarHeight,
49
52
  type NotificationsPageProps,
50
53
  type NotificationsPageSlotMap,
51
54
  type NotificationItem,
52
55
  } from "./notifications-page";
53
56
 
57
+ export {
58
+ InboxPage,
59
+ formatInboxTime,
60
+ getInboxPageStackOptions,
61
+ showInboxActions,
62
+ type InboxItem,
63
+ type InboxPageProps,
64
+ type InboxPageSlotMap,
65
+ type InboxSwipeAction,
66
+ } from "./inbox-page";
67
+
68
+ export {
69
+ ThreadPage,
70
+ getThreadPageStackOptions,
71
+ readReceiptFor,
72
+ type ThreadAttachment,
73
+ type ThreadComposer,
74
+ type ThreadLabels,
75
+ type ThreadMessage,
76
+ type ThreadPageProps,
77
+ type ThreadPageSlotMap,
78
+ } from "./thread-page";
79
+
54
80
  export {
55
81
  AuthForm,
56
82
  SocialAuthRow,
@@ -64,7 +90,14 @@ export {
64
90
  } from "./auth";
65
91
 
66
92
  export { AuthScreen, type AuthScreenProps, type AuthScreenSlotMap } from "./auth-screen";
67
- export { KeyboardScrollProvider, useKeyboardScroll, type KeyboardScrollProps } from "./keyboard";
93
+ export {
94
+ KEYBOARD_TOOLBAR_HEIGHT,
95
+ KeyboardScrollProvider,
96
+ useKeyboardScroll,
97
+ useKeyboardToolbar,
98
+ type KeyboardScrollProps,
99
+ type KeyboardToolbarProps,
100
+ } from "./keyboard";
68
101
 
69
102
  export {
70
103
  AppleSignInButton,
@@ -73,3 +106,5 @@ export {
73
106
  type AppleProviderOptions,
74
107
  type AppleSignInButtonProps,
75
108
  } from "./apple-sign-in";
109
+
110
+ export { googleProvider, type GoogleProviderOptions } from "./google-sign-in";
@@ -4,15 +4,24 @@
4
4
  * `KeyboardAvoidingView` for real apps; it is an optional peer here, so an app
5
5
  * that has it passes it once:
6
6
  *
7
- * import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
8
- * <KeyboardScrollProvider component={KeyboardAwareScrollView}>…</KeyboardScrollProvider>
7
+ * import { KeyboardAwareScrollView, KeyboardProvider, KeyboardToolbar } from "react-native-keyboard-controller";
8
+ * <KeyboardProvider>
9
+ * <KeyboardScrollProvider component={KeyboardAwareScrollView} toolbar={KeyboardToolbar}>…</KeyboardScrollProvider>
10
+ * </KeyboardProvider>
9
11
  *
10
- * (The native app shell does this for you.) Without it, form screens fall back
11
- * to `KeyboardAvoidingView`.
12
+ * `KeyboardAwareScrollView` does nothing without react-native-keyboard-controller's
13
+ * `KeyboardProvider` above it, mounted once at the root. (The native app
14
+ * shell does both, with `keyboardProvider` and `keyboardScroll`.) Without a
15
+ * scroll view here, form screens fall back to `KeyboardAvoidingView`.
16
+ *
17
+ * `toolbar` (optional, `KeyboardToolbar`) adds the previous / next / done bar
18
+ * above the keyboard on Genesis's multi-field form layouts (`AuthScreen`,
19
+ * `SettingsSubPage`). It needs `component` too: the bar sits beside the
20
+ * keyboard-aware scroll view. Without it, nothing changes.
12
21
  *
13
22
  * @stability Beta
14
23
  */
15
- import { createContext, createElement, useContext, type ComponentType, type ReactNode } from "react";
24
+ import { createContext, createElement, useContext, useMemo, type ComponentType, type ReactNode } from "react";
16
25
  import type { ViewStyle } from "react-native";
17
26
 
18
27
  /** The props Genesis passes to a keyboard-aware scroll view. */
@@ -27,13 +36,56 @@ export interface KeyboardScrollProps {
27
36
  bottomOffset?: number;
28
37
  }
29
38
 
30
- const KeyboardScrollContext = createContext<ComponentType<KeyboardScrollProps> | null>(null);
39
+ /**
40
+ * The props Genesis may pass to a keyboard toolbar, all optional and all
41
+ * `KeyboardToolbar`'s own: a settings form passes none (previous / next /
42
+ * done), a one-question form (forms-native's `FormFocus`) hides the arrows
43
+ * and makes Done its Next or Send. To theme it, pass a wrapper defined at
44
+ * module scope that renders it with your props and forwards these.
45
+ */
46
+ export interface KeyboardToolbarProps {
47
+ /** Show the previous / next arrows. `KeyboardToolbar`'s default is true. */
48
+ showArrows?: boolean;
49
+ /** The done button's label. */
50
+ doneText?: ReactNode;
51
+ /** Called when done is pressed. The keyboard closes too, unless the callback calls `event.preventDefault()`. */
52
+ onDoneCallback?: (event: { preventDefault(): void }) => void;
53
+ }
54
+
55
+ /**
56
+ * Height of react-native-keyboard-controller's `KeyboardToolbar`, kept clear
57
+ * above the focused input. Mirrors `KEYBOARD_TOOLBAR_HEIGHT` in the library's
58
+ * `src/components/KeyboardToolbar/constants.ts` (1.22): move them together.
59
+ */
60
+ export const KEYBOARD_TOOLBAR_HEIGHT = 42;
61
+
62
+ interface KeyboardScrollValue {
63
+ component: ComponentType<KeyboardScrollProps>;
64
+ toolbar: ComponentType<KeyboardToolbarProps> | null;
65
+ }
66
+
67
+ const KeyboardScrollContext = createContext<KeyboardScrollValue | null>(null);
31
68
 
32
- export function KeyboardScrollProvider({ component, children }: { component: ComponentType<KeyboardScrollProps>; children: ReactNode }) {
33
- return createElement(KeyboardScrollContext.Provider, { value: component }, children);
69
+ export function KeyboardScrollProvider({
70
+ component,
71
+ toolbar,
72
+ children,
73
+ }: {
74
+ component: ComponentType<KeyboardScrollProps>;
75
+ /** `KeyboardToolbar` from react-native-keyboard-controller: previous / next / done above the keyboard. */
76
+ toolbar?: ComponentType<KeyboardToolbarProps>;
77
+ children: ReactNode;
78
+ }) {
79
+ const value = useMemo(() => ({ component, toolbar: toolbar ?? null }), [component, toolbar]);
80
+ return createElement(KeyboardScrollContext.Provider, { value }, children);
34
81
  }
35
82
 
36
83
  /** The app's keyboard-aware scroll view, or null when none was provided. */
37
84
  export function useKeyboardScroll(): ComponentType<KeyboardScrollProps> | null {
38
- return useContext(KeyboardScrollContext);
85
+ return useContext(KeyboardScrollContext)?.component ?? null;
86
+ }
87
+
88
+ /** The app's keyboard toolbar, or null when none was provided (or no scroll view to go with it). */
89
+ export function useKeyboardToolbar(): ComponentType<KeyboardToolbarProps> | null {
90
+ return useContext(KeyboardScrollContext)?.toolbar ?? null;
39
91
  }
@@ -20,20 +20,23 @@
20
20
  *
21
21
  * @stability Beta
22
22
  */
23
- import { useMemo, type ReactNode } from "react";
23
+ import { useCallback, useContext, useMemo, type ReactNode } from "react";
24
24
  import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
25
25
  import {
26
+ Platform,
26
27
  Pressable,
27
28
  RefreshControl,
29
+ ScrollView,
28
30
  SectionList,
29
31
  Text,
30
32
  View,
31
33
  } from "react-native";
32
- import { SafeAreaView } from "react-native-safe-area-context";
34
+ import { SafeAreaInsetsContext, SafeAreaView } from "react-native-safe-area-context";
33
35
  import { NativeSectionListHeader } from "../components/section-list";
34
36
  import { NativeListItem } from "../components/list-item";
35
37
  import { NativeEmptyState } from "../components/empty-state";
36
38
  import { cn } from "../utils";
39
+ import { useGenesisModules } from "../native-modules";
37
40
  import {
38
41
  composeHeaderOptions,
39
42
  type ScreenHeaderProps,
@@ -84,6 +87,16 @@ export interface NotificationsPageProps extends ScreenHeaderProps {
84
87
  emptyTitle?: string;
85
88
  /** Optional override of the empty-state body copy. */
86
89
  emptyBody?: string;
90
+ /**
91
+ * Where a section header sticks, in points from the top of the list. Under a large-title header
92
+ * (`getNotificationsPageStackOptions`' default) the list runs under the native header (iOS
93
+ * insets its rows, and the title collapses as it scrolls), so a header stuck at 0 would sit
94
+ * under the status bar. Default on iOS: under the collapsed navigation bar of an iPhone in
95
+ * portrait (`defaultStickyHeaderOffset`); elsewhere 0. Pass 0 when the list starts below an
96
+ * opaque header (a standard one before iOS 26), the safe area's top with no header, and your own
97
+ * value on iPad (a 50 pt bar) or in landscape (32 pt).
98
+ */
99
+ stickyHeaderOffset?: number;
87
100
  /** Override root container styling. */
88
101
  className?: string;
89
102
  /** testID on the root container. Default `"notifications-page"`. */
@@ -182,8 +195,50 @@ function groupByDate(items: NotificationItem[], now = new Date()): Section[] {
182
195
  }));
183
196
  }
184
197
 
198
+ type FlatRow = { kind: "header"; title: string } | { kind: "item"; item: NotificationItem; last: boolean };
199
+
200
+ function flattenSections(sections: Section[]): { rows: FlatRow[]; headerIndices: number[] } {
201
+ const rows: FlatRow[] = [];
202
+ const headerIndices: number[] = [];
203
+ for (const section of sections) {
204
+ headerIndices.push(rows.length);
205
+ rows.push({ kind: "header", title: section.title });
206
+ section.data.forEach((item, i) => rows.push({ kind: "item", item, last: i === section.data.length - 1 }));
207
+ }
208
+ return { rows, headerIndices };
209
+ }
210
+
211
+ function flatRowKey(row: FlatRow) {
212
+ return row.kind === "header" ? `header:${row.title}` : row.item.id;
213
+ }
214
+
215
+ /** A row with its separator and the section's last row differ in height: separate recycling pools. */
216
+ function flatRowType(row: FlatRow) {
217
+ return row.kind === "header" ? "header" : row.last ? "item-last" : "item";
218
+ }
219
+
220
+ const NO_SLOTS = {};
221
+
222
+ /**
223
+ * The height of iOS's compact navigation bar, below the status bar: 44 pt up to iOS 18, 54 pt
224
+ * from iOS 26 (measured on an iOS 26 simulator, the collapsed large-title bar of a native stack).
225
+ */
226
+ export function iosCompactNavigationBarHeight(version: number | string): number {
227
+ const major = typeof version === "number" ? version : parseInt(version, 10);
228
+ return Number.isFinite(major) && major >= 26 ? 54 : 44;
229
+ }
230
+
231
+ /**
232
+ * Where a list's section headers stick by default: on iOS, the bottom of the collapsed
233
+ * navigation bar (the safe area's top plus the compact bar), since the list runs under the
234
+ * header; elsewhere 0 (the header sits above the list).
235
+ */
236
+ export function defaultStickyHeaderOffset(os: string, version: number | string, safeAreaTop: number): number {
237
+ return os === "ios" ? safeAreaTop + iosCompactNavigationBarHeight(version) : 0;
238
+ }
239
+
185
240
  // Expose internal helpers for unit tests via a side-channel export.
186
- export const __test = { bucketFor, groupByDate };
241
+ export const __test = { bucketFor, groupByDate, flattenSections };
187
242
 
188
243
  export function NotificationsPage({
189
244
  items,
@@ -194,34 +249,92 @@ export function NotificationsPage({
194
249
  emptyBody,
195
250
  className,
196
251
  testID = "notifications-page",
197
- slots = {},
198
- slotProps = {},
252
+ slots = NO_SLOTS,
253
+ slotProps = NO_SLOTS,
254
+ stickyHeaderOffset,
199
255
  }: NotificationsPageProps) {
256
+ // The context, not useSafeAreaInsets(): before a provider has measured (tests, the first frame) it is null, not a throw.
257
+ const safeTop = useContext(SafeAreaInsetsContext)?.top ?? 0;
258
+ const stickAt = stickyHeaderOffset ?? defaultStickyHeaderOffset(Platform.OS, Platform.Version, safeTop);
200
259
  // Note: header props (headerTitle, headerLeft, headerRight, large,
201
260
  // scrollEdgeBehavior, headerOptions) are accepted on the type for API
202
261
  // ergonomics but consumed by getNotificationsPageStackOptions() at the
203
262
  // consumer's <Stack.Screen> level — not by this component.
204
263
 
205
264
  const sections = useMemo(() => groupByDate(items), [items]);
265
+ // FlashList v2 (`modules.list`) has no SectionList: the sections become one
266
+ // flat list whose header rows stick (FlashList's own section-list recipe).
267
+ const { list: FlashList } = useGenesisModules();
268
+ const flat = useMemo(() => flattenSections(sections), [sections]);
269
+ // Stable, so a parent re-render doesn't re-render every visible cell.
270
+ const renderFlatRow = useCallback(
271
+ ({ item: row }: { item: FlatRow }) =>
272
+ row.kind === "header" ? (
273
+ renderSlot(DefaultSectionHeader, slots.sectionHeader, { title: row.title }, slotProps.sectionHeader)
274
+ ) : (
275
+ <>
276
+ {renderSlot(DefaultRow, slots.row, { ...row.item, testID: row.item.testID ?? `${testID}-row-${row.item.id}` }, slotProps.row)}
277
+ {row.last ? null : <RowSeparator />}
278
+ </>
279
+ ),
280
+ [slots, slotProps, testID],
281
+ );
206
282
 
207
283
  if (items.length === 0) {
284
+ // A scroll view, like the lists below: iOS insets only scroll views for the large-title
285
+ // header and the tab bar, so a plain view would sit under the header (and the Dynamic Island).
286
+ return (
287
+ <SafeAreaView
288
+ testID={testID}
289
+ edges={["left", "right", "bottom"]}
290
+ className={cn("flex-1 bg-background", className)}
291
+ >
292
+ <ScrollView
293
+ testID={`${testID}-empty-scroll`}
294
+ contentInsetAdjustmentBehavior="automatic"
295
+ contentContainerStyle={{ flexGrow: 1, justifyContent: "center" }}
296
+ refreshControl={
297
+ onRefresh ? (
298
+ <RefreshControl testID={`${testID}-refresh`} refreshing={!!refreshing} onRefresh={onRefresh} />
299
+ ) : undefined
300
+ }
301
+ >
302
+ {emptyState ??
303
+ renderSlot(
304
+ DefaultEmpty,
305
+ slots.empty,
306
+ {
307
+ title: emptyTitle ?? "No notifications",
308
+ body: emptyBody ?? "When you get a notification, it'll show up here.",
309
+ testID: `${testID}-empty`,
310
+ },
311
+ slotProps.empty,
312
+ )}
313
+ </ScrollView>
314
+ </SafeAreaView>
315
+ );
316
+ }
317
+
318
+ if (FlashList) {
208
319
  return (
209
320
  <SafeAreaView
210
321
  testID={testID}
211
322
  edges={["left", "right", "bottom"]}
212
323
  className={cn("flex-1 bg-background", className)}
213
324
  >
214
- {emptyState ??
215
- renderSlot(
216
- DefaultEmpty,
217
- slots.empty,
218
- {
219
- title: emptyTitle ?? "No notifications",
220
- body: emptyBody ?? "When you get a notification, it'll show up here.",
221
- testID: `${testID}-empty`,
222
- },
223
- slotProps.empty,
224
- )}
325
+ <FlashList
326
+ testID={`${testID}-list`}
327
+ data={flat.rows}
328
+ keyExtractor={flatRowKey}
329
+ getItemType={flatRowType}
330
+ stickyHeaderIndices={flat.headerIndices}
331
+ // Under the native header, not under the status bar.
332
+ stickyHeaderConfig={{ offset: stickAt }}
333
+ renderItem={renderFlatRow}
334
+ refreshing={onRefresh ? !!refreshing : undefined}
335
+ onRefresh={onRefresh ? () => void onRefresh() : undefined}
336
+ contentContainerStyle={{ paddingBottom: 28 }}
337
+ />
225
338
  </SafeAreaView>
226
339
  );
227
340
  }
@@ -243,6 +356,10 @@ export function NotificationsPage({
243
356
  renderSlot(DefaultRow, slots.row, { ...item, testID: item.testID ?? `${testID}-row-${item.id}` }, slotProps.row)
244
357
  }
245
358
  ItemSeparatorComponent={RowSeparator}
359
+ // React Native's sticky headers pin to the very top of the list, which is under the native
360
+ // header on iOS, with no offset to move them down: with one, the headers scroll with
361
+ // their rows instead. (FlashList, `modules.list`, sticks them under the header.)
362
+ stickySectionHeadersEnabled={stickAt === 0}
246
363
  refreshControl={
247
364
  onRefresh ? (
248
365
  <RefreshControl
@@ -14,9 +14,15 @@
14
14
  * passthrough. The composed options are rendered via the consumer's own
15
15
  * `<Stack.Screen options={...}>` — see `getStackScreenOptions()` helper.
16
16
  *
17
- * Colors come from theme roles: on iOS the page is `systemGroupedBackground`
18
- * with inset, rounded cells on `secondarySystemGroupedBackground`, like the
19
- * Settings app; elsewhere, full-width cells on the Genesis tokens.
17
+ * Colors come from theme roles (`useThemeRoles`). On iOS it is the Settings
18
+ * app's inset grouped style: the page is `systemGroupedBackground`, each
19
+ * section a rounded group of cells on `secondarySystemGroupedBackground` with
20
+ * hairline `separator` lines between cells, inset from the leading edge to
21
+ * the cell text; the header is an uppercase footnote in `secondaryLabel`
22
+ * above the group and the footnote sits under it in the same color. On
23
+ * Android, cells are full width and the header is a Material subheader in the
24
+ * theme's primary color. Neither platform draws a band or a rule behind a
25
+ * header. Cell content itself is `NativeListItem`'s.
20
26
  *
21
27
  * Slots: replace or drop one part without leaving the layout. `slots`
22
28
  * swaps a part (`sectionHeader`, `row`, `footnote`, `dangerousActions`) for
@@ -28,12 +34,11 @@
28
34
  *
29
35
  * @stability Beta
30
36
  */
31
- import { Fragment, type ReactNode } from "react";
37
+ import { Fragment, useState, type ReactNode } from "react";
32
38
  import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
33
- import { Platform, View } from "react-native";
39
+ import { Platform, StyleSheet, View } from "react-native";
34
40
  import { useThemeRoles } from "../hooks/use-theme-roles";
35
- import { NativeListItem, NativeListItemDivider } from "../components/list-item";
36
- import { NativeSectionListHeader } from "../components/section-list";
41
+ import { NativeListItem } from "../components/list-item";
37
42
  import { NativeText } from "../components/text";
38
43
  import { NativeButton } from "../components/button";
39
44
  import { cn } from "../utils";
@@ -71,6 +76,12 @@ export interface SettingsPageSection {
71
76
  footnote?: string;
72
77
  /** Rows in render order. */
73
78
  rows: SettingsPageRow[];
79
+ /**
80
+ * Content rendered inside the section's group, after the rows: a part that
81
+ * a pattern built on SettingsPage lets you replace (a block's slot), kept
82
+ * under the same header, in the same group and above the same footnote.
83
+ */
84
+ children?: ReactNode;
74
85
  }
75
86
 
76
87
  /** A destructive-tone action in the footer, e.g. "Sign out". */
@@ -170,8 +181,12 @@ export function SettingsPage({
170
181
  )
171
182
  : null}
172
183
  <View
173
- className={inset ? "mx-4 overflow-hidden rounded-xl" : "border-y"}
174
- style={{ backgroundColor: colors.surface, borderColor: colors.separator }}
184
+ testID={`${testID}-section-${section.id}-group`}
185
+ className={inset ? "overflow-hidden" : "border-y"}
186
+ style={[
187
+ { backgroundColor: colors.surface, borderColor: colors.separator },
188
+ inset ? { marginHorizontal: IOS_GROUP_MARGIN, borderRadius: iosGroupRadius() } : null,
189
+ ]}
175
190
  >
176
191
  {section.rows.map((row, rowIndex) => (
177
192
  <Fragment key={row.id}>
@@ -183,6 +198,7 @@ export function SettingsPage({
183
198
  )}
184
199
  </Fragment>
185
200
  ))}
201
+ {section.children}
186
202
  </View>
187
203
  {section.footnote
188
204
  ? renderSlot(DefaultFootnote, slots.footnote, { text: section.footnote }, slotProps.footnote)
@@ -205,11 +221,69 @@ export function SettingsPage({
205
221
  );
206
222
  }
207
223
 
224
+ /** UIKit's inset grouped margin on a phone, in points. */
225
+ const IOS_GROUP_MARGIN = 16;
226
+
227
+ /** UIKit's inset grouped corner radius: 10pt through iOS 18, 26pt from iOS 26. */
228
+ function iosGroupRadius(): number {
229
+ return Number.parseFloat(String(Platform.Version)) >= 26 ? 26 : 10;
230
+ }
231
+
232
+ /** From iOS 26 a separator also stops short of the trailing edge. */
233
+ function iosTrailingSeparatorInset(): boolean {
234
+ return Platform.OS === "ios" && Number.parseFloat(String(Platform.Version)) >= 26;
235
+ }
236
+
237
+ /**
238
+ * iOS: the Settings app's inset grouped header, an uppercase footnote in
239
+ * `secondaryLabel` on the page background. It sits over the group (same
240
+ * margin) and is padded like a cell (`px-4`), so it lines up with the cell
241
+ * text. Android: a Material list subheader in the brand's primary color
242
+ * (`text-primary`, which follows the app's theme). Neither draws a band or a
243
+ * rule. iOS reads uppercased text as written in capitals, so the label is the
244
+ * title as written, and VoiceOver doesn't spell short words out.
245
+ */
208
246
  function DefaultSectionHeader({ title, testID }: SettingsPageSlotMap["sectionHeader"]) {
209
- return <NativeSectionListHeader title={title} testID={testID} />;
247
+ const colors = useThemeRoles();
248
+ if (Platform.OS === "ios") {
249
+ return (
250
+ <NativeText
251
+ testID={testID}
252
+ accessibilityRole="header"
253
+ accessibilityLabel={title}
254
+ dynamicTypeRamp="footnote"
255
+ className="px-4 pb-1.5 pt-2"
256
+ style={{
257
+ marginHorizontal: IOS_GROUP_MARGIN,
258
+ color: colors.secondaryLabel,
259
+ fontSize: 13,
260
+ lineHeight: 18,
261
+ textTransform: "uppercase",
262
+ }}
263
+ >
264
+ {title}
265
+ </NativeText>
266
+ );
267
+ }
268
+ return (
269
+ <NativeText
270
+ testID={testID}
271
+ accessibilityRole="header"
272
+ className="px-4 pb-2 pt-4 text-primary"
273
+ style={{ fontSize: 14, lineHeight: 20, fontWeight: "500" }}
274
+ >
275
+ {title}
276
+ </NativeText>
277
+ );
210
278
  }
211
279
 
212
- function DefaultRow({ isLast, id: _id, ...row }: SettingsPageSlotMap["row"]) {
280
+ function DefaultRow({ isLast, id: _id, leading, ...row }: SettingsPageSlotMap["row"]) {
281
+ const colors = useThemeRoles();
282
+ // A separator starts at the cell text: the same `px-4` (and `mr-3` past a
283
+ // leading icon, measured once it lays out) as `NativeListItem`, so it lines
284
+ // up whatever the NativeWind rem is. A row lays out start to end, so this
285
+ // follows right-to-left layouts too.
286
+ const [leadingWidth, setLeadingWidth] = useState(0);
213
287
  return (
214
288
  <>
215
289
  <NativeListItem
@@ -218,20 +292,49 @@ function DefaultRow({ isLast, id: _id, ...row }: SettingsPageSlotMap["row"]) {
218
292
  className="bg-transparent"
219
293
  title={row.title}
220
294
  subtitle={row.subtitle}
221
- leading={row.leading}
295
+ leading={
296
+ leading ? (
297
+ <View onLayout={(event) => setLeadingWidth(event.nativeEvent.layout.width)}>{leading}</View>
298
+ ) : undefined
299
+ }
222
300
  trailing={row.trailing}
223
301
  showChevron={row.showChevron}
224
302
  onPress={row.onPress}
225
303
  disabled={row.disabled}
226
304
  />
227
- {isLast ? null : <NativeListItemDivider className="ml-4" />}
305
+ {isLast ? null : (
306
+ <View
307
+ testID={`${row.testID}-separator`}
308
+ accessibilityElementsHidden
309
+ importantForAccessibility="no-hide-descendants"
310
+ className="flex-row"
311
+ style={{ height: StyleSheet.hairlineWidth }}
312
+ >
313
+ <View className="w-4" />
314
+ {leading ? <View className="mr-3" style={{ width: leadingWidth }} /> : null}
315
+ <View testID={`${row.testID}-separator-line`} className="flex-1" style={{ backgroundColor: colors.separator }} />
316
+ {iosTrailingSeparatorInset() ? <View className="w-4" /> : null}
317
+ </View>
318
+ )}
228
319
  </>
229
320
  );
230
321
  }
231
322
 
232
323
  function DefaultFootnote({ text }: SettingsPageSlotMap["footnote"]) {
324
+ const colors = useThemeRoles();
325
+ if (Platform.OS === "ios") {
326
+ return (
327
+ <NativeText
328
+ dynamicTypeRamp="footnote"
329
+ className="px-4 pt-1.5"
330
+ style={{ marginHorizontal: IOS_GROUP_MARGIN, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18 }}
331
+ >
332
+ {text}
333
+ </NativeText>
334
+ );
335
+ }
233
336
  return (
234
- <NativeText preset="body-sm" className="px-4 pt-2 text-muted-foreground">
337
+ <NativeText preset="body-sm" className="px-4 pt-2" style={{ color: colors.secondaryLabel }}>
235
338
  {text}
236
339
  </NativeText>
237
340
  );
@@ -19,7 +19,7 @@
19
19
  import { useCallback, type ReactNode } from "react";
20
20
  import { Alert, KeyboardAvoidingView, Platform, View } from "react-native";
21
21
  import { cn } from "../utils";
22
- import { useKeyboardScroll } from "./keyboard";
22
+ import { KEYBOARD_TOOLBAR_HEIGHT, useKeyboardScroll, useKeyboardToolbar } from "./keyboard";
23
23
  import {
24
24
  ScreenContainer,
25
25
  composeHeaderOptions,
@@ -163,14 +163,19 @@ export function SettingsSubPage({
163
163
  void _onConfirmLeave;
164
164
 
165
165
  const KeyboardScroll = useKeyboardScroll();
166
+ const KeyboardToolbar = useKeyboardToolbar();
166
167
  if (KeyboardScroll) {
168
+ // No bottom edge here: the toolbar sticks to the keyboard from the container's bottom, so a
169
+ // bottom inset (the home indicator, or a tab bar's height) would float it that far above the
170
+ // keyboard, and leave it showing above the tab bar with the keyboard closed. The scroll view's
171
+ // automatic content inset keeps the last field clear of the bottom instead.
167
172
  return (
168
- <ScreenContainer safeAreaEdges={["left", "right", "bottom"]} testID={testID}>
173
+ <ScreenContainer safeAreaEdges={["left", "right"]} testID={testID}>
169
174
  <KeyboardScroll
170
175
  testID={`${testID}-keyboard`}
171
176
  keyboardShouldPersistTaps="handled"
172
177
  contentInsetAdjustmentBehavior="automatic"
173
- bottomOffset={24}
178
+ bottomOffset={KeyboardToolbar ? 24 + KEYBOARD_TOOLBAR_HEIGHT : 24}
174
179
  >
175
180
  {/* Same padding and className as the fallback path, so `className` overrides it the same way. */}
176
181
  <View className={cn("p-4", className)}>
@@ -179,6 +184,7 @@ export function SettingsSubPage({
179
184
  </View>
180
185
  </View>
181
186
  </KeyboardScroll>
187
+ {KeyboardToolbar ? <KeyboardToolbar /> : null}
182
188
  </ScreenContainer>
183
189
  );
184
190
  }