@marktiderman/genesis-ui-native 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -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-2WCXMJL6.js → chunk-FIITITXO.js} +67 -108
- package/dist/chunk-FIITITXO.js.map +1 -0
- package/dist/chunk-H4Q7COTI.js +1587 -0
- package/dist/chunk-H4Q7COTI.js.map +1 -0
- package/dist/{chunk-TXJT55JC.js → chunk-Q445I7WO.js} +715 -324
- package/dist/chunk-Q445I7WO.js.map +1 -0
- package/dist/{chunk-ULS7I6ZS.js → chunk-W2UBJ56D.js} +99 -12
- package/dist/chunk-W2UBJ56D.js.map +1 -0
- package/dist/components/index.d.ts +146 -18
- 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 +60 -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 +329 -4
- package/dist/layouts/index.js +3 -3
- package/dist/native-modules-BGO2MnFF.d.ts +219 -0
- package/package.json +34 -5
- package/src/__tests__/fake-modules.tsx +134 -0
- package/src/__tests__/native-modules-lists.test.tsx +71 -0
- package/src/__tests__/native-modules.test.tsx +631 -0
- package/src/components/__tests__/refresh-control.test.tsx +35 -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/refresh-control.tsx +11 -45
- 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/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 +62 -0
- package/src/icons/lucide.ts +114 -0
- package/src/layouts/__tests__/google-sign-in.test.tsx +26 -0
- package/src/layouts/__tests__/inbox-page.test.tsx +200 -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/auth-screen.tsx +6 -3
- package/src/layouts/google-sign-in.tsx +42 -0
- package/src/layouts/inbox-page.tsx +455 -0
- package/src/layouts/index.ts +37 -2
- package/src/layouts/keyboard.tsx +61 -9
- package/src/layouts/notifications-page.tsx +133 -16
- 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-2WCXMJL6.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-FZTUSM56.js +0 -935
- package/dist/chunk-FZTUSM56.js.map +0 -1
- package/dist/chunk-TXJT55JC.js.map +0 -1
- package/dist/chunk-ULS7I6ZS.js.map +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// @feat:inbox-thread
|
|
2
|
+
import { forwardRef, useImperativeHandle, type ReactNode } from "react";
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { ThreadPage, getThreadPageStackOptions, readReceiptFor, type ThreadMessage } from "../thread-page";
|
|
6
|
+
import { KeyboardScrollProvider, type KeyboardScrollProps } from "../keyboard";
|
|
7
|
+
|
|
8
|
+
const messages: ThreadMessage[] = [
|
|
9
|
+
{ id: "1", body: "The save button does nothing", mine: true, timestamp: "2026-10-24T09:00:00Z" },
|
|
10
|
+
{ id: "2", body: "Thanks, we're on it.", mine: false, authorName: "Support", timestamp: "2026-10-24T09:05:00Z" },
|
|
11
|
+
{ id: "3", body: "It happens on every screen", mine: true, timestamp: "2026-10-24T09:10:00Z", attachments: [{ id: "s", uri: "file:///shot.png", width: 390, height: 844 }] },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const composer = (over: Partial<Parameters<typeof ThreadPage>[0]["composer"] & object> = {}) => ({
|
|
15
|
+
value: "",
|
|
16
|
+
onChangeText: vi.fn(),
|
|
17
|
+
onSend: vi.fn(),
|
|
18
|
+
...over,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe("readReceiptFor", () => {
|
|
22
|
+
it("is my newest message sent before the other side read the thread", () => {
|
|
23
|
+
expect(readReceiptFor(messages, "2026-10-24T09:11:00Z")).toBe("3");
|
|
24
|
+
expect(readReceiptFor(messages, "2026-10-24T09:06:00Z")).toBe("1");
|
|
25
|
+
expect(readReceiptFor(messages, "2026-10-24T08:00:00Z")).toBeNull();
|
|
26
|
+
expect(readReceiptFor(messages, null)).toBeNull();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("never marks a message that is still sending or failed", () => {
|
|
30
|
+
const pending: ThreadMessage[] = [...messages, { id: "4", body: "x", mine: true, timestamp: "2026-10-24T09:12:00Z", status: "sending" }];
|
|
31
|
+
expect(readReceiptFor(pending, "2026-10-24T09:20:00Z")).toBe("3");
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("ThreadPage", () => {
|
|
36
|
+
it("renders messages oldest first, theirs with the author's name, and attachments", () => {
|
|
37
|
+
render(<ThreadPage testID="t" messages={messages} composer={composer()} />);
|
|
38
|
+
const list = screen.getByTestId("t-messages");
|
|
39
|
+
const ids = [...list.querySelectorAll('[data-testid^="t-message-"]')].map((el) => el.getAttribute("data-testid")).filter((id) => !id!.endsWith("-time"));
|
|
40
|
+
expect(ids).toEqual(["t-message-1", "t-message-2", "t-message-3"]);
|
|
41
|
+
expect(list.textContent).toContain("Support");
|
|
42
|
+
expect(screen.getByTestId("t-attachment-s")).toBeTruthy();
|
|
43
|
+
expect(screen.getByTestId("t-message-1").getAttribute("aria-label")).toMatch(/^You, The save button does nothing/);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("shows the read receipt under my newest read message", () => {
|
|
47
|
+
render(<ThreadPage testID="t" messages={messages} composer={composer()} readAt="2026-10-24T09:11:00Z" readLabel="Seen" />);
|
|
48
|
+
expect(screen.getByTestId("t-read-receipt").textContent).toBe("Seen");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("sends from the composer, and won't send a blank message", () => {
|
|
52
|
+
const c = composer({ value: " " });
|
|
53
|
+
const { rerender } = render(<ThreadPage testID="t" messages={messages} composer={c} />);
|
|
54
|
+
expect((screen.getByTestId("t-composer-send") as HTMLButtonElement).disabled).toBe(true);
|
|
55
|
+
const typed = composer({ value: "More detail" });
|
|
56
|
+
rerender(<ThreadPage testID="t" messages={messages} composer={typed} />);
|
|
57
|
+
fireEvent.change(screen.getByTestId("t-composer-input"), { target: { value: "More detail!" } });
|
|
58
|
+
expect(typed.onChangeText).toHaveBeenCalledWith("More detail!");
|
|
59
|
+
fireEvent.click(screen.getByTestId("t-composer-send"));
|
|
60
|
+
expect(typed.onSend).toHaveBeenCalled();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("shows a spinner instead of Send while sending", () => {
|
|
64
|
+
render(<ThreadPage testID="t" messages={messages} composer={composer({ value: "x", sending: true })} />);
|
|
65
|
+
expect(screen.getByTestId("t-composer-sending")).toBeTruthy();
|
|
66
|
+
expect(screen.queryByTestId("t-composer-send")).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("is read-only with no composer, and says why", () => {
|
|
70
|
+
render(<ThreadPage testID="t" messages={messages} composer={null} closedNotice="This report is closed." />);
|
|
71
|
+
expect(screen.queryByTestId("t-composer")).toBeNull();
|
|
72
|
+
expect(screen.getByTestId("t-closed").textContent).toBe("This report is closed.");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("retries a failed message on tap", () => {
|
|
76
|
+
const onRetry = vi.fn();
|
|
77
|
+
render(<ThreadPage testID="t" messages={[{ id: "f", body: "hi", mine: true, timestamp: "2026-10-24T09:00:00Z", status: "failed", onRetry }]} composer={composer()} />);
|
|
78
|
+
expect(screen.getByTestId("t-message-f-time").textContent).toMatch(/Not sent/);
|
|
79
|
+
fireEvent.click(screen.getByTestId("t-message-f"));
|
|
80
|
+
expect(onRetry).toHaveBeenCalled();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("loads earlier messages from the top", () => {
|
|
84
|
+
const onLoadEarlier = vi.fn();
|
|
85
|
+
render(<ThreadPage testID="t" messages={messages} composer={composer()} hasEarlier onLoadEarlier={onLoadEarlier} />);
|
|
86
|
+
fireEvent.click(screen.getByTestId("t-earlier"));
|
|
87
|
+
expect(onLoadEarlier).toHaveBeenCalled();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("fills the composer accessory and header slots", () => {
|
|
91
|
+
const Attach = ({ testID }: { testID: string }) => <button data-testid={testID}>Attach</button>;
|
|
92
|
+
render(<ThreadPage testID="t" messages={messages} composer={composer()} header={<span data-testid="about" />} slots={{ composerAccessory: Attach }} />);
|
|
93
|
+
expect(screen.getByTestId("t-composer-accessory")).toBeTruthy();
|
|
94
|
+
expect(screen.getByTestId("about")).toBeTruthy();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("shows the empty state for a thread with no messages", () => {
|
|
98
|
+
render(<ThreadPage testID="t" messages={[]} composer={composer()} emptyTitle="Say hello" />);
|
|
99
|
+
expect(screen.getByTestId("t-empty").textContent).toContain("Say hello");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("falls back to a KeyboardAvoidingView without a keyboard scroll view", () => {
|
|
103
|
+
render(<ThreadPage testID="t" messages={messages} composer={composer()} />);
|
|
104
|
+
expect(screen.getByTestId("t-kav")).toBeTruthy();
|
|
105
|
+
expect(screen.queryByTestId("t-keyboard")).toBeNull();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("puts the messages and the composer in the app's keyboard scroll view, and scrolls to the newest", () => {
|
|
109
|
+
const scrollToEnd = vi.fn();
|
|
110
|
+
const Scroll = forwardRef<unknown, KeyboardScrollProps & { children?: ReactNode }>(function Scroll({ children, testID }, ref) {
|
|
111
|
+
useImperativeHandle(ref, () => ({ scrollToEnd }));
|
|
112
|
+
return <div data-testid={testID}>{children}</div>;
|
|
113
|
+
});
|
|
114
|
+
render(
|
|
115
|
+
<KeyboardScrollProvider component={Scroll}>
|
|
116
|
+
<ThreadPage testID="t" messages={messages} composer={composer()} />
|
|
117
|
+
</KeyboardScrollProvider>,
|
|
118
|
+
);
|
|
119
|
+
const scroll = screen.getByTestId("t-keyboard");
|
|
120
|
+
expect(scroll.querySelector('[data-testid="t-composer-input"]')).toBeTruthy();
|
|
121
|
+
expect(screen.queryByTestId("t-kav")).toBeNull();
|
|
122
|
+
expect(scrollToEnd).toHaveBeenCalled();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("composes a standard header by default", () => {
|
|
126
|
+
expect(getThreadPageStackOptions({ headerTitle: "Report" })).toEqual({ title: "Report" });
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The form stays above the keyboard on small phones: with the app's
|
|
9
9
|
* `KeyboardScrollProvider` (react-native-keyboard-controller), else with
|
|
10
|
-
* `KeyboardAvoidingView`.
|
|
10
|
+
* `KeyboardAvoidingView`. With the provider's `toolbar` (`KeyboardToolbar`),
|
|
11
|
+
* a previous / next / done bar rides above the keyboard. In development, on
|
|
11
12
|
* iOS, it warns when a third-party provider is offered without Sign in with
|
|
12
13
|
* Apple (App Store Review Guideline 4.8 rejects that). `appleProvider()`
|
|
13
14
|
* adds Apple's own button in one line.
|
|
@@ -31,7 +32,7 @@ import {
|
|
|
31
32
|
type SocialAuthProvider,
|
|
32
33
|
} from "./auth";
|
|
33
34
|
import { ScreenContainer } from "./screen-container";
|
|
34
|
-
import { useKeyboardScroll } from "./keyboard";
|
|
35
|
+
import { KEYBOARD_TOOLBAR_HEIGHT, useKeyboardScroll, useKeyboardToolbar } from "./keyboard";
|
|
35
36
|
|
|
36
37
|
/** The parts of an {@link AuthScreen} that `slots` and `slotProps` reach. */
|
|
37
38
|
export type AuthScreenSlotMap = {
|
|
@@ -80,6 +81,7 @@ export function AuthScreen({
|
|
|
80
81
|
onForgotPassword && (form.mode ?? "password") === "password" ? <ForgotPasswordLink onPress={onForgotPassword} /> : null;
|
|
81
82
|
const formProps: AuthFormProps = { ...form, belowFields: form.belowFields ?? forgot, testID: form.testID ?? `${testID}-form` };
|
|
82
83
|
const KeyboardScroll = useKeyboardScroll();
|
|
84
|
+
const KeyboardToolbar = useKeyboardToolbar();
|
|
83
85
|
const content = (
|
|
84
86
|
<>
|
|
85
87
|
{branding ? renderSlot(AuthBranding, slots.branding, { ...branding, testID: branding.testID ?? `${testID}-branding` }, slotProps.branding) : null}
|
|
@@ -97,11 +99,12 @@ export function AuthScreen({
|
|
|
97
99
|
testID={`${testID}-keyboard`}
|
|
98
100
|
keyboardShouldPersistTaps="handled"
|
|
99
101
|
contentInsetAdjustmentBehavior="automatic"
|
|
100
|
-
bottomOffset={24}
|
|
102
|
+
bottomOffset={KeyboardToolbar ? 24 + KEYBOARD_TOOLBAR_HEIGHT : 24}
|
|
101
103
|
contentContainerStyle={{ flexGrow: 1, justifyContent: "center", gap: 24, paddingHorizontal: 24, paddingVertical: 32 }}
|
|
102
104
|
>
|
|
103
105
|
{content}
|
|
104
106
|
</KeyboardScroll>
|
|
107
|
+
{KeyboardToolbar ? <KeyboardToolbar /> : null}
|
|
105
108
|
</ScreenContainer>
|
|
106
109
|
);
|
|
107
110
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google sign-in for `AuthScreen` / `SocialAuthRow`: the provider entry,
|
|
3
|
+
* drawn as the row's outline button. Nothing here imports
|
|
4
|
+
* `@react-native-google-signin/google-signin`; sign in with
|
|
5
|
+
* `signInWithGoogle` from `@marktiderman/genesis-supabase/native`.
|
|
6
|
+
*
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <AuthScreen providers={[appleProvider({ apple, onPress: onApple }), googleProvider({ onPress: onGoogle })]} … />
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Google's branding guidelines want its "G" mark on the button: pass it as
|
|
12
|
+
* `icon` (Genesis ships no Google artwork). On iOS, offer Sign in with Apple
|
|
13
|
+
* too (App Store Review Guideline 4.8); `AuthScreen` warns in development
|
|
14
|
+
* when it's missing.
|
|
15
|
+
*
|
|
16
|
+
* @stability Beta
|
|
17
|
+
*/
|
|
18
|
+
import type { ReactNode } from "react";
|
|
19
|
+
import type { SocialAuthProvider } from "./auth";
|
|
20
|
+
|
|
21
|
+
export interface GoogleProviderOptions {
|
|
22
|
+
/** Usually `() => signInWithGoogle(supabase, GoogleOneTapSignIn, { digest })`. */
|
|
23
|
+
onPress: () => void | Promise<void>;
|
|
24
|
+
/** Default "Continue with Google", Google's own wording. */
|
|
25
|
+
label?: string;
|
|
26
|
+
/** Google's "G" mark, as the app draws it. */
|
|
27
|
+
icon?: ReactNode;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** `false` (or `null`) gives `null`, so a switched-off provider goes in the list as is. Default true. */
|
|
30
|
+
enabled?: boolean | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A `SocialAuthProvider` (id `"google"`) for `AuthScreen`'s `providers`, or
|
|
35
|
+
* `null` when `enabled` is false.
|
|
36
|
+
*
|
|
37
|
+
* @stability Beta
|
|
38
|
+
*/
|
|
39
|
+
export function googleProvider({ onPress, label = "Continue with Google", icon, disabled, enabled = true }: GoogleProviderOptions): SocialAuthProvider | null {
|
|
40
|
+
if (!enabled) return null;
|
|
41
|
+
return { id: "google", label, icon, onPress, disabled };
|
|
42
|
+
}
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InboxPage — a list of conversations or tickets: unread state, a time, a
|
|
3
|
+
* preview line, swipe actions, pull to refresh, paging and an empty state.
|
|
4
|
+
*
|
|
5
|
+
* Generic: the rows are whatever the app has (support reports, direct
|
|
6
|
+
* messages, an idea board). Data and actions come in as props; the layout
|
|
7
|
+
* draws them the platform's way. On iOS it is the Settings app's inset
|
|
8
|
+
* grouped style, like `SettingsPage`: the page is `groupedBackground`, the
|
|
9
|
+
* rows one rounded group on `surface` with hairline separators that start at
|
|
10
|
+
* the text. On Android rows are full width.
|
|
11
|
+
*
|
|
12
|
+
* Swipe actions: each row's `swipeActions` are always reachable without a
|
|
13
|
+
* gesture library, as VoiceOver / TalkBack custom actions and on long press
|
|
14
|
+
* (a menu). For the swipe itself, fill the `swipeable` slot with your
|
|
15
|
+
* gesture-handler wrapper (`ReanimatedSwipeable` from
|
|
16
|
+
* react-native-gesture-handler, an optional peer); it receives the actions
|
|
17
|
+
* and the row.
|
|
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
|
+
*
|
|
23
|
+
* Slots: `row`, `swipeable`, `header` (above the group), `footer` (below it,
|
|
24
|
+
* the paging spinner by default) and `empty`. `slots` swaps a part for your
|
|
25
|
+
* component (same props), `slotProps` feeds the default more props, `null`
|
|
26
|
+
* drops it.
|
|
27
|
+
*
|
|
28
|
+
* Header: `getInboxPageStackOptions()` for `<Stack.Screen options>`.
|
|
29
|
+
*
|
|
30
|
+
* @stability Beta
|
|
31
|
+
*/
|
|
32
|
+
import { Fragment, useState, type ReactNode } from "react";
|
|
33
|
+
import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
|
|
34
|
+
import { ActivityIndicator, Alert, FlatList, Platform, Pressable, ScrollView, StyleSheet, View } from "react-native";
|
|
35
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
36
|
+
import { useThemeRoles } from "../hooks/use-theme-roles";
|
|
37
|
+
import { NativeEmptyState } from "../components/empty-state";
|
|
38
|
+
import { NativeText } from "../components/text";
|
|
39
|
+
import { NativeButton } from "../components/button";
|
|
40
|
+
import { NativeBadge } from "../components/badge";
|
|
41
|
+
import { NativeRefreshControl } from "../components/refresh-control";
|
|
42
|
+
import { composeHeaderOptions, type ScreenHeaderProps } from "./screen-container";
|
|
43
|
+
|
|
44
|
+
/** An action on a row: swipe, long press, or an accessibility action. */
|
|
45
|
+
export interface InboxSwipeAction {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
onPress: () => void;
|
|
49
|
+
/** Destructive tone (delete, leave). */
|
|
50
|
+
destructive?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface InboxItem {
|
|
54
|
+
/** Stable id for keying. */
|
|
55
|
+
id: string;
|
|
56
|
+
title: string;
|
|
57
|
+
/** The latest message or a summary, at most two lines. */
|
|
58
|
+
preview?: string;
|
|
59
|
+
/** When it last changed. Shown as a short time or date. */
|
|
60
|
+
timestamp?: string | Date;
|
|
61
|
+
/** Something new the person hasn't read: a dot, and the title in bold. */
|
|
62
|
+
unread?: boolean;
|
|
63
|
+
/** How many unread messages; shown as a count instead of the dot when above 0. */
|
|
64
|
+
unreadCount?: number;
|
|
65
|
+
/** A short status shown under the preview ("In progress", "12 votes"). */
|
|
66
|
+
meta?: string;
|
|
67
|
+
/** Replaces the unread dot (an icon). For a picture of who it is, use `avatar`, which keeps the dot. */
|
|
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;
|
|
78
|
+
/** Shown at the end of the row (a vote button, a badge). Replaces the chevron. */
|
|
79
|
+
trailing?: ReactNode;
|
|
80
|
+
/** Opens the conversation. Rows with `onPress` show a chevron unless `trailing` is set. */
|
|
81
|
+
onPress?: () => void;
|
|
82
|
+
swipeActions?: InboxSwipeAction[];
|
|
83
|
+
/** testID override. Default `<page testID>-row-<id>`. */
|
|
84
|
+
testID?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The parts `slots` and `slotProps` reach, with the props each receives. */
|
|
88
|
+
export type InboxPageSlotMap = {
|
|
89
|
+
row: InboxItem & { testID: string; isFirst: boolean; isLast: boolean; timeLabel: string | null };
|
|
90
|
+
swipeable: { actions: InboxSwipeAction[]; testID: string; children?: ReactNode };
|
|
91
|
+
header: { testID: string };
|
|
92
|
+
footer: { loadingMore: boolean; testID: string };
|
|
93
|
+
empty: { title: string; body: string; actionLabel?: string; onAction?: () => void; testID: string };
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export interface InboxPageProps extends ScreenHeaderProps {
|
|
97
|
+
/** Newest first, as they should show. Empty → the empty state. */
|
|
98
|
+
items: InboxItem[];
|
|
99
|
+
refreshing?: boolean;
|
|
100
|
+
onRefresh?: () => void | Promise<void>;
|
|
101
|
+
/** Called near the end of the list, to load the next page. */
|
|
102
|
+
onEndReached?: () => void;
|
|
103
|
+
/** A next page is loading: the default footer shows a spinner. */
|
|
104
|
+
loadingMore?: boolean;
|
|
105
|
+
/** Above the group (a filter, a call to action). Prefer `slots.header` for a component. */
|
|
106
|
+
header?: ReactNode;
|
|
107
|
+
/** An optional title over the group, in the Settings header style. */
|
|
108
|
+
sectionTitle?: string;
|
|
109
|
+
emptyTitle?: string;
|
|
110
|
+
emptyBody?: string;
|
|
111
|
+
/** The first page is loading: a spinner instead of the empty state. */
|
|
112
|
+
loading?: boolean;
|
|
113
|
+
/** The read failed: the empty slot shows `errorTitle` / `errorBody` instead (and pull to refresh retries). */
|
|
114
|
+
error?: boolean;
|
|
115
|
+
errorTitle?: string;
|
|
116
|
+
errorBody?: string;
|
|
117
|
+
/** A button in the empty state ("Send feedback"). */
|
|
118
|
+
emptyActionLabel?: string;
|
|
119
|
+
onEmptyAction?: () => void;
|
|
120
|
+
/** How a row's time reads. Default: the time today, "Yesterday", the weekday this week, else the date. */
|
|
121
|
+
formatTime?: (date: Date, now: Date) => string;
|
|
122
|
+
/** The clock, for tests. */
|
|
123
|
+
now?: () => Date;
|
|
124
|
+
slots?: Slots<InboxPageSlotMap>;
|
|
125
|
+
slotProps?: SlotPropsFor<InboxPageSlotMap>;
|
|
126
|
+
/** testID on the root. Default `"inbox-page"`. */
|
|
127
|
+
testID?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** `<Stack.Screen options>` for an InboxPage: a large title that collapses on scroll. */
|
|
131
|
+
export function getInboxPageStackOptions(props: ScreenHeaderProps & { headerTitle?: string }): Record<string, unknown> {
|
|
132
|
+
return composeHeaderOptions({
|
|
133
|
+
headerTitle: props.headerTitle ?? "Inbox",
|
|
134
|
+
large: props.large ?? true,
|
|
135
|
+
scrollEdgeBehavior: props.scrollEdgeBehavior ?? "match",
|
|
136
|
+
headerLeft: props.headerLeft,
|
|
137
|
+
headerRight: props.headerRight,
|
|
138
|
+
headerOptions: props.headerOptions,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
143
|
+
|
|
144
|
+
/** The default row time: `9:41`, `Yesterday`, `Monday`, then a short date. */
|
|
145
|
+
export function formatInboxTime(date: Date, now: Date): string {
|
|
146
|
+
const start = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
147
|
+
const days = Math.round((start(now) - start(date)) / DAY_MS);
|
|
148
|
+
if (days <= 0) return date.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" });
|
|
149
|
+
if (days === 1) return "Yesterday";
|
|
150
|
+
if (days < 7) return date.toLocaleDateString(undefined, { weekday: "long" });
|
|
151
|
+
return date.toLocaleDateString(undefined, { day: "numeric", month: "short", year: date.getFullYear() === now.getFullYear() ? undefined : "numeric" });
|
|
152
|
+
}
|
|
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
|
+
|
|
160
|
+
/** UIKit's inset grouped margin on a phone, in points (as SettingsPage). */
|
|
161
|
+
const IOS_GROUP_MARGIN = 16;
|
|
162
|
+
|
|
163
|
+
function iosGroupRadius(): number {
|
|
164
|
+
return Number.parseFloat(String(Platform.Version)) >= 26 ? 26 : 10;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function InboxPage({
|
|
168
|
+
items,
|
|
169
|
+
refreshing,
|
|
170
|
+
onRefresh,
|
|
171
|
+
onEndReached,
|
|
172
|
+
loadingMore = false,
|
|
173
|
+
header,
|
|
174
|
+
sectionTitle,
|
|
175
|
+
emptyTitle,
|
|
176
|
+
emptyBody,
|
|
177
|
+
emptyActionLabel,
|
|
178
|
+
onEmptyAction,
|
|
179
|
+
loading = false,
|
|
180
|
+
error = false,
|
|
181
|
+
errorTitle,
|
|
182
|
+
errorBody,
|
|
183
|
+
formatTime = formatInboxTime,
|
|
184
|
+
now = () => new Date(),
|
|
185
|
+
slots = {},
|
|
186
|
+
slotProps = {},
|
|
187
|
+
testID = "inbox-page",
|
|
188
|
+
}: InboxPageProps) {
|
|
189
|
+
const colors = useThemeRoles();
|
|
190
|
+
const clock = now();
|
|
191
|
+
const rows: InboxPageSlotMap["row"][] = items.map((item, index) => ({
|
|
192
|
+
...item,
|
|
193
|
+
testID: item.testID ?? `${testID}-row-${item.id}`,
|
|
194
|
+
isFirst: index === 0,
|
|
195
|
+
isLast: index === items.length - 1,
|
|
196
|
+
timeLabel: item.timestamp ? formatTime(typeof item.timestamp === "string" ? new Date(item.timestamp) : item.timestamp, clock) : null,
|
|
197
|
+
}));
|
|
198
|
+
|
|
199
|
+
const headerNode = (
|
|
200
|
+
<View>
|
|
201
|
+
{header ?? renderSlot(EmptyPart, slots.header, { testID: `${testID}-header` }, slotProps.header)}
|
|
202
|
+
{sectionTitle ? <SectionTitle title={sectionTitle} testID={`${testID}-section-title`} /> : null}
|
|
203
|
+
</View>
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
const refreshControl = onRefresh ? <NativeRefreshControl testID={`${testID}-refresh`} refreshing={!!refreshing} onRefresh={() => void onRefresh()} /> : undefined;
|
|
207
|
+
|
|
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.
|
|
212
|
+
return (
|
|
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
|
+
>
|
|
221
|
+
{headerNode}
|
|
222
|
+
{loading ? (
|
|
223
|
+
<View testID={`${testID}-loading`} style={{ paddingVertical: 32 }}>
|
|
224
|
+
<ActivityIndicator accessibilityLabel="Loading" />
|
|
225
|
+
</View>
|
|
226
|
+
) : (
|
|
227
|
+
renderSlot(
|
|
228
|
+
DefaultEmpty,
|
|
229
|
+
slots.empty,
|
|
230
|
+
error
|
|
231
|
+
? {
|
|
232
|
+
title: errorTitle ?? "Couldn't load this",
|
|
233
|
+
body: errorBody ?? "Check your connection, then pull to refresh.",
|
|
234
|
+
actionLabel: onRefresh ? "Try again" : undefined,
|
|
235
|
+
onAction: onRefresh ? () => void onRefresh() : undefined,
|
|
236
|
+
testID: `${testID}-error`,
|
|
237
|
+
}
|
|
238
|
+
: {
|
|
239
|
+
title: emptyTitle ?? "Nothing here yet",
|
|
240
|
+
body: emptyBody ?? "When there's something new, it shows up here.",
|
|
241
|
+
actionLabel: emptyActionLabel,
|
|
242
|
+
onAction: onEmptyAction,
|
|
243
|
+
testID: `${testID}-empty`,
|
|
244
|
+
},
|
|
245
|
+
slotProps.empty,
|
|
246
|
+
)
|
|
247
|
+
)}
|
|
248
|
+
</ScrollView>
|
|
249
|
+
</SafeAreaView>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<SafeAreaView testID={testID} edges={["left", "right", "bottom"]} style={{ flex: 1, backgroundColor: colors.groupedBackground }}>
|
|
255
|
+
<FlatList
|
|
256
|
+
testID={`${testID}-list`}
|
|
257
|
+
data={rows}
|
|
258
|
+
keyExtractor={(row) => row.id}
|
|
259
|
+
contentInsetAdjustmentBehavior="automatic"
|
|
260
|
+
// The header can hold a text field (the idea board's "Suggest"): its button's first tap
|
|
261
|
+
// must press it, not only close the keyboard.
|
|
262
|
+
keyboardShouldPersistTaps="handled"
|
|
263
|
+
ListHeaderComponent={headerNode}
|
|
264
|
+
ListFooterComponent={renderSlot(DefaultFooter, slots.footer, { loadingMore, testID: `${testID}-footer` }, slotProps.footer)}
|
|
265
|
+
contentContainerStyle={{ paddingTop: 8, paddingBottom: 32 }}
|
|
266
|
+
onEndReached={onEndReached}
|
|
267
|
+
onEndReachedThreshold={0.5}
|
|
268
|
+
refreshControl={refreshControl}
|
|
269
|
+
renderItem={({ item: row }) => {
|
|
270
|
+
const content = renderSlot(DefaultRow, slots.row, row, slotProps.row);
|
|
271
|
+
const actions = row.swipeActions ?? [];
|
|
272
|
+
return (
|
|
273
|
+
<Fragment>
|
|
274
|
+
{actions.length && slots.swipeable !== null
|
|
275
|
+
? renderSlot(PassThroughSwipeable, slots.swipeable, { actions, testID: `${row.testID}-swipe`, children: content }, slotProps.swipeable)
|
|
276
|
+
: content}
|
|
277
|
+
</Fragment>
|
|
278
|
+
);
|
|
279
|
+
}}
|
|
280
|
+
/>
|
|
281
|
+
</SafeAreaView>
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function EmptyPart(_props: InboxPageSlotMap["header"]) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** The default `swipeable`: no gesture, just the row (its actions are on long press and in the accessibility actions). */
|
|
290
|
+
function PassThroughSwipeable({ children }: InboxPageSlotMap["swipeable"]) {
|
|
291
|
+
return <>{children}</>;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function SectionTitle({ title, testID }: { title: string; testID: string }) {
|
|
295
|
+
const colors = useThemeRoles();
|
|
296
|
+
const ios = Platform.OS === "ios";
|
|
297
|
+
return (
|
|
298
|
+
<NativeText
|
|
299
|
+
testID={testID}
|
|
300
|
+
accessibilityRole="header"
|
|
301
|
+
className={ios ? "px-4 pb-1.5 pt-2" : "px-4 pb-2 pt-4 text-primary"}
|
|
302
|
+
style={
|
|
303
|
+
ios
|
|
304
|
+
? { marginHorizontal: IOS_GROUP_MARGIN, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18, textTransform: "uppercase" }
|
|
305
|
+
: { fontSize: 14, lineHeight: 20, fontWeight: "500" }
|
|
306
|
+
}
|
|
307
|
+
>
|
|
308
|
+
{title}
|
|
309
|
+
</NativeText>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** Opens a row's actions as a menu (long press). */
|
|
314
|
+
export function showInboxActions(title: string, actions: InboxSwipeAction[], cancelLabel = "Cancel"): void {
|
|
315
|
+
Alert.alert(title, undefined, [
|
|
316
|
+
...actions.map((a) => ({ text: a.label, style: a.destructive ? ("destructive" as const) : ("default" as const), onPress: a.onPress })),
|
|
317
|
+
{ text: cancelLabel, style: "cancel" as const },
|
|
318
|
+
]);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function DefaultRow(row: InboxPageSlotMap["row"]) {
|
|
322
|
+
const colors = useThemeRoles();
|
|
323
|
+
const ios = Platform.OS === "ios";
|
|
324
|
+
const [pressed, setPressed] = useState(false);
|
|
325
|
+
const actions = row.swipeActions ?? [];
|
|
326
|
+
const radius = iosGroupRadius();
|
|
327
|
+
const unreadLabel = row.unreadCount && row.unreadCount > 0 ? `${row.unreadCount} unread` : row.unread ? "Unread" : null;
|
|
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);
|
|
332
|
+
return (
|
|
333
|
+
<View
|
|
334
|
+
testID={`${row.testID}-cell`}
|
|
335
|
+
style={[
|
|
336
|
+
{ backgroundColor: colors.surface },
|
|
337
|
+
ios
|
|
338
|
+
? {
|
|
339
|
+
marginHorizontal: IOS_GROUP_MARGIN,
|
|
340
|
+
borderTopLeftRadius: row.isFirst ? radius : 0,
|
|
341
|
+
borderTopRightRadius: row.isFirst ? radius : 0,
|
|
342
|
+
borderBottomLeftRadius: row.isLast ? radius : 0,
|
|
343
|
+
borderBottomRightRadius: row.isLast ? radius : 0,
|
|
344
|
+
overflow: "hidden",
|
|
345
|
+
}
|
|
346
|
+
: null,
|
|
347
|
+
]}
|
|
348
|
+
>
|
|
349
|
+
<Pressable
|
|
350
|
+
testID={row.testID}
|
|
351
|
+
accessibilityRole={row.onPress ? "button" : undefined}
|
|
352
|
+
accessibilityLabel={label}
|
|
353
|
+
accessibilityActions={actions.map((a) => ({ name: a.id, label: a.label }))}
|
|
354
|
+
onAccessibilityAction={(event) => actions.find((a) => a.id === event.nativeEvent.actionName)?.onPress()}
|
|
355
|
+
onPress={row.onPress}
|
|
356
|
+
onLongPress={actions.length ? () => showInboxActions(row.title, actions) : undefined}
|
|
357
|
+
onPressIn={() => setPressed(true)}
|
|
358
|
+
onPressOut={() => setPressed(false)}
|
|
359
|
+
style={{ flexDirection: "row", alignItems: "center", paddingHorizontal: ROW_PADDING, paddingVertical: 11, minHeight: 60, backgroundColor: pressed && row.onPress ? colors.fill : undefined }}
|
|
360
|
+
>
|
|
361
|
+
<View style={{ width: LEADING_WIDTH, alignItems: "flex-start" }}>
|
|
362
|
+
{row.leading ?? (row.unreadCount && row.unreadCount > 0 ? null : <UnreadDot unread={!!row.unread} testID={`${row.testID}-unread`} color={colors.tint} />)}
|
|
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}
|
|
375
|
+
<View style={{ flex: 1, minWidth: 0 }}>
|
|
376
|
+
<View style={{ flexDirection: "row", alignItems: "baseline" }}>
|
|
377
|
+
<NativeText
|
|
378
|
+
numberOfLines={1}
|
|
379
|
+
style={{ flex: 1, color: colors.label, fontSize: 17, lineHeight: 22, fontWeight: row.unread || (row.unreadCount ?? 0) > 0 ? "600" : "400" }}
|
|
380
|
+
>
|
|
381
|
+
{row.title}
|
|
382
|
+
</NativeText>
|
|
383
|
+
{row.timeLabel ? (
|
|
384
|
+
<NativeText testID={`${row.testID}-time`} style={{ marginLeft: 8, color: colors.secondaryLabel, fontSize: 15, lineHeight: 20 }}>
|
|
385
|
+
{row.timeLabel}
|
|
386
|
+
</NativeText>
|
|
387
|
+
) : null}
|
|
388
|
+
</View>
|
|
389
|
+
{row.preview ? (
|
|
390
|
+
<NativeText numberOfLines={2} style={{ marginTop: 2, color: colors.secondaryLabel, fontSize: 15, lineHeight: 20 }}>
|
|
391
|
+
{row.preview}
|
|
392
|
+
</NativeText>
|
|
393
|
+
) : null}
|
|
394
|
+
{row.meta ? (
|
|
395
|
+
<NativeText testID={`${row.testID}-meta`} style={{ marginTop: 4, color: colors.tertiaryLabel, fontSize: 13, lineHeight: 18 }}>
|
|
396
|
+
{row.meta}
|
|
397
|
+
</NativeText>
|
|
398
|
+
) : null}
|
|
399
|
+
</View>
|
|
400
|
+
{row.unreadCount && row.unreadCount > 0 ? (
|
|
401
|
+
<View style={{ marginLeft: 8 }}>
|
|
402
|
+
<NativeBadge testID={`${row.testID}-count`}>{String(row.unreadCount)}</NativeBadge>
|
|
403
|
+
</View>
|
|
404
|
+
) : null}
|
|
405
|
+
{row.trailing ? <View style={{ marginLeft: 8 }}>{row.trailing}</View> : row.onPress ? <Chevron color={colors.tertiaryLabel} /> : null}
|
|
406
|
+
</Pressable>
|
|
407
|
+
{row.isLast ? null : (
|
|
408
|
+
<View accessibilityElementsHidden importantForAccessibility="no-hide-descendants" style={{ flexDirection: "row", height: StyleSheet.hairlineWidth }}>
|
|
409
|
+
<View testID={`${row.testID}-separator-inset`} style={{ width: separatorInset }} />
|
|
410
|
+
<View testID={`${row.testID}-separator-line`} style={{ flex: 1, backgroundColor: colors.separator }} />
|
|
411
|
+
</View>
|
|
412
|
+
)}
|
|
413
|
+
</View>
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function Chevron({ color }: { color: unknown }) {
|
|
418
|
+
return (
|
|
419
|
+
<NativeText accessibilityElementsHidden importantForAccessibility="no" style={{ marginLeft: 8, color: color as string, fontSize: 20, lineHeight: 22 }}>
|
|
420
|
+
›
|
|
421
|
+
</NativeText>
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function UnreadDot({ unread, testID, color }: { unread: boolean; testID: string; color: unknown }) {
|
|
426
|
+
if (!unread) return <View testID={testID} style={{ width: 10, height: 10 }} />;
|
|
427
|
+
return <View testID={testID} style={{ width: 10, height: 10, borderRadius: 5, backgroundColor: color as string }} />;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function DefaultFooter({ loadingMore, testID }: InboxPageSlotMap["footer"]) {
|
|
431
|
+
if (!loadingMore) return null;
|
|
432
|
+
return (
|
|
433
|
+
<View testID={testID} style={{ paddingVertical: 16 }}>
|
|
434
|
+
<ActivityIndicator accessibilityLabel="Loading more" />
|
|
435
|
+
</View>
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function DefaultEmpty({ title, body, actionLabel, onAction, testID }: InboxPageSlotMap["empty"]) {
|
|
440
|
+
return (
|
|
441
|
+
<NativeEmptyState
|
|
442
|
+
variant="first-run"
|
|
443
|
+
title={title}
|
|
444
|
+
body={body}
|
|
445
|
+
testID={testID}
|
|
446
|
+
primaryAction={
|
|
447
|
+
actionLabel && onAction ? (
|
|
448
|
+
<NativeButton onPress={onAction} testID={`${testID}-action`}>
|
|
449
|
+
{actionLabel}
|
|
450
|
+
</NativeButton>
|
|
451
|
+
) : undefined
|
|
452
|
+
}
|
|
453
|
+
/>
|
|
454
|
+
);
|
|
455
|
+
}
|