@marktiderman/genesis-ui-native 3.5.1 → 3.7.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 +115 -7
- package/dist/{chunk-ONH2PCGH.js → chunk-3KFUS7O6.js} +9 -15
- package/dist/chunk-3KFUS7O6.js.map +1 -0
- package/dist/{chunk-LBVD7XXL.js → chunk-7NDKIIOT.js} +627 -20
- package/dist/chunk-7NDKIIOT.js.map +1 -0
- package/dist/chunk-CAI7LGN6.js +39 -0
- package/dist/chunk-CAI7LGN6.js.map +1 -0
- package/dist/{chunk-ABVSSJNT.js → chunk-GBNIBHSU.js} +198 -168
- package/dist/chunk-GBNIBHSU.js.map +1 -0
- package/dist/chunk-IXC3LO2K.js +410 -0
- package/dist/chunk-IXC3LO2K.js.map +1 -0
- package/dist/{chunk-GHYUNNNU.js → chunk-KH2RVAI5.js} +174 -93
- package/dist/chunk-KH2RVAI5.js.map +1 -0
- package/dist/{chunk-6KWEAGRD.js → chunk-O4BMDV7I.js} +110 -17
- package/dist/chunk-O4BMDV7I.js.map +1 -0
- package/dist/chunk-RTYO24SC.js +105 -0
- package/dist/chunk-RTYO24SC.js.map +1 -0
- package/dist/{chunk-D5RKSPMH.js → chunk-YWDDDYDI.js} +4 -3
- package/dist/chunk-YWDDDYDI.js.map +1 -0
- package/dist/components/index.d.ts +382 -10
- package/dist/components/index.js +6 -5
- package/dist/data/index.d.ts +68 -4
- package/dist/data/index.js +231 -30
- package/dist/data/index.js.map +1 -1
- package/dist/hooks/index.d.ts +90 -2
- package/dist/hooks/index.js +3 -3
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/icons/lucide.js +7 -1
- package/dist/icons/lucide.js.map +1 -1
- package/dist/{inbox-page-BEarNEIP.d.ts → inbox-page-B7_Oi2fS.d.ts} +2 -44
- package/dist/index.d.ts +8 -5
- package/dist/index.js +9 -8
- package/dist/layouts/index.d.ts +40 -51
- package/dist/layouts/index.js +6 -4
- package/dist/{native-modules-PwnGltOU.d.ts → native-modules-DEJJQhDx.d.ts} +55 -1
- package/package.json +101 -4
- package/src/__tests__/doctor-rules.test.ts +87 -0
- package/src/__tests__/native-modules-lists.test.tsx +1 -0
- package/src/components/__tests__/button-haptic.test.tsx +52 -0
- package/src/components/__tests__/composer-bar.test.tsx +79 -0
- package/src/components/__tests__/gallery-card.test.tsx +59 -0
- package/src/components/__tests__/gallery-grid.test.tsx +160 -0
- package/src/components/__tests__/lightbox-resnap.test.tsx +50 -0
- package/src/components/__tests__/lightbox-zoom.test.ts +33 -0
- package/src/components/__tests__/lightbox.test.tsx +141 -0
- package/src/components/__tests__/live-indicator.test.tsx +72 -0
- package/src/components/__tests__/rating.test.tsx +82 -0
- package/src/components/__tests__/thread-list.test.tsx +219 -0
- package/src/components/button.tsx +18 -1
- package/src/components/composer-bar.tsx +276 -0
- package/src/components/drawer.tsx +15 -9
- package/src/components/gallery-card.tsx +109 -0
- package/src/components/gallery-grid.tsx +285 -0
- package/src/components/gallery-layout.ts +2 -0
- package/src/components/gallery-types.ts +2 -0
- package/src/components/index.ts +44 -0
- package/src/components/lightbox-zoom.tsx +282 -0
- package/src/components/lightbox.tsx +342 -0
- package/src/components/live-indicator.tsx +139 -0
- package/src/components/rating.tsx +128 -0
- package/src/components/skeleton.tsx +9 -4
- package/src/components/thread-list.tsx +457 -0
- package/src/components/toast.tsx +7 -4
- package/src/data/NativeConflictSheet.tsx +181 -0
- package/src/data/NativeResourceForm.tsx +15 -1
- package/src/data/index.ts +2 -0
- package/src/data/resource-view/NativeRecordView.tsx +85 -8
- package/src/data/resource-view/NativeResourceView.tsx +79 -32
- package/src/data/resource-view/__tests__/native-record-view.test.tsx +95 -1
- package/src/data/resource-view/__tests__/native-resource-gallery.test.tsx +125 -0
- package/src/hooks/__tests__/use-haptics.test.tsx +146 -0
- package/src/hooks/__tests__/use-motion.test.tsx +106 -0
- package/src/hooks/__tests__/use-thread-jump.test.tsx +88 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-haptics.ts +64 -0
- package/src/hooks/use-motion.ts +128 -0
- package/src/hooks/use-press-feedback.ts +87 -0
- package/src/hooks/use-thread-jump.ts +110 -0
- package/src/icon-names.ts +6 -0
- package/src/icons/lucide.ts +12 -0
- package/src/layouts/__tests__/inbox-page.test.tsx +6 -0
- package/src/layouts/__tests__/thread-page.test.tsx +114 -14
- package/src/layouts/inbox-page.tsx +6 -55
- package/src/layouts/index.ts +2 -0
- package/src/layouts/thread-page.tsx +326 -262
- package/src/native-modules.tsx +20 -2
- package/dist/chunk-6KWEAGRD.js.map +0 -1
- package/dist/chunk-7PCWEY6R.js +0 -27
- package/dist/chunk-7PCWEY6R.js.map +0 -1
- package/dist/chunk-ABVSSJNT.js.map +0 -1
- package/dist/chunk-D5RKSPMH.js.map +0 -1
- package/dist/chunk-GHYUNNNU.js.map +0 -1
- package/dist/chunk-LBVD7XXL.js.map +0 -1
- package/dist/chunk-ONH2PCGH.js.map +0 -1
- package/dist/chunk-Z3AQYVUA.js +0 -36
- package/dist/chunk-Z3AQYVUA.js.map +0 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeGalleryCard — a photo or video cover with an optional title line
|
|
3
|
+
* under it, and slots over the picture for badges (top-left) and actions
|
|
4
|
+
* (top-right). An album, a session recording, a product shot.
|
|
5
|
+
*
|
|
6
|
+
* The cover is `NativeImage` at `ratio` (4:3 by default); without `src`, or
|
|
7
|
+
* while `loading`, it is a muted box with a `NativeSkeleton`. The whole card
|
|
8
|
+
* is a button when `onPress` is given. Same props as the web `GalleryCard`.
|
|
9
|
+
*
|
|
10
|
+
* @stability Beta
|
|
11
|
+
*/
|
|
12
|
+
import type { ReactNode } from "react";
|
|
13
|
+
import { Pressable, Text, View } from "react-native";
|
|
14
|
+
import { cn } from "../utils";
|
|
15
|
+
import { NativeImage } from "./image";
|
|
16
|
+
import { NativeSkeleton } from "./skeleton";
|
|
17
|
+
|
|
18
|
+
export interface NativeGalleryCardProps {
|
|
19
|
+
/** The cover picture. Without it the cover is a placeholder. */
|
|
20
|
+
src?: string;
|
|
21
|
+
alt?: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
subtitle?: string;
|
|
24
|
+
/** Over the cover, top-left (a `NativeBadge`, a `NativeLiveIndicator`). */
|
|
25
|
+
badges?: ReactNode;
|
|
26
|
+
/** Over the cover, top-right (an icon button, a menu). */
|
|
27
|
+
actions?: ReactNode;
|
|
28
|
+
/** Cover width ÷ height. Default 4/3. */
|
|
29
|
+
ratio?: number;
|
|
30
|
+
/** Draws the cover as a skeleton. */
|
|
31
|
+
loading?: boolean;
|
|
32
|
+
onPress?: () => void;
|
|
33
|
+
className?: string;
|
|
34
|
+
testID?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function NativeGalleryCard({
|
|
38
|
+
src,
|
|
39
|
+
alt,
|
|
40
|
+
title,
|
|
41
|
+
subtitle,
|
|
42
|
+
badges,
|
|
43
|
+
actions,
|
|
44
|
+
ratio = 4 / 3,
|
|
45
|
+
loading = false,
|
|
46
|
+
onPress,
|
|
47
|
+
className,
|
|
48
|
+
testID = "native-gallery-card",
|
|
49
|
+
}: NativeGalleryCardProps) {
|
|
50
|
+
const aspectRatio = Number.isFinite(ratio) && ratio > 0 ? ratio : 4 / 3;
|
|
51
|
+
const placeholder = loading || !src;
|
|
52
|
+
const body = (
|
|
53
|
+
<>
|
|
54
|
+
<View testID={`${testID}-cover`} className="relative w-full overflow-hidden bg-muted" style={{ aspectRatio }}>
|
|
55
|
+
{placeholder ? (
|
|
56
|
+
<NativeSkeleton testID={`${testID}-skeleton`} className="absolute inset-0 h-full w-full rounded-none" />
|
|
57
|
+
) : (
|
|
58
|
+
<NativeImage src={src} alt={alt} className="h-full w-full" />
|
|
59
|
+
)}
|
|
60
|
+
{badges ? (
|
|
61
|
+
<View testID={`${testID}-badges`} className="absolute left-2 top-2 flex-row items-center gap-1">
|
|
62
|
+
{badges}
|
|
63
|
+
</View>
|
|
64
|
+
) : null}
|
|
65
|
+
{actions ? (
|
|
66
|
+
<View testID={`${testID}-actions`} className="absolute right-2 top-2 flex-row items-center gap-1">
|
|
67
|
+
{actions}
|
|
68
|
+
</View>
|
|
69
|
+
) : null}
|
|
70
|
+
</View>
|
|
71
|
+
{title || subtitle ? (
|
|
72
|
+
<View testID={`${testID}-footer`} className="gap-0.5 px-3 py-2">
|
|
73
|
+
{title ? (
|
|
74
|
+
<Text testID={`${testID}-title`} numberOfLines={1} className="text-sm font-semibold text-foreground">
|
|
75
|
+
{title}
|
|
76
|
+
</Text>
|
|
77
|
+
) : null}
|
|
78
|
+
{subtitle ? (
|
|
79
|
+
<Text testID={`${testID}-subtitle`} numberOfLines={1} className="text-xs text-muted-foreground">
|
|
80
|
+
{subtitle}
|
|
81
|
+
</Text>
|
|
82
|
+
) : null}
|
|
83
|
+
</View>
|
|
84
|
+
) : null}
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
const classes = cn("overflow-hidden rounded-lg border border-border bg-card", className);
|
|
88
|
+
|
|
89
|
+
if (onPress) {
|
|
90
|
+
return (
|
|
91
|
+
<Pressable
|
|
92
|
+
testID={testID}
|
|
93
|
+
accessibilityRole="button"
|
|
94
|
+
accessibilityLabel={title ?? alt}
|
|
95
|
+
accessibilityHint={subtitle}
|
|
96
|
+
accessibilityState={loading ? { busy: true } : undefined}
|
|
97
|
+
onPress={onPress}
|
|
98
|
+
className={classes}
|
|
99
|
+
>
|
|
100
|
+
{body}
|
|
101
|
+
</Pressable>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return (
|
|
105
|
+
<View testID={testID} accessibilityState={loading ? { busy: true } : undefined} className={classes}>
|
|
106
|
+
{body}
|
|
107
|
+
</View>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeGalleryGrid — photos in rows: justified (each row scaled to fill the
|
|
3
|
+
* width, as in a photo library) or a fixed-column grid (square tiles by
|
|
4
|
+
* default, or each item's own shape with `aspectRatio="item"`).
|
|
5
|
+
*
|
|
6
|
+
* Rows come from the pure `justifyRows`, so the same items pack the same way
|
|
7
|
+
* as the web `GalleryGrid`, with the same defaults (`GALLERY_DEFAULTS`) and
|
|
8
|
+
* the same props, `onItemPress` in place of the web's `onItemClick` (as
|
|
9
|
+
* `NativeResourcePage` pairs with `ResourcePage`). The container width comes
|
|
10
|
+
* from `onLayout`; until it is measured nothing is drawn. The rows are a
|
|
11
|
+
* virtualized `FlatList` (the grid scrolls itself; `header` and `footer` go
|
|
12
|
+
* above and below), so a long gallery mounts only what's near the screen and
|
|
13
|
+
* `loadMore` fires when scrolling nears the end, for "load more". Don't put
|
|
14
|
+
* it inside a ScrollView: it fills its parent (`flex-1`), and nested it would
|
|
15
|
+
* draw every row and fire `loadMore` at once. Put what goes above or below
|
|
16
|
+
* it in `header` and `footer`. Tiles are
|
|
17
|
+
* `NativeImage` over a `bg-muted` placeholder sized from the item's ratio (so
|
|
18
|
+
* rows don't reflow while the picture loads), tappable when `onItemPress` is
|
|
19
|
+
* given (or when selecting); `renderItem` replaces the tile's content and
|
|
20
|
+
* `renderBadges` overlays its top-left.
|
|
21
|
+
*
|
|
22
|
+
* Selection (`selected` + `onSelectionChange`) toggles an id per press, in
|
|
23
|
+
* place of `onItemPress` (as on web), and rings the chosen tiles. `groupBy`
|
|
24
|
+
* lays each group out separately under a header.
|
|
25
|
+
*
|
|
26
|
+
* @stability Beta
|
|
27
|
+
*/
|
|
28
|
+
import { useMemo, useState, type ReactNode } from "react";
|
|
29
|
+
import { FlatList, Pressable, Text, View, type LayoutChangeEvent } from "react-native";
|
|
30
|
+
import { cn } from "../utils";
|
|
31
|
+
import { galleryItemRatio, justifyRows } from "./gallery-layout";
|
|
32
|
+
import { GALLERY_DEFAULTS, type GalleryItem, type GalleryTileAspect } from "./gallery-types";
|
|
33
|
+
import { NativeImage } from "./image";
|
|
34
|
+
|
|
35
|
+
export type NativeGalleryLayout = "justified" | "grid";
|
|
36
|
+
|
|
37
|
+
export interface NativeGalleryGridProps {
|
|
38
|
+
items: GalleryItem[];
|
|
39
|
+
/** Default "justified". */
|
|
40
|
+
layout?: NativeGalleryLayout;
|
|
41
|
+
/** Grid layout only: tiles per row. Default 3. */
|
|
42
|
+
columns?: number;
|
|
43
|
+
/** Grid layout only: each tile's shape, a ratio or `"item"` for the item's own. Default 1 (square), as on web. */
|
|
44
|
+
aspectRatio?: GalleryTileAspect;
|
|
45
|
+
/** Justified layout only: target row height in points. Default 180. */
|
|
46
|
+
rowHeight?: number;
|
|
47
|
+
/** Points between tiles. Default 4. */
|
|
48
|
+
gap?: number;
|
|
49
|
+
/** Called on a press. Not called when `onSelectionChange` is set: a press then only toggles the selection. */
|
|
50
|
+
onItemPress?: (item: GalleryItem, index: number) => void;
|
|
51
|
+
/** Replaces the tile's content (the image by default). */
|
|
52
|
+
renderItem?: (item: GalleryItem, index: number) => ReactNode;
|
|
53
|
+
/** Overlaid top-left of the default tile. */
|
|
54
|
+
renderBadges?: (item: GalleryItem, index: number) => ReactNode;
|
|
55
|
+
/** Ids of the selected items. With `onSelectionChange`, a press toggles the tile. */
|
|
56
|
+
selected?: string[];
|
|
57
|
+
onSelectionChange?: (ids: string[], detail: { item: GalleryItem; index: number }) => void;
|
|
58
|
+
/** Called when scrolling nears the last rows (FlatList's `onEndReached`): the hook for "load more" (NativeResourceView's name). */
|
|
59
|
+
loadMore?: () => void;
|
|
60
|
+
/** @deprecated Use `loadMore`. */
|
|
61
|
+
onNearEnd?: () => void;
|
|
62
|
+
/** Above the first row, scrolling with it. */
|
|
63
|
+
header?: ReactNode;
|
|
64
|
+
/** Below the last row (a "Loading more" spinner). */
|
|
65
|
+
footer?: ReactNode;
|
|
66
|
+
/** Groups items (in order of first appearance), each under a header reading the key (a view's `groupBy`, for an array). */
|
|
67
|
+
groupBy?: (item: GalleryItem) => string;
|
|
68
|
+
/** @deprecated Use `groupBy`. */
|
|
69
|
+
getGroup?: (item: GalleryItem) => string;
|
|
70
|
+
className?: string;
|
|
71
|
+
testID?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface Group {
|
|
75
|
+
key: string | null;
|
|
76
|
+
entries: { item: GalleryItem; index: number }[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function groupItems(items: GalleryItem[], groupBy?: (item: GalleryItem) => string): Group[] {
|
|
80
|
+
if (!groupBy) return [{ key: null, entries: items.map((item, index) => ({ item, index })) }];
|
|
81
|
+
const groups: Group[] = [];
|
|
82
|
+
const byKey = new Map<string, Group>();
|
|
83
|
+
items.forEach((item, index) => {
|
|
84
|
+
const key = groupBy(item);
|
|
85
|
+
let group = byKey.get(key);
|
|
86
|
+
if (!group) {
|
|
87
|
+
group = { key, entries: [] };
|
|
88
|
+
byKey.set(key, group);
|
|
89
|
+
groups.push(group);
|
|
90
|
+
}
|
|
91
|
+
group.entries.push({ item, index });
|
|
92
|
+
});
|
|
93
|
+
return groups;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** One line of the list: a group's header, or a row of tiles with their sizes. */
|
|
97
|
+
type Line =
|
|
98
|
+
| { kind: "header"; key: string; group: string }
|
|
99
|
+
| { kind: "row"; key: string; group: string | null; first: boolean; tiles: { item: GalleryItem; index: number; width: number; height: number }[] };
|
|
100
|
+
|
|
101
|
+
export function NativeGalleryGrid({
|
|
102
|
+
items,
|
|
103
|
+
layout = "justified",
|
|
104
|
+
columns = GALLERY_DEFAULTS.columns,
|
|
105
|
+
aspectRatio = 1,
|
|
106
|
+
rowHeight = GALLERY_DEFAULTS.rowHeight,
|
|
107
|
+
gap = GALLERY_DEFAULTS.gap,
|
|
108
|
+
onItemPress,
|
|
109
|
+
renderItem,
|
|
110
|
+
renderBadges,
|
|
111
|
+
selected,
|
|
112
|
+
onSelectionChange,
|
|
113
|
+
loadMore: loadMoreProp,
|
|
114
|
+
onNearEnd,
|
|
115
|
+
header,
|
|
116
|
+
footer,
|
|
117
|
+
groupBy: groupByProp,
|
|
118
|
+
getGroup,
|
|
119
|
+
className,
|
|
120
|
+
testID = "native-gallery-grid",
|
|
121
|
+
}: NativeGalleryGridProps) {
|
|
122
|
+
const loadMore = loadMoreProp ?? onNearEnd;
|
|
123
|
+
const groupBy = groupByProp ?? getGroup;
|
|
124
|
+
const [width, setWidth] = useState(0);
|
|
125
|
+
const onLayout = (e: LayoutChangeEvent) => {
|
|
126
|
+
const next = e.nativeEvent.layout.width;
|
|
127
|
+
if (next !== width) setWidth(next);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const selecting = Boolean(onSelectionChange);
|
|
131
|
+
const selectedIds = selected ?? [];
|
|
132
|
+
const isSelected = (item: GalleryItem) => selectedIds.includes(item.id);
|
|
133
|
+
|
|
134
|
+
const lines = useMemo<Line[]>(() => {
|
|
135
|
+
if (width <= 0) return [];
|
|
136
|
+
const out: Line[] = [];
|
|
137
|
+
groupItems(items, groupBy).forEach((group) => {
|
|
138
|
+
if (group.key !== null) out.push({ kind: "header", key: `h:${group.key}`, group: group.key });
|
|
139
|
+
const rows: Line[] = [];
|
|
140
|
+
if (layout === "grid") {
|
|
141
|
+
const cols = Math.max(1, Math.floor(columns));
|
|
142
|
+
const side = (width - gap * (cols - 1)) / cols;
|
|
143
|
+
for (let i = 0; i < group.entries.length; i += cols) {
|
|
144
|
+
const slice = group.entries.slice(i, i + cols);
|
|
145
|
+
// A row is as tall as its tallest tile ("item" shapes differ); squares by default.
|
|
146
|
+
const heights = slice.map(({ item }) => side / (aspectRatio === "item" ? galleryItemRatio(item) : aspectRatio));
|
|
147
|
+
rows.push({
|
|
148
|
+
kind: "row",
|
|
149
|
+
key: `r:${group.key ?? ""}:${i}`,
|
|
150
|
+
group: group.key,
|
|
151
|
+
first: i === 0,
|
|
152
|
+
tiles: slice.map(({ item, index }, n) => ({ item, index, width: side, height: heights[n]! })),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
justifyRows(group.entries.map((e) => e.item), width, rowHeight, gap).forEach((row, r) => {
|
|
157
|
+
rows.push({
|
|
158
|
+
kind: "row",
|
|
159
|
+
key: `r:${group.key ?? ""}:${r}`,
|
|
160
|
+
group: group.key,
|
|
161
|
+
first: r === 0,
|
|
162
|
+
tiles: row.tiles.map((t) => ({ item: t.item, index: group.entries[t.index]!.index, width: t.width, height: t.height })),
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
out.push(...rows);
|
|
167
|
+
});
|
|
168
|
+
return out;
|
|
169
|
+
}, [width, items, groupBy, layout, columns, aspectRatio, rowHeight, gap]);
|
|
170
|
+
|
|
171
|
+
const press = (item: GalleryItem, index: number) => {
|
|
172
|
+
if (onSelectionChange) {
|
|
173
|
+
const next = isSelected(item) ? selectedIds.filter((id) => id !== item.id) : [...selectedIds, item.id];
|
|
174
|
+
onSelectionChange(next, { item, index });
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
onItemPress?.(item, index);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const tile = (item: GalleryItem, index: number, size: { width: number; height: number }) => {
|
|
181
|
+
const chosen = isSelected(item);
|
|
182
|
+
const content = renderItem ? (
|
|
183
|
+
renderItem(item, index)
|
|
184
|
+
) : (
|
|
185
|
+
<>
|
|
186
|
+
<View className="absolute inset-0 bg-muted" />
|
|
187
|
+
{item.src ? (
|
|
188
|
+
<NativeImage src={item.src} alt={item.alt} className="h-full w-full" />
|
|
189
|
+
) : (
|
|
190
|
+
// No image: a neutral tile with its words, so the count matches what's drawn. The tile's
|
|
191
|
+
// own label (alt, then caption) names a pressable tile, so the words are hidden from
|
|
192
|
+
// readers then; a plain tile isn't pressable, so the placeholder is the named image.
|
|
193
|
+
<View
|
|
194
|
+
testID={`${testID}-placeholder-${item.id}`}
|
|
195
|
+
{...(onItemPress || selecting
|
|
196
|
+
? { importantForAccessibility: "no-hide-descendants" as const, accessibilityElementsHidden: true }
|
|
197
|
+
: {
|
|
198
|
+
accessible: true,
|
|
199
|
+
accessibilityRole: "image" as const,
|
|
200
|
+
accessibilityLabel: item.alt ?? item.caption ?? `Photo ${index + 1} of ${items.length}`,
|
|
201
|
+
})}
|
|
202
|
+
className="h-full w-full items-center justify-center gap-0.5 p-2"
|
|
203
|
+
>
|
|
204
|
+
{item.alt ? (
|
|
205
|
+
<Text numberOfLines={2} className="text-center text-sm font-medium text-foreground">
|
|
206
|
+
{item.alt}
|
|
207
|
+
</Text>
|
|
208
|
+
) : null}
|
|
209
|
+
{item.caption ? (
|
|
210
|
+
<Text numberOfLines={2} className="text-center text-xs text-muted-foreground">
|
|
211
|
+
{item.caption}
|
|
212
|
+
</Text>
|
|
213
|
+
) : null}
|
|
214
|
+
</View>
|
|
215
|
+
)}
|
|
216
|
+
{renderBadges ? (
|
|
217
|
+
<View testID={`${testID}-badges-${item.id}`} pointerEvents="box-none" className="absolute left-1 top-1 flex-row items-center gap-1">
|
|
218
|
+
{renderBadges(item, index)}
|
|
219
|
+
</View>
|
|
220
|
+
) : null}
|
|
221
|
+
</>
|
|
222
|
+
);
|
|
223
|
+
const tileID = `${testID}-item-${item.id}`;
|
|
224
|
+
const tileClass = cn("overflow-hidden rounded-md bg-muted", chosen && "border-2 border-ring");
|
|
225
|
+
if (onItemPress || selecting) {
|
|
226
|
+
return (
|
|
227
|
+
<Pressable
|
|
228
|
+
key={item.id}
|
|
229
|
+
testID={tileID}
|
|
230
|
+
accessibilityRole="button"
|
|
231
|
+
accessibilityLabel={item.alt ?? item.caption ?? `Photo ${index + 1} of ${items.length}`}
|
|
232
|
+
accessibilityState={selecting ? { selected: chosen } : undefined}
|
|
233
|
+
onPress={() => press(item, index)}
|
|
234
|
+
className={tileClass}
|
|
235
|
+
style={size}
|
|
236
|
+
>
|
|
237
|
+
{content}
|
|
238
|
+
</Pressable>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
return (
|
|
242
|
+
<View key={item.id} testID={tileID} className={tileClass} style={size}>
|
|
243
|
+
{content}
|
|
244
|
+
</View>
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const renderLine = ({ item: line, index: n }: { item: Line; index: number }) => {
|
|
249
|
+
if (line.kind === "header") {
|
|
250
|
+
return (
|
|
251
|
+
<Text accessibilityRole="header" testID={`${testID}-group-${line.group}`} className="mb-2 text-sm font-medium text-muted-foreground" style={{ marginTop: n === 0 ? 0 : gap * 3 }}>
|
|
252
|
+
{line.group}
|
|
253
|
+
</Text>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
return (
|
|
257
|
+
<View
|
|
258
|
+
className="flex-row"
|
|
259
|
+
testID={line.group === null ? undefined : `${testID}-row-${line.group}`}
|
|
260
|
+
style={{ gap, marginTop: line.first ? 0 : gap }}
|
|
261
|
+
>
|
|
262
|
+
{line.tiles.map((t) => tile(t.item, t.index, { width: t.width, height: t.height }))}
|
|
263
|
+
</View>
|
|
264
|
+
);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<View testID={testID} onLayout={onLayout} className={cn("w-full flex-1", className)}>
|
|
269
|
+
{width > 0 ? (
|
|
270
|
+
<FlatList
|
|
271
|
+
testID={`${testID}-list`}
|
|
272
|
+
data={lines}
|
|
273
|
+
keyExtractor={(line) => line.key}
|
|
274
|
+
renderItem={renderLine}
|
|
275
|
+
ListHeaderComponent={header ? <>{header}</> : undefined}
|
|
276
|
+
ListFooterComponent={footer ? <>{footer}</> : undefined}
|
|
277
|
+
onEndReached={loadMore ? () => loadMore() : undefined}
|
|
278
|
+
onEndReachedThreshold={0.5}
|
|
279
|
+
initialNumToRender={8}
|
|
280
|
+
windowSize={7}
|
|
281
|
+
/>
|
|
282
|
+
) : null}
|
|
283
|
+
</View>
|
|
284
|
+
);
|
|
285
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -284,6 +284,7 @@ export type {
|
|
|
284
284
|
GenesisDatePickerProps,
|
|
285
285
|
GenesisNavigationModule,
|
|
286
286
|
GenesisNavigationTheme,
|
|
287
|
+
KeyboardAvoidingLike,
|
|
287
288
|
} from "../native-modules";
|
|
288
289
|
|
|
289
290
|
export { NativeIcon } from "./icon";
|
|
@@ -296,3 +297,46 @@ export type { NativeImageProps } from "./image";
|
|
|
296
297
|
|
|
297
298
|
export { NativeGlassSurface, useLiquidGlass, useReduceTransparency } from "./glass-surface";
|
|
298
299
|
export type { NativeGlassSurfaceProps } from "./glass-surface";
|
|
300
|
+
|
|
301
|
+
export {
|
|
302
|
+
NativeThreadList,
|
|
303
|
+
threadListMode,
|
|
304
|
+
threadNearBottom,
|
|
305
|
+
THREAD_AT_BOTTOM_POINTS,
|
|
306
|
+
} from "./thread-list";
|
|
307
|
+
export type { NativeThreadListProps, NativeThreadListHandle, ThreadRowInfo } from "./thread-list";
|
|
308
|
+
export { NativeComposerBar } from "./composer-bar";
|
|
309
|
+
export type { NativeComposerBarProps, ComposerMode, ComposerTone, ComposerSendAction } from "./composer-bar";
|
|
310
|
+
|
|
311
|
+
// --- Gallery and media primitives ---
|
|
312
|
+
|
|
313
|
+
export { GALLERY_DEFAULTS, type GalleryItem, type GalleryTileAspect } from "./gallery-types";
|
|
314
|
+
export { justifyRows, galleryItemRatio, DEFAULT_GALLERY_RATIO } from "./gallery-layout";
|
|
315
|
+
export type { JustifiedRow, JustifiedTile } from "./gallery-layout";
|
|
316
|
+
|
|
317
|
+
export { NativeRating, nextRating } from "./rating";
|
|
318
|
+
export type { NativeRatingProps, NativeRatingSize } from "./rating";
|
|
319
|
+
|
|
320
|
+
export { NativeGalleryGrid } from "./gallery-grid";
|
|
321
|
+
export type { NativeGalleryGridProps, NativeGalleryLayout } from "./gallery-grid";
|
|
322
|
+
|
|
323
|
+
export { NativeLightbox, defaultNativeLightboxLabels } from "./lightbox";
|
|
324
|
+
export type { NativeLightboxProps, NativeLightboxLabels } from "./lightbox";
|
|
325
|
+
export {
|
|
326
|
+
NativeZoomablePhoto,
|
|
327
|
+
lightboxShouldDismiss,
|
|
328
|
+
lightboxPinchScale,
|
|
329
|
+
lightboxTouchDistance,
|
|
330
|
+
lightboxPanLimit,
|
|
331
|
+
LIGHTBOX_DISMISS_DISTANCE,
|
|
332
|
+
LIGHTBOX_DISMISS_VELOCITY,
|
|
333
|
+
LIGHTBOX_MAX_ZOOM,
|
|
334
|
+
LIGHTBOX_DOUBLE_TAP_MS,
|
|
335
|
+
} from "./lightbox-zoom";
|
|
336
|
+
export type { NativeZoomablePhotoProps } from "./lightbox-zoom";
|
|
337
|
+
|
|
338
|
+
export { NativeGalleryCard } from "./gallery-card";
|
|
339
|
+
export type { NativeGalleryCardProps } from "./gallery-card";
|
|
340
|
+
|
|
341
|
+
export { NativeLiveIndicator } from "./live-indicator";
|
|
342
|
+
export type { NativeLiveIndicatorProps, NativeLiveIndicatorState, NativeLiveIndicatorVariant } from "./live-indicator";
|