@marktiderman/genesis-ui-native 2.1.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.
- package/README.md +134 -0
- package/dist/chunk-7PCWEY6R.js +27 -0
- package/dist/chunk-7PCWEY6R.js.map +1 -0
- package/dist/chunk-D5RKSPMH.js +24 -0
- package/dist/chunk-D5RKSPMH.js.map +1 -0
- package/dist/{chunk-5HRGIA6F.js → chunk-EFXCJ5AN.js} +76 -3
- package/dist/chunk-EFXCJ5AN.js.map +1 -0
- package/dist/{chunk-ULS7I6ZS.js → chunk-ERHGCWTY.js} +81 -12
- package/dist/chunk-ERHGCWTY.js.map +1 -0
- package/dist/{chunk-3LK5ZJ4M.js → chunk-FIITITXO.js} +67 -108
- package/dist/chunk-FIITITXO.js.map +1 -0
- package/dist/chunk-FZY2IXOX.js +1559 -0
- package/dist/chunk-FZY2IXOX.js.map +1 -0
- package/dist/{chunk-TXJT55JC.js → chunk-W7BK3ARU.js} +715 -293
- package/dist/chunk-W7BK3ARU.js.map +1 -0
- package/dist/components/index.d.ts +143 -17
- package/dist/components/index.js +6 -4
- package/dist/data/index.d.ts +7 -1
- package/dist/data/index.js +31 -6
- package/dist/data/index.js.map +1 -1
- package/dist/hooks/index.js +2 -1
- package/dist/icons/lucide.d.ts +7 -0
- package/dist/icons/lucide.js +47 -0
- package/dist/icons/lucide.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +7 -6
- package/dist/layouts/index.d.ts +399 -7
- package/dist/layouts/index.js +3 -3
- package/dist/native-modules-BSVaEb3D.d.ts +206 -0
- package/package.json +34 -5
- package/src/__tests__/fake-modules.tsx +134 -0
- package/src/__tests__/native-modules-lists.test.tsx +70 -0
- package/src/__tests__/native-modules.test.tsx +631 -0
- package/src/components/__tests__/sheet.test.tsx +193 -0
- package/src/components/__tests__/toast.test.tsx +15 -0
- package/src/components/avatar.tsx +69 -16
- package/src/components/date-time-picker.tsx +128 -10
- package/src/components/drawer.tsx +158 -68
- package/src/components/dropdown-menu.tsx +7 -6
- package/src/components/glass-surface.tsx +150 -0
- package/src/components/icon.tsx +66 -0
- package/src/components/image.tsx +89 -0
- package/src/components/index.ts +33 -2
- package/src/components/list-item.tsx +29 -9
- package/src/components/popover.tsx +12 -9
- package/src/components/segmented-control.tsx +7 -1
- package/src/components/sheet.tsx +276 -133
- package/src/components/skeleton.tsx +75 -53
- package/src/components/textarea.tsx +1 -0
- package/src/components/toast.tsx +185 -87
- package/src/data/NativeResourcePage.tsx +48 -3
- package/src/data/__tests__/resource-page-offline.test.tsx +47 -0
- package/src/hooks/use-reduced-motion.ts +24 -10
- package/src/icon-names.ts +49 -0
- package/src/icons/lucide.ts +88 -0
- package/src/layouts/__tests__/apple-sign-in.test.tsx +97 -0
- package/src/layouts/__tests__/google-sign-in.test.tsx +26 -0
- package/src/layouts/__tests__/inbox-page.test.tsx +155 -0
- package/src/layouts/__tests__/keyboard-scroll.test.tsx +42 -1
- package/src/layouts/__tests__/settings-page-native-look.test.tsx +142 -0
- package/src/layouts/__tests__/thread-page.test.tsx +128 -0
- package/src/layouts/apple-sign-in.tsx +136 -0
- package/src/layouts/auth-screen.tsx +17 -8
- package/src/layouts/auth.tsx +29 -19
- package/src/layouts/google-sign-in.tsx +42 -0
- package/src/layouts/inbox-page.tsx +408 -0
- package/src/layouts/index.ts +45 -2
- package/src/layouts/keyboard.tsx +61 -9
- package/src/layouts/notifications-page.tsx +133 -16
- package/src/layouts/screen-container.tsx +6 -2
- package/src/layouts/settings-page.tsx +117 -14
- package/src/layouts/settings-sub-page.tsx +9 -3
- package/src/layouts/thread-page.tsx +444 -0
- package/src/native-modules.tsx +186 -0
- package/dist/chunk-3LK5ZJ4M.js.map +0 -1
- package/dist/chunk-5HRGIA6F.js.map +0 -1
- package/dist/chunk-F2TGDKOO.js +0 -43
- package/dist/chunk-F2TGDKOO.js.map +0 -1
- package/dist/chunk-TXJT55JC.js.map +0 -1
- package/dist/chunk-U2SPACTV.js +0 -876
- package/dist/chunk-U2SPACTV.js.map +0 -1
- package/dist/chunk-ULS7I6ZS.js.map +0 -1
|
@@ -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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
|
@@ -139,6 +139,11 @@ export function composeHeaderOptions(
|
|
|
139
139
|
|
|
140
140
|
const DEFAULT_EDGES: SafeAreaEdge[] = ["left", "right"];
|
|
141
141
|
|
|
142
|
+
// A see-through Android status bar. React Native 0.88 dropped both props from StatusBar's types
|
|
143
|
+
// (Android is always edge to edge there, so they do nothing); earlier versions still need them.
|
|
144
|
+
// Spread untyped so the screen compiles against either.
|
|
145
|
+
const TRANSLUCENT_ANDROID_BAR: Record<string, unknown> = { translucent: true, backgroundColor: "transparent" };
|
|
146
|
+
|
|
142
147
|
/**
|
|
143
148
|
* Resolve the StatusBar bar style from the user's `statusBar` setting +
|
|
144
149
|
* the resolved theme mode. `"auto"` follows theme; explicit overrides
|
|
@@ -205,8 +210,7 @@ export function ScreenContainer({
|
|
|
205
210
|
| "light-content"
|
|
206
211
|
| "dark-content"
|
|
207
212
|
}
|
|
208
|
-
|
|
209
|
-
backgroundColor="transparent"
|
|
213
|
+
{...TRANSLUCENT_ANDROID_BAR}
|
|
210
214
|
/>
|
|
211
215
|
) : (
|
|
212
216
|
<StatusBar hidden />
|
|
@@ -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
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
|
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
|
-
|
|
174
|
-
|
|
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
|
-
|
|
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={
|
|
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 :
|
|
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
|
|
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"
|
|
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
|
}
|