@marktiderman/genesis-ui-native 2.3.0 → 2.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.
- package/dist/{chunk-FZY2IXOX.js → chunk-6TLBCRS6.js} +57 -29
- package/dist/chunk-6TLBCRS6.js.map +1 -0
- package/dist/{chunk-W7BK3ARU.js → chunk-7VSW3XWJ.js} +37 -35
- package/dist/chunk-7VSW3XWJ.js.map +1 -0
- package/dist/{chunk-ERHGCWTY.js → chunk-BPD5DCFP.js} +30 -4
- package/dist/chunk-BPD5DCFP.js.map +1 -0
- package/dist/components/index.d.ts +21 -4
- package/dist/components/index.js +2 -2
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/icons/lucide.js +22 -1
- package/dist/icons/lucide.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/layouts/index.d.ts +10 -1
- package/dist/layouts/index.js +2 -2
- package/dist/{native-modules-BSVaEb3D.d.ts → native-modules-_Q5vIbd5.d.ts} +21 -0
- package/package.json +1 -1
- package/src/__tests__/native-modules-lists.test.tsx +2 -0
- package/src/components/__tests__/full-screen-modal.test.tsx +52 -0
- package/src/components/__tests__/refresh-control.test.tsx +35 -0
- package/src/components/full-screen-modal.tsx +70 -0
- package/src/components/index.ts +3 -0
- package/src/components/refresh-control.tsx +11 -45
- package/src/icon-names.ts +21 -0
- package/src/icons/lucide.ts +42 -0
- package/src/layouts/__tests__/inbox-page.test.tsx +45 -0
- package/src/layouts/inbox-page.tsx +54 -7
- package/dist/chunk-ERHGCWTY.js.map +0 -1
- package/dist/chunk-FZY2IXOX.js.map +0 -1
- package/dist/chunk-W7BK3ARU.js.map +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FullScreenModal — content that takes the whole screen over the app: a
|
|
3
|
+
* photo or video viewer, a camera, a scanner.
|
|
4
|
+
*
|
|
5
|
+
* React Native's `Modal`, over the whole screen on both platforms
|
|
6
|
+
* (`overFullScreen` on iOS; under the system bars on Android), faded in (no
|
|
7
|
+
* animation with Reduce Motion). `tone="dark"` (the default) is a black
|
|
8
|
+
* backdrop with light status bar content, for media; `tone="app"` is the
|
|
9
|
+
* theme's background; `tone="none"` draws no backdrop, for content that
|
|
10
|
+
* draws its own (a viewer that fades to show the app as it's dragged away,
|
|
11
|
+
* with `FULL_SCREEN_DARK` behind it). Content
|
|
12
|
+
* gets its own safe area (`useSafeAreaInsets` inside is the modal's) and
|
|
13
|
+
* places its own close control: Android back and the VoiceOver escape
|
|
14
|
+
* gesture call `onOpenChange(false)`.
|
|
15
|
+
*
|
|
16
|
+
* For a short task over the app, use <NativeSheet>; for a confirmation,
|
|
17
|
+
* <NativeDialog>.
|
|
18
|
+
*
|
|
19
|
+
* @stability Beta
|
|
20
|
+
*/
|
|
21
|
+
import type { ReactNode } from "react";
|
|
22
|
+
import { Modal, StatusBar, View } from "react-native";
|
|
23
|
+
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
24
|
+
import { useReducedMotion } from "../hooks/use-reduced-motion";
|
|
25
|
+
import { useThemeRoles } from "../hooks/use-theme-roles";
|
|
26
|
+
|
|
27
|
+
export interface NativeFullScreenModalProps {
|
|
28
|
+
open: boolean;
|
|
29
|
+
/** Fired with false on Android back and the VoiceOver escape gesture. Set `open` false in it. */
|
|
30
|
+
onOpenChange: (open: boolean) => void;
|
|
31
|
+
/** `"dark"` (default): black, for photos and video. `"app"`: the theme's background. `"none"`: the content draws its own. */
|
|
32
|
+
tone?: "dark" | "app" | "none";
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
testID?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The dark tone's backdrop: media reads best on true black in light and dark mode alike. */
|
|
38
|
+
export const FULL_SCREEN_DARK = "#000000";
|
|
39
|
+
|
|
40
|
+
/** @stability Beta */
|
|
41
|
+
export function NativeFullScreenModal({ open, onOpenChange, tone = "dark", children, testID = "native-full-screen-modal" }: NativeFullScreenModalProps) {
|
|
42
|
+
const reducedMotion = useReducedMotion();
|
|
43
|
+
const roles = useThemeRoles();
|
|
44
|
+
const background = tone === "dark" ? FULL_SCREEN_DARK : tone === "app" ? roles.background : "transparent";
|
|
45
|
+
const close = () => onOpenChange(false);
|
|
46
|
+
return (
|
|
47
|
+
<Modal
|
|
48
|
+
visible={open}
|
|
49
|
+
animationType={reducedMotion ? "none" : "fade"}
|
|
50
|
+
transparent
|
|
51
|
+
presentationStyle="overFullScreen"
|
|
52
|
+
statusBarTranslucent
|
|
53
|
+
navigationBarTranslucent
|
|
54
|
+
onRequestClose={close}
|
|
55
|
+
testID={testID}
|
|
56
|
+
>
|
|
57
|
+
{tone !== "app" ? <StatusBar barStyle="light-content" animated /> : null}
|
|
58
|
+
<SafeAreaProvider>
|
|
59
|
+
<View
|
|
60
|
+
testID={`${testID}-body`}
|
|
61
|
+
accessibilityViewIsModal
|
|
62
|
+
onAccessibilityEscape={close}
|
|
63
|
+
style={{ flex: 1, backgroundColor: background }}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</View>
|
|
67
|
+
</SafeAreaProvider>
|
|
68
|
+
</Modal>
|
|
69
|
+
);
|
|
70
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -29,6 +29,9 @@ export type {
|
|
|
29
29
|
export { NativeSheet, NativeSheetProvider, NativeSheetScrollView } from "./sheet";
|
|
30
30
|
export type { NativeSheetLibrary, NativeSheetProps, NativeSheetProviderProps } from "./sheet";
|
|
31
31
|
|
|
32
|
+
export { NativeFullScreenModal, FULL_SCREEN_DARK } from "./full-screen-modal";
|
|
33
|
+
export type { NativeFullScreenModalProps } from "./full-screen-modal";
|
|
34
|
+
|
|
32
35
|
export {
|
|
33
36
|
NativePopover,
|
|
34
37
|
NativePopoverTrigger,
|
|
@@ -2,23 +2,14 @@
|
|
|
2
2
|
* RefreshControl wrapper — token-aware tint over RN's RefreshControl.
|
|
3
3
|
*
|
|
4
4
|
* Use as the `refreshControl` prop on ScrollView / FlatList / SectionList.
|
|
5
|
-
* The tint defaults to
|
|
6
|
-
*
|
|
5
|
+
* The tint defaults to the theme's `tint` role; consumers can override
|
|
6
|
+
* per-call. We re-export RN's
|
|
7
7
|
* RefreshControl shape so the API mirrors what consumers already know.
|
|
8
8
|
*
|
|
9
9
|
* @stability Beta
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function resolveRefreshControl(): React.ComponentType<NativeRefreshControlProps> | null {
|
|
14
|
-
try {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
16
|
-
const rn = require("react-native");
|
|
17
|
-
return rn.RefreshControl as React.ComponentType<NativeRefreshControlProps>;
|
|
18
|
-
} catch {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
11
|
+
import { RefreshControl } from "react-native";
|
|
12
|
+
import { useThemeRoles } from "../hooks/use-theme-roles";
|
|
22
13
|
|
|
23
14
|
export interface NativeRefreshControlProps {
|
|
24
15
|
refreshing: boolean;
|
|
@@ -37,37 +28,12 @@ export interface NativeRefreshControlProps {
|
|
|
37
28
|
}
|
|
38
29
|
|
|
39
30
|
/**
|
|
40
|
-
*
|
|
41
|
-
* tint. Returns undefined on platforms where the theme provider isn't
|
|
42
|
-
* mounted (consumer can still pass `tintColor` explicitly).
|
|
31
|
+
* Pull to refresh, tinted with the theme's `tint` role. Works under any Genesis root.
|
|
43
32
|
*/
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
(() => {
|
|
51
|
-
try {
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
53
|
-
const provider = require("@marktiderman/genesis-design-system/providers/native");
|
|
54
|
-
return provider.useGenesisTheme ?? null;
|
|
55
|
-
} catch {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
})();
|
|
59
|
-
|
|
60
|
-
export function NativeRefreshControl(props: NativeRefreshControlProps) {
|
|
61
|
-
const RC = resolveRefreshControl();
|
|
62
|
-
const theme = useGenesisThemeRef ? useGenesisThemeRef() : null;
|
|
63
|
-
const themePrimary = theme?.colors?.primary;
|
|
64
|
-
if (!RC) return null;
|
|
65
|
-
return (
|
|
66
|
-
<RC
|
|
67
|
-
tintColor={props.tintColor ?? themePrimary}
|
|
68
|
-
colors={props.colors ?? (themePrimary ? [themePrimary] : undefined)}
|
|
69
|
-
{...props}
|
|
70
|
-
testID={props.testID ?? "native-refresh-control"}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
33
|
+
// The tint comes from `useThemeRoles`, not `useGenesisTheme` from `providers/native`: that is
|
|
34
|
+
// another context, which the native app shell's `GenesisThemeProvider` never mounts, so it threw there.
|
|
35
|
+
export function NativeRefreshControl({ tintColor, colors, testID, ...rest }: NativeRefreshControlProps) {
|
|
36
|
+
const tint = useThemeRoles().tint;
|
|
37
|
+
const androidTint = typeof tint === "string" ? [tint] : undefined;
|
|
38
|
+
return <RefreshControl {...rest} tintColor={tintColor ?? (tint as string)} colors={colors ?? androidTint} testID={testID ?? "native-refresh-control"} />;
|
|
73
39
|
}
|
package/src/icon-names.ts
CHANGED
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export const SF_SYMBOLS = {
|
|
10
10
|
"arrow-left": "arrow.left",
|
|
11
|
+
"arrow-up": "arrow.up",
|
|
11
12
|
bell: "bell",
|
|
12
13
|
calendar: "calendar",
|
|
14
|
+
camera: "camera",
|
|
15
|
+
"camera-flip": "arrow.triangle.2.circlepath.camera",
|
|
13
16
|
check: "checkmark",
|
|
14
17
|
"chevron-down": "chevron.down",
|
|
15
18
|
"chevron-left": "chevron.left",
|
|
@@ -17,28 +20,46 @@ export const SF_SYMBOLS = {
|
|
|
17
20
|
"chevron-up": "chevron.up",
|
|
18
21
|
clock: "clock",
|
|
19
22
|
close: "xmark",
|
|
23
|
+
compose: "square.and.pencil",
|
|
24
|
+
copy: "doc.on.doc",
|
|
25
|
+
download: "square.and.arrow.down",
|
|
20
26
|
edit: "pencil",
|
|
21
27
|
error: "xmark.circle",
|
|
28
|
+
expand: "arrow.up.left.and.arrow.down.right",
|
|
22
29
|
"external-link": "arrow.up.right.square",
|
|
30
|
+
file: "doc",
|
|
23
31
|
filter: "line.3.horizontal.decrease",
|
|
24
32
|
heart: "heart",
|
|
25
33
|
home: "house",
|
|
34
|
+
image: "photo",
|
|
26
35
|
info: "info.circle",
|
|
27
36
|
lock: "lock",
|
|
28
37
|
"log-out": "rectangle.portrait.and.arrow.right",
|
|
29
38
|
mail: "envelope",
|
|
30
39
|
menu: "line.3.horizontal",
|
|
40
|
+
message: "bubble.left",
|
|
41
|
+
mic: "mic",
|
|
31
42
|
minus: "minus",
|
|
32
43
|
more: "ellipsis",
|
|
44
|
+
paperclip: "paperclip",
|
|
45
|
+
pause: "pause.fill",
|
|
46
|
+
pin: "pin",
|
|
47
|
+
play: "play.fill",
|
|
33
48
|
plus: "plus",
|
|
34
49
|
refresh: "arrow.clockwise",
|
|
50
|
+
reply: "arrowshape.turn.up.left",
|
|
35
51
|
search: "magnifyingglass",
|
|
36
52
|
settings: "gearshape",
|
|
37
53
|
share: "square.and.arrow.up",
|
|
54
|
+
smile: "face.smiling",
|
|
38
55
|
star: "star",
|
|
56
|
+
stop: "stop.fill",
|
|
39
57
|
success: "checkmark.circle",
|
|
40
58
|
trash: "trash",
|
|
41
59
|
user: "person",
|
|
60
|
+
video: "video",
|
|
61
|
+
volume: "speaker.wave.2.fill",
|
|
62
|
+
"volume-off": "speaker.slash.fill",
|
|
42
63
|
warning: "exclamationmark.triangle",
|
|
43
64
|
} as const;
|
|
44
65
|
|
package/src/icons/lucide.ts
CHANGED
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import {
|
|
12
12
|
ArrowLeft,
|
|
13
|
+
ArrowUp,
|
|
13
14
|
Bell,
|
|
14
15
|
Calendar,
|
|
16
|
+
Camera,
|
|
15
17
|
Check,
|
|
16
18
|
ChevronDown,
|
|
17
19
|
ChevronLeft,
|
|
@@ -20,27 +22,46 @@ import {
|
|
|
20
22
|
CircleCheck,
|
|
21
23
|
CircleX,
|
|
22
24
|
Clock,
|
|
25
|
+
Copy,
|
|
26
|
+
Download,
|
|
23
27
|
Ellipsis,
|
|
24
28
|
ExternalLink,
|
|
29
|
+
File,
|
|
25
30
|
Funnel,
|
|
26
31
|
Heart,
|
|
27
32
|
House,
|
|
33
|
+
Image,
|
|
28
34
|
Info,
|
|
35
|
+
Maximize2,
|
|
29
36
|
Lock,
|
|
30
37
|
LogOut,
|
|
31
38
|
Mail,
|
|
32
39
|
Menu,
|
|
40
|
+
MessageCircle,
|
|
41
|
+
Mic,
|
|
33
42
|
Minus,
|
|
43
|
+
Paperclip,
|
|
44
|
+
Pause,
|
|
34
45
|
Pencil,
|
|
46
|
+
Pin,
|
|
47
|
+
Play,
|
|
35
48
|
Plus,
|
|
36
49
|
RefreshCw,
|
|
50
|
+
Reply,
|
|
37
51
|
Search,
|
|
52
|
+
Square,
|
|
53
|
+
SwitchCamera,
|
|
38
54
|
Settings,
|
|
39
55
|
Share,
|
|
56
|
+
Smile,
|
|
57
|
+
SquarePen,
|
|
40
58
|
Star,
|
|
41
59
|
Trash2,
|
|
42
60
|
TriangleAlert,
|
|
43
61
|
User,
|
|
62
|
+
Video,
|
|
63
|
+
Volume2,
|
|
64
|
+
VolumeX,
|
|
44
65
|
X,
|
|
45
66
|
} from "lucide-react-native";
|
|
46
67
|
import type { NativeIconName } from "../icon-names";
|
|
@@ -48,8 +69,11 @@ import type { GenesisIconComponent } from "../native-modules";
|
|
|
48
69
|
|
|
49
70
|
export const lucideIcons: Record<NativeIconName, GenesisIconComponent> = {
|
|
50
71
|
"arrow-left": ArrowLeft,
|
|
72
|
+
"arrow-up": ArrowUp,
|
|
51
73
|
bell: Bell,
|
|
52
74
|
calendar: Calendar,
|
|
75
|
+
camera: Camera,
|
|
76
|
+
"camera-flip": SwitchCamera,
|
|
53
77
|
check: Check,
|
|
54
78
|
"chevron-down": ChevronDown,
|
|
55
79
|
"chevron-left": ChevronLeft,
|
|
@@ -57,28 +81,46 @@ export const lucideIcons: Record<NativeIconName, GenesisIconComponent> = {
|
|
|
57
81
|
"chevron-up": ChevronUp,
|
|
58
82
|
clock: Clock,
|
|
59
83
|
close: X,
|
|
84
|
+
compose: SquarePen,
|
|
85
|
+
copy: Copy,
|
|
86
|
+
download: Download,
|
|
60
87
|
edit: Pencil,
|
|
61
88
|
error: CircleX,
|
|
89
|
+
expand: Maximize2,
|
|
62
90
|
"external-link": ExternalLink,
|
|
91
|
+
file: File,
|
|
63
92
|
filter: Funnel,
|
|
64
93
|
heart: Heart,
|
|
65
94
|
home: House,
|
|
95
|
+
image: Image,
|
|
66
96
|
info: Info,
|
|
67
97
|
lock: Lock,
|
|
68
98
|
"log-out": LogOut,
|
|
69
99
|
mail: Mail,
|
|
70
100
|
menu: Menu,
|
|
101
|
+
message: MessageCircle,
|
|
102
|
+
mic: Mic,
|
|
71
103
|
minus: Minus,
|
|
72
104
|
more: Ellipsis,
|
|
105
|
+
paperclip: Paperclip,
|
|
106
|
+
pause: Pause,
|
|
107
|
+
pin: Pin,
|
|
108
|
+
play: Play,
|
|
73
109
|
plus: Plus,
|
|
74
110
|
refresh: RefreshCw,
|
|
111
|
+
reply: Reply,
|
|
75
112
|
search: Search,
|
|
76
113
|
settings: Settings,
|
|
77
114
|
share: Share,
|
|
115
|
+
smile: Smile,
|
|
78
116
|
star: Star,
|
|
117
|
+
stop: Square,
|
|
79
118
|
success: CircleCheck,
|
|
80
119
|
trash: Trash2,
|
|
81
120
|
user: User,
|
|
121
|
+
video: Video,
|
|
122
|
+
volume: Volume2,
|
|
123
|
+
"volume-off": VolumeX,
|
|
82
124
|
warning: TriangleAlert,
|
|
83
125
|
// The cast widens lucide's declared `color: string` to `ColorValue`. On iOS
|
|
84
126
|
// NativeIcon passes theme roles as `PlatformColor` objects; lucide hands
|
|
@@ -152,4 +152,49 @@ describe("InboxPage", () => {
|
|
|
152
152
|
it("composes a large-title header by default", () => {
|
|
153
153
|
expect(getInboxPageStackOptions({ headerTitle: "Help" })).toMatchObject({ title: "Help", headerLargeTitle: true });
|
|
154
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
|
+
});
|
|
155
200
|
});
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* react-native-gesture-handler, an optional peer); it receives the actions
|
|
17
17
|
* and the row.
|
|
18
18
|
*
|
|
19
|
+
* Rows: `avatar` puts a picture of who it is between the unread dot and the
|
|
20
|
+
* text (an unread count shows at the end of the row, as in Mail); `leading`
|
|
21
|
+
* replaces the dot.
|
|
22
|
+
*
|
|
19
23
|
* Slots: `row`, `swipeable`, `header` (above the group), `footer` (below it,
|
|
20
24
|
* the paging spinner by default) and `empty`. `slots` swaps a part for your
|
|
21
25
|
* component (same props), `slotProps` feeds the default more props, `null`
|
|
@@ -27,13 +31,14 @@
|
|
|
27
31
|
*/
|
|
28
32
|
import { Fragment, useState, type ReactNode } from "react";
|
|
29
33
|
import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
|
|
30
|
-
import { ActivityIndicator, Alert, FlatList, Platform, Pressable,
|
|
34
|
+
import { ActivityIndicator, Alert, FlatList, Platform, Pressable, ScrollView, StyleSheet, View } from "react-native";
|
|
31
35
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
32
36
|
import { useThemeRoles } from "../hooks/use-theme-roles";
|
|
33
37
|
import { NativeEmptyState } from "../components/empty-state";
|
|
34
38
|
import { NativeText } from "../components/text";
|
|
35
39
|
import { NativeButton } from "../components/button";
|
|
36
40
|
import { NativeBadge } from "../components/badge";
|
|
41
|
+
import { NativeRefreshControl } from "../components/refresh-control";
|
|
37
42
|
import { composeHeaderOptions, type ScreenHeaderProps } from "./screen-container";
|
|
38
43
|
|
|
39
44
|
/** An action on a row: swipe, long press, or an accessibility action. */
|
|
@@ -59,8 +64,17 @@ export interface InboxItem {
|
|
|
59
64
|
unreadCount?: number;
|
|
60
65
|
/** A short status shown under the preview ("In progress", "12 votes"). */
|
|
61
66
|
meta?: string;
|
|
62
|
-
/** Replaces the unread dot (an
|
|
67
|
+
/** Replaces the unread dot (an icon). For a picture of who it is, use `avatar`, which keeps the dot. */
|
|
63
68
|
leading?: ReactNode;
|
|
69
|
+
/**
|
|
70
|
+
* A picture of who or what it is (a `NativeAvatar`, about 40pt), between the
|
|
71
|
+
* unread dot and the text. The separator then starts at the text. It is hidden
|
|
72
|
+
* from screen readers; when it shows someone `title` doesn't name, say who in
|
|
73
|
+
* `avatarLabel`.
|
|
74
|
+
*/
|
|
75
|
+
avatar?: ReactNode;
|
|
76
|
+
/** Who the avatar shows, read before the title, when `title` doesn't name them. */
|
|
77
|
+
avatarLabel?: string;
|
|
64
78
|
/** Shown at the end of the row (a vote button, a badge). Replaces the chevron. */
|
|
65
79
|
trailing?: ReactNode;
|
|
66
80
|
/** Opens the conversation. Rows with `onPress` show a chevron unless `trailing` is set. */
|
|
@@ -137,6 +151,12 @@ export function formatInboxTime(date: Date, now: Date): string {
|
|
|
137
151
|
return date.toLocaleDateString(undefined, { day: "numeric", month: "short", year: date.getFullYear() === now.getFullYear() ? undefined : "numeric" });
|
|
138
152
|
}
|
|
139
153
|
|
|
154
|
+
/** The row's leading padding, the unread dot's column, an avatar's default size and its gap to the text. */
|
|
155
|
+
const ROW_PADDING = 16;
|
|
156
|
+
const LEADING_WIDTH = 18;
|
|
157
|
+
const DEFAULT_AVATAR = 40;
|
|
158
|
+
const AVATAR_GAP = 12;
|
|
159
|
+
|
|
140
160
|
/** UIKit's inset grouped margin on a phone, in points (as SettingsPage). */
|
|
141
161
|
const IOS_GROUP_MARGIN = 16;
|
|
142
162
|
|
|
@@ -183,9 +203,21 @@ export function InboxPage({
|
|
|
183
203
|
</View>
|
|
184
204
|
);
|
|
185
205
|
|
|
206
|
+
const refreshControl = onRefresh ? <NativeRefreshControl testID={`${testID}-refresh`} refreshing={!!refreshing} onRefresh={() => void onRefresh()} /> : undefined;
|
|
207
|
+
|
|
186
208
|
if (items.length === 0) {
|
|
209
|
+
// A scroll view, not a plain view: under a large-title (or translucent) header only a
|
|
210
|
+
// scroll view's automatic content inset moves the content below the header, and pull to
|
|
211
|
+
// refresh needs one too.
|
|
187
212
|
return (
|
|
188
213
|
<SafeAreaView testID={testID} edges={["left", "right", "bottom"]} style={{ flex: 1, backgroundColor: colors.groupedBackground }}>
|
|
214
|
+
<ScrollView
|
|
215
|
+
testID={`${testID}-empty-scroll`}
|
|
216
|
+
contentInsetAdjustmentBehavior="automatic"
|
|
217
|
+
keyboardShouldPersistTaps="handled"
|
|
218
|
+
contentContainerStyle={{ flexGrow: 1, paddingTop: 8, paddingBottom: 32 }}
|
|
219
|
+
refreshControl={refreshControl}
|
|
220
|
+
>
|
|
189
221
|
{headerNode}
|
|
190
222
|
{loading ? (
|
|
191
223
|
<View testID={`${testID}-loading`} style={{ paddingVertical: 32 }}>
|
|
@@ -213,6 +245,7 @@ export function InboxPage({
|
|
|
213
245
|
slotProps.empty,
|
|
214
246
|
)
|
|
215
247
|
)}
|
|
248
|
+
</ScrollView>
|
|
216
249
|
</SafeAreaView>
|
|
217
250
|
);
|
|
218
251
|
}
|
|
@@ -232,7 +265,7 @@ export function InboxPage({
|
|
|
232
265
|
contentContainerStyle={{ paddingTop: 8, paddingBottom: 32 }}
|
|
233
266
|
onEndReached={onEndReached}
|
|
234
267
|
onEndReachedThreshold={0.5}
|
|
235
|
-
refreshControl={
|
|
268
|
+
refreshControl={refreshControl}
|
|
236
269
|
renderItem={({ item: row }) => {
|
|
237
270
|
const content = renderSlot(DefaultRow, slots.row, row, slotProps.row);
|
|
238
271
|
const actions = row.swipeActions ?? [];
|
|
@@ -292,7 +325,10 @@ function DefaultRow(row: InboxPageSlotMap["row"]) {
|
|
|
292
325
|
const actions = row.swipeActions ?? [];
|
|
293
326
|
const radius = iosGroupRadius();
|
|
294
327
|
const unreadLabel = row.unreadCount && row.unreadCount > 0 ? `${row.unreadCount} unread` : row.unread ? "Unread" : null;
|
|
295
|
-
const label = [unreadLabel, row.title, row.timeLabel, row.preview, row.meta].filter(Boolean).join(", ");
|
|
328
|
+
const label = [unreadLabel, row.avatar ? row.avatarLabel : null, row.title, row.timeLabel, row.preview, row.meta].filter(Boolean).join(", ");
|
|
329
|
+
// The separator starts at the text: the row's padding, the dot's column, and the avatar when there is one.
|
|
330
|
+
const [avatarWidth, setAvatarWidth] = useState(0);
|
|
331
|
+
const separatorInset = ROW_PADDING + LEADING_WIDTH + (row.avatar ? (avatarWidth || DEFAULT_AVATAR) + AVATAR_GAP : 0);
|
|
296
332
|
return (
|
|
297
333
|
<View
|
|
298
334
|
testID={`${row.testID}-cell`}
|
|
@@ -320,11 +356,22 @@ function DefaultRow(row: InboxPageSlotMap["row"]) {
|
|
|
320
356
|
onLongPress={actions.length ? () => showInboxActions(row.title, actions) : undefined}
|
|
321
357
|
onPressIn={() => setPressed(true)}
|
|
322
358
|
onPressOut={() => setPressed(false)}
|
|
323
|
-
style={{ flexDirection: "row", alignItems: "center", paddingHorizontal:
|
|
359
|
+
style={{ flexDirection: "row", alignItems: "center", paddingHorizontal: ROW_PADDING, paddingVertical: 11, minHeight: 60, backgroundColor: pressed && row.onPress ? colors.fill : undefined }}
|
|
324
360
|
>
|
|
325
|
-
<View style={{ width:
|
|
361
|
+
<View style={{ width: LEADING_WIDTH, alignItems: "flex-start" }}>
|
|
326
362
|
{row.leading ?? (row.unreadCount && row.unreadCount > 0 ? null : <UnreadDot unread={!!row.unread} testID={`${row.testID}-unread`} color={colors.tint} />)}
|
|
327
363
|
</View>
|
|
364
|
+
{row.avatar ? (
|
|
365
|
+
<View
|
|
366
|
+
testID={`${row.testID}-avatar`}
|
|
367
|
+
accessibilityElementsHidden
|
|
368
|
+
importantForAccessibility="no-hide-descendants"
|
|
369
|
+
onLayout={(e) => setAvatarWidth(Math.round(e.nativeEvent.layout.width))}
|
|
370
|
+
style={{ marginRight: AVATAR_GAP }}
|
|
371
|
+
>
|
|
372
|
+
{row.avatar}
|
|
373
|
+
</View>
|
|
374
|
+
) : null}
|
|
328
375
|
<View style={{ flex: 1, minWidth: 0 }}>
|
|
329
376
|
<View style={{ flexDirection: "row", alignItems: "baseline" }}>
|
|
330
377
|
<NativeText
|
|
@@ -359,7 +406,7 @@ function DefaultRow(row: InboxPageSlotMap["row"]) {
|
|
|
359
406
|
</Pressable>
|
|
360
407
|
{row.isLast ? null : (
|
|
361
408
|
<View accessibilityElementsHidden importantForAccessibility="no-hide-descendants" style={{ flexDirection: "row", height: StyleSheet.hairlineWidth }}>
|
|
362
|
-
<View style={{ width:
|
|
409
|
+
<View testID={`${row.testID}-separator-inset`} style={{ width: separatorInset }} />
|
|
363
410
|
<View testID={`${row.testID}-separator-line`} style={{ flex: 1, backgroundColor: colors.separator }} />
|
|
364
411
|
</View>
|
|
365
412
|
)}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/empty-state.tsx","../src/icon-names.ts","../src/components/icon.tsx","../src/components/list-item.tsx","../src/components/section-list.tsx"],"names":["jsx","View","jsxs","Text","Platform"],"mappings":";;;;;;AAwEA,IAAM,QAAA,GAA6E;AAAA,EACjF,WAAA,EAAa,EAAE,KAAA,EAAO,kBAAA,EAAoB,MAAM,uBAAA,EAAwB;AAAA,EACxE,YAAA,EAAc,EAAE,KAAA,EAAO,YAAA,EAAc,MAAM,uBAAA,EAAwB;AAAA,EACnE,KAAA,EAAO,EAAE,KAAA,EAAO,sBAAA,EAAwB,MAAM,kBAAA;AAChD,CAAA;AAEO,SAAS,gBAAA,CAAiB;AAAA,EAC/B,OAAA,GAAU,WAAA;AAAA,EACV,KAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,IAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA,EAA0B;AACxB,EAAA,MAAM,IAAA,GAAO,SAAS,OAAO,CAAA;AAC7B,EAAA,MAAM,eAAe,IAAA,IAAQ,WAAA;AAC7B,EAAA,MAAM,kBAAkB,aAAA,IAAiB,MAAA;AAKzC,EAAA,MAAM,OAAQ,UAAA,CACX,OAAA;AACH,EAAA,MAAM,OAAA,GAAU,MAAM,GAAA,EAAK,QAAA;AAC3B,EAAA,MAAM,KAAA,GAAQ,OAAA,KAAY,aAAA,IAAiB,OAAA,KAAY,MAAA;AAEvD,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,MAAA,EAAQ,MAAA,IAAU,CAAA,YAAA,EAAe,OAAO,CAAA,CAAA;AAAA,MACxC,iBAAA,EAAkB,SAAA;AAAA,MAClB,SAAA,EAAW,EAAA;AAAA,QACT,8CAAA;AAAA,QACA;AAAA,OACF;AAAA,M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when a list / screen has no data.\n *\n * Three semantic variants drive default messaging:\n * - \"first-run\": user has never had data here. Optimistic.\n * - \"no-results\": user filtered/searched and got nothing. Suggest reset.\n * - \"error\": fetching failed. Suggest retry.\n *\n * The variant only sets sensible defaults for `title` and tone — pass\n * your own `title`, `body`, `primaryAction`, `secondaryAction`, etc. to\n * override. Mirrors the @marktiderman/genesis-ui web `<EmptyState>` API where\n * possible (illustration vs icon slot, primary/secondary actions).\n *\n * @stability Beta\n */\nimport { Text, View } from \"react-native\";\nimport { cn } from \"../utils\";\n\nexport type NativeEmptyStateVariant = \"first-run\" | \"no-results\" | \"error\";\n\n/**\n * Action descriptor for primary/secondary CTAs. Either pass a structured\n * object (renders a Pressable button via the consumer's button slot) or\n * pass an arbitrary node via `action` for maximum flexibility.\n */\nexport interface NativeEmptyStateAction {\n label: string;\n onPress: () => void;\n testID?: string;\n}\n\nexport interface NativeEmptyStateProps {\n /** Variant drives default tone + default title. Default \"first-run\". */\n variant?: NativeEmptyStateVariant;\n /** Headline. Falls back to a variant-specific default. */\n title?: string;\n /** Body copy shown below the title. (Alias: `description`.) */\n body?: string;\n /**\n * @deprecated Prefer `body`. `description` remains for back-compat with\n * the original C3 API; both are accepted but `body` wins if both passed.\n */\n description?: string;\n /** Optional illustration (artwork node) above the title. */\n illustration?: React.ReactNode;\n /** Optional icon node above the title (use either icon or illustration). */\n icon?: React.ReactNode;\n /**\n * Primary CTA. When provided, the consumer is responsible for rendering\n * the button itself (we accept a node, not a label) so brand + token\n * styling is honored. The web API takes a `{label, onPress}` descriptor;\n * on native, prefer to pass a `<NativeButton>` directly to avoid\n * cross-package coupling.\n */\n primaryAction?: React.ReactNode;\n /** Secondary CTA, rendered below the primary. */\n secondaryAction?: React.ReactNode;\n /**\n * Free-form action slot. Equivalent to `primaryAction`; accepted for\n * back-compat with the C3 API. If both `action` and `primaryAction` are\n * passed, `primaryAction` wins.\n */\n action?: React.ReactNode;\n /**\n * Developer-facing error details. Only rendered when __DEV__ is true at\n * runtime (we infer by reading `process.env.NODE_ENV !== \"production\"`).\n */\n details?: string;\n className?: string;\n testID?: string;\n}\n\nconst defaults: Record<NativeEmptyStateVariant, { title: string; tone: string }> = {\n \"first-run\": { title: \"Nothing here yet\", tone: \"text-muted-foreground\" },\n \"no-results\": { title: \"No results\", tone: \"text-muted-foreground\" },\n error: { title: \"Something went wrong\", tone: \"text-destructive\" },\n};\n\nexport function NativeEmptyState({\n variant = \"first-run\",\n title,\n body,\n description,\n illustration,\n icon,\n primaryAction,\n secondaryAction,\n action,\n details,\n className,\n testID,\n}: NativeEmptyStateProps) {\n const meta = defaults[variant];\n const resolvedBody = body ?? description;\n const resolvedPrimary = primaryAction ?? action;\n // Read NODE_ENV defensively — some bundlers don't define `process` at\n // runtime (e.g., RN classic), so we guard via globalThis. The `details`\n // slot is dev-only; we explicitly enumerate non-production values so an\n // undefined NODE_ENV doesn't accidentally leak diagnostic strings.\n const proc = (globalThis as { process?: { env?: { NODE_ENV?: string } } })\n .process;\n const nodeEnv = proc?.env?.NODE_ENV;\n const isDev = nodeEnv === \"development\" || nodeEnv === \"test\";\n\n return (\n <View\n testID={testID ?? `empty-state-${variant}`}\n accessibilityRole=\"summary\"\n className={cn(\n \"items-center justify-center gap-3 px-8 py-12\",\n className\n )}\n >\n {illustration ? <View accessibilityElementsHidden>{illustration}</View> : null}\n {icon && !illustration ? (\n <View accessibilityElementsHidden>{icon}</View>\n ) : null}\n <Text\n testID={testID ? `${testID}-title` : undefined}\n className={cn(\n \"text-center text-lg font-semibold\",\n variant === \"error\" ? \"text-destructive\" : \"text-foreground\"\n )}\n >\n {title ?? meta.title}\n </Text>\n {resolvedBody ? (\n <Text\n testID={testID ? `${testID}-body` : undefined}\n className={cn(\"max-w-sm text-center text-sm\", meta.tone)}\n >\n {resolvedBody}\n </Text>\n ) : null}\n {resolvedPrimary ? (\n <View\n testID={testID ? `${testID}-primary-action` : undefined}\n className=\"mt-2\"\n >\n {resolvedPrimary}\n </View>\n ) : null}\n {secondaryAction ? (\n <View\n testID={testID ? `${testID}-secondary-action` : undefined}\n className=\"mt-1\"\n >\n {secondaryAction}\n </View>\n ) : null}\n {details && isDev ? (\n <Text\n testID={testID ? `${testID}-details` : undefined}\n className=\"mt-2 max-w-sm text-center text-xs text-muted-foreground\"\n >\n {details}\n </Text>\n ) : null}\n </View>\n );\n}\n","/**\n * The semantic icon names Genesis components ask for, and the SF Symbol each\n * one draws on iOS. Components say \"settings\" or \"bell\", never a library's\n * own name; `lucideIcons` (`/icons/lucide`) maps the same names for Android,\n * web and the SF Symbol fallback.\n *\n * @stability Beta\n */\nexport const SF_SYMBOLS = {\n \"arrow-left\": \"arrow.left\",\n bell: \"bell\",\n calendar: \"calendar\",\n check: \"checkmark\",\n \"chevron-down\": \"chevron.down\",\n \"chevron-left\": \"chevron.left\",\n \"chevron-right\": \"chevron.right\",\n \"chevron-up\": \"chevron.up\",\n clock: \"clock\",\n close: \"xmark\",\n edit: \"pencil\",\n error: \"xmark.circle\",\n \"external-link\": \"arrow.up.right.square\",\n filter: \"line.3.horizontal.decrease\",\n heart: \"heart\",\n home: \"house\",\n info: \"info.circle\",\n lock: \"lock\",\n \"log-out\": \"rectangle.portrait.and.arrow.right\",\n mail: \"envelope\",\n menu: \"line.3.horizontal\",\n minus: \"minus\",\n more: \"ellipsis\",\n plus: \"plus\",\n refresh: \"arrow.clockwise\",\n search: \"magnifyingglass\",\n settings: \"gearshape\",\n share: \"square.and.arrow.up\",\n star: \"star\",\n success: \"checkmark.circle\",\n trash: \"trash\",\n user: \"person\",\n warning: \"exclamationmark.triangle\",\n} as const;\n\n/** A semantic icon name: what the icon is for. */\nexport type NativeIconName = keyof typeof SF_SYMBOLS;\n\n/** Every semantic icon name. */\nexport const NATIVE_ICON_NAMES = Object.keys(SF_SYMBOLS) as NativeIconName[];\n","/**\n * NativeIcon — an icon by what it is for (\"settings\", \"bell\"), not by a\n * library's name. On iOS it draws the SF Symbol (expo-symbols' `SymbolView`,\n * passed as `modules.symbol`); on Android and web, and as the SF Symbol's\n * fallback, it draws the icon set given as `modules.icons` (`lucideIcons`\n * from `@marktiderman/genesis-ui-native/icons/lucide`). With neither, it\n * keeps the icon's space empty and warns once in development.\n *\n * Decorative by default (hidden from screen readers). Give `label` when the\n * icon carries meaning on its own, such as an icon-only button's content.\n *\n * @stability Beta\n */\nimport { Platform, View, type ColorValue } from \"react-native\";\nimport { useThemeRoles } from \"../hooks/use-theme-roles\";\nimport { SF_SYMBOLS, type NativeIconName } from \"../icon-names\";\nimport { useGenesisModules } from \"../native-modules\";\n\nexport interface NativeIconProps {\n name: NativeIconName;\n /** Points. Default 20. */\n size?: number;\n /** Default the theme's label color. */\n color?: ColorValue;\n /** iOS SF Symbol weight. */\n weight?: \"ultraLight\" | \"thin\" | \"light\" | \"regular\" | \"medium\" | \"semibold\" | \"bold\" | \"heavy\" | \"black\";\n /** Read by screen readers. Without it the icon is decorative and hidden from them. */\n label?: string;\n testID?: string;\n}\n\ndeclare const __DEV__: boolean | undefined;\nconst warned = new Set<string>();\n\nfunction warnOnce(name: string) {\n if (typeof __DEV__ === \"undefined\" || !__DEV__ || warned.has(name)) return;\n warned.add(name);\n console.warn(\n `[genesis] NativeIcon \"${name}\" has nothing to draw with: pass modules.icons (lucideIcons from \"@marktiderman/genesis-ui-native/icons/lucide\") and, for SF Symbols on iOS, modules.symbol (SymbolView from \"expo-symbols\") to GenesisModulesProvider.`,\n );\n}\n\nexport function NativeIcon({ name, size = 20, color, weight, label, testID }: NativeIconProps) {\n const { symbol: SymbolView, icons } = useGenesisModules();\n const roles = useThemeRoles();\n const tint = color ?? roles.label;\n const a11y = label\n ? { accessible: true, accessibilityRole: \"image\" as const, accessibilityLabel: label }\n : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: \"no-hide-descendants\" as const };\n const Fallback = icons?.[name];\n const fallback = Fallback ? <Fallback size={size} color={tint} testID={testID ? `${testID}-fallback` : undefined} /> : null;\n\n if (Platform.OS === \"ios\" && SymbolView) {\n return (\n <View {...a11y} testID={testID} style={{ width: size, height: size }}>\n <SymbolView name={SF_SYMBOLS[name]} size={size} tintColor={tint} weight={weight} fallback={fallback} style={{ width: size, height: size }} />\n </View>\n );\n }\n if (!fallback) warnOnce(name);\n return (\n <View {...a11y} testID={testID} style={{ width: size, height: size, alignItems: \"center\", justifyContent: \"center\" }}>\n {fallback}\n </View>\n );\n}\n","/**\n * ListItem — recurring row in a list (settings, contacts, results).\n *\n * Slots: leading (avatar / icon), title, subtitle, trailing\n * (chevron / accessory / action). Supports pressable variants with\n * automatic divider rendering between adjacent items via a wrapper\n * pattern (see <NativeListItemDivider>).\n *\n * For platform-default chevrons, pass `showChevron`; the chevron uses\n * the muted-foreground token.\n *\n * @stability Beta\n */\nimport { Platform, Pressable, Text, View } from \"react-native\";\nimport { cn } from \"../utils\";\nimport { useThemeRoles } from \"../hooks/use-theme-roles\";\nimport { useGenesisModules } from \"../native-modules\";\nimport { NativeIcon } from \"./icon\";\n\nexport interface NativeListItemProps {\n title: string;\n subtitle?: string;\n /** Slot rendered to the left of the title (avatar / icon). */\n leading?: React.ReactNode;\n /** Slot rendered to the right of the title (badge / accessory). */\n trailing?: React.ReactNode;\n /** When true, renders a chevron-right at the end. */\n showChevron?: boolean;\n /** When provided, the row becomes pressable. */\n onPress?: () => void;\n disabled?: boolean;\n className?: string;\n testID?: string;\n}\n\nexport function NativeListItem({\n title,\n subtitle,\n leading,\n trailing,\n showChevron,\n onPress,\n disabled,\n className,\n testID,\n}: NativeListItemProps) {\n const inner = (\n <>\n {leading ? <View className=\"mr-3\">{leading}</View> : null}\n <View className=\"flex-1\">\n <Text className=\"text-base text-foreground\" numberOfLines={1}>\n {title}\n </Text>\n {subtitle ? (\n <Text\n className=\"mt-0.5 text-xs text-muted-foreground\"\n numberOfLines={2}\n >\n {subtitle}\n </Text>\n ) : null}\n </View>\n {trailing ? <View className=\"ml-3\">{trailing}</View> : null}\n {showChevron ? <Chevron /> : null}\n </>\n );\n\n if (onPress) {\n return (\n <Pressable\n testID={testID ?? \"native-list-item\"}\n accessibilityRole=\"button\"\n accessibilityLabel={subtitle ? `${title}, ${subtitle}` : title}\n accessibilityState={{ disabled }}\n disabled={disabled}\n onPress={onPress}\n className={cn(\n \"min-h-[44px] flex-row items-center bg-background px-4 py-3\",\n disabled && \"opacity-50\",\n className\n )}\n >\n {inner}\n </Pressable>\n );\n }\n\n return (\n <View\n testID={testID ?? \"native-list-item\"}\n accessibilityLabel={subtitle ? `${title}, ${subtitle}` : title}\n className={cn(\n \"min-h-[44px] flex-row items-center bg-background px-4 py-3\",\n className\n )}\n >\n {inner}\n </View>\n );\n}\n\n/**\n * The drill-in chevron: an SF Symbol on iOS or the app's icon set\n * (`modules.symbol` / `modules.icons`) when given, else a text \"›\".\n */\nfunction Chevron() {\n const { symbol, icons } = useGenesisModules();\n const roles = useThemeRoles();\n if ((Platform.OS === \"ios\" && symbol) || icons?.[\"chevron-right\"]) {\n return (\n <View className=\"ml-2\">\n <NativeIcon name=\"chevron-right\" size={14} weight=\"semibold\" color={roles.tertiaryLabel} testID=\"native-list-item-chevron\" />\n </View>\n );\n }\n return (\n <Text\n accessibilityElementsHidden\n className=\"ml-2 text-base text-muted-foreground\"\n >\n ›\n </Text>\n );\n}\n\nexport function NativeListItemDivider({ className }: { className?: string }) {\n return <View className={cn(\"h-px bg-border\", className)} />;\n}\n","/**\n * SectionList header pattern — opinionated header style for\n * react-native SectionList rows.\n *\n * The full SectionList API stays with React Native; Genesis ships the\n * header component so consumers can pass it as `renderSectionHeader`\n * and get a consistent visual: muted background, uppercase tracking,\n * sticky-friendly padding.\n *\n * Pattern:\n *\n * <SectionList\n * sections={...}\n * renderItem={({ item }) => <NativeListItem title={item.label} />}\n * renderSectionHeader={({ section }) => (\n * <NativeSectionListHeader title={section.title} />\n * )}\n * />\n *\n * @stability Beta\n */\nimport { Text, View } from \"react-native\";\nimport { cn } from \"../utils\";\n\nexport interface NativeSectionListHeaderProps {\n title: string;\n /** Optional trailing content (e.g., a count badge). */\n trailing?: React.ReactNode;\n className?: string;\n testID?: string;\n}\n\nexport function NativeSectionListHeader({\n title,\n trailing,\n className,\n testID,\n}: NativeSectionListHeaderProps) {\n return (\n <View\n testID={testID ?? \"native-section-header\"}\n accessibilityRole=\"header\"\n className={cn(\n \"flex-row items-center justify-between border-b border-border bg-muted px-4 py-2\",\n className\n )}\n >\n <Text className=\"text-xs font-semibold uppercase tracking-wider text-muted-foreground\">\n {title}\n </Text>\n {trailing}\n </View>\n );\n}\n"]}
|