@marktiderman/genesis-ui-native 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-ULS7I6ZS.js → chunk-ERHGCWTY.js} +81 -12
- package/dist/chunk-ERHGCWTY.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-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 +142 -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 +320 -4
- 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/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__/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/auth-screen.tsx +6 -3
- package/src/layouts/google-sign-in.tsx +42 -0
- package/src/layouts/inbox-page.tsx +408 -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,1559 @@
|
|
|
1
|
+
import { NativeListItem, NativeSectionListHeader, NativeEmptyState } from './chunk-ERHGCWTY.js';
|
|
2
|
+
import { NativeText, NativeButton, useGenesisModules, NativeBadge, NativeInput } from './chunk-EFXCJ5AN.js';
|
|
3
|
+
import { useThemeMode, useThemeRoles } from './chunk-Z3AQYVUA.js';
|
|
4
|
+
import { cn } from './chunk-OHZD7KRO.js';
|
|
5
|
+
import { ScrollView, View, StatusBar, Pressable, Text, TextInput, Platform, StyleSheet, Alert, KeyboardAvoidingView, RefreshControl, SectionList, ActivityIndicator, FlatList, Image } from 'react-native';
|
|
6
|
+
import { SafeAreaView, SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
7
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
8
|
+
import { nativeColors } from '@marktiderman/genesis-design-system/tokens/native';
|
|
9
|
+
import { createContext, Fragment, useState, useMemo, createElement, useContext, useCallback, useRef, useEffect } from 'react';
|
|
10
|
+
import { renderSlot } from '@marktiderman/genesis-core/slots';
|
|
11
|
+
|
|
12
|
+
function composeHeaderOptions(props) {
|
|
13
|
+
const {
|
|
14
|
+
headerTitle,
|
|
15
|
+
headerLeft,
|
|
16
|
+
headerRight,
|
|
17
|
+
large,
|
|
18
|
+
scrollEdgeBehavior,
|
|
19
|
+
headerOptions
|
|
20
|
+
} = props;
|
|
21
|
+
const opts = {};
|
|
22
|
+
if (headerTitle !== void 0) opts.title = headerTitle;
|
|
23
|
+
if (headerLeft) opts.headerLeft = headerLeft;
|
|
24
|
+
if (headerRight) opts.headerRight = headerRight;
|
|
25
|
+
if (large) {
|
|
26
|
+
opts.headerLargeTitle = true;
|
|
27
|
+
if (scrollEdgeBehavior === "transparent") {
|
|
28
|
+
opts.headerTransparent = true;
|
|
29
|
+
} else if (scrollEdgeBehavior === "opaque") {
|
|
30
|
+
opts.headerLargeTitleShadowVisible = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (headerOptions) {
|
|
34
|
+
Object.assign(opts, headerOptions);
|
|
35
|
+
}
|
|
36
|
+
return opts;
|
|
37
|
+
}
|
|
38
|
+
var DEFAULT_EDGES = ["left", "right"];
|
|
39
|
+
var TRANSLUCENT_ANDROID_BAR = { translucent: true, backgroundColor: "transparent" };
|
|
40
|
+
function resolveBarStyle(statusBar, resolvedMode) {
|
|
41
|
+
if (statusBar === "auto") {
|
|
42
|
+
return resolvedMode === "dark" ? "light-content" : "dark-content";
|
|
43
|
+
}
|
|
44
|
+
if (statusBar === "light") return "light-content";
|
|
45
|
+
if (statusBar === "dark") return "dark-content";
|
|
46
|
+
return "default";
|
|
47
|
+
}
|
|
48
|
+
function ScreenContainer({
|
|
49
|
+
children,
|
|
50
|
+
scroll = false,
|
|
51
|
+
safeAreaEdges = DEFAULT_EDGES,
|
|
52
|
+
statusBar = "auto",
|
|
53
|
+
themeMode = "system",
|
|
54
|
+
className,
|
|
55
|
+
contentClassName,
|
|
56
|
+
keyboardShouldPersistTaps = "handled",
|
|
57
|
+
style,
|
|
58
|
+
testID
|
|
59
|
+
}) {
|
|
60
|
+
const osMode = useThemeMode();
|
|
61
|
+
const resolvedMode = themeMode === "system" ? osMode : themeMode;
|
|
62
|
+
const barStyle = resolveBarStyle(statusBar, resolvedMode);
|
|
63
|
+
const body = scroll ? /* @__PURE__ */ jsx(
|
|
64
|
+
ScrollView,
|
|
65
|
+
{
|
|
66
|
+
testID: testID ? `${testID}-scroll` : void 0,
|
|
67
|
+
keyboardShouldPersistTaps,
|
|
68
|
+
contentInsetAdjustmentBehavior: "automatic",
|
|
69
|
+
contentContainerClassName: cn("flex-grow", contentClassName),
|
|
70
|
+
children
|
|
71
|
+
}
|
|
72
|
+
) : /* @__PURE__ */ jsx(
|
|
73
|
+
View,
|
|
74
|
+
{
|
|
75
|
+
testID: testID ? `${testID}-body` : void 0,
|
|
76
|
+
className: cn("flex-1", contentClassName),
|
|
77
|
+
children
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
return /* @__PURE__ */ jsxs(
|
|
81
|
+
SafeAreaView,
|
|
82
|
+
{
|
|
83
|
+
testID: testID ?? "screen-container",
|
|
84
|
+
edges: safeAreaEdges,
|
|
85
|
+
className: cn("flex-1 bg-background", className),
|
|
86
|
+
style,
|
|
87
|
+
children: [
|
|
88
|
+
statusBar !== "hidden" ? /* @__PURE__ */ jsx(
|
|
89
|
+
StatusBar,
|
|
90
|
+
{
|
|
91
|
+
barStyle,
|
|
92
|
+
...TRANSLUCENT_ANDROID_BAR
|
|
93
|
+
}
|
|
94
|
+
) : /* @__PURE__ */ jsx(StatusBar, { hidden: true }),
|
|
95
|
+
body
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function NavBarSaveButton({
|
|
101
|
+
onPress,
|
|
102
|
+
label = "Save",
|
|
103
|
+
disabled,
|
|
104
|
+
loading,
|
|
105
|
+
destructive,
|
|
106
|
+
className,
|
|
107
|
+
testID
|
|
108
|
+
}) {
|
|
109
|
+
const isDisabled = !!disabled || !!loading || !onPress;
|
|
110
|
+
return /* @__PURE__ */ jsx(
|
|
111
|
+
Pressable,
|
|
112
|
+
{
|
|
113
|
+
testID: testID ?? "nav-bar-save-button",
|
|
114
|
+
accessibilityRole: "button",
|
|
115
|
+
accessibilityLabel: label,
|
|
116
|
+
accessibilityState: { disabled: isDisabled, busy: !!loading },
|
|
117
|
+
onPress: isDisabled ? void 0 : onPress,
|
|
118
|
+
disabled: isDisabled,
|
|
119
|
+
className: cn("min-h-[44px] justify-center px-3", className),
|
|
120
|
+
hitSlop: 8,
|
|
121
|
+
children: /* @__PURE__ */ jsx(
|
|
122
|
+
Text,
|
|
123
|
+
{
|
|
124
|
+
className: cn(
|
|
125
|
+
"text-base font-semibold",
|
|
126
|
+
destructive ? "text-destructive" : "text-primary",
|
|
127
|
+
isDisabled && "opacity-40"
|
|
128
|
+
),
|
|
129
|
+
children: loading ? "\u2026" : label
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
function NavBarTitle({
|
|
136
|
+
title,
|
|
137
|
+
subtitle,
|
|
138
|
+
onPress,
|
|
139
|
+
className,
|
|
140
|
+
testID
|
|
141
|
+
}) {
|
|
142
|
+
const inner = /* @__PURE__ */ jsxs(View, { className: cn("items-center justify-center", className), children: [
|
|
143
|
+
/* @__PURE__ */ jsx(
|
|
144
|
+
Text,
|
|
145
|
+
{
|
|
146
|
+
testID: testID ? `${testID}-title` : void 0,
|
|
147
|
+
className: "text-base font-semibold text-foreground",
|
|
148
|
+
numberOfLines: 1,
|
|
149
|
+
children: title
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
subtitle ? /* @__PURE__ */ jsx(
|
|
153
|
+
Text,
|
|
154
|
+
{
|
|
155
|
+
testID: testID ? `${testID}-subtitle` : void 0,
|
|
156
|
+
className: "text-xs text-muted-foreground",
|
|
157
|
+
numberOfLines: 1,
|
|
158
|
+
children: subtitle
|
|
159
|
+
}
|
|
160
|
+
) : null
|
|
161
|
+
] });
|
|
162
|
+
if (onPress) {
|
|
163
|
+
return /* @__PURE__ */ jsx(
|
|
164
|
+
Pressable,
|
|
165
|
+
{
|
|
166
|
+
testID: testID ?? "nav-bar-title",
|
|
167
|
+
accessibilityRole: "button",
|
|
168
|
+
accessibilityLabel: subtitle ? `${title}, ${subtitle}` : title,
|
|
169
|
+
onPress,
|
|
170
|
+
hitSlop: 8,
|
|
171
|
+
children: inner
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return /* @__PURE__ */ jsx(View, { testID: testID ?? "nav-bar-title", accessibilityRole: "header", children: inner });
|
|
176
|
+
}
|
|
177
|
+
function NavBarSearchBar({
|
|
178
|
+
value,
|
|
179
|
+
onChangeText,
|
|
180
|
+
placeholder = "Search",
|
|
181
|
+
onSubmit,
|
|
182
|
+
clearable = true,
|
|
183
|
+
className,
|
|
184
|
+
testID
|
|
185
|
+
}) {
|
|
186
|
+
return /* @__PURE__ */ jsxs(
|
|
187
|
+
View,
|
|
188
|
+
{
|
|
189
|
+
testID: testID ?? "nav-bar-search",
|
|
190
|
+
className: cn(
|
|
191
|
+
"min-h-[36px] flex-row items-center rounded-full bg-muted px-3",
|
|
192
|
+
className
|
|
193
|
+
),
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsx(
|
|
196
|
+
TextInput,
|
|
197
|
+
{
|
|
198
|
+
testID: testID ? `${testID}-input` : void 0,
|
|
199
|
+
accessibilityLabel: placeholder,
|
|
200
|
+
value,
|
|
201
|
+
onChangeText,
|
|
202
|
+
onSubmitEditing: onSubmit,
|
|
203
|
+
placeholder,
|
|
204
|
+
placeholderTextColor: nativeColors.neutral[400],
|
|
205
|
+
returnKeyType: "search",
|
|
206
|
+
autoCorrect: false,
|
|
207
|
+
autoCapitalize: "none",
|
|
208
|
+
clearButtonMode: clearable ? "while-editing" : "never",
|
|
209
|
+
className: "flex-1 text-base text-foreground"
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
clearable && value.length > 0 ? /* @__PURE__ */ jsx(
|
|
213
|
+
Pressable,
|
|
214
|
+
{
|
|
215
|
+
testID: testID ? `${testID}-clear` : void 0,
|
|
216
|
+
accessibilityRole: "button",
|
|
217
|
+
accessibilityLabel: "Clear search",
|
|
218
|
+
onPress: () => onChangeText(""),
|
|
219
|
+
hitSlop: 8,
|
|
220
|
+
className: "ml-2 px-1",
|
|
221
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: "\xD7" })
|
|
222
|
+
}
|
|
223
|
+
) : null
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
function getSettingsPageStackOptions(props) {
|
|
229
|
+
return composeHeaderOptions({
|
|
230
|
+
headerTitle: props.headerTitle ?? "Settings",
|
|
231
|
+
large: props.large ?? true,
|
|
232
|
+
scrollEdgeBehavior: props.scrollEdgeBehavior ?? "match",
|
|
233
|
+
headerLeft: props.headerLeft,
|
|
234
|
+
headerRight: props.headerRight,
|
|
235
|
+
headerOptions: props.headerOptions
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function SettingsPage({
|
|
239
|
+
sections,
|
|
240
|
+
dangerousActions,
|
|
241
|
+
className,
|
|
242
|
+
testID = "settings-page",
|
|
243
|
+
children,
|
|
244
|
+
slots = {},
|
|
245
|
+
slotProps = {}
|
|
246
|
+
}) {
|
|
247
|
+
const colors = useThemeRoles();
|
|
248
|
+
const inset = Platform.OS === "ios";
|
|
249
|
+
return /* @__PURE__ */ jsxs(
|
|
250
|
+
ScreenContainer,
|
|
251
|
+
{
|
|
252
|
+
scroll: true,
|
|
253
|
+
safeAreaEdges: ["left", "right", "bottom"],
|
|
254
|
+
testID,
|
|
255
|
+
contentClassName: "pb-8",
|
|
256
|
+
className,
|
|
257
|
+
style: { backgroundColor: colors.groupedBackground },
|
|
258
|
+
children: [
|
|
259
|
+
children ? /* @__PURE__ */ jsx(View, { className: "px-4 pt-2", children }) : null,
|
|
260
|
+
sections.map((section) => /* @__PURE__ */ jsxs(
|
|
261
|
+
View,
|
|
262
|
+
{
|
|
263
|
+
testID: `${testID}-section-${section.id}`,
|
|
264
|
+
className: "mt-6",
|
|
265
|
+
children: [
|
|
266
|
+
section.title ? renderSlot(
|
|
267
|
+
DefaultSectionHeader,
|
|
268
|
+
slots.sectionHeader,
|
|
269
|
+
{ title: section.title, testID: `${testID}-section-${section.id}-header` },
|
|
270
|
+
slotProps.sectionHeader
|
|
271
|
+
) : null,
|
|
272
|
+
/* @__PURE__ */ jsxs(
|
|
273
|
+
View,
|
|
274
|
+
{
|
|
275
|
+
testID: `${testID}-section-${section.id}-group`,
|
|
276
|
+
className: inset ? "overflow-hidden" : "border-y",
|
|
277
|
+
style: [
|
|
278
|
+
{ backgroundColor: colors.surface, borderColor: colors.separator },
|
|
279
|
+
inset ? { marginHorizontal: IOS_GROUP_MARGIN, borderRadius: iosGroupRadius() } : null
|
|
280
|
+
],
|
|
281
|
+
children: [
|
|
282
|
+
section.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(Fragment, { children: renderSlot(
|
|
283
|
+
DefaultRow,
|
|
284
|
+
slots.row,
|
|
285
|
+
{ ...row, testID: row.testID ?? `${testID}-row-${row.id}`, isLast: rowIndex === section.rows.length - 1 },
|
|
286
|
+
slotProps.row
|
|
287
|
+
) }, row.id)),
|
|
288
|
+
section.children
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
section.footnote ? renderSlot(DefaultFootnote, slots.footnote, { text: section.footnote }, slotProps.footnote) : null
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
section.id
|
|
296
|
+
)),
|
|
297
|
+
dangerousActions && dangerousActions.length > 0 ? renderSlot(
|
|
298
|
+
DefaultDangerousActions,
|
|
299
|
+
slots.dangerousActions,
|
|
300
|
+
{
|
|
301
|
+
actions: dangerousActions.map((action) => ({ ...action, testID: action.testID ?? `${testID}-danger-${slug(action.label)}` })),
|
|
302
|
+
testID: `${testID}-dangerous-actions`
|
|
303
|
+
},
|
|
304
|
+
slotProps.dangerousActions
|
|
305
|
+
) : null
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
var IOS_GROUP_MARGIN = 16;
|
|
311
|
+
function iosGroupRadius() {
|
|
312
|
+
return Number.parseFloat(String(Platform.Version)) >= 26 ? 26 : 10;
|
|
313
|
+
}
|
|
314
|
+
function iosTrailingSeparatorInset() {
|
|
315
|
+
return Platform.OS === "ios" && Number.parseFloat(String(Platform.Version)) >= 26;
|
|
316
|
+
}
|
|
317
|
+
function DefaultSectionHeader({ title, testID }) {
|
|
318
|
+
const colors = useThemeRoles();
|
|
319
|
+
if (Platform.OS === "ios") {
|
|
320
|
+
return /* @__PURE__ */ jsx(
|
|
321
|
+
NativeText,
|
|
322
|
+
{
|
|
323
|
+
testID,
|
|
324
|
+
accessibilityRole: "header",
|
|
325
|
+
accessibilityLabel: title,
|
|
326
|
+
dynamicTypeRamp: "footnote",
|
|
327
|
+
className: "px-4 pb-1.5 pt-2",
|
|
328
|
+
style: {
|
|
329
|
+
marginHorizontal: IOS_GROUP_MARGIN,
|
|
330
|
+
color: colors.secondaryLabel,
|
|
331
|
+
fontSize: 13,
|
|
332
|
+
lineHeight: 18,
|
|
333
|
+
textTransform: "uppercase"
|
|
334
|
+
},
|
|
335
|
+
children: title
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
return /* @__PURE__ */ jsx(
|
|
340
|
+
NativeText,
|
|
341
|
+
{
|
|
342
|
+
testID,
|
|
343
|
+
accessibilityRole: "header",
|
|
344
|
+
className: "px-4 pb-2 pt-4 text-primary",
|
|
345
|
+
style: { fontSize: 14, lineHeight: 20, fontWeight: "500" },
|
|
346
|
+
children: title
|
|
347
|
+
}
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
function DefaultRow({ isLast, id: _id, leading, ...row }) {
|
|
351
|
+
const colors = useThemeRoles();
|
|
352
|
+
const [leadingWidth, setLeadingWidth] = useState(0);
|
|
353
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
354
|
+
/* @__PURE__ */ jsx(
|
|
355
|
+
NativeListItem,
|
|
356
|
+
{
|
|
357
|
+
testID: row.testID,
|
|
358
|
+
className: "bg-transparent",
|
|
359
|
+
title: row.title,
|
|
360
|
+
subtitle: row.subtitle,
|
|
361
|
+
leading: leading ? /* @__PURE__ */ jsx(View, { onLayout: (event) => setLeadingWidth(event.nativeEvent.layout.width), children: leading }) : void 0,
|
|
362
|
+
trailing: row.trailing,
|
|
363
|
+
showChevron: row.showChevron,
|
|
364
|
+
onPress: row.onPress,
|
|
365
|
+
disabled: row.disabled
|
|
366
|
+
}
|
|
367
|
+
),
|
|
368
|
+
isLast ? null : /* @__PURE__ */ jsxs(
|
|
369
|
+
View,
|
|
370
|
+
{
|
|
371
|
+
testID: `${row.testID}-separator`,
|
|
372
|
+
accessibilityElementsHidden: true,
|
|
373
|
+
importantForAccessibility: "no-hide-descendants",
|
|
374
|
+
className: "flex-row",
|
|
375
|
+
style: { height: StyleSheet.hairlineWidth },
|
|
376
|
+
children: [
|
|
377
|
+
/* @__PURE__ */ jsx(View, { className: "w-4" }),
|
|
378
|
+
leading ? /* @__PURE__ */ jsx(View, { className: "mr-3", style: { width: leadingWidth } }) : null,
|
|
379
|
+
/* @__PURE__ */ jsx(View, { testID: `${row.testID}-separator-line`, className: "flex-1", style: { backgroundColor: colors.separator } }),
|
|
380
|
+
iosTrailingSeparatorInset() ? /* @__PURE__ */ jsx(View, { className: "w-4" }) : null
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
] });
|
|
385
|
+
}
|
|
386
|
+
function DefaultFootnote({ text }) {
|
|
387
|
+
const colors = useThemeRoles();
|
|
388
|
+
if (Platform.OS === "ios") {
|
|
389
|
+
return /* @__PURE__ */ jsx(
|
|
390
|
+
NativeText,
|
|
391
|
+
{
|
|
392
|
+
dynamicTypeRamp: "footnote",
|
|
393
|
+
className: "px-4 pt-1.5",
|
|
394
|
+
style: { marginHorizontal: IOS_GROUP_MARGIN, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18 },
|
|
395
|
+
children: text
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
return /* @__PURE__ */ jsx(NativeText, { preset: "body-sm", className: "px-4 pt-2", style: { color: colors.secondaryLabel }, children: text });
|
|
400
|
+
}
|
|
401
|
+
function DefaultDangerousActions({ actions, testID }) {
|
|
402
|
+
return /* @__PURE__ */ jsx(View, { testID, className: cn("mt-8 gap-2 px-4"), children: actions.map((action) => /* @__PURE__ */ jsx(
|
|
403
|
+
NativeButton,
|
|
404
|
+
{
|
|
405
|
+
testID: action.testID,
|
|
406
|
+
variant: action.emphasized ? "destructive" : "outline",
|
|
407
|
+
onPress: action.onPress,
|
|
408
|
+
children: action.label
|
|
409
|
+
},
|
|
410
|
+
action.label
|
|
411
|
+
)) });
|
|
412
|
+
}
|
|
413
|
+
function slug(s) {
|
|
414
|
+
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
415
|
+
}
|
|
416
|
+
var KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
417
|
+
var KeyboardScrollContext = createContext(null);
|
|
418
|
+
function KeyboardScrollProvider({
|
|
419
|
+
component,
|
|
420
|
+
toolbar,
|
|
421
|
+
children
|
|
422
|
+
}) {
|
|
423
|
+
const value = useMemo(() => ({ component, toolbar: toolbar ?? null }), [component, toolbar]);
|
|
424
|
+
return createElement(KeyboardScrollContext.Provider, { value }, children);
|
|
425
|
+
}
|
|
426
|
+
function useKeyboardScroll() {
|
|
427
|
+
return useContext(KeyboardScrollContext)?.component ?? null;
|
|
428
|
+
}
|
|
429
|
+
function useKeyboardToolbar() {
|
|
430
|
+
return useContext(KeyboardScrollContext)?.toolbar ?? null;
|
|
431
|
+
}
|
|
432
|
+
function confirmDiscardChanges(proceed) {
|
|
433
|
+
Alert.alert(
|
|
434
|
+
"Discard changes?",
|
|
435
|
+
"You have unsaved changes. Leave this screen and lose them?",
|
|
436
|
+
[
|
|
437
|
+
{ text: "Keep editing", style: "cancel" },
|
|
438
|
+
{
|
|
439
|
+
text: "Discard",
|
|
440
|
+
style: "destructive",
|
|
441
|
+
onPress: () => proceed()
|
|
442
|
+
}
|
|
443
|
+
]
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
function getSettingsSubPageStackOptions(props) {
|
|
447
|
+
const {
|
|
448
|
+
headerTitle,
|
|
449
|
+
dirty,
|
|
450
|
+
saving,
|
|
451
|
+
onSave,
|
|
452
|
+
saveLabel = "Save",
|
|
453
|
+
large = false,
|
|
454
|
+
scrollEdgeBehavior,
|
|
455
|
+
headerLeft,
|
|
456
|
+
headerRight,
|
|
457
|
+
headerOptions
|
|
458
|
+
} = props;
|
|
459
|
+
const resolvedHeaderRight = headerRight ?? (onSave ? () => /* @__PURE__ */ jsx(
|
|
460
|
+
NavBarSaveButton,
|
|
461
|
+
{
|
|
462
|
+
label: saveLabel,
|
|
463
|
+
onPress: () => {
|
|
464
|
+
void onSave();
|
|
465
|
+
},
|
|
466
|
+
disabled: !dirty,
|
|
467
|
+
loading: saving
|
|
468
|
+
}
|
|
469
|
+
) : void 0);
|
|
470
|
+
return composeHeaderOptions({
|
|
471
|
+
headerTitle,
|
|
472
|
+
headerLeft,
|
|
473
|
+
headerRight: resolvedHeaderRight,
|
|
474
|
+
large,
|
|
475
|
+
scrollEdgeBehavior,
|
|
476
|
+
headerOptions
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
function SettingsSubPage({
|
|
480
|
+
children,
|
|
481
|
+
onConfirmLeave,
|
|
482
|
+
className,
|
|
483
|
+
testID = "settings-sub-page"
|
|
484
|
+
}) {
|
|
485
|
+
useCallback(
|
|
486
|
+
(proceed) => {
|
|
487
|
+
if (onConfirmLeave === null) {
|
|
488
|
+
proceed();
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
const fn = onConfirmLeave ?? confirmDiscardChanges;
|
|
492
|
+
fn(proceed);
|
|
493
|
+
},
|
|
494
|
+
[onConfirmLeave]
|
|
495
|
+
);
|
|
496
|
+
const KeyboardScroll = useKeyboardScroll();
|
|
497
|
+
const KeyboardToolbar = useKeyboardToolbar();
|
|
498
|
+
if (KeyboardScroll) {
|
|
499
|
+
return /* @__PURE__ */ jsxs(ScreenContainer, { safeAreaEdges: ["left", "right"], testID, children: [
|
|
500
|
+
/* @__PURE__ */ jsx(
|
|
501
|
+
KeyboardScroll,
|
|
502
|
+
{
|
|
503
|
+
testID: `${testID}-keyboard`,
|
|
504
|
+
keyboardShouldPersistTaps: "handled",
|
|
505
|
+
contentInsetAdjustmentBehavior: "automatic",
|
|
506
|
+
bottomOffset: KeyboardToolbar ? 24 + KEYBOARD_TOOLBAR_HEIGHT : 24,
|
|
507
|
+
children: /* @__PURE__ */ jsx(View, { className: cn("p-4", className), children: /* @__PURE__ */ jsx(View, { testID: `${testID}-form`, className: "gap-4", children }) })
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
KeyboardToolbar ? /* @__PURE__ */ jsx(KeyboardToolbar, {}) : null
|
|
511
|
+
] });
|
|
512
|
+
}
|
|
513
|
+
return /* @__PURE__ */ jsx(
|
|
514
|
+
KeyboardAvoidingView,
|
|
515
|
+
{
|
|
516
|
+
testID: `${testID}-kav`,
|
|
517
|
+
style: { flex: 1 },
|
|
518
|
+
behavior: Platform.OS === "ios" ? "padding" : void 0,
|
|
519
|
+
children: /* @__PURE__ */ jsx(
|
|
520
|
+
ScreenContainer,
|
|
521
|
+
{
|
|
522
|
+
scroll: true,
|
|
523
|
+
safeAreaEdges: ["left", "right", "bottom"],
|
|
524
|
+
testID,
|
|
525
|
+
contentClassName: cn("p-4", className),
|
|
526
|
+
keyboardShouldPersistTaps: "handled",
|
|
527
|
+
children: /* @__PURE__ */ jsx(View, { testID: `${testID}-form`, className: "gap-4", children })
|
|
528
|
+
}
|
|
529
|
+
)
|
|
530
|
+
}
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
function getNotificationsPageStackOptions(props) {
|
|
534
|
+
const {
|
|
535
|
+
headerTitle,
|
|
536
|
+
onMarkAllRead,
|
|
537
|
+
large,
|
|
538
|
+
scrollEdgeBehavior,
|
|
539
|
+
headerLeft,
|
|
540
|
+
headerRight,
|
|
541
|
+
headerOptions
|
|
542
|
+
} = props;
|
|
543
|
+
const resolvedHeaderRight = headerRight ?? (onMarkAllRead ? () => /* @__PURE__ */ jsx(
|
|
544
|
+
Pressable,
|
|
545
|
+
{
|
|
546
|
+
testID: "notifications-mark-all-read",
|
|
547
|
+
accessibilityRole: "button",
|
|
548
|
+
accessibilityLabel: "Mark all read",
|
|
549
|
+
onPress: onMarkAllRead,
|
|
550
|
+
hitSlop: 8,
|
|
551
|
+
className: "min-h-[44px] justify-center px-3",
|
|
552
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-primary", children: "Mark all read" })
|
|
553
|
+
}
|
|
554
|
+
) : void 0);
|
|
555
|
+
return composeHeaderOptions({
|
|
556
|
+
headerTitle: headerTitle ?? "Notifications",
|
|
557
|
+
headerLeft,
|
|
558
|
+
headerRight: resolvedHeaderRight,
|
|
559
|
+
large: large ?? true,
|
|
560
|
+
scrollEdgeBehavior: scrollEdgeBehavior ?? "match",
|
|
561
|
+
headerOptions
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
function bucketFor(ts, now = /* @__PURE__ */ new Date()) {
|
|
565
|
+
const d = typeof ts === "string" ? new Date(ts) : ts;
|
|
566
|
+
const startOfDay = (date) => {
|
|
567
|
+
const x = new Date(date);
|
|
568
|
+
x.setHours(0, 0, 0, 0);
|
|
569
|
+
return x.getTime();
|
|
570
|
+
};
|
|
571
|
+
const today = startOfDay(now);
|
|
572
|
+
const yesterday = today - 24 * 60 * 60 * 1e3;
|
|
573
|
+
const day = startOfDay(d);
|
|
574
|
+
if (day === today) return "Today";
|
|
575
|
+
if (day === yesterday) return "Yesterday";
|
|
576
|
+
return "Earlier";
|
|
577
|
+
}
|
|
578
|
+
function groupByDate(items, now = /* @__PURE__ */ new Date()) {
|
|
579
|
+
const map = /* @__PURE__ */ new Map();
|
|
580
|
+
for (const item of items) {
|
|
581
|
+
const bucket = bucketFor(item.timestamp, now);
|
|
582
|
+
const arr = map.get(bucket) ?? [];
|
|
583
|
+
arr.push(item);
|
|
584
|
+
map.set(bucket, arr);
|
|
585
|
+
}
|
|
586
|
+
const order = ["Today", "Yesterday", "Earlier"];
|
|
587
|
+
return order.filter((title) => map.has(title)).map((title) => ({
|
|
588
|
+
title,
|
|
589
|
+
data: map.get(title) ?? []
|
|
590
|
+
}));
|
|
591
|
+
}
|
|
592
|
+
function flattenSections(sections) {
|
|
593
|
+
const rows = [];
|
|
594
|
+
const headerIndices = [];
|
|
595
|
+
for (const section of sections) {
|
|
596
|
+
headerIndices.push(rows.length);
|
|
597
|
+
rows.push({ kind: "header", title: section.title });
|
|
598
|
+
section.data.forEach((item, i) => rows.push({ kind: "item", item, last: i === section.data.length - 1 }));
|
|
599
|
+
}
|
|
600
|
+
return { rows, headerIndices };
|
|
601
|
+
}
|
|
602
|
+
function flatRowKey(row) {
|
|
603
|
+
return row.kind === "header" ? `header:${row.title}` : row.item.id;
|
|
604
|
+
}
|
|
605
|
+
function flatRowType(row) {
|
|
606
|
+
return row.kind === "header" ? "header" : row.last ? "item-last" : "item";
|
|
607
|
+
}
|
|
608
|
+
var NO_SLOTS = {};
|
|
609
|
+
function iosCompactNavigationBarHeight(version) {
|
|
610
|
+
const major = typeof version === "number" ? version : parseInt(version, 10);
|
|
611
|
+
return Number.isFinite(major) && major >= 26 ? 54 : 44;
|
|
612
|
+
}
|
|
613
|
+
function defaultStickyHeaderOffset(os, version, safeAreaTop) {
|
|
614
|
+
return os === "ios" ? safeAreaTop + iosCompactNavigationBarHeight(version) : 0;
|
|
615
|
+
}
|
|
616
|
+
function NotificationsPage({
|
|
617
|
+
items,
|
|
618
|
+
refreshing,
|
|
619
|
+
onRefresh,
|
|
620
|
+
emptyState,
|
|
621
|
+
emptyTitle,
|
|
622
|
+
emptyBody,
|
|
623
|
+
className,
|
|
624
|
+
testID = "notifications-page",
|
|
625
|
+
slots = NO_SLOTS,
|
|
626
|
+
slotProps = NO_SLOTS,
|
|
627
|
+
stickyHeaderOffset
|
|
628
|
+
}) {
|
|
629
|
+
const safeTop = useContext(SafeAreaInsetsContext)?.top ?? 0;
|
|
630
|
+
const stickAt = stickyHeaderOffset ?? defaultStickyHeaderOffset(Platform.OS, Platform.Version, safeTop);
|
|
631
|
+
const sections = useMemo(() => groupByDate(items), [items]);
|
|
632
|
+
const { list: FlashList } = useGenesisModules();
|
|
633
|
+
const flat = useMemo(() => flattenSections(sections), [sections]);
|
|
634
|
+
const renderFlatRow = useCallback(
|
|
635
|
+
({ item: row }) => row.kind === "header" ? renderSlot(DefaultSectionHeader2, slots.sectionHeader, { title: row.title }, slotProps.sectionHeader) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
636
|
+
renderSlot(DefaultRow2, slots.row, { ...row.item, testID: row.item.testID ?? `${testID}-row-${row.item.id}` }, slotProps.row),
|
|
637
|
+
row.last ? null : /* @__PURE__ */ jsx(RowSeparator, {})
|
|
638
|
+
] }),
|
|
639
|
+
[slots, slotProps, testID]
|
|
640
|
+
);
|
|
641
|
+
if (items.length === 0) {
|
|
642
|
+
return /* @__PURE__ */ jsx(
|
|
643
|
+
SafeAreaView,
|
|
644
|
+
{
|
|
645
|
+
testID,
|
|
646
|
+
edges: ["left", "right", "bottom"],
|
|
647
|
+
className: cn("flex-1 bg-background", className),
|
|
648
|
+
children: /* @__PURE__ */ jsx(
|
|
649
|
+
ScrollView,
|
|
650
|
+
{
|
|
651
|
+
testID: `${testID}-empty-scroll`,
|
|
652
|
+
contentInsetAdjustmentBehavior: "automatic",
|
|
653
|
+
contentContainerStyle: { flexGrow: 1, justifyContent: "center" },
|
|
654
|
+
refreshControl: onRefresh ? /* @__PURE__ */ jsx(RefreshControl, { testID: `${testID}-refresh`, refreshing: !!refreshing, onRefresh }) : void 0,
|
|
655
|
+
children: emptyState ?? renderSlot(
|
|
656
|
+
DefaultEmpty,
|
|
657
|
+
slots.empty,
|
|
658
|
+
{
|
|
659
|
+
title: emptyTitle ?? "No notifications",
|
|
660
|
+
body: emptyBody ?? "When you get a notification, it'll show up here.",
|
|
661
|
+
testID: `${testID}-empty`
|
|
662
|
+
},
|
|
663
|
+
slotProps.empty
|
|
664
|
+
)
|
|
665
|
+
}
|
|
666
|
+
)
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
if (FlashList) {
|
|
671
|
+
return /* @__PURE__ */ jsx(
|
|
672
|
+
SafeAreaView,
|
|
673
|
+
{
|
|
674
|
+
testID,
|
|
675
|
+
edges: ["left", "right", "bottom"],
|
|
676
|
+
className: cn("flex-1 bg-background", className),
|
|
677
|
+
children: /* @__PURE__ */ jsx(
|
|
678
|
+
FlashList,
|
|
679
|
+
{
|
|
680
|
+
testID: `${testID}-list`,
|
|
681
|
+
data: flat.rows,
|
|
682
|
+
keyExtractor: flatRowKey,
|
|
683
|
+
getItemType: flatRowType,
|
|
684
|
+
stickyHeaderIndices: flat.headerIndices,
|
|
685
|
+
stickyHeaderConfig: { offset: stickAt },
|
|
686
|
+
renderItem: renderFlatRow,
|
|
687
|
+
refreshing: onRefresh ? !!refreshing : void 0,
|
|
688
|
+
onRefresh: onRefresh ? () => void onRefresh() : void 0,
|
|
689
|
+
contentContainerStyle: { paddingBottom: 28 }
|
|
690
|
+
}
|
|
691
|
+
)
|
|
692
|
+
}
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
return /* @__PURE__ */ jsx(
|
|
696
|
+
SafeAreaView,
|
|
697
|
+
{
|
|
698
|
+
testID,
|
|
699
|
+
edges: ["left", "right", "bottom"],
|
|
700
|
+
className: cn("flex-1 bg-background", className),
|
|
701
|
+
children: /* @__PURE__ */ jsx(
|
|
702
|
+
SectionList,
|
|
703
|
+
{
|
|
704
|
+
testID: `${testID}-list`,
|
|
705
|
+
sections,
|
|
706
|
+
keyExtractor: (item) => item.id,
|
|
707
|
+
renderSectionHeader: ({ section }) => renderSlot(DefaultSectionHeader2, slots.sectionHeader, { title: section.title }, slotProps.sectionHeader),
|
|
708
|
+
renderItem: ({ item }) => renderSlot(DefaultRow2, slots.row, { ...item, testID: item.testID ?? `${testID}-row-${item.id}` }, slotProps.row),
|
|
709
|
+
ItemSeparatorComponent: RowSeparator,
|
|
710
|
+
stickySectionHeadersEnabled: stickAt === 0,
|
|
711
|
+
refreshControl: onRefresh ? /* @__PURE__ */ jsx(
|
|
712
|
+
RefreshControl,
|
|
713
|
+
{
|
|
714
|
+
testID: `${testID}-refresh`,
|
|
715
|
+
refreshing: !!refreshing,
|
|
716
|
+
onRefresh
|
|
717
|
+
}
|
|
718
|
+
) : void 0,
|
|
719
|
+
contentContainerClassName: "pb-8"
|
|
720
|
+
}
|
|
721
|
+
)
|
|
722
|
+
}
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
function RowSeparator() {
|
|
726
|
+
return /* @__PURE__ */ jsx(View, { className: "h-px bg-border ml-4" });
|
|
727
|
+
}
|
|
728
|
+
function DefaultSectionHeader2({ title }) {
|
|
729
|
+
return /* @__PURE__ */ jsx(NativeSectionListHeader, { title });
|
|
730
|
+
}
|
|
731
|
+
function DefaultRow2(item) {
|
|
732
|
+
return /* @__PURE__ */ jsx(
|
|
733
|
+
NativeListItem,
|
|
734
|
+
{
|
|
735
|
+
testID: item.testID,
|
|
736
|
+
title: item.title,
|
|
737
|
+
subtitle: item.body,
|
|
738
|
+
leading: item.leading ?? /* @__PURE__ */ jsx(UnreadDot, { unread: !!item.unread, testID: `${item.testID}-unread` }),
|
|
739
|
+
onPress: item.onPress
|
|
740
|
+
}
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
function DefaultEmpty({ title, body, testID }) {
|
|
744
|
+
return /* @__PURE__ */ jsx(NativeEmptyState, { variant: "first-run", title, body, testID });
|
|
745
|
+
}
|
|
746
|
+
function UnreadDot({
|
|
747
|
+
unread,
|
|
748
|
+
testID
|
|
749
|
+
}) {
|
|
750
|
+
if (!unread) {
|
|
751
|
+
return /* @__PURE__ */ jsx(View, { className: "h-2 w-2", testID });
|
|
752
|
+
}
|
|
753
|
+
return /* @__PURE__ */ jsx(
|
|
754
|
+
View,
|
|
755
|
+
{
|
|
756
|
+
testID,
|
|
757
|
+
accessibilityLabel: "Unread",
|
|
758
|
+
className: "h-2 w-2 rounded-full bg-primary"
|
|
759
|
+
}
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
function getInboxPageStackOptions(props) {
|
|
763
|
+
return composeHeaderOptions({
|
|
764
|
+
headerTitle: props.headerTitle ?? "Inbox",
|
|
765
|
+
large: props.large ?? true,
|
|
766
|
+
scrollEdgeBehavior: props.scrollEdgeBehavior ?? "match",
|
|
767
|
+
headerLeft: props.headerLeft,
|
|
768
|
+
headerRight: props.headerRight,
|
|
769
|
+
headerOptions: props.headerOptions
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
773
|
+
function formatInboxTime(date, now) {
|
|
774
|
+
const start = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
775
|
+
const days = Math.round((start(now) - start(date)) / DAY_MS);
|
|
776
|
+
if (days <= 0) return date.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
777
|
+
if (days === 1) return "Yesterday";
|
|
778
|
+
if (days < 7) return date.toLocaleDateString(void 0, { weekday: "long" });
|
|
779
|
+
return date.toLocaleDateString(void 0, { day: "numeric", month: "short", year: date.getFullYear() === now.getFullYear() ? void 0 : "numeric" });
|
|
780
|
+
}
|
|
781
|
+
var IOS_GROUP_MARGIN2 = 16;
|
|
782
|
+
function iosGroupRadius2() {
|
|
783
|
+
return Number.parseFloat(String(Platform.Version)) >= 26 ? 26 : 10;
|
|
784
|
+
}
|
|
785
|
+
function InboxPage({
|
|
786
|
+
items,
|
|
787
|
+
refreshing,
|
|
788
|
+
onRefresh,
|
|
789
|
+
onEndReached,
|
|
790
|
+
loadingMore = false,
|
|
791
|
+
header,
|
|
792
|
+
sectionTitle,
|
|
793
|
+
emptyTitle,
|
|
794
|
+
emptyBody,
|
|
795
|
+
emptyActionLabel,
|
|
796
|
+
onEmptyAction,
|
|
797
|
+
loading = false,
|
|
798
|
+
error = false,
|
|
799
|
+
errorTitle,
|
|
800
|
+
errorBody,
|
|
801
|
+
formatTime = formatInboxTime,
|
|
802
|
+
now = () => /* @__PURE__ */ new Date(),
|
|
803
|
+
slots = {},
|
|
804
|
+
slotProps = {},
|
|
805
|
+
testID = "inbox-page"
|
|
806
|
+
}) {
|
|
807
|
+
const colors = useThemeRoles();
|
|
808
|
+
const clock = now();
|
|
809
|
+
const rows = items.map((item, index) => ({
|
|
810
|
+
...item,
|
|
811
|
+
testID: item.testID ?? `${testID}-row-${item.id}`,
|
|
812
|
+
isFirst: index === 0,
|
|
813
|
+
isLast: index === items.length - 1,
|
|
814
|
+
timeLabel: item.timestamp ? formatTime(typeof item.timestamp === "string" ? new Date(item.timestamp) : item.timestamp, clock) : null
|
|
815
|
+
}));
|
|
816
|
+
const headerNode = /* @__PURE__ */ jsxs(View, { children: [
|
|
817
|
+
header ?? renderSlot(EmptyPart, slots.header, { testID: `${testID}-header` }, slotProps.header),
|
|
818
|
+
sectionTitle ? /* @__PURE__ */ jsx(SectionTitle, { title: sectionTitle, testID: `${testID}-section-title` }) : null
|
|
819
|
+
] });
|
|
820
|
+
if (items.length === 0) {
|
|
821
|
+
return /* @__PURE__ */ jsxs(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: { flex: 1, backgroundColor: colors.groupedBackground }, children: [
|
|
822
|
+
headerNode,
|
|
823
|
+
loading ? /* @__PURE__ */ jsx(View, { testID: `${testID}-loading`, style: { paddingVertical: 32 }, children: /* @__PURE__ */ jsx(ActivityIndicator, { accessibilityLabel: "Loading" }) }) : renderSlot(
|
|
824
|
+
DefaultEmpty2,
|
|
825
|
+
slots.empty,
|
|
826
|
+
error ? {
|
|
827
|
+
title: errorTitle ?? "Couldn't load this",
|
|
828
|
+
body: errorBody ?? "Check your connection, then pull to refresh.",
|
|
829
|
+
actionLabel: onRefresh ? "Try again" : void 0,
|
|
830
|
+
onAction: onRefresh ? () => void onRefresh() : void 0,
|
|
831
|
+
testID: `${testID}-error`
|
|
832
|
+
} : {
|
|
833
|
+
title: emptyTitle ?? "Nothing here yet",
|
|
834
|
+
body: emptyBody ?? "When there's something new, it shows up here.",
|
|
835
|
+
actionLabel: emptyActionLabel,
|
|
836
|
+
onAction: onEmptyAction,
|
|
837
|
+
testID: `${testID}-empty`
|
|
838
|
+
},
|
|
839
|
+
slotProps.empty
|
|
840
|
+
)
|
|
841
|
+
] });
|
|
842
|
+
}
|
|
843
|
+
return /* @__PURE__ */ jsx(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: { flex: 1, backgroundColor: colors.groupedBackground }, children: /* @__PURE__ */ jsx(
|
|
844
|
+
FlatList,
|
|
845
|
+
{
|
|
846
|
+
testID: `${testID}-list`,
|
|
847
|
+
data: rows,
|
|
848
|
+
keyExtractor: (row) => row.id,
|
|
849
|
+
contentInsetAdjustmentBehavior: "automatic",
|
|
850
|
+
keyboardShouldPersistTaps: "handled",
|
|
851
|
+
ListHeaderComponent: headerNode,
|
|
852
|
+
ListFooterComponent: renderSlot(DefaultFooter, slots.footer, { loadingMore, testID: `${testID}-footer` }, slotProps.footer),
|
|
853
|
+
contentContainerStyle: { paddingTop: 8, paddingBottom: 32 },
|
|
854
|
+
onEndReached,
|
|
855
|
+
onEndReachedThreshold: 0.5,
|
|
856
|
+
refreshControl: onRefresh ? /* @__PURE__ */ jsx(RefreshControl, { testID: `${testID}-refresh`, refreshing: !!refreshing, onRefresh }) : void 0,
|
|
857
|
+
renderItem: ({ item: row }) => {
|
|
858
|
+
const content = renderSlot(DefaultRow3, slots.row, row, slotProps.row);
|
|
859
|
+
const actions = row.swipeActions ?? [];
|
|
860
|
+
return /* @__PURE__ */ jsx(Fragment, { children: actions.length && slots.swipeable !== null ? renderSlot(PassThroughSwipeable, slots.swipeable, { actions, testID: `${row.testID}-swipe`, children: content }, slotProps.swipeable) : content });
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
) });
|
|
864
|
+
}
|
|
865
|
+
function EmptyPart(_props) {
|
|
866
|
+
return null;
|
|
867
|
+
}
|
|
868
|
+
function PassThroughSwipeable({ children }) {
|
|
869
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
870
|
+
}
|
|
871
|
+
function SectionTitle({ title, testID }) {
|
|
872
|
+
const colors = useThemeRoles();
|
|
873
|
+
const ios = Platform.OS === "ios";
|
|
874
|
+
return /* @__PURE__ */ jsx(
|
|
875
|
+
NativeText,
|
|
876
|
+
{
|
|
877
|
+
testID,
|
|
878
|
+
accessibilityRole: "header",
|
|
879
|
+
className: ios ? "px-4 pb-1.5 pt-2" : "px-4 pb-2 pt-4 text-primary",
|
|
880
|
+
style: ios ? { marginHorizontal: IOS_GROUP_MARGIN2, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18, textTransform: "uppercase" } : { fontSize: 14, lineHeight: 20, fontWeight: "500" },
|
|
881
|
+
children: title
|
|
882
|
+
}
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
function showInboxActions(title, actions, cancelLabel = "Cancel") {
|
|
886
|
+
Alert.alert(title, void 0, [
|
|
887
|
+
...actions.map((a) => ({ text: a.label, style: a.destructive ? "destructive" : "default", onPress: a.onPress })),
|
|
888
|
+
{ text: cancelLabel, style: "cancel" }
|
|
889
|
+
]);
|
|
890
|
+
}
|
|
891
|
+
function DefaultRow3(row) {
|
|
892
|
+
const colors = useThemeRoles();
|
|
893
|
+
const ios = Platform.OS === "ios";
|
|
894
|
+
const [pressed, setPressed] = useState(false);
|
|
895
|
+
const actions = row.swipeActions ?? [];
|
|
896
|
+
const radius = iosGroupRadius2();
|
|
897
|
+
const unreadLabel = row.unreadCount && row.unreadCount > 0 ? `${row.unreadCount} unread` : row.unread ? "Unread" : null;
|
|
898
|
+
const label = [unreadLabel, row.title, row.timeLabel, row.preview, row.meta].filter(Boolean).join(", ");
|
|
899
|
+
return /* @__PURE__ */ jsxs(
|
|
900
|
+
View,
|
|
901
|
+
{
|
|
902
|
+
testID: `${row.testID}-cell`,
|
|
903
|
+
style: [
|
|
904
|
+
{ backgroundColor: colors.surface },
|
|
905
|
+
ios ? {
|
|
906
|
+
marginHorizontal: IOS_GROUP_MARGIN2,
|
|
907
|
+
borderTopLeftRadius: row.isFirst ? radius : 0,
|
|
908
|
+
borderTopRightRadius: row.isFirst ? radius : 0,
|
|
909
|
+
borderBottomLeftRadius: row.isLast ? radius : 0,
|
|
910
|
+
borderBottomRightRadius: row.isLast ? radius : 0,
|
|
911
|
+
overflow: "hidden"
|
|
912
|
+
} : null
|
|
913
|
+
],
|
|
914
|
+
children: [
|
|
915
|
+
/* @__PURE__ */ jsxs(
|
|
916
|
+
Pressable,
|
|
917
|
+
{
|
|
918
|
+
testID: row.testID,
|
|
919
|
+
accessibilityRole: row.onPress ? "button" : void 0,
|
|
920
|
+
accessibilityLabel: label,
|
|
921
|
+
accessibilityActions: actions.map((a) => ({ name: a.id, label: a.label })),
|
|
922
|
+
onAccessibilityAction: (event) => actions.find((a) => a.id === event.nativeEvent.actionName)?.onPress(),
|
|
923
|
+
onPress: row.onPress,
|
|
924
|
+
onLongPress: actions.length ? () => showInboxActions(row.title, actions) : void 0,
|
|
925
|
+
onPressIn: () => setPressed(true),
|
|
926
|
+
onPressOut: () => setPressed(false),
|
|
927
|
+
style: { flexDirection: "row", alignItems: "center", paddingHorizontal: 16, paddingVertical: 11, minHeight: 60, backgroundColor: pressed && row.onPress ? colors.fill : void 0 },
|
|
928
|
+
children: [
|
|
929
|
+
/* @__PURE__ */ jsx(View, { style: { width: 18, alignItems: "flex-start" }, children: row.leading ?? (row.unreadCount && row.unreadCount > 0 ? null : /* @__PURE__ */ jsx(UnreadDot2, { unread: !!row.unread, testID: `${row.testID}-unread`, color: colors.tint })) }),
|
|
930
|
+
/* @__PURE__ */ jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [
|
|
931
|
+
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "baseline" }, children: [
|
|
932
|
+
/* @__PURE__ */ jsx(
|
|
933
|
+
NativeText,
|
|
934
|
+
{
|
|
935
|
+
numberOfLines: 1,
|
|
936
|
+
style: { flex: 1, color: colors.label, fontSize: 17, lineHeight: 22, fontWeight: row.unread || (row.unreadCount ?? 0) > 0 ? "600" : "400" },
|
|
937
|
+
children: row.title
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
row.timeLabel ? /* @__PURE__ */ jsx(NativeText, { testID: `${row.testID}-time`, style: { marginLeft: 8, color: colors.secondaryLabel, fontSize: 15, lineHeight: 20 }, children: row.timeLabel }) : null
|
|
941
|
+
] }),
|
|
942
|
+
row.preview ? /* @__PURE__ */ jsx(NativeText, { numberOfLines: 2, style: { marginTop: 2, color: colors.secondaryLabel, fontSize: 15, lineHeight: 20 }, children: row.preview }) : null,
|
|
943
|
+
row.meta ? /* @__PURE__ */ jsx(NativeText, { testID: `${row.testID}-meta`, style: { marginTop: 4, color: colors.tertiaryLabel, fontSize: 13, lineHeight: 18 }, children: row.meta }) : null
|
|
944
|
+
] }),
|
|
945
|
+
row.unreadCount && row.unreadCount > 0 ? /* @__PURE__ */ jsx(View, { style: { marginLeft: 8 }, children: /* @__PURE__ */ jsx(NativeBadge, { testID: `${row.testID}-count`, children: String(row.unreadCount) }) }) : null,
|
|
946
|
+
row.trailing ? /* @__PURE__ */ jsx(View, { style: { marginLeft: 8 }, children: row.trailing }) : row.onPress ? /* @__PURE__ */ jsx(Chevron, { color: colors.tertiaryLabel }) : null
|
|
947
|
+
]
|
|
948
|
+
}
|
|
949
|
+
),
|
|
950
|
+
row.isLast ? null : /* @__PURE__ */ jsxs(View, { accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { flexDirection: "row", height: StyleSheet.hairlineWidth }, children: [
|
|
951
|
+
/* @__PURE__ */ jsx(View, { style: { width: 34 } }),
|
|
952
|
+
/* @__PURE__ */ jsx(View, { testID: `${row.testID}-separator-line`, style: { flex: 1, backgroundColor: colors.separator } })
|
|
953
|
+
] })
|
|
954
|
+
]
|
|
955
|
+
}
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
function Chevron({ color }) {
|
|
959
|
+
return /* @__PURE__ */ jsx(NativeText, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { marginLeft: 8, color, fontSize: 20, lineHeight: 22 }, children: "\u203A" });
|
|
960
|
+
}
|
|
961
|
+
function UnreadDot2({ unread, testID, color }) {
|
|
962
|
+
if (!unread) return /* @__PURE__ */ jsx(View, { testID, style: { width: 10, height: 10 } });
|
|
963
|
+
return /* @__PURE__ */ jsx(View, { testID, style: { width: 10, height: 10, borderRadius: 5, backgroundColor: color } });
|
|
964
|
+
}
|
|
965
|
+
function DefaultFooter({ loadingMore, testID }) {
|
|
966
|
+
if (!loadingMore) return null;
|
|
967
|
+
return /* @__PURE__ */ jsx(View, { testID, style: { paddingVertical: 16 }, children: /* @__PURE__ */ jsx(ActivityIndicator, { accessibilityLabel: "Loading more" }) });
|
|
968
|
+
}
|
|
969
|
+
function DefaultEmpty2({ title, body, actionLabel, onAction, testID }) {
|
|
970
|
+
return /* @__PURE__ */ jsx(
|
|
971
|
+
NativeEmptyState,
|
|
972
|
+
{
|
|
973
|
+
variant: "first-run",
|
|
974
|
+
title,
|
|
975
|
+
body,
|
|
976
|
+
testID,
|
|
977
|
+
primaryAction: actionLabel && onAction ? /* @__PURE__ */ jsx(NativeButton, { onPress: onAction, testID: `${testID}-action`, children: actionLabel }) : void 0
|
|
978
|
+
}
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
var DEFAULT_LABELS = { you: "You", sending: "Sending", notSent: "Not sent. Tap to retry.", retryHint: "Double tap to send again" };
|
|
982
|
+
function getThreadPageStackOptions(props) {
|
|
983
|
+
return composeHeaderOptions({
|
|
984
|
+
headerTitle: props.headerTitle ?? "Conversation",
|
|
985
|
+
large: props.large ?? false,
|
|
986
|
+
scrollEdgeBehavior: props.scrollEdgeBehavior,
|
|
987
|
+
headerLeft: props.headerLeft,
|
|
988
|
+
headerRight: props.headerRight,
|
|
989
|
+
headerOptions: props.headerOptions
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
var toDate = (value) => typeof value === "string" ? new Date(value) : value;
|
|
993
|
+
function defaultTime(date) {
|
|
994
|
+
return date.toLocaleString(void 0, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" });
|
|
995
|
+
}
|
|
996
|
+
function readReceiptFor(messages, readAt) {
|
|
997
|
+
if (!readAt) return null;
|
|
998
|
+
const read = toDate(readAt).getTime();
|
|
999
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1000
|
+
const m = messages[i];
|
|
1001
|
+
if (m.mine && m.status !== "sending" && m.status !== "failed" && toDate(m.timestamp).getTime() <= read) return m.id;
|
|
1002
|
+
}
|
|
1003
|
+
return null;
|
|
1004
|
+
}
|
|
1005
|
+
function ThreadPage({
|
|
1006
|
+
messages,
|
|
1007
|
+
composer,
|
|
1008
|
+
closedNotice,
|
|
1009
|
+
header,
|
|
1010
|
+
readAt,
|
|
1011
|
+
readLabel = "Read",
|
|
1012
|
+
hasEarlier = false,
|
|
1013
|
+
onLoadEarlier,
|
|
1014
|
+
loadingEarlier = false,
|
|
1015
|
+
earlierLabel = "Load earlier messages",
|
|
1016
|
+
emptyTitle,
|
|
1017
|
+
emptyBody,
|
|
1018
|
+
formatTime = defaultTime,
|
|
1019
|
+
labels: labelOverrides,
|
|
1020
|
+
slots = {},
|
|
1021
|
+
slotProps = {},
|
|
1022
|
+
testID = "thread-page"
|
|
1023
|
+
}) {
|
|
1024
|
+
const colors = useThemeRoles();
|
|
1025
|
+
const KeyboardScroll = useKeyboardScroll();
|
|
1026
|
+
const scrollRef = useRef(null);
|
|
1027
|
+
const receiptFor = readReceiptFor(messages, readAt);
|
|
1028
|
+
const labels = { ...DEFAULT_LABELS, ...labelOverrides };
|
|
1029
|
+
const newest = messages[messages.length - 1]?.id;
|
|
1030
|
+
useEffect(() => {
|
|
1031
|
+
scrollRef.current?.scrollToEnd?.({ animated: true });
|
|
1032
|
+
}, [newest]);
|
|
1033
|
+
const body = /* @__PURE__ */ jsxs(View, { style: { flexGrow: 1 }, children: [
|
|
1034
|
+
header ?? renderSlot(Nothing, slots.header, { testID: `${testID}-header` }, slotProps.header),
|
|
1035
|
+
hasEarlier && onLoadEarlier ? renderSlot(
|
|
1036
|
+
DefaultEarlier,
|
|
1037
|
+
slots.earlier,
|
|
1038
|
+
{ loading: loadingEarlier, onPress: onLoadEarlier, label: earlierLabel, testID: `${testID}-earlier` },
|
|
1039
|
+
slotProps.earlier
|
|
1040
|
+
) : null,
|
|
1041
|
+
/* @__PURE__ */ jsx(View, { testID: `${testID}-messages`, accessibilityRole: "list", style: { flexGrow: 1, justifyContent: "flex-end", paddingHorizontal: 12, paddingVertical: 8, gap: 6 }, children: messages.length === 0 ? renderSlot(
|
|
1042
|
+
DefaultEmpty3,
|
|
1043
|
+
slots.empty,
|
|
1044
|
+
{ title: emptyTitle ?? "No messages yet", body: emptyBody ?? "Write the first one below.", testID: `${testID}-empty` },
|
|
1045
|
+
slotProps.empty
|
|
1046
|
+
) : messages.map((message) => /* @__PURE__ */ jsxs(View, { children: [
|
|
1047
|
+
renderSlot(
|
|
1048
|
+
DefaultMessage,
|
|
1049
|
+
slots.message,
|
|
1050
|
+
{
|
|
1051
|
+
...message,
|
|
1052
|
+
testID: `${testID}-message-${message.id}`,
|
|
1053
|
+
timeLabel: formatTime(toDate(message.timestamp)),
|
|
1054
|
+
showReadReceipt: message.id === receiptFor,
|
|
1055
|
+
labels
|
|
1056
|
+
},
|
|
1057
|
+
slotProps.message
|
|
1058
|
+
),
|
|
1059
|
+
message.attachments?.length ? /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 6, justifyContent: message.mine ? "flex-end" : "flex-start", marginTop: 4 }, children: message.attachments.map((attachment) => /* @__PURE__ */ jsx(View, { children: renderSlot(
|
|
1060
|
+
DefaultAttachment,
|
|
1061
|
+
slots.attachment,
|
|
1062
|
+
{ ...attachment, mine: message.mine, testID: `${testID}-attachment-${attachment.id}` },
|
|
1063
|
+
slotProps.attachment
|
|
1064
|
+
) }, attachment.id)) }) : null,
|
|
1065
|
+
message.id === receiptFor ? renderSlot(DefaultReadReceipt, slots.readReceipt, { label: readLabel, testID: `${testID}-read-receipt` }, slotProps.readReceipt) : null
|
|
1066
|
+
] }, message.id)) })
|
|
1067
|
+
] });
|
|
1068
|
+
const footer = composer ? renderSlot(
|
|
1069
|
+
DefaultComposer,
|
|
1070
|
+
slots.composer,
|
|
1071
|
+
{
|
|
1072
|
+
...composer,
|
|
1073
|
+
testID: `${testID}-composer`,
|
|
1074
|
+
accessory: renderSlot(Nothing, slots.composerAccessory, { testID: `${testID}-composer-accessory` }, slotProps.composerAccessory)
|
|
1075
|
+
},
|
|
1076
|
+
slotProps.composer
|
|
1077
|
+
) : closedNotice ? /* @__PURE__ */ jsx(NativeText, { testID: `${testID}-closed`, style: { textAlign: "center", padding: 16, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18 }, children: closedNotice }) : null;
|
|
1078
|
+
const page = { flex: 1, backgroundColor: colors.groupedBackground };
|
|
1079
|
+
const onContentSizeChange = () => scrollRef.current?.scrollToEnd?.({ animated: false });
|
|
1080
|
+
if (KeyboardScroll) {
|
|
1081
|
+
return /* @__PURE__ */ jsx(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: page, children: createElement(
|
|
1082
|
+
KeyboardScroll,
|
|
1083
|
+
{
|
|
1084
|
+
ref: scrollRef,
|
|
1085
|
+
testID: `${testID}-keyboard`,
|
|
1086
|
+
keyboardShouldPersistTaps: "handled",
|
|
1087
|
+
contentInsetAdjustmentBehavior: "automatic",
|
|
1088
|
+
contentContainerStyle: { flexGrow: 1 },
|
|
1089
|
+
bottomOffset: 8,
|
|
1090
|
+
onContentSizeChange
|
|
1091
|
+
},
|
|
1092
|
+
body,
|
|
1093
|
+
footer
|
|
1094
|
+
) });
|
|
1095
|
+
}
|
|
1096
|
+
return /* @__PURE__ */ jsx(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: page, children: /* @__PURE__ */ jsxs(KeyboardAvoidingView, { testID: `${testID}-kav`, style: { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : void 0, keyboardVerticalOffset: Platform.OS === "ios" ? 100 : 0, children: [
|
|
1097
|
+
/* @__PURE__ */ jsx(
|
|
1098
|
+
ScrollView,
|
|
1099
|
+
{
|
|
1100
|
+
ref: scrollRef,
|
|
1101
|
+
testID: `${testID}-scroll`,
|
|
1102
|
+
keyboardShouldPersistTaps: "handled",
|
|
1103
|
+
contentInsetAdjustmentBehavior: "automatic",
|
|
1104
|
+
contentContainerStyle: { flexGrow: 1 },
|
|
1105
|
+
onContentSizeChange,
|
|
1106
|
+
children: body
|
|
1107
|
+
}
|
|
1108
|
+
),
|
|
1109
|
+
footer
|
|
1110
|
+
] }) });
|
|
1111
|
+
}
|
|
1112
|
+
function Nothing(_props) {
|
|
1113
|
+
return null;
|
|
1114
|
+
}
|
|
1115
|
+
function DefaultEarlier({ loading, onPress, label, testID }) {
|
|
1116
|
+
return /* @__PURE__ */ jsx(View, { style: { alignItems: "center", paddingTop: 8 }, children: /* @__PURE__ */ jsx(NativeButton, { variant: "ghost", size: "sm", onPress, loading, testID, children: label }) });
|
|
1117
|
+
}
|
|
1118
|
+
function DefaultEmpty3({ title, body, testID }) {
|
|
1119
|
+
return /* @__PURE__ */ jsx(NativeEmptyState, { variant: "first-run", title, body, testID });
|
|
1120
|
+
}
|
|
1121
|
+
var MINE_TEXT = { fontSize: 17, lineHeight: 22 };
|
|
1122
|
+
function DefaultMessage(message) {
|
|
1123
|
+
const colors = useThemeRoles();
|
|
1124
|
+
const failed = message.status === "failed";
|
|
1125
|
+
const { labels } = message;
|
|
1126
|
+
const label = [message.mine ? labels.you : message.authorName ?? "", message.body, message.timeLabel, failed ? labels.notSent : message.status === "sending" ? labels.sending : null].filter(Boolean).join(", ");
|
|
1127
|
+
return /* @__PURE__ */ jsxs(View, { style: { alignItems: message.mine ? "flex-end" : "flex-start" }, children: [
|
|
1128
|
+
!message.mine && message.authorName ? /* @__PURE__ */ jsx(NativeText, { style: { marginLeft: 12, marginBottom: 2, color: colors.secondaryLabel, fontSize: 12, lineHeight: 16 }, children: message.authorName }) : null,
|
|
1129
|
+
/* @__PURE__ */ jsx(
|
|
1130
|
+
Pressable,
|
|
1131
|
+
{
|
|
1132
|
+
testID: message.testID,
|
|
1133
|
+
accessible: true,
|
|
1134
|
+
accessibilityLabel: label,
|
|
1135
|
+
accessibilityHint: failed && message.onRetry ? labels.retryHint : void 0,
|
|
1136
|
+
onPress: failed ? message.onRetry : void 0,
|
|
1137
|
+
style: {
|
|
1138
|
+
maxWidth: "80%",
|
|
1139
|
+
paddingHorizontal: 14,
|
|
1140
|
+
paddingVertical: 8,
|
|
1141
|
+
borderRadius: 18,
|
|
1142
|
+
backgroundColor: message.mine ? colors.tint : colors.surface,
|
|
1143
|
+
opacity: message.status === "sending" ? 0.6 : 1
|
|
1144
|
+
},
|
|
1145
|
+
children: /* @__PURE__ */ jsx(NativeText, { className: message.mine ? "text-primary-foreground" : void 0, style: message.mine ? MINE_TEXT : { ...MINE_TEXT, color: colors.label }, children: message.body })
|
|
1146
|
+
}
|
|
1147
|
+
),
|
|
1148
|
+
/* @__PURE__ */ jsx(
|
|
1149
|
+
NativeText,
|
|
1150
|
+
{
|
|
1151
|
+
testID: `${message.testID}-time`,
|
|
1152
|
+
style: { marginTop: 2, marginHorizontal: 12, color: failed ? colors.destructive : colors.tertiaryLabel, fontSize: 11, lineHeight: 14 },
|
|
1153
|
+
children: failed ? labels.notSent : message.timeLabel
|
|
1154
|
+
}
|
|
1155
|
+
)
|
|
1156
|
+
] });
|
|
1157
|
+
}
|
|
1158
|
+
function DefaultAttachment({ uri, width, height, accessibilityLabel, onPress, testID }) {
|
|
1159
|
+
const ratio = width && height ? width / height : 0.6;
|
|
1160
|
+
const w = 140;
|
|
1161
|
+
return /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "image", accessibilityLabel: accessibilityLabel ?? "Attachment", onPress, disabled: !onPress, children: /* @__PURE__ */ jsx(Image, { source: { uri }, style: { width: w, height: Math.round(w / ratio), borderRadius: 12 }, resizeMode: "cover" }) });
|
|
1162
|
+
}
|
|
1163
|
+
function DefaultReadReceipt({ label, testID }) {
|
|
1164
|
+
const colors = useThemeRoles();
|
|
1165
|
+
return /* @__PURE__ */ jsx(NativeText, { testID, style: { alignSelf: "flex-end", marginHorizontal: 12, color: colors.secondaryLabel, fontSize: 11, lineHeight: 14 }, children: label });
|
|
1166
|
+
}
|
|
1167
|
+
function DefaultComposer({
|
|
1168
|
+
value,
|
|
1169
|
+
onChangeText,
|
|
1170
|
+
onSend,
|
|
1171
|
+
sending = false,
|
|
1172
|
+
placeholder = "Message",
|
|
1173
|
+
sendLabel = "Send",
|
|
1174
|
+
disabled = false,
|
|
1175
|
+
maxLength,
|
|
1176
|
+
testID,
|
|
1177
|
+
accessory
|
|
1178
|
+
}) {
|
|
1179
|
+
const colors = useThemeRoles();
|
|
1180
|
+
const blank = !value.trim();
|
|
1181
|
+
return /* @__PURE__ */ jsxs(
|
|
1182
|
+
View,
|
|
1183
|
+
{
|
|
1184
|
+
testID,
|
|
1185
|
+
style: { flexDirection: "row", alignItems: "flex-end", gap: 8, paddingHorizontal: 12, paddingTop: 8, paddingBottom: 8, backgroundColor: colors.groupedBackground },
|
|
1186
|
+
children: [
|
|
1187
|
+
accessory,
|
|
1188
|
+
/* @__PURE__ */ jsx(
|
|
1189
|
+
TextInput,
|
|
1190
|
+
{
|
|
1191
|
+
testID: `${testID}-input`,
|
|
1192
|
+
value,
|
|
1193
|
+
onChangeText,
|
|
1194
|
+
placeholder,
|
|
1195
|
+
placeholderTextColor: colors.tertiaryLabel,
|
|
1196
|
+
accessibilityLabel: placeholder,
|
|
1197
|
+
multiline: true,
|
|
1198
|
+
maxLength,
|
|
1199
|
+
editable: !sending,
|
|
1200
|
+
style: {
|
|
1201
|
+
flex: 1,
|
|
1202
|
+
minHeight: 36,
|
|
1203
|
+
maxHeight: 120,
|
|
1204
|
+
paddingHorizontal: 14,
|
|
1205
|
+
paddingTop: 8,
|
|
1206
|
+
paddingBottom: 8,
|
|
1207
|
+
borderRadius: 18,
|
|
1208
|
+
fontSize: 17,
|
|
1209
|
+
color: colors.label,
|
|
1210
|
+
backgroundColor: colors.surface
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
),
|
|
1214
|
+
sending ? /* @__PURE__ */ jsx(View, { style: { height: 36, justifyContent: "center", paddingHorizontal: 8 }, children: /* @__PURE__ */ jsx(ActivityIndicator, { testID: `${testID}-sending`, accessibilityLabel: "Sending" }) }) : /* @__PURE__ */ jsx(NativeButton, { size: "sm", onPress: onSend, disabled: disabled || blank, testID: `${testID}-send`, children: sendLabel })
|
|
1215
|
+
]
|
|
1216
|
+
}
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
function AuthBranding({
|
|
1220
|
+
logo,
|
|
1221
|
+
headline,
|
|
1222
|
+
subhead,
|
|
1223
|
+
className,
|
|
1224
|
+
testID = "auth-branding"
|
|
1225
|
+
}) {
|
|
1226
|
+
return /* @__PURE__ */ jsxs(
|
|
1227
|
+
View,
|
|
1228
|
+
{
|
|
1229
|
+
testID,
|
|
1230
|
+
accessibilityRole: "header",
|
|
1231
|
+
className: cn("items-center gap-3 pb-8", className),
|
|
1232
|
+
children: [
|
|
1233
|
+
logo ? /* @__PURE__ */ jsx(View, { testID: `${testID}-logo`, className: "mb-2", children: logo }) : null,
|
|
1234
|
+
headline ? /* @__PURE__ */ jsx(
|
|
1235
|
+
NativeText,
|
|
1236
|
+
{
|
|
1237
|
+
preset: "h1",
|
|
1238
|
+
testID: `${testID}-headline`,
|
|
1239
|
+
className: "text-center",
|
|
1240
|
+
children: headline
|
|
1241
|
+
}
|
|
1242
|
+
) : null,
|
|
1243
|
+
subhead ? /* @__PURE__ */ jsx(
|
|
1244
|
+
NativeText,
|
|
1245
|
+
{
|
|
1246
|
+
preset: "body",
|
|
1247
|
+
testID: `${testID}-subhead`,
|
|
1248
|
+
className: "text-center text-muted-foreground",
|
|
1249
|
+
children: subhead
|
|
1250
|
+
}
|
|
1251
|
+
) : null
|
|
1252
|
+
]
|
|
1253
|
+
}
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
function SocialAuthRow({
|
|
1257
|
+
providers,
|
|
1258
|
+
separator = "or",
|
|
1259
|
+
className,
|
|
1260
|
+
testID = "social-auth-row"
|
|
1261
|
+
}) {
|
|
1262
|
+
if (providers.length === 0) return null;
|
|
1263
|
+
return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
|
|
1264
|
+
/* @__PURE__ */ jsx(View, { className: "gap-2", children: providers.map(
|
|
1265
|
+
(p) => p.render ? /* @__PURE__ */ jsx(Fragment, { children: p.render({ testID: `${testID}-${p.id}`, disabled: p.disabled }) }, p.id) : /* @__PURE__ */ jsx(
|
|
1266
|
+
NativeButton,
|
|
1267
|
+
{
|
|
1268
|
+
testID: `${testID}-${p.id}`,
|
|
1269
|
+
variant: "outline",
|
|
1270
|
+
disabled: p.disabled,
|
|
1271
|
+
onPress: () => {
|
|
1272
|
+
void p.onPress();
|
|
1273
|
+
},
|
|
1274
|
+
children: /* @__PURE__ */ jsxs(View, { className: "flex-row items-center gap-2", children: [
|
|
1275
|
+
p.icon,
|
|
1276
|
+
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: p.label })
|
|
1277
|
+
] })
|
|
1278
|
+
},
|
|
1279
|
+
p.id
|
|
1280
|
+
)
|
|
1281
|
+
) }),
|
|
1282
|
+
separator !== null && separator !== void 0 ? /* @__PURE__ */ jsxs(
|
|
1283
|
+
View,
|
|
1284
|
+
{
|
|
1285
|
+
testID: `${testID}-separator`,
|
|
1286
|
+
className: "my-2 flex-row items-center gap-3",
|
|
1287
|
+
accessibilityElementsHidden: true,
|
|
1288
|
+
children: [
|
|
1289
|
+
/* @__PURE__ */ jsx(View, { className: "h-px flex-1 bg-border" }),
|
|
1290
|
+
/* @__PURE__ */ jsx(Text, { className: "text-xs uppercase tracking-wider text-muted-foreground", children: separator }),
|
|
1291
|
+
/* @__PURE__ */ jsx(View, { className: "h-px flex-1 bg-border" })
|
|
1292
|
+
]
|
|
1293
|
+
}
|
|
1294
|
+
) : null
|
|
1295
|
+
] });
|
|
1296
|
+
}
|
|
1297
|
+
function AuthForm({
|
|
1298
|
+
mode = "password",
|
|
1299
|
+
onSubmit,
|
|
1300
|
+
validate,
|
|
1301
|
+
submitLabel,
|
|
1302
|
+
loading,
|
|
1303
|
+
errorMessage,
|
|
1304
|
+
initialEmail = "",
|
|
1305
|
+
belowFields,
|
|
1306
|
+
className,
|
|
1307
|
+
testID = "auth-form"
|
|
1308
|
+
}) {
|
|
1309
|
+
const [email, setEmail] = useState(initialEmail);
|
|
1310
|
+
const [password, setPassword] = useState("");
|
|
1311
|
+
const [localError, setLocalError] = useState(null);
|
|
1312
|
+
const [submitting, setSubmitting] = useState(false);
|
|
1313
|
+
const passwordRef = useRef(null);
|
|
1314
|
+
const isMagic = mode === "magic-link";
|
|
1315
|
+
const resolvedSubmitLabel = submitLabel ?? (isMagic ? "Send magic link" : "Sign in");
|
|
1316
|
+
const handleSubmit = useCallback(async () => {
|
|
1317
|
+
if (submitting || loading) return;
|
|
1318
|
+
setLocalError(null);
|
|
1319
|
+
const values = {
|
|
1320
|
+
email: email.trim(),
|
|
1321
|
+
password: isMagic ? "" : password
|
|
1322
|
+
};
|
|
1323
|
+
if (validate) {
|
|
1324
|
+
const err = validate(values);
|
|
1325
|
+
if (err) {
|
|
1326
|
+
setLocalError(err);
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
if (!values.email) {
|
|
1331
|
+
setLocalError("Email is required");
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
if (!isMagic && !values.password) {
|
|
1335
|
+
setLocalError("Password is required");
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
setSubmitting(true);
|
|
1339
|
+
try {
|
|
1340
|
+
await onSubmit(values);
|
|
1341
|
+
} catch (err) {
|
|
1342
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1343
|
+
setLocalError(message);
|
|
1344
|
+
} finally {
|
|
1345
|
+
setSubmitting(false);
|
|
1346
|
+
}
|
|
1347
|
+
}, [email, password, isMagic, validate, onSubmit, submitting, loading]);
|
|
1348
|
+
const visibleError = errorMessage ?? localError ?? null;
|
|
1349
|
+
return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
|
|
1350
|
+
/* @__PURE__ */ jsxs(View, { className: "gap-1", children: [
|
|
1351
|
+
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: "Email" }),
|
|
1352
|
+
/* @__PURE__ */ jsx(
|
|
1353
|
+
NativeInput,
|
|
1354
|
+
{
|
|
1355
|
+
testID: `${testID}-email`,
|
|
1356
|
+
accessibilityLabel: "Email",
|
|
1357
|
+
value: email,
|
|
1358
|
+
onChangeText: setEmail,
|
|
1359
|
+
placeholder: "you@example.com",
|
|
1360
|
+
autoCapitalize: "none",
|
|
1361
|
+
autoCorrect: false,
|
|
1362
|
+
keyboardType: "email-address",
|
|
1363
|
+
textContentType: "emailAddress",
|
|
1364
|
+
autoComplete: "email",
|
|
1365
|
+
returnKeyType: isMagic ? "send" : "next",
|
|
1366
|
+
editable: !loading && !submitting,
|
|
1367
|
+
submitBehavior: isMagic ? "blurAndSubmit" : "submit",
|
|
1368
|
+
onSubmitEditing: isMagic ? handleSubmit : () => passwordRef.current?.focus()
|
|
1369
|
+
}
|
|
1370
|
+
)
|
|
1371
|
+
] }),
|
|
1372
|
+
isMagic ? null : /* @__PURE__ */ jsxs(View, { className: "gap-1", children: [
|
|
1373
|
+
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: "Password" }),
|
|
1374
|
+
/* @__PURE__ */ jsx(
|
|
1375
|
+
NativeInput,
|
|
1376
|
+
{
|
|
1377
|
+
ref: passwordRef,
|
|
1378
|
+
testID: `${testID}-password`,
|
|
1379
|
+
accessibilityLabel: "Password",
|
|
1380
|
+
value: password,
|
|
1381
|
+
onChangeText: setPassword,
|
|
1382
|
+
placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
1383
|
+
secureTextEntry: true,
|
|
1384
|
+
textContentType: "password",
|
|
1385
|
+
autoComplete: "current-password",
|
|
1386
|
+
autoCapitalize: "none",
|
|
1387
|
+
autoCorrect: false,
|
|
1388
|
+
returnKeyType: "send",
|
|
1389
|
+
editable: !loading && !submitting,
|
|
1390
|
+
onSubmitEditing: handleSubmit
|
|
1391
|
+
}
|
|
1392
|
+
)
|
|
1393
|
+
] }),
|
|
1394
|
+
belowFields,
|
|
1395
|
+
visibleError ? /* @__PURE__ */ jsx(
|
|
1396
|
+
Text,
|
|
1397
|
+
{
|
|
1398
|
+
testID: `${testID}-error`,
|
|
1399
|
+
accessibilityRole: "alert",
|
|
1400
|
+
className: "text-sm text-destructive",
|
|
1401
|
+
children: visibleError
|
|
1402
|
+
}
|
|
1403
|
+
) : null,
|
|
1404
|
+
/* @__PURE__ */ jsx(
|
|
1405
|
+
NativeButton,
|
|
1406
|
+
{
|
|
1407
|
+
testID: `${testID}-submit`,
|
|
1408
|
+
onPress: () => {
|
|
1409
|
+
void handleSubmit();
|
|
1410
|
+
},
|
|
1411
|
+
loading: loading || submitting,
|
|
1412
|
+
disabled: loading || submitting,
|
|
1413
|
+
children: resolvedSubmitLabel
|
|
1414
|
+
}
|
|
1415
|
+
)
|
|
1416
|
+
] });
|
|
1417
|
+
}
|
|
1418
|
+
function ForgotPasswordLink({
|
|
1419
|
+
onPress,
|
|
1420
|
+
label = "Forgot password?",
|
|
1421
|
+
testID = "auth-forgot-password"
|
|
1422
|
+
}) {
|
|
1423
|
+
return /* @__PURE__ */ jsx(
|
|
1424
|
+
Pressable,
|
|
1425
|
+
{
|
|
1426
|
+
testID,
|
|
1427
|
+
accessibilityRole: "link",
|
|
1428
|
+
accessibilityLabel: label,
|
|
1429
|
+
onPress,
|
|
1430
|
+
hitSlop: 8,
|
|
1431
|
+
className: "self-end",
|
|
1432
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-primary", children: label })
|
|
1433
|
+
}
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
function AuthScreen({
|
|
1437
|
+
branding,
|
|
1438
|
+
providers: givenProviders,
|
|
1439
|
+
form,
|
|
1440
|
+
onForgotPassword,
|
|
1441
|
+
footer,
|
|
1442
|
+
slots = {},
|
|
1443
|
+
slotProps = {},
|
|
1444
|
+
testID = "auth-screen"
|
|
1445
|
+
}) {
|
|
1446
|
+
const providers = givenProviders?.filter((p) => !!p);
|
|
1447
|
+
warnIfNoAppleSignIn(providers);
|
|
1448
|
+
const forgot = onForgotPassword && (form.mode ?? "password") === "password" ? /* @__PURE__ */ jsx(ForgotPasswordLink, { onPress: onForgotPassword }) : null;
|
|
1449
|
+
const formProps = { ...form, belowFields: form.belowFields ?? forgot, testID: form.testID ?? `${testID}-form` };
|
|
1450
|
+
const KeyboardScroll = useKeyboardScroll();
|
|
1451
|
+
const KeyboardToolbar = useKeyboardToolbar();
|
|
1452
|
+
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1453
|
+
branding ? renderSlot(AuthBranding, slots.branding, { ...branding, testID: branding.testID ?? `${testID}-branding` }, slotProps.branding) : null,
|
|
1454
|
+
providers?.length ? renderSlot(DefaultSocial, slots.social, { providers, testID: `${testID}-social` }, slotProps.social) : null,
|
|
1455
|
+
renderSlot(AuthForm, slots.form, formProps, slotProps.form),
|
|
1456
|
+
footer ? renderSlot(DefaultFooter2, slots.footer, { children: footer, testID: `${testID}-footer` }, slotProps.footer) : null
|
|
1457
|
+
] });
|
|
1458
|
+
if (KeyboardScroll) {
|
|
1459
|
+
return /* @__PURE__ */ jsxs(ScreenContainer, { testID, children: [
|
|
1460
|
+
/* @__PURE__ */ jsx(
|
|
1461
|
+
KeyboardScroll,
|
|
1462
|
+
{
|
|
1463
|
+
testID: `${testID}-keyboard`,
|
|
1464
|
+
keyboardShouldPersistTaps: "handled",
|
|
1465
|
+
contentInsetAdjustmentBehavior: "automatic",
|
|
1466
|
+
bottomOffset: KeyboardToolbar ? 24 + KEYBOARD_TOOLBAR_HEIGHT : 24,
|
|
1467
|
+
contentContainerStyle: { flexGrow: 1, justifyContent: "center", gap: 24, paddingHorizontal: 24, paddingVertical: 32 },
|
|
1468
|
+
children: content
|
|
1469
|
+
}
|
|
1470
|
+
),
|
|
1471
|
+
KeyboardToolbar ? /* @__PURE__ */ jsx(KeyboardToolbar, {}) : null
|
|
1472
|
+
] });
|
|
1473
|
+
}
|
|
1474
|
+
return /* @__PURE__ */ jsx(KeyboardAvoidingView, { testID: `${testID}-kav`, style: { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : void 0, children: /* @__PURE__ */ jsx(ScreenContainer, { scroll: true, keyboardShouldPersistTaps: "handled", testID, contentClassName: "flex-grow justify-center gap-6 px-6 py-8", children: content }) });
|
|
1475
|
+
}
|
|
1476
|
+
var warnedNoApple = /* @__PURE__ */ new Set();
|
|
1477
|
+
function warnIfNoAppleSignIn(providers) {
|
|
1478
|
+
const dev = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process !== "undefined" && process.env.NODE_ENV !== "production";
|
|
1479
|
+
if (!dev || Platform.OS !== "ios" || !providers?.length) return;
|
|
1480
|
+
if (providers.some((p) => p.id === "apple")) return;
|
|
1481
|
+
const ids = providers.map((p) => p.id).join(",");
|
|
1482
|
+
if (warnedNoApple.has(ids)) return;
|
|
1483
|
+
warnedNoApple.add(ids);
|
|
1484
|
+
console.warn(
|
|
1485
|
+
`[genesis] AuthScreen offers ${providers.map((p) => p.label).join(", ")} on iOS without Sign in with Apple. App Store Review Guideline 4.8 requires it; add appleProvider({ apple: AppleAuthentication, onPress }) (or any provider with id "apple"). If you did, expo-apple-authentication wasn't passed in.`
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
function DefaultSocial({ providers, testID }) {
|
|
1489
|
+
return /* @__PURE__ */ jsx(SocialAuthRow, { providers, testID });
|
|
1490
|
+
}
|
|
1491
|
+
function DefaultFooter2({ children, testID }) {
|
|
1492
|
+
return /* @__PURE__ */ jsx(View, { testID, className: "items-center", children });
|
|
1493
|
+
}
|
|
1494
|
+
function AppleSignInButton({
|
|
1495
|
+
apple,
|
|
1496
|
+
onPress,
|
|
1497
|
+
type = "continue",
|
|
1498
|
+
appearance = "auto",
|
|
1499
|
+
cornerRadius = 10,
|
|
1500
|
+
height = 44,
|
|
1501
|
+
disabled,
|
|
1502
|
+
testID = "apple-sign-in"
|
|
1503
|
+
}) {
|
|
1504
|
+
const mode = useThemeMode();
|
|
1505
|
+
const pending = useRef(false);
|
|
1506
|
+
const [busy, setBusy] = useState(false);
|
|
1507
|
+
if (Platform.OS !== "ios") return null;
|
|
1508
|
+
const press = async () => {
|
|
1509
|
+
if (disabled || pending.current) return;
|
|
1510
|
+
pending.current = true;
|
|
1511
|
+
setBusy(true);
|
|
1512
|
+
try {
|
|
1513
|
+
await onPress();
|
|
1514
|
+
} finally {
|
|
1515
|
+
pending.current = false;
|
|
1516
|
+
setBusy(false);
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
const inactive = !!disabled || busy;
|
|
1520
|
+
const { AppleAuthenticationButton, AppleAuthenticationButtonType: Type, AppleAuthenticationButtonStyle: Style } = apple;
|
|
1521
|
+
const buttonType = type === "sign-in" ? Type.SIGN_IN : type === "sign-up" ? Type.SIGN_UP : Type.CONTINUE;
|
|
1522
|
+
const resolved = appearance === "auto" ? mode === "dark" ? "white" : "black" : appearance;
|
|
1523
|
+
const buttonStyle = resolved === "white" ? Style.WHITE : resolved === "white-outline" ? Style.WHITE_OUTLINE : Style.BLACK;
|
|
1524
|
+
return /* @__PURE__ */ jsx(View, { testID: `${testID}-container`, pointerEvents: inactive ? "none" : "auto", style: disabled ? { opacity: 0.5 } : void 0, children: /* @__PURE__ */ jsx(
|
|
1525
|
+
AppleAuthenticationButton,
|
|
1526
|
+
{
|
|
1527
|
+
testID,
|
|
1528
|
+
buttonType,
|
|
1529
|
+
buttonStyle,
|
|
1530
|
+
cornerRadius,
|
|
1531
|
+
style: { width: "100%", height },
|
|
1532
|
+
accessibilityState: { disabled: inactive, busy },
|
|
1533
|
+
onPress: () => {
|
|
1534
|
+
void press();
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
) });
|
|
1538
|
+
}
|
|
1539
|
+
var APPLE_LABELS = { continue: "Continue with Apple", "sign-in": "Sign in with Apple", "sign-up": "Sign up with Apple" };
|
|
1540
|
+
function appleProvider({ apple, label, ...button }) {
|
|
1541
|
+
if (Platform.OS !== "ios" || !apple) return null;
|
|
1542
|
+
return {
|
|
1543
|
+
id: "apple",
|
|
1544
|
+
label: label ?? APPLE_LABELS[button.type ?? "continue"],
|
|
1545
|
+
onPress: button.onPress,
|
|
1546
|
+
disabled: button.disabled,
|
|
1547
|
+
render: ({ testID, disabled }) => /* @__PURE__ */ jsx(AppleSignInButton, { apple, ...button, disabled, testID })
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
// src/layouts/google-sign-in.tsx
|
|
1552
|
+
function googleProvider({ onPress, label = "Continue with Google", icon, disabled, enabled = true }) {
|
|
1553
|
+
if (!enabled) return null;
|
|
1554
|
+
return { id: "google", label, icon, onPress, disabled };
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, InboxPage, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, NavBarSaveButton, NavBarSearchBar, NavBarTitle, NotificationsPage, ScreenContainer, SettingsPage, SettingsSubPage, SocialAuthRow, ThreadPage, appleProvider, composeHeaderOptions, confirmDiscardChanges, defaultStickyHeaderOffset, formatInboxTime, getInboxPageStackOptions, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight, readReceiptFor, showInboxActions, useKeyboardScroll, useKeyboardToolbar };
|
|
1558
|
+
//# sourceMappingURL=chunk-FZY2IXOX.js.map
|
|
1559
|
+
//# sourceMappingURL=chunk-FZY2IXOX.js.map
|