@marktiderman/genesis-ui-native 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-HNIEFTEL.js → chunk-F2TGDKOO.js} +2 -2
- package/dist/{chunk-HNIEFTEL.js.map → chunk-F2TGDKOO.js.map} +1 -1
- package/dist/{chunk-OMTXD7ND.js → chunk-U2SPACTV.js} +191 -76
- package/dist/chunk-U2SPACTV.js.map +1 -0
- package/dist/chunk-Z3AQYVUA.js +36 -0
- package/dist/chunk-Z3AQYVUA.js.map +1 -0
- package/dist/hooks/index.d.ts +12 -2
- package/dist/hooks/index.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -3
- package/dist/layouts/index.d.ts +110 -13
- package/dist/layouts/index.js +2 -2
- package/package.json +6 -6
- package/src/components/__tests__/badge.test.tsx +1 -0
- package/src/hooks/__tests__/use-theme-roles.test.tsx +30 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-theme-roles.ts +45 -0
- package/src/layouts/__tests__/auth-screen.test.tsx +72 -0
- package/src/layouts/__tests__/auth.test.tsx +1 -0
- package/src/layouts/__tests__/keyboard-scroll.test.tsx +34 -0
- package/src/layouts/__tests__/nav-bar.test.tsx +1 -0
- package/src/layouts/__tests__/notifications-page-slots.test.tsx +23 -0
- package/src/layouts/__tests__/notifications-page.test.tsx +1 -0
- package/src/layouts/__tests__/screen-container.test.tsx +1 -0
- package/src/layouts/__tests__/settings-page-slots.test.tsx +41 -0
- package/src/layouts/__tests__/settings-page.test.tsx +1 -0
- package/src/layouts/__tests__/settings-sub-page.test.tsx +1 -0
- package/src/layouts/auth-screen.tsx +138 -0
- package/src/layouts/auth.tsx +13 -6
- package/src/layouts/index.ts +7 -1
- package/src/layouts/keyboard.tsx +39 -0
- package/src/layouts/notifications-page.tsx +63 -35
- package/src/layouts/screen-container.tsx +5 -1
- package/src/layouts/settings-page.tsx +122 -55
- package/src/layouts/settings-sub-page.tsx +21 -0
- package/dist/chunk-N4WHTQIO.js +0 -20
- package/dist/chunk-N4WHTQIO.js.map +0 -1
- package/dist/chunk-OMTXD7ND.js.map +0 -1
|
@@ -11,13 +11,17 @@
|
|
|
11
11
|
* requires gesture-handler — consumers wire it via their own row
|
|
12
12
|
* wrapper; this layout exposes the unread state via row props).
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* Slots: replace or drop (`null`) `sectionHeader`, `row` or `empty`
|
|
15
|
+
* through `slots`; feed a default part through `slotProps`.
|
|
16
|
+
*
|
|
17
|
+
* Header customization: `headerTitle`, `headerLeft`, `headerRight`,
|
|
15
18
|
* `headerOptions`. Use `getNotificationsPageStackOptions()` to wire a
|
|
16
19
|
* "Mark all read" action via `headerRight` automatically.
|
|
17
20
|
*
|
|
18
21
|
* @stability Beta
|
|
19
22
|
*/
|
|
20
|
-
import { type ReactNode } from "react";
|
|
23
|
+
import { useMemo, type ReactNode } from "react";
|
|
24
|
+
import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
|
|
21
25
|
import {
|
|
22
26
|
Pressable,
|
|
23
27
|
RefreshControl,
|
|
@@ -54,6 +58,13 @@ export interface NotificationItem {
|
|
|
54
58
|
testID?: string;
|
|
55
59
|
}
|
|
56
60
|
|
|
61
|
+
/** The parts of a {@link NotificationsPage} that `slots` and `slotProps` reach. */
|
|
62
|
+
export type NotificationsPageSlotMap = {
|
|
63
|
+
sectionHeader: { title: string };
|
|
64
|
+
row: NotificationItem & { testID: string };
|
|
65
|
+
empty: { title: string; body: string; testID: string };
|
|
66
|
+
};
|
|
67
|
+
|
|
57
68
|
export interface NotificationsPageProps extends ScreenHeaderProps {
|
|
58
69
|
/** Notification items. Empty array → empty state. */
|
|
59
70
|
items: NotificationItem[];
|
|
@@ -63,8 +74,12 @@ export interface NotificationsPageProps extends ScreenHeaderProps {
|
|
|
63
74
|
onRefresh?: () => void | Promise<void>;
|
|
64
75
|
/** Mark-all-read handler. When provided, exposes a header action. */
|
|
65
76
|
onMarkAllRead?: () => void;
|
|
66
|
-
/** Override the auto-rendered empty state. */
|
|
77
|
+
/** Override the auto-rendered empty state. Prefer `slots.empty`. */
|
|
67
78
|
emptyState?: ReactNode;
|
|
79
|
+
/** Replace (a component) or drop (`null`) one part. */
|
|
80
|
+
slots?: Slots<NotificationsPageSlotMap>;
|
|
81
|
+
/** More props for a default part, merged over what the layout passes. */
|
|
82
|
+
slotProps?: SlotPropsFor<NotificationsPageSlotMap>;
|
|
68
83
|
/** Optional override of the empty-state title. */
|
|
69
84
|
emptyTitle?: string;
|
|
70
85
|
/** Optional override of the empty-state body copy. */
|
|
@@ -179,13 +194,15 @@ export function NotificationsPage({
|
|
|
179
194
|
emptyBody,
|
|
180
195
|
className,
|
|
181
196
|
testID = "notifications-page",
|
|
197
|
+
slots = {},
|
|
198
|
+
slotProps = {},
|
|
182
199
|
}: NotificationsPageProps) {
|
|
183
200
|
// Note: header props (headerTitle, headerLeft, headerRight, large,
|
|
184
201
|
// scrollEdgeBehavior, headerOptions) are accepted on the type for API
|
|
185
202
|
// ergonomics but consumed by getNotificationsPageStackOptions() at the
|
|
186
203
|
// consumer's <Stack.Screen> level — not by this component.
|
|
187
204
|
|
|
188
|
-
const sections = groupByDate(items);
|
|
205
|
+
const sections = useMemo(() => groupByDate(items), [items]);
|
|
189
206
|
|
|
190
207
|
if (items.length === 0) {
|
|
191
208
|
return (
|
|
@@ -194,17 +211,17 @@ export function NotificationsPage({
|
|
|
194
211
|
edges={["left", "right", "bottom"]}
|
|
195
212
|
className={cn("flex-1 bg-background", className)}
|
|
196
213
|
>
|
|
197
|
-
{emptyState ??
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
"When you get a notification, it'll show up here."
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
214
|
+
{emptyState ??
|
|
215
|
+
renderSlot(
|
|
216
|
+
DefaultEmpty,
|
|
217
|
+
slots.empty,
|
|
218
|
+
{
|
|
219
|
+
title: emptyTitle ?? "No notifications",
|
|
220
|
+
body: emptyBody ?? "When you get a notification, it'll show up here.",
|
|
221
|
+
testID: `${testID}-empty`,
|
|
222
|
+
},
|
|
223
|
+
slotProps.empty,
|
|
224
|
+
)}
|
|
208
225
|
</SafeAreaView>
|
|
209
226
|
);
|
|
210
227
|
}
|
|
@@ -219,26 +236,13 @@ export function NotificationsPage({
|
|
|
219
236
|
testID={`${testID}-list`}
|
|
220
237
|
sections={sections}
|
|
221
238
|
keyExtractor={(item) => item.id}
|
|
222
|
-
renderSectionHeader={({ section }) =>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
renderItem={({ item }) =>
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
subtitle={item.body}
|
|
230
|
-
leading={
|
|
231
|
-
item.leading ?? (
|
|
232
|
-
<UnreadDot
|
|
233
|
-
unread={!!item.unread}
|
|
234
|
-
testID={`${testID}-row-${item.id}-unread`}
|
|
235
|
-
/>
|
|
236
|
-
)
|
|
237
|
-
}
|
|
238
|
-
onPress={item.onPress}
|
|
239
|
-
/>
|
|
240
|
-
)}
|
|
241
|
-
ItemSeparatorComponent={() => <View className="h-px bg-border ml-4" />}
|
|
239
|
+
renderSectionHeader={({ section }) =>
|
|
240
|
+
renderSlot(DefaultSectionHeader, slots.sectionHeader, { title: section.title }, slotProps.sectionHeader)
|
|
241
|
+
}
|
|
242
|
+
renderItem={({ item }) =>
|
|
243
|
+
renderSlot(DefaultRow, slots.row, { ...item, testID: item.testID ?? `${testID}-row-${item.id}` }, slotProps.row)
|
|
244
|
+
}
|
|
245
|
+
ItemSeparatorComponent={RowSeparator}
|
|
242
246
|
refreshControl={
|
|
243
247
|
onRefresh ? (
|
|
244
248
|
<RefreshControl
|
|
@@ -254,6 +258,30 @@ export function NotificationsPage({
|
|
|
254
258
|
);
|
|
255
259
|
}
|
|
256
260
|
|
|
261
|
+
function RowSeparator() {
|
|
262
|
+
return <View className="h-px bg-border ml-4" />;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function DefaultSectionHeader({ title }: NotificationsPageSlotMap["sectionHeader"]) {
|
|
266
|
+
return <NativeSectionListHeader title={title} />;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function DefaultRow(item: NotificationsPageSlotMap["row"]) {
|
|
270
|
+
return (
|
|
271
|
+
<NativeListItem
|
|
272
|
+
testID={item.testID}
|
|
273
|
+
title={item.title}
|
|
274
|
+
subtitle={item.body}
|
|
275
|
+
leading={item.leading ?? <UnreadDot unread={!!item.unread} testID={`${item.testID}-unread`} />}
|
|
276
|
+
onPress={item.onPress}
|
|
277
|
+
/>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function DefaultEmpty({ title, body, testID }: NotificationsPageSlotMap["empty"]) {
|
|
282
|
+
return <NativeEmptyState variant="first-run" title={title} body={body} testID={testID} />;
|
|
283
|
+
}
|
|
284
|
+
|
|
257
285
|
function UnreadDot({
|
|
258
286
|
unread,
|
|
259
287
|
testID,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @stability Beta
|
|
28
28
|
*/
|
|
29
29
|
import type { ReactNode } from "react";
|
|
30
|
-
import { ScrollView, StatusBar, View } from "react-native";
|
|
30
|
+
import { ScrollView, StatusBar, View, type ViewStyle } from "react-native";
|
|
31
31
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
32
32
|
import { cn } from "../utils";
|
|
33
33
|
import { useThemeMode } from "../hooks/use-theme-mode";
|
|
@@ -64,6 +64,8 @@ export interface ScreenContainerProps {
|
|
|
64
64
|
* Only used when `scroll` is true.
|
|
65
65
|
*/
|
|
66
66
|
keyboardShouldPersistTaps?: "always" | "never" | "handled";
|
|
67
|
+
/** Style on the root, e.g. a theme-role background color. */
|
|
68
|
+
style?: ViewStyle;
|
|
67
69
|
/** testID on the root container. */
|
|
68
70
|
testID?: string;
|
|
69
71
|
}
|
|
@@ -163,6 +165,7 @@ export function ScreenContainer({
|
|
|
163
165
|
className,
|
|
164
166
|
contentClassName,
|
|
165
167
|
keyboardShouldPersistTaps = "handled",
|
|
168
|
+
style,
|
|
166
169
|
testID,
|
|
167
170
|
}: ScreenContainerProps) {
|
|
168
171
|
const osMode = useThemeMode();
|
|
@@ -192,6 +195,7 @@ export function ScreenContainer({
|
|
|
192
195
|
testID={testID ?? "screen-container"}
|
|
193
196
|
edges={safeAreaEdges}
|
|
194
197
|
className={cn("flex-1 bg-background", className)}
|
|
198
|
+
style={style}
|
|
195
199
|
>
|
|
196
200
|
{statusBar !== "hidden" ? (
|
|
197
201
|
<StatusBar
|
|
@@ -14,13 +14,24 @@
|
|
|
14
14
|
* passthrough. The composed options are rendered via the consumer's own
|
|
15
15
|
* `<Stack.Screen options={...}>` — see `getStackScreenOptions()` helper.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Colors come from theme roles: on iOS the page is `systemGroupedBackground`
|
|
18
|
+
* with inset, rounded cells on `secondarySystemGroupedBackground`, like the
|
|
19
|
+
* Settings app; elsewhere, full-width cells on the Genesis tokens.
|
|
20
|
+
*
|
|
21
|
+
* Slots: replace or drop one part without leaving the layout. `slots`
|
|
22
|
+
* swaps a part (`sectionHeader`, `row`, `footnote`, `dangerousActions`) for
|
|
23
|
+
* your component, which receives exactly the props the default would;
|
|
24
|
+
* `slotProps` feeds the default more props; `null` drops the part.
|
|
25
|
+
*
|
|
26
|
+
* Escape hatch: drop down to `<ScreenContainer>` if the layout structure
|
|
27
|
+
* doesn't fit.
|
|
19
28
|
*
|
|
20
29
|
* @stability Beta
|
|
21
30
|
*/
|
|
22
31
|
import { Fragment, type ReactNode } from "react";
|
|
23
|
-
import {
|
|
32
|
+
import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
|
|
33
|
+
import { Platform, View } from "react-native";
|
|
34
|
+
import { useThemeRoles } from "../hooks/use-theme-roles";
|
|
24
35
|
import { NativeListItem, NativeListItemDivider } from "../components/list-item";
|
|
25
36
|
import { NativeSectionListHeader } from "../components/section-list";
|
|
26
37
|
import { NativeText } from "../components/text";
|
|
@@ -62,6 +73,23 @@ export interface SettingsPageSection {
|
|
|
62
73
|
rows: SettingsPageRow[];
|
|
63
74
|
}
|
|
64
75
|
|
|
76
|
+
/** A destructive-tone action in the footer, e.g. "Sign out". */
|
|
77
|
+
export interface SettingsPageDangerousAction {
|
|
78
|
+
label: string;
|
|
79
|
+
onPress: () => void;
|
|
80
|
+
/** When true, renders with extra emphasis. Default `false`. */
|
|
81
|
+
emphasized?: boolean;
|
|
82
|
+
testID?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The parts of a {@link SettingsPage} that `slots` and `slotProps` reach, with the props each receives. */
|
|
86
|
+
export type SettingsPageSlotMap = {
|
|
87
|
+
sectionHeader: { title: string; testID: string };
|
|
88
|
+
row: SettingsPageRow & { testID: string; isLast: boolean };
|
|
89
|
+
footnote: { text: string };
|
|
90
|
+
dangerousActions: { actions: SettingsPageDangerousAction[]; testID: string };
|
|
91
|
+
};
|
|
92
|
+
|
|
65
93
|
export interface SettingsPageProps extends ScreenHeaderProps {
|
|
66
94
|
/** Sectioned content. Order is preserved. */
|
|
67
95
|
sections: SettingsPageSection[];
|
|
@@ -69,13 +97,11 @@ export interface SettingsPageProps extends ScreenHeaderProps {
|
|
|
69
97
|
* Optional dangerous-action row(s) shown after the last section in a
|
|
70
98
|
* destructive-tone footer. Typical: "Sign out", "Delete account".
|
|
71
99
|
*/
|
|
72
|
-
dangerousActions?:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
testID?: string;
|
|
78
|
-
}[];
|
|
100
|
+
dangerousActions?: SettingsPageDangerousAction[];
|
|
101
|
+
/** Replace (a component) or drop (`null`) one part. */
|
|
102
|
+
slots?: Slots<SettingsPageSlotMap>;
|
|
103
|
+
/** More props for a default part, merged over what the layout passes. */
|
|
104
|
+
slotProps?: SlotPropsFor<SettingsPageSlotMap>;
|
|
79
105
|
/** Override root container styling. */
|
|
80
106
|
className?: string;
|
|
81
107
|
/** testID on the root container. Default `"settings-page"`. */
|
|
@@ -109,10 +135,14 @@ export function SettingsPage({
|
|
|
109
135
|
className,
|
|
110
136
|
testID = "settings-page",
|
|
111
137
|
children,
|
|
138
|
+
slots = {},
|
|
139
|
+
slotProps = {},
|
|
112
140
|
}: SettingsPageProps) {
|
|
113
141
|
// Note: header props (headerTitle, headerLeft, headerRight, etc.) are
|
|
114
142
|
// accepted on the type for API ergonomics but consumed by
|
|
115
143
|
// getSettingsPageStackOptions() at the consumer's <Stack.Screen> level.
|
|
144
|
+
const colors = useThemeRoles();
|
|
145
|
+
const inset = Platform.OS === "ios";
|
|
116
146
|
|
|
117
147
|
return (
|
|
118
148
|
<ScreenContainer
|
|
@@ -121,6 +151,7 @@ export function SettingsPage({
|
|
|
121
151
|
testID={testID}
|
|
122
152
|
contentClassName="pb-8"
|
|
123
153
|
className={className}
|
|
154
|
+
style={{ backgroundColor: colors.groupedBackground }}
|
|
124
155
|
>
|
|
125
156
|
{children ? <View className="px-4 pt-2">{children}</View> : null}
|
|
126
157
|
|
|
@@ -130,63 +161,99 @@ export function SettingsPage({
|
|
|
130
161
|
testID={`${testID}-section-${section.id}`}
|
|
131
162
|
className="mt-6"
|
|
132
163
|
>
|
|
133
|
-
{section.title
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
164
|
+
{section.title
|
|
165
|
+
? renderSlot(
|
|
166
|
+
DefaultSectionHeader,
|
|
167
|
+
slots.sectionHeader,
|
|
168
|
+
{ title: section.title, testID: `${testID}-section-${section.id}-header` },
|
|
169
|
+
slotProps.sectionHeader,
|
|
170
|
+
)
|
|
171
|
+
: null}
|
|
172
|
+
<View
|
|
173
|
+
className={inset ? "mx-4 overflow-hidden rounded-xl" : "border-y"}
|
|
174
|
+
style={{ backgroundColor: colors.surface, borderColor: colors.separator }}
|
|
175
|
+
>
|
|
140
176
|
{section.rows.map((row, rowIndex) => (
|
|
141
177
|
<Fragment key={row.id}>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
showChevron={row.showChevron}
|
|
149
|
-
onPress={row.onPress}
|
|
150
|
-
disabled={row.disabled}
|
|
151
|
-
/>
|
|
152
|
-
{rowIndex < section.rows.length - 1 ? (
|
|
153
|
-
<NativeListItemDivider className="ml-4" />
|
|
154
|
-
) : null}
|
|
178
|
+
{renderSlot(
|
|
179
|
+
DefaultRow,
|
|
180
|
+
slots.row,
|
|
181
|
+
{ ...row, testID: row.testID ?? `${testID}-row-${row.id}`, isLast: rowIndex === section.rows.length - 1 },
|
|
182
|
+
slotProps.row,
|
|
183
|
+
)}
|
|
155
184
|
</Fragment>
|
|
156
185
|
))}
|
|
157
186
|
</View>
|
|
158
|
-
{section.footnote
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
className="px-4 pt-2 text-muted-foreground"
|
|
162
|
-
>
|
|
163
|
-
{section.footnote}
|
|
164
|
-
</NativeText>
|
|
165
|
-
) : null}
|
|
187
|
+
{section.footnote
|
|
188
|
+
? renderSlot(DefaultFootnote, slots.footnote, { text: section.footnote }, slotProps.footnote)
|
|
189
|
+
: null}
|
|
166
190
|
</View>
|
|
167
191
|
))}
|
|
168
192
|
|
|
169
|
-
{dangerousActions && dangerousActions.length > 0
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
>
|
|
181
|
-
{action.label}
|
|
182
|
-
</NativeButton>
|
|
183
|
-
))}
|
|
184
|
-
</View>
|
|
185
|
-
) : null}
|
|
193
|
+
{dangerousActions && dangerousActions.length > 0
|
|
194
|
+
? renderSlot(
|
|
195
|
+
DefaultDangerousActions,
|
|
196
|
+
slots.dangerousActions,
|
|
197
|
+
{
|
|
198
|
+
actions: dangerousActions.map((action) => ({ ...action, testID: action.testID ?? `${testID}-danger-${slug(action.label)}` })),
|
|
199
|
+
testID: `${testID}-dangerous-actions`,
|
|
200
|
+
},
|
|
201
|
+
slotProps.dangerousActions,
|
|
202
|
+
)
|
|
203
|
+
: null}
|
|
186
204
|
</ScreenContainer>
|
|
187
205
|
);
|
|
188
206
|
}
|
|
189
207
|
|
|
208
|
+
function DefaultSectionHeader({ title, testID }: SettingsPageSlotMap["sectionHeader"]) {
|
|
209
|
+
return <NativeSectionListHeader title={title} testID={testID} />;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function DefaultRow({ isLast, id: _id, ...row }: SettingsPageSlotMap["row"]) {
|
|
213
|
+
return (
|
|
214
|
+
<>
|
|
215
|
+
<NativeListItem
|
|
216
|
+
testID={row.testID}
|
|
217
|
+
// The cell wrapper carries the surface color from theme roles.
|
|
218
|
+
className="bg-transparent"
|
|
219
|
+
title={row.title}
|
|
220
|
+
subtitle={row.subtitle}
|
|
221
|
+
leading={row.leading}
|
|
222
|
+
trailing={row.trailing}
|
|
223
|
+
showChevron={row.showChevron}
|
|
224
|
+
onPress={row.onPress}
|
|
225
|
+
disabled={row.disabled}
|
|
226
|
+
/>
|
|
227
|
+
{isLast ? null : <NativeListItemDivider className="ml-4" />}
|
|
228
|
+
</>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function DefaultFootnote({ text }: SettingsPageSlotMap["footnote"]) {
|
|
233
|
+
return (
|
|
234
|
+
<NativeText preset="body-sm" className="px-4 pt-2 text-muted-foreground">
|
|
235
|
+
{text}
|
|
236
|
+
</NativeText>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function DefaultDangerousActions({ actions, testID }: SettingsPageSlotMap["dangerousActions"]) {
|
|
241
|
+
return (
|
|
242
|
+
<View testID={testID} className={cn("mt-8 gap-2 px-4")}>
|
|
243
|
+
{actions.map((action) => (
|
|
244
|
+
<NativeButton
|
|
245
|
+
key={action.label}
|
|
246
|
+
testID={action.testID}
|
|
247
|
+
variant={action.emphasized ? "destructive" : "outline"}
|
|
248
|
+
onPress={action.onPress}
|
|
249
|
+
>
|
|
250
|
+
{action.label}
|
|
251
|
+
</NativeButton>
|
|
252
|
+
))}
|
|
253
|
+
</View>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
190
257
|
function slug(s: string): string {
|
|
191
258
|
return s
|
|
192
259
|
.toLowerCase()
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { useCallback, type ReactNode } from "react";
|
|
20
20
|
import { Alert, KeyboardAvoidingView, Platform, View } from "react-native";
|
|
21
21
|
import { cn } from "../utils";
|
|
22
|
+
import { useKeyboardScroll } from "./keyboard";
|
|
22
23
|
import {
|
|
23
24
|
ScreenContainer,
|
|
24
25
|
composeHeaderOptions,
|
|
@@ -161,6 +162,26 @@ export function SettingsSubPage({
|
|
|
161
162
|
);
|
|
162
163
|
void _onConfirmLeave;
|
|
163
164
|
|
|
165
|
+
const KeyboardScroll = useKeyboardScroll();
|
|
166
|
+
if (KeyboardScroll) {
|
|
167
|
+
return (
|
|
168
|
+
<ScreenContainer safeAreaEdges={["left", "right", "bottom"]} testID={testID}>
|
|
169
|
+
<KeyboardScroll
|
|
170
|
+
testID={`${testID}-keyboard`}
|
|
171
|
+
keyboardShouldPersistTaps="handled"
|
|
172
|
+
contentInsetAdjustmentBehavior="automatic"
|
|
173
|
+
bottomOffset={24}
|
|
174
|
+
>
|
|
175
|
+
{/* Same padding and className as the fallback path, so `className` overrides it the same way. */}
|
|
176
|
+
<View className={cn("p-4", className)}>
|
|
177
|
+
<View testID={`${testID}-form`} className="gap-4">
|
|
178
|
+
{children}
|
|
179
|
+
</View>
|
|
180
|
+
</View>
|
|
181
|
+
</KeyboardScroll>
|
|
182
|
+
</ScreenContainer>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
164
185
|
return (
|
|
165
186
|
<KeyboardAvoidingView
|
|
166
187
|
testID={`${testID}-kav`}
|
package/dist/chunk-N4WHTQIO.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import { Appearance } from 'react-native';
|
|
3
|
-
|
|
4
|
-
// src/hooks/use-theme-mode.ts
|
|
5
|
-
function useThemeMode() {
|
|
6
|
-
const [scheme, setScheme] = useState(
|
|
7
|
-
Appearance.getColorScheme()
|
|
8
|
-
);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const sub = Appearance.addChangeListener(({ colorScheme }) => {
|
|
11
|
-
setScheme(colorScheme);
|
|
12
|
-
});
|
|
13
|
-
return () => sub.remove();
|
|
14
|
-
}, []);
|
|
15
|
-
return scheme === "dark" ? "dark" : "light";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { useThemeMode };
|
|
19
|
-
//# sourceMappingURL=chunk-N4WHTQIO.js.map
|
|
20
|
-
//# sourceMappingURL=chunk-N4WHTQIO.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-theme-mode.ts"],"names":[],"mappings":";;;;AAiBO,SAAS,YAAA,GAA0B;AACxC,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,QAAA;AAAA,IAC1B,WAAW,cAAA;AAAe,GAC5B;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,MAAM,UAAA,CAAW,iBAAA,CAAkB,CAAC,EAAE,aAAY,KAAM;AAC5D,MAAA,SAAA,CAAU,WAAW,CAAA;AAAA,IACvB,CAAC,CAAA;AACD,IAAA,OAAO,MAAM,IAAI,MAAA,EAAO;AAAA,EAC1B,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,MAAA,KAAW,SAAS,MAAA,GAAS,OAAA;AACtC","file":"chunk-N4WHTQIO.js","sourcesContent":["/**\n * useThemeMode — read the active color scheme (light / dark / unset).\n *\n * Wraps RN's `Appearance.getColorScheme()` + `Appearance.addChangeListener`\n * with a stable React hook so consumers don't have to wire it themselves.\n *\n * Use this in tokens-aware components when you need to choose between\n * light/dark variants OUTSIDE of Tailwind's `dark:` modifier (e.g., to pick\n * an asset, run an extra-color computation, or set StatusBar style).\n *\n * @stability Beta\n */\nimport { useEffect, useState } from \"react\";\nimport { Appearance, type ColorSchemeName } from \"react-native\";\n\nexport type ThemeMode = \"light\" | \"dark\";\n\nexport function useThemeMode(): ThemeMode {\n const [scheme, setScheme] = useState<ColorSchemeName>(\n Appearance.getColorScheme(),\n );\n\n useEffect(() => {\n const sub = Appearance.addChangeListener(({ colorScheme }) => {\n setScheme(colorScheme);\n });\n return () => sub.remove();\n }, []);\n\n return scheme === \"dark\" ? \"dark\" : \"light\";\n}\n"]}
|