The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 02:00 UTC
refactor(mobile): components/ui platform primitives are iOS files with .android overrides (#33173)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 8, 2026 at 20:11 UTC
415f68d2fe8b79dbcabc0e3e9bf1eae4be44f231
63 files changed
+898
-890
apps/mobile/package.json
+1
-1
@@ -48,7 +48,7 @@
48
"generate:highlights": "node scripts/generate-highlights.mts",
49
"generate:nitro": "cd modules/t3-highlights && nitrogen",
50
"eas-build-on-success": "node scripts/upload-sourcemaps.mts build",
51
- "test": "vp test run --project unit --project react && T3_MOBILE_TEST_PLATFORM=android vp test run --project react src/components/FilePreviewModal.test.tsx",
51
+ "test": "vp test run --project unit --project react",
52
"typecheck": "effect-tsgo tsrs --noEmit"
53
},
54
"dependencies": {
apps/mobile/src/components/ComposerAttachmentStrip.tsx
+2
-2
@@ -1,4 +1,4 @@
1
-import { FilePreviewGallery, useFilePreviewGallery } from "./FilePreviewGallery";
1
+import { FilePreviewGallery, useFilePreviewGallery } from "./ui/FilePreviewGallery";
2
import { composerImageGallery } from "../lib/composerImageGallery";
3
import { SymbolView } from "./ui/AppSymbol";
4
import { imageMimeType } from "@t3tools/shared/image";
@@ -21,7 +21,7 @@ import { resolveOwnedComposerAttachmentFileUri } from "../lib/composerAttachment
21
import { VideoAttachmentTile } from "./VideoAttachmentTile";
22
import { type MediaActionsSource } from "../lib/mediaActionsSource";
23
import { PresentationSource } from "./ui/NativePresentation";
24
-import type { FilePreviewSource } from "./FilePreviewModal";
24
+import type { FilePreviewSource } from "./ui/FilePreviewModal";
25
import { isPdfFile } from "../lib/filePreview";
26
import type { EnvironmentId } from "@t3tools/contracts";
27
import {
apps/mobile/src/components/ComposerContextAttachment.tsx
+1
-1
@@ -16,7 +16,7 @@ import { downloadAndShareAttachment } from "../lib/attachmentDownload";
16
import { assetImageSource } from "../lib/assetImageSource";
17
import { useAssetUrlState, useRefreshAssetUrl } from "../state/assets";
18
import { AppText as Text } from "./ui/AppText";
19
-import { FilePreviewModal } from "./FilePreviewModal";
19
+import { FilePreviewModal } from "./ui/FilePreviewModal";
20
import { PresentationSource } from "./ui/NativePresentation";
21
22
export function ComposerContextAttachment(props: {
apps/mobile/src/components/ComposerContextSheet.tsx
+2
-2
@@ -23,8 +23,8 @@ import {
23
type DraftComposerAttachment,
24
} from "../lib/composerImages";
25
import { contextImageGallery } from "../lib/contextImageGallery";
26
-import { FilePreviewModal } from "./FilePreviewModal";
27
-import { VideoPreviewModal } from "./VideoPreviewModal";
26
+import { FilePreviewModal } from "./ui/FilePreviewModal";
27
+import { VideoPreviewModal } from "./ui/VideoPreviewModal";
28
import { ComposerContextAttachment } from "./ComposerContextAttachment";
29
import { AppText as Text } from "./ui/AppText";
30
import { Sheet } from "./ui/Sheet";
apps/mobile/src/components/FilePreviewModal.test.tsx
deleted
-140
@@ -1,140 +0,0 @@
1
-import { act } from "react";
2
-import { createRoot } from "react-dom/client";
3
-import { expect, it, vi } from "vite-plus/test";
4
-import { EnvironmentId, SOURCE_CONTROL_MEDIA_ASSET } from "@t3tools/contracts";
5
-
6
-const harness = vi.hoisted(() => ({
7
- refreshAssetUrl: vi.fn<(environmentId: string, resource: { url: string }) => Promise<string>>(),
8
- alert: vi.fn(),
9
- previews: [] as unknown[],
10
- mounts: 0,
11
- platform: { OS: process.env.T3_MOBILE_TEST_PLATFORM === "android" ? "android" : "ios" },
12
-}));
13
-
14
-vi.mock("react-native", () => ({ Platform: harness.platform }));
15
-vi.mock("../state/assets", () => ({ refreshAssetUrl: harness.refreshAssetUrl }));
16
-vi.mock("../lib/localAttachmentPreview", () => ({ loadLocalAttachmentPreview: vi.fn() }));
17
-vi.mock("../lib/attachmentDownload", () => ({
18
- downloadAndShareAttachment: vi.fn(),
19
- nativeViewerErrorMessage: () => "",
20
- shareLocalAttachment: vi.fn(),
21
-}));
22
-vi.mock("../lib/previewPresentation", () => ({ usePreviewPresentation: () => {} }));
23
-vi.mock("./ui/Dialog", () => ({ alert: harness.alert }));
24
-vi.mock("./FilePreview", async () => {
25
- const { useState } = await import("react");
26
- return {
27
- FilePreview: (props: { source: unknown }) => {
28
- useState(() => harness.mounts++);
29
- harness.previews.push(props.source);
30
- return null;
31
- },
32
- };
33
-});
34
-
35
-import type { FilePreviewItem } from "./FilePreviewModal.types";
36
-import { FilePreviewModal } from "./FilePreviewModal";
37
-
38
-const environmentId = EnvironmentId.make("environment");
39
-const image = (url: string): FilePreviewItem => ({
40
- kind: "image",
41
- environmentId,
42
- resource: { _tag: SOURCE_CONTROL_MEDIA_ASSET, cwd: "/repo", url },
43
-});
44
-
45
-async function openGallery(
46
- selected: FilePreviewItem,
47
- gallery: readonly FilePreviewItem[],
48
- platform = harness.platform.OS,
49
-) {
50
- harness.platform.OS = platform;
51
- (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
52
- harness.previews.length = 0;
53
- harness.mounts = 0;
54
- harness.alert.mockClear();
55
- const root = createRoot(document.createElement("div"));
56
- const onRequestClose = vi.fn();
57
- await act(async () =>
58
- root.render(
59
- <FilePreviewModal source={{ ...selected, gallery }} onRequestClose={onRequestClose} />,
60
- ),
61
- );
62
- return { onRequestClose, [Symbol.asyncDispose]: () => act(async () => root.unmount()) };
63
-}
64
-
65
-it("keeps the gallery stable while a sibling is still resolving", async () => {
66
- const platform = harness.platform.OS;
67
- const slow = Promise.withResolvers<string>();
68
- harness.refreshAssetUrl.mockImplementation(async (_environmentId, resource) =>
69
- resource.url.endsWith("slow.png") ? slow.promise : "https://signed.test/a.png",
70
- );
71
- const selected = image("https://github.com/a.png");
72
- await using _preview = await openGallery(
73
- selected,
74
- [image("https://github.com/slow.png"), selected],
75
- platform,
76
- );
77
-
78
- if (platform === "ios") {
79
- expect(harness.previews.at(-1)).toMatchObject({
80
- kind: "image",
81
- selectedIndex: 1,
82
- images: [
83
- expect.not.objectContaining({ uri: expect.anything() }),
84
- { uri: "https://signed.test/a.png" },
85
- ],
86
- });
87
- } else {
88
- expect(harness.previews).toEqual([]);
89
- }
90
- await act(async () => slow.resolve("https://signed.test/slow.png"));
91
- expect(harness.previews.at(-1)).toMatchObject({
92
- selectedIndex: 1,
93
- images: [{ uri: "https://signed.test/slow.png" }, { uri: "https://signed.test/a.png" }],
94
- });
95
- expect(harness.mounts).toBe(1);
96
-});
97
-
98
-it("handles a failed sibling without leaving a pending page", async () => {
99
- const platform = harness.platform.OS;
100
- harness.refreshAssetUrl.mockImplementation(async (_environmentId, resource) => {
101
- if (resource.url.endsWith("missing.png")) throw new Error("not found");
102
- return `https://signed.test/${resource.url.split("/").pop()}`;
103
- });
104
- const selected = image("https://github.com/a.png");
105
- await using preview = await openGallery(
106
- selected,
107
- [selected, image("https://github.com/missing.png"), image("https://github.com/c.png")],
108
- platform,
109
- );
110
-
111
- if (platform === "android") {
112
- expect(preview.onRequestClose).toHaveBeenCalledOnce();
113
- expect(harness.alert).toHaveBeenCalledOnce();
114
- expect(harness.previews).toEqual([]);
115
- return;
116
- }
117
-
118
- expect(preview.onRequestClose).not.toHaveBeenCalled();
119
- expect(harness.alert).not.toHaveBeenCalled();
120
- expect(harness.previews.at(-1)).toMatchObject({
121
- selectedIndex: 0,
122
- images: [
123
- { uri: "https://signed.test/a.png" },
124
- { failed: true },
125
- { uri: "https://signed.test/c.png" },
126
- ],
127
- });
128
-});
129
-
130
-it("closes the preview when the selected image cannot be resolved", async () => {
131
- harness.refreshAssetUrl.mockImplementation(async (_environmentId, resource) => {
132
- if (resource.url.endsWith("missing.png")) throw new Error("not found");
133
- return `https://signed.test/${resource.url.split("/").pop()}`;
134
- });
135
- const selected = image("https://github.com/missing.png");
136
- await using preview = await openGallery(selected, [image("https://github.com/a.png"), selected]);
137
-
138
- expect(preview.onRequestClose).toHaveBeenCalledOnce();
139
- expect(harness.alert).toHaveBeenCalledOnce();
140
-});
apps/mobile/src/components/MediaImagePreview.tsx
deleted
-58
@@ -1,58 +0,0 @@
1
-import { createContext, useContext } from "react";
2
-import { View } from "react-native";
3
-import ImageViewing from "react-native-image-viewing";
4
-import { useSafeAreaInsets } from "react-native-safe-area-context";
5
-
6
-import { useMediaActions } from "../state/mediaActions";
7
-import type { FilePreviewImages } from "./FilePreviewModal.types";
8
-import { MediaPreviewHeader } from "./MediaPreviewHeader";
9
-
10
-type MediaImagePreviewProps = {
11
- readonly source: FilePreviewImages;
12
- readonly onRequestClose: () => void;
13
-};
14
-
15
-const ImagePreviewContext = createContext<MediaImagePreviewProps | null>(null);
16
-
17
-function ImagePreviewHeader(header: { readonly imageIndex: number }) {
18
- const props = useContext(ImagePreviewContext)!;
19
- const source = props.source.images[header.imageIndex];
20
- const insets = useSafeAreaInsets();
21
- const mediaActions = useMediaActions(source?.actionsSource, props.onRequestClose);
22
- return (
23
- <View className="bg-black/70" style={{ paddingTop: insets.top }}>
24
- <MediaPreviewHeader
25
- title={source?.name ?? "Image"}
26
- media={mediaActions}
27
- closeAccessibilityLabel="Close image"
28
- onClose={props.onRequestClose}
29
- />
30
- </View>
31
- );
32
-}
33
-
34
-// Images still resolving show the viewer's loading page, and remount by key once their URL arrives.
35
-export function imageViewingProps(source: FilePreviewImages) {
36
- return {
37
- images: source.images.map((image) => (image.uri ? { uri: image.uri } : {})),
38
- keyExtractor: (_: unknown, index: number) => source.images[index]?.uri ?? `pending:${index}`,
39
- // Stays fixed: react-native-image-viewing remounts the Modal and replays its fade when it changes.
40
- imageIndex: source.selectedIndex,
41
- };
42
-}
43
-
44
-export function MediaImagePreview(props: MediaImagePreviewProps) {
45
- return (
46
- <ImagePreviewContext value={props}>
47
- <ImageViewing
48
- {...imageViewingProps(props.source)}
49
- visible
50
- presentationStyle="fullScreen"
51
- onRequestClose={props.onRequestClose}
52
- swipeToCloseEnabled={false}
53
- doubleTapToZoomEnabled
54
- HeaderComponent={ImagePreviewHeader}
55
- />
56
- </ImagePreviewContext>
57
- );
58
-}
apps/mobile/src/components/ui/AndroidAnchoredMenu.android.tsx
renamed
apps/mobile/src/components/ui/AndroidScreenHeader.android.tsx
renamed
+1
-1
@@ -7,7 +7,7 @@ import { View } from "react-native";
7
import type { AppSymbolName } from "./AppSymbol";
8
import { NativeAppBar } from "./NativeAppBar.android";
9
import { IconButton } from "./IconButton";
10
-import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
10
+import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu.android";
11
import { splitAndroidHeaderActions } from "./headerMenu.android";
12
import { useScaledTextRole } from "../../features/settings/appearance/useScaledTextRole";
13
import { useToolbarLayout } from "./useToolbarLayout";
apps/mobile/src/components/ui/AppBar.android.test.tsx
+1
-1
@@ -13,7 +13,7 @@ vi.mock("@react-navigation/native", () => ({
13
throw new Error("Couldn't find a navigation object.");
14
},
15
}));
16
-vi.mock("./AndroidScreenHeader", () => ({
16
+vi.mock("./AndroidScreenHeader.android", () => ({
17
AndroidScreenHeader: (props: { readonly title: string }) => <h1>{props.title}</h1>,
18
}));
19
vi.mock("./WorkspaceAppBar.android", () => ({
apps/mobile/src/components/ui/AppBar.android.tsx
+1
-1
@@ -8,7 +8,7 @@ import { useSidebarToggle } from "../../features/layout/useSidebarToggle";
8
import { useAdaptiveWorkspaceLayout } from "../../features/layout/adaptive-workspace-context";
9
import { InspectorCloseContext } from "../../features/layout/inspector-bar-store";
10
import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";
11
-import { AndroidHeaderIconButton, AndroidScreenHeader } from "./AndroidScreenHeader";
11
+import { AndroidHeaderIconButton, AndroidScreenHeader } from "./AndroidScreenHeader.android";
12
import { ScreenHeaderButton } from "./ScreenHeaderButton.android";
13
import { Menu } from "./Menu";
14
import { Button } from "./Button";
apps/mobile/src/components/ui/AppSymbol.android.tsx
new
+370
@@ -0,0 +1,370 @@
1
+import type { Icon } from "@tabler/icons-react-native/types";
2
+/* Package-root imports eagerly register the entire Tabler icon set in Metro. */
3
+import IconAdjustmentsHorizontal from "@tabler/icons-react-native/IconAdjustmentsHorizontal";
4
+import IconAlignLeft from "@tabler/icons-react-native/IconAlignLeft";
5
+import IconAlertCircle from "@tabler/icons-react-native/IconAlertCircle";
6
+import IconAlertTriangle from "@tabler/icons-react-native/IconAlertTriangle";
7
+import IconApps from "@tabler/icons-react-native/IconApps";
8
+import IconArchive from "@tabler/icons-react-native/IconArchive";
9
+import IconCalendarClock from "@tabler/icons-react-native/IconCalendarClock";
10
+import IconArrowBackUp from "@tabler/icons-react-native/IconArrowBackUp";
11
+import IconArrowDown from "@tabler/icons-react-native/IconArrowDown";
12
+import IconArrowForwardUp from "@tabler/icons-react-native/IconArrowForwardUp";
13
+import IconArrowLeft from "@tabler/icons-react-native/IconArrowLeft";
14
+import IconArrowRight from "@tabler/icons-react-native/IconArrowRight";
15
+import IconArrowDownCircle from "@tabler/icons-react-native/IconArrowDownCircle";
16
+import IconArrowRightCircle from "@tabler/icons-react-native/IconArrowRightCircle";
17
+import IconArrowUp from "@tabler/icons-react-native/IconArrowUp";
18
+import IconArrowUpCircle from "@tabler/icons-react-native/IconArrowUpCircle";
19
+import IconArrowUpRight from "@tabler/icons-react-native/IconArrowUpRight";
20
+import IconArrowUpRightCircle from "@tabler/icons-react-native/IconArrowUpRightCircle";
21
+import IconArrowsLeftRight from "@tabler/icons-react-native/IconArrowsLeftRight";
22
+import IconArrowsDiagonal2 from "@tabler/icons-react-native/IconArrowsDiagonal2";
23
+import IconArrowsMinimize from "@tabler/icons-react-native/IconArrowsMinimize";
24
+import IconBan from "@tabler/icons-react-native/IconBan";
25
+import IconBellRinging from "@tabler/icons-react-native/IconBellRinging";
26
+import IconBolt from "@tabler/icons-react-native/IconBolt";
27
+import IconBox from "@tabler/icons-react-native/IconBox";
28
+import IconBrain from "@tabler/icons-react-native/IconBrain";
29
+import IconCamera from "@tabler/icons-react-native/IconCamera";
30
+import IconCar from "@tabler/icons-react-native/IconCar";
31
+import IconChartBar from "@tabler/icons-react-native/IconChartBar";
32
+import IconCheck from "@tabler/icons-react-native/IconCheck";
33
+import IconCloud from "@tabler/icons-react-native/IconCloud";
34
+import IconChevronDown from "@tabler/icons-react-native/IconChevronDown";
35
+import IconChevronLeft from "@tabler/icons-react-native/IconChevronLeft";
36
+import IconChevronRight from "@tabler/icons-react-native/IconChevronRight";
37
+import IconChevronUp from "@tabler/icons-react-native/IconChevronUp";
38
+import IconCircle from "@tabler/icons-react-native/IconCircle";
39
+import IconCircleFilled from "@tabler/icons-react-native/IconCircleFilled";
40
+import IconCircleCheck from "@tabler/icons-react-native/IconCircleCheck";
41
+import IconCircleDashed from "@tabler/icons-react-native/IconCircleDashed";
42
+import IconCircleDot from "@tabler/icons-react-native/IconCircleDot";
43
+import IconCircleXFilled from "@tabler/icons-react-native/IconCircleXFilled";
44
+import IconMoodPlus from "@tabler/icons-react-native/IconMoodPlus";
45
+import IconTag from "@tabler/icons-react-native/IconTag";
46
+import IconTicket from "@tabler/icons-react-native/IconTicket";
47
+import IconClock from "@tabler/icons-react-native/IconClock";
48
+import IconCode from "@tabler/icons-react-native/IconCode";
49
+import IconCopy from "@tabler/icons-react-native/IconCopy";
50
+import IconDatabase from "@tabler/icons-react-native/IconDatabase";
51
+import IconDeviceDesktop from "@tabler/icons-react-native/IconDeviceDesktop";
52
+import IconDeviceLaptop from "@tabler/icons-react-native/IconDeviceLaptop";
53
+import IconDeviceMobile from "@tabler/icons-react-native/IconDeviceMobile";
54
+import IconDots from "@tabler/icons-react-native/IconDots";
55
+import IconPlusMinus from "@tabler/icons-react-native/IconPlusMinus";
56
+import IconDotsVertical from "@tabler/icons-react-native/IconDotsVertical";
57
+import IconDotsCircleHorizontal from "@tabler/icons-react-native/IconDotsCircleHorizontal";
58
+import IconEdit from "@tabler/icons-react-native/IconEdit";
59
+import IconExternalLink from "@tabler/icons-react-native/IconExternalLink";
60
+import IconEyeOff from "@tabler/icons-react-native/IconEyeOff";
61
+import IconEye from "@tabler/icons-react-native/IconEye";
62
+import IconFileText from "@tabler/icons-react-native/IconFileText";
63
+import IconFileDiff from "@tabler/icons-react-native/IconFileDiff";
64
+import IconFilter from "@tabler/icons-react-native/IconFilter";
65
+import IconFilterFilled from "@tabler/icons-react-native/IconFilterFilled";
66
+import IconFolder from "@tabler/icons-react-native/IconFolder";
67
+import IconFolderOpen from "@tabler/icons-react-native/IconFolderOpen";
68
+import IconHeadphones from "@tabler/icons-react-native/IconHeadphones";
69
+import IconFolderPlus from "@tabler/icons-react-native/IconFolderPlus";
70
+import IconGitPullRequestClosed from "@tabler/icons-react-native/IconGitPullRequestClosed";
71
+import IconGitPullRequestDraft from "@tabler/icons-react-native/IconGitPullRequestDraft";
72
+import IconGitCommit from "@tabler/icons-react-native/IconGitCommit";
73
+import IconGitBranch from "@tabler/icons-react-native/IconGitBranch";
74
+import IconGitMerge from "@tabler/icons-react-native/IconGitMerge";
75
+import IconGitPullRequest from "@tabler/icons-react-native/IconGitPullRequest";
76
+import IconHammer from "@tabler/icons-react-native/IconHammer";
77
+import IconHome from "@tabler/icons-react-native/IconHome";
78
+import IconInfoCircle from "@tabler/icons-react-native/IconInfoCircle";
79
+import IconKeyboard from "@tabler/icons-react-native/IconKeyboard";
80
+import IconKeyboardHide from "@tabler/icons-react-native/IconKeyboardHide";
81
+import IconLock from "@tabler/icons-react-native/IconLock";
82
+import IconLayoutColumns from "@tabler/icons-react-native/IconLayoutColumns";
83
+import IconLayoutSidebar from "@tabler/icons-react-native/IconLayoutSidebar";
84
+import IconLayoutSidebarRight from "@tabler/icons-react-native/IconLayoutSidebarRight";
85
+import IconLetterSpacing from "@tabler/icons-react-native/IconLetterSpacing";
86
+import IconMicrophone from "@tabler/icons-react-native/IconMicrophone";
87
+import IconLink from "@tabler/icons-react-native/IconLink";
88
+import IconListNumbers from "@tabler/icons-react-native/IconListNumbers";
89
+import IconMenu2 from "@tabler/icons-react-native/IconMenu2";
90
+import IconMessageCircleQuestion from "@tabler/icons-react-native/IconMessageCircleQuestion";
91
+import IconMessage from "@tabler/icons-react-native/IconMessage";
92
+import IconMessagePlus from "@tabler/icons-react-native/IconMessagePlus";
93
+import IconMinus from "@tabler/icons-react-native/IconMinus";
94
+import IconMoon from "@tabler/icons-react-native/IconMoon";
95
+import IconNetwork from "@tabler/icons-react-native/IconNetwork";
96
+import IconPalette from "@tabler/icons-react-native/IconPalette";
97
+import IconPencil from "@tabler/icons-react-native/IconPencil";
98
+import IconPlug from "@tabler/icons-react-native/IconPlug";
99
+import IconPhoto from "@tabler/icons-react-native/IconPhoto";
100
+import IconPin from "@tabler/icons-react-native/IconPin";
101
+import IconPinnedOff from "@tabler/icons-react-native/IconPinnedOff";
102
+import IconPlayerPause from "@tabler/icons-react-native/IconPlayerPause";
103
+import IconPlayerPlay from "@tabler/icons-react-native/IconPlayerPlay";
104
+import IconPlayerStopFilled from "@tabler/icons-react-native/IconPlayerStopFilled";
105
+import IconPlus from "@tabler/icons-react-native/IconPlus";
106
+import IconQrcode from "@tabler/icons-react-native/IconQrcode";
107
+import IconRefresh from "@tabler/icons-react-native/IconRefresh";
108
+import IconSearch from "@tabler/icons-react-native/IconSearch";
109
+import IconShare from "@tabler/icons-react-native/IconShare";
110
+import IconServer from "@tabler/icons-react-native/IconServer";
111
+import IconSettings from "@tabler/icons-react-native/IconSettings";
112
+import IconSparkles from "@tabler/icons-react-native/IconSparkles";
113
+import IconStack2 from "@tabler/icons-react-native/IconStack2";
114
+import IconStar from "@tabler/icons-react-native/IconStar";
115
+import IconStarFilled from "@tabler/icons-react-native/IconStarFilled";
116
+import IconStethoscope from "@tabler/icons-react-native/IconStethoscope";
117
+import IconSun from "@tabler/icons-react-native/IconSun";
118
+import IconShieldQuestion from "@tabler/icons-react-native/IconShieldQuestion";
119
+import IconTarget from "@tabler/icons-react-native/IconTarget";
120
+import IconTerminal2 from "@tabler/icons-react-native/IconTerminal2";
121
+import IconTextDecrease from "@tabler/icons-react-native/IconTextDecrease";
122
+import IconTextIncrease from "@tabler/icons-react-native/IconTextIncrease";
123
+import IconTool from "@tabler/icons-react-native/IconTool";
124
+import IconTrash from "@tabler/icons-react-native/IconTrash";
125
+import IconTypography from "@tabler/icons-react-native/IconTypography";
126
+import IconDownload from "@tabler/icons-react-native/IconDownload";
127
+import IconSitemap from "@tabler/icons-react-native/IconSitemap";
128
+import IconUpload from "@tabler/icons-react-native/IconUpload";
129
+import IconUserCircle from "@tabler/icons-react-native/IconUserCircle";
130
+import IconUserCheck from "@tabler/icons-react-native/IconUserCheck";
131
+import IconUserX from "@tabler/icons-react-native/IconUserX";
132
+import IconUserQuestion from "@tabler/icons-react-native/IconUserQuestion";
133
+import IconUserPlus from "@tabler/icons-react-native/IconUserPlus";
134
+import IconUsers from "@tabler/icons-react-native/IconUsers";
135
+import IconWifi from "@tabler/icons-react-native/IconWifi";
136
+import IconWifiOff from "@tabler/icons-react-native/IconWifiOff";
137
+import IconWorld from "@tabler/icons-react-native/IconWorld";
138
+import IconX from "@tabler/icons-react-native/IconX";
139
+import type { AndroidSymbol, SFSymbol, SymbolViewProps } from "expo-symbols";
140
+import { withUniwind } from "uniwind";
141
+
142
+const ANDROID_ICON_BY_SF_SYMBOL = {
143
+ plusminus: IconPlusMinus,
144
+ "git.pull-request.closed": IconGitPullRequestClosed,
145
+ "git.pull-request.draft": IconGitPullRequestDraft,
146
+ "git.commit": IconGitCommit,
147
+ "arrow.branch": IconGitBranch,
148
+ "arrow.left": IconArrowLeft,
149
+ "arrow.right": IconArrowRight,
150
+ "arrow.left.arrow.right": IconArrowsLeftRight,
151
+ "arrow.clockwise": IconRefresh,
152
+ "arrow.down": IconArrowDown,
153
+ "arrow.down.circle": IconArrowDownCircle,
154
+ "arrow.right.circle": IconArrowRightCircle,
155
+ "arrow.triangle.branch": IconGitBranch,
156
+ "arrow.triangle.merge": IconGitMerge,
157
+ "arrow.triangle.pull": IconGitPullRequest,
158
+ "square.3.layers.3d": IconStack2,
159
+ "arrow.turn.left.up": IconArrowBackUp,
160
+ "arrow.up": IconArrowUp,
161
+ "arrow.up.circle": IconArrowUpCircle,
162
+ "arrow.up.left.and.arrow.down.right": IconArrowsDiagonal2,
163
+ "arrow.down.right.and.arrow.up.left": IconArrowsMinimize,
164
+ "arrow.up.right": IconArrowUpRight,
165
+ "arrow.up.right.circle": IconArrowUpRightCircle,
166
+ "arrow.uturn.backward": IconArrowBackUp,
167
+ "arrow.uturn.forward": IconArrowForwardUp,
168
+ archivebox: IconArchive,
169
+ "archivebox.fill": IconArchive,
170
+ "bell.badge": IconBellRinging,
171
+ "bolt.circle": IconBolt,
172
+ "bolt.horizontal.circle": IconBolt,
173
+ brain: IconBrain,
174
+ "cable.connector": IconPlug,
175
+ camera: IconCamera,
176
+ car: IconCar,
177
+ "chart.bar.xaxis": IconChartBar,
178
+ checkmark: IconCheck,
179
+ "checkmark.circle": IconCircleCheck,
180
+ "checkmark.circle.fill": IconCircleCheck,
181
+ circle: IconCircle,
182
+ "circle.fill": IconCircleFilled,
183
+ "circle.dashed": IconCircleDashed,
184
+ "circle.inset.filled": IconCircleDot,
185
+ "circle.dashed.inset.filled": IconCircleDot,
186
+ "calendar.badge.clock": IconCalendarClock,
187
+ clock: IconClock,
188
+ timer: IconClock,
189
+ "face.smiling": IconMoodPlus,
190
+ tag: IconTag,
191
+ ticket: IconTicket,
192
+ cloud: IconCloud,
193
+ cube: IconBox,
194
+ "chevron.down": IconChevronDown,
195
+ "chevron.left": IconChevronLeft,
196
+ "chevron.left.forwardslash.chevron.right": IconCode,
197
+ "chevron.right": IconChevronRight,
198
+ "chevron.up": IconChevronUp,
199
+ desktopcomputer: IconDeviceDesktop,
200
+ doc: IconFileText,
201
+ "doc.on.doc": IconCopy,
202
+ "doc.text": IconFileText,
203
+ "file.diff": IconFileDiff,
204
+ ellipsis: IconDots,
205
+ moon: IconMoon,
206
+ "ellipsis.circle": IconDotsCircleHorizontal,
207
+ "exclamationmark.triangle": IconAlertTriangle,
208
+ "exclamationmark.circle": IconAlertCircle,
209
+ eye: IconEye,
210
+ "eye.slash": IconEyeOff,
211
+ folder: IconFolder,
212
+ "folder.badge.plus": IconFolderPlus,
213
+ "folder.fill": IconFolder,
214
+ gearshape: IconSettings,
215
+ globe: IconWorld,
216
+ hammer: IconHammer,
217
+ headphones: IconHeadphones,
218
+ house: IconHome,
219
+ "info.circle": IconInfoCircle,
220
+ internaldrive: IconDatabase,
221
+ iphone: IconDeviceMobile,
222
+ keyboard: IconKeyboard,
223
+ laptopcomputer: IconDeviceLaptop,
224
+ link: IconLink,
225
+ "list.number": IconListNumbers,
226
+ "line.3.horizontal": IconMenu2,
227
+ "line.3.horizontal.decrease": IconFilter,
228
+ "line.3.horizontal.decrease.circle": IconFilter,
229
+ "line.3.horizontal.decrease.circle.fill": IconFilterFilled,
230
+ macmini: IconServer,
231
+ macstudio: IconDeviceDesktop,
232
+ magnifyingglass: IconSearch,
233
+ mic: IconMicrophone,
234
+ paintbrush: IconPalette,
235
+ pencil: IconPencil,
236
+ "person.crop.circle": IconUserCircle,
237
+ "person.2": IconUsers,
238
+ "person.fill.checkmark": IconUserCheck,
239
+ "person.fill.xmark": IconUserX,
240
+ "person.badge.clock": IconUserQuestion,
241
+ "person.badge.plus": IconUserPlus,
242
+ photo: IconPhoto,
243
+ pin: IconPin,
244
+ "pin.slash": IconPinnedOff,
245
+ play: IconPlayerPlay,
246
+ pause: IconPlayerPause,
247
+ plus: IconPlus,
248
+ minus: IconMinus,
249
+ "slash.circle": IconBan,
250
+ "qrcode.viewfinder": IconQrcode,
251
+ "point.3.connected.trianglepath.dotted": IconNetwork,
252
+ flowchart: IconSitemap,
253
+ "point.topleft.down.curvedto.point.bottomright.up": IconGitMerge,
254
+ safari: IconExternalLink,
255
+ "server.rack": IconServer,
256
+ stethoscope: IconStethoscope,
257
+ "sidebar.left": IconLayoutSidebar,
258
+ "sidebar.right": IconLayoutSidebarRight,
259
+ "slider.horizontal.3": IconAdjustmentsHorizontal,
260
+ "square.and.arrow.up": IconShare,
261
+ "square.and.pencil": IconEdit,
262
+ "square.on.square": IconCopy,
263
+ "square.grid.2x2": IconApps,
264
+ "square.split.2x1": IconLayoutColumns,
265
+ star: IconStar,
266
+ "star.fill": IconStarFilled,
267
+ "sun.max": IconSun,
268
+ "stop.fill": IconPlayerStopFilled,
269
+ target: IconTarget,
270
+ terminal: IconTerminal2,
271
+ "text.alignleft": IconAlignLeft,
272
+ "text.bubble": IconMessage,
273
+ "questionmark.bubble": IconMessageCircleQuestion,
274
+ "exclamationmark.shield": IconShieldQuestion,
275
+ "bubble.left.and.bubble.right": IconMessage,
276
+ "bubble.left": IconMessage,
277
+ sparkles: IconSparkles,
278
+ "plus.bubble": IconMessagePlus,
279
+ "text.word.spacing": IconLetterSpacing,
280
+ "textformat.size": IconTypography,
281
+ "textformat.size.larger": IconTextIncrease,
282
+ "textformat.size.smaller": IconTextDecrease,
283
+ "tray.and.arrow.down": IconDownload,
284
+ "tray.and.arrow.up": IconUpload,
285
+ trash: IconTrash,
286
+ wifi: IconWifi,
287
+ "wifi.slash": IconWifiOff,
288
+ xmark: IconX,
289
+ "xmark.circle.fill": IconCircleXFilled,
290
+} satisfies Partial<
291
+ Record<
292
+ SFSymbol | "git.pull-request.closed" | "git.pull-request.draft" | "git.commit" | "file.diff",
293
+ Icon
294
+ >
295
+>;
296
+const SF_ICON_LOOKUP: Partial<
297
+ Record<
298
+ SFSymbol | "git.pull-request.closed" | "git.pull-request.draft" | "git.commit" | "file.diff",
299
+ Icon
300
+ >
301
+> = ANDROID_ICON_BY_SF_SYMBOL;
302
+
303
+const ANDROID_ICON_BY_MATERIAL_NAME = {
304
+ auto_awesome: IconSparkles,
305
+ bolt: IconBolt,
306
+ build: IconTool,
307
+ chat: IconMessage,
308
+ chat_bubble: IconMessage,
309
+ check: IconCheck,
310
+ close: IconX,
311
+ construction: IconHammer,
312
+ content_copy: IconCopy,
313
+ desktop_windows: IconDeviceDesktop,
314
+ edit: IconEdit,
315
+ error: IconAlertCircle,
316
+ folder: IconFolder,
317
+ folder_open: IconFolderOpen,
318
+ keyboard: IconKeyboard,
319
+ keyboard_arrow_down: IconChevronDown,
320
+ keyboard_arrow_up: IconChevronUp,
321
+ keyboard_hide: IconKeyboardHide,
322
+ lock: IconLock,
323
+ more_vert: IconDotsVertical,
324
+ merge: IconGitMerge,
325
+ psychology: IconBrain,
326
+ public: IconWorld,
327
+ remove: IconMinus,
328
+ smartphone: IconDeviceMobile,
329
+ terminal: IconTerminal2,
330
+ visibility: IconEye,
331
+} satisfies Partial<Record<AndroidSymbol, Icon>>;
332
+
333
+export type { SFSymbol } from "expo-symbols";
334
+export type AppSymbolName =
335
+ | keyof typeof ANDROID_ICON_BY_SF_SYMBOL
336
+ | {
337
+ ios: SFSymbol;
338
+ android: keyof typeof ANDROID_ICON_BY_MATERIAL_NAME;
339
+ };
340
+
341
+export type AppSymbolViewProps = Omit<SymbolViewProps, "name"> & { name: AppSymbolName };
342
+
343
+export function isAppSymbolName(name: string): name is Extract<AppSymbolName, string> {
344
+ return Object.prototype.hasOwnProperty.call(ANDROID_ICON_BY_SF_SYMBOL, name);
345
+}
346
+
347
+function AppSymbolView(props: AppSymbolViewProps) {
348
+ const materialName = typeof props.name === "string" ? undefined : props.name.android;
349
+ const sfSymbol = typeof props.name === "string" ? props.name : props.name.ios;
350
+ const AndroidIcon =
351
+ (materialName ? ANDROID_ICON_BY_MATERIAL_NAME[materialName] : undefined) ??
352
+ (sfSymbol ? SF_ICON_LOOKUP[sfSymbol] : undefined);
353
+
354
+ if (!AndroidIcon) {
355
+ return props.fallback ?? null;
356
+ }
357
+
358
+ return (
359
+ <AndroidIcon
360
+ accessibilityLabel={props.accessibilityLabel}
361
+ color={props.tintColor}
362
+ size={props.size}
363
+ strokeWidth={2}
364
+ style={props.style}
365
+ testID={props.testID}
366
+ />
367
+ );
368
+}
369
+
370
+export const SymbolView = withUniwind(AppSymbolView);
apps/mobile/src/components/ui/AppSymbol.ios.tsx
deleted
-46
@@ -1,46 +0,0 @@
1
-import IconGitBranch from "@tabler/icons-react-native/IconGitBranch";
2
-import IconGitMerge from "@tabler/icons-react-native/IconGitMerge";
3
-import IconGitCommit from "@tabler/icons-react-native/IconGitCommit";
4
-import IconGitPullRequestClosed from "@tabler/icons-react-native/IconGitPullRequestClosed";
5
-import IconGitPullRequestDraft from "@tabler/icons-react-native/IconGitPullRequestDraft";
6
-import type { SFSymbol } from "expo-symbols";
7
-import IconGitPullRequest from "@tabler/icons-react-native/IconGitPullRequest";
8
-import IconFileDiff from "@tabler/icons-react-native/IconFileDiff";
9
-import { SymbolView as ExpoSymbolView } from "expo-symbols";
10
-import { withUniwind } from "uniwind";
11
-import type { AppSymbolViewProps } from "./AppSymbol";
12
-
13
-export type { SFSymbol } from "expo-symbols";
14
-export type { AppSymbolName } from "./AppSymbol";
15
-
16
-const CUSTOM_ICONS = {
17
- "file.diff": IconFileDiff,
18
- "arrow.triangle.pull": IconGitPullRequest,
19
- "arrow.triangle.merge": IconGitMerge,
20
- "arrow.triangle.branch": IconGitBranch,
21
- "arrow.branch": IconGitBranch,
22
- "git.pull-request.closed": IconGitPullRequestClosed,
23
- "git.pull-request.draft": IconGitPullRequestDraft,
24
- "git.commit": IconGitCommit,
25
-};
26
-
27
-function AppSymbolView(props: AppSymbolViewProps) {
28
- const name = typeof props.name === "string" ? props.name : props.name.ios;
29
- const CustomIcon = CUSTOM_ICONS[name as keyof typeof CUSTOM_ICONS];
30
- if (CustomIcon) {
31
- return (
32
- <CustomIcon
33
- accessibilityLabel={props.accessibilityLabel}
34
- color={props.tintColor}
35
- size={props.size}
36
- strokeWidth={2}
37
- style={props.style}
38
- testID={props.testID}
39
- />
40
- );
41
- }
42
-
43
- return <ExpoSymbolView {...props} name={name as SFSymbol} />;
44
-}
45
-
46
-export const SymbolView = withUniwind(AppSymbolView);
apps/mobile/src/components/ui/AppSymbol.tsx
+31
-355
@@ -1,370 +1,46 @@
1
-import type { Icon } from "@tabler/icons-react-native/types";
2
-/* Package-root imports eagerly register the entire Tabler icon set in Metro. */
3
-import IconAdjustmentsHorizontal from "@tabler/icons-react-native/IconAdjustmentsHorizontal";
4
-import IconAlignLeft from "@tabler/icons-react-native/IconAlignLeft";
5
-import IconAlertCircle from "@tabler/icons-react-native/IconAlertCircle";
6
-import IconAlertTriangle from "@tabler/icons-react-native/IconAlertTriangle";
7
-import IconApps from "@tabler/icons-react-native/IconApps";
8
-import IconArchive from "@tabler/icons-react-native/IconArchive";
9
-import IconCalendarClock from "@tabler/icons-react-native/IconCalendarClock";
10
-import IconArrowBackUp from "@tabler/icons-react-native/IconArrowBackUp";
11
-import IconArrowDown from "@tabler/icons-react-native/IconArrowDown";
12
-import IconArrowForwardUp from "@tabler/icons-react-native/IconArrowForwardUp";
13
-import IconArrowLeft from "@tabler/icons-react-native/IconArrowLeft";
14
-import IconArrowRight from "@tabler/icons-react-native/IconArrowRight";
15
-import IconArrowDownCircle from "@tabler/icons-react-native/IconArrowDownCircle";
16
-import IconArrowRightCircle from "@tabler/icons-react-native/IconArrowRightCircle";
17
-import IconArrowUp from "@tabler/icons-react-native/IconArrowUp";
18
-import IconArrowUpCircle from "@tabler/icons-react-native/IconArrowUpCircle";
19
-import IconArrowUpRight from "@tabler/icons-react-native/IconArrowUpRight";
20
-import IconArrowUpRightCircle from "@tabler/icons-react-native/IconArrowUpRightCircle";
21
-import IconArrowsLeftRight from "@tabler/icons-react-native/IconArrowsLeftRight";
22
-import IconArrowsDiagonal2 from "@tabler/icons-react-native/IconArrowsDiagonal2";
23
-import IconArrowsMinimize from "@tabler/icons-react-native/IconArrowsMinimize";
24
-import IconBan from "@tabler/icons-react-native/IconBan";
25
-import IconBellRinging from "@tabler/icons-react-native/IconBellRinging";
26
-import IconBolt from "@tabler/icons-react-native/IconBolt";
27
-import IconBox from "@tabler/icons-react-native/IconBox";
28
-import IconBrain from "@tabler/icons-react-native/IconBrain";
29
-import IconCamera from "@tabler/icons-react-native/IconCamera";
30
-import IconCar from "@tabler/icons-react-native/IconCar";
31
-import IconChartBar from "@tabler/icons-react-native/IconChartBar";
32
-import IconCheck from "@tabler/icons-react-native/IconCheck";
33
-import IconCloud from "@tabler/icons-react-native/IconCloud";
34
-import IconChevronDown from "@tabler/icons-react-native/IconChevronDown";
35
-import IconChevronLeft from "@tabler/icons-react-native/IconChevronLeft";
36
-import IconChevronRight from "@tabler/icons-react-native/IconChevronRight";
37
-import IconChevronUp from "@tabler/icons-react-native/IconChevronUp";
38
-import IconCircle from "@tabler/icons-react-native/IconCircle";
39
-import IconCircleFilled from "@tabler/icons-react-native/IconCircleFilled";
40
-import IconCircleCheck from "@tabler/icons-react-native/IconCircleCheck";
41
-import IconCircleDashed from "@tabler/icons-react-native/IconCircleDashed";
42
-import IconCircleDot from "@tabler/icons-react-native/IconCircleDot";
43
-import IconCircleXFilled from "@tabler/icons-react-native/IconCircleXFilled";
44
-import IconMoodPlus from "@tabler/icons-react-native/IconMoodPlus";
45
-import IconTag from "@tabler/icons-react-native/IconTag";
46
-import IconTicket from "@tabler/icons-react-native/IconTicket";
47
-import IconClock from "@tabler/icons-react-native/IconClock";
48
-import IconCode from "@tabler/icons-react-native/IconCode";
49
-import IconCopy from "@tabler/icons-react-native/IconCopy";
50
-import IconDatabase from "@tabler/icons-react-native/IconDatabase";
51
-import IconDeviceDesktop from "@tabler/icons-react-native/IconDeviceDesktop";
52
-import IconDeviceLaptop from "@tabler/icons-react-native/IconDeviceLaptop";
53
-import IconDeviceMobile from "@tabler/icons-react-native/IconDeviceMobile";
54
-import IconDots from "@tabler/icons-react-native/IconDots";
55
-import IconPlusMinus from "@tabler/icons-react-native/IconPlusMinus";
56
-import IconDotsVertical from "@tabler/icons-react-native/IconDotsVertical";
57
-import IconDotsCircleHorizontal from "@tabler/icons-react-native/IconDotsCircleHorizontal";
58
-import IconEdit from "@tabler/icons-react-native/IconEdit";
59
-import IconExternalLink from "@tabler/icons-react-native/IconExternalLink";
60
-import IconEyeOff from "@tabler/icons-react-native/IconEyeOff";
61
-import IconEye from "@tabler/icons-react-native/IconEye";
62
-import IconFileText from "@tabler/icons-react-native/IconFileText";
63
-import IconFileDiff from "@tabler/icons-react-native/IconFileDiff";
64
-import IconFilter from "@tabler/icons-react-native/IconFilter";
65
-import IconFilterFilled from "@tabler/icons-react-native/IconFilterFilled";
66
-import IconFolder from "@tabler/icons-react-native/IconFolder";
67
-import IconFolderOpen from "@tabler/icons-react-native/IconFolderOpen";
68
-import IconHeadphones from "@tabler/icons-react-native/IconHeadphones";
69
-import IconFolderPlus from "@tabler/icons-react-native/IconFolderPlus";
70
-import IconGitPullRequestClosed from "@tabler/icons-react-native/IconGitPullRequestClosed";
71
-import IconGitPullRequestDraft from "@tabler/icons-react-native/IconGitPullRequestDraft";
72
-import IconGitCommit from "@tabler/icons-react-native/IconGitCommit";
1
import IconGitBranch from "@tabler/icons-react-native/IconGitBranch";
2
import IconGitMerge from "@tabler/icons-react-native/IconGitMerge";
3
+import IconGitCommit from "@tabler/icons-react-native/IconGitCommit";
4
+import IconGitPullRequestClosed from "@tabler/icons-react-native/IconGitPullRequestClosed";
5
+import IconGitPullRequestDraft from "@tabler/icons-react-native/IconGitPullRequestDraft";
6
+import type { SFSymbol } from "expo-symbols";
7
import IconGitPullRequest from "@tabler/icons-react-native/IconGitPullRequest";
76
-import IconHammer from "@tabler/icons-react-native/IconHammer";
77
-import IconHome from "@tabler/icons-react-native/IconHome";
78
-import IconInfoCircle from "@tabler/icons-react-native/IconInfoCircle";
79
-import IconKeyboard from "@tabler/icons-react-native/IconKeyboard";
80
-import IconKeyboardHide from "@tabler/icons-react-native/IconKeyboardHide";
81
-import IconLock from "@tabler/icons-react-native/IconLock";
82
-import IconLayoutColumns from "@tabler/icons-react-native/IconLayoutColumns";
83
-import IconLayoutSidebar from "@tabler/icons-react-native/IconLayoutSidebar";
84
-import IconLayoutSidebarRight from "@tabler/icons-react-native/IconLayoutSidebarRight";
85
-import IconLetterSpacing from "@tabler/icons-react-native/IconLetterSpacing";
86
-import IconMicrophone from "@tabler/icons-react-native/IconMicrophone";
87
-import IconLink from "@tabler/icons-react-native/IconLink";
88
-import IconListNumbers from "@tabler/icons-react-native/IconListNumbers";
89
-import IconMenu2 from "@tabler/icons-react-native/IconMenu2";
90
-import IconMessageCircleQuestion from "@tabler/icons-react-native/IconMessageCircleQuestion";
91
-import IconMessage from "@tabler/icons-react-native/IconMessage";
92
-import IconMessagePlus from "@tabler/icons-react-native/IconMessagePlus";
93
-import IconMinus from "@tabler/icons-react-native/IconMinus";
94
-import IconMoon from "@tabler/icons-react-native/IconMoon";
95
-import IconNetwork from "@tabler/icons-react-native/IconNetwork";
96
-import IconPalette from "@tabler/icons-react-native/IconPalette";
97
-import IconPencil from "@tabler/icons-react-native/IconPencil";
98
-import IconPlug from "@tabler/icons-react-native/IconPlug";
99
-import IconPhoto from "@tabler/icons-react-native/IconPhoto";
100
-import IconPin from "@tabler/icons-react-native/IconPin";
101
-import IconPinnedOff from "@tabler/icons-react-native/IconPinnedOff";
102
-import IconPlayerPause from "@tabler/icons-react-native/IconPlayerPause";
103
-import IconPlayerPlay from "@tabler/icons-react-native/IconPlayerPlay";
104
-import IconPlayerStopFilled from "@tabler/icons-react-native/IconPlayerStopFilled";
105
-import IconPlus from "@tabler/icons-react-native/IconPlus";
106
-import IconQrcode from "@tabler/icons-react-native/IconQrcode";
107
-import IconRefresh from "@tabler/icons-react-native/IconRefresh";
108
-import IconSearch from "@tabler/icons-react-native/IconSearch";
109
-import IconShare from "@tabler/icons-react-native/IconShare";
110
-import IconServer from "@tabler/icons-react-native/IconServer";
111
-import IconSettings from "@tabler/icons-react-native/IconSettings";
112
-import IconSparkles from "@tabler/icons-react-native/IconSparkles";
113
-import IconStack2 from "@tabler/icons-react-native/IconStack2";
114
-import IconStar from "@tabler/icons-react-native/IconStar";
115
-import IconStarFilled from "@tabler/icons-react-native/IconStarFilled";
116
-import IconStethoscope from "@tabler/icons-react-native/IconStethoscope";
117
-import IconSun from "@tabler/icons-react-native/IconSun";
118
-import IconShieldQuestion from "@tabler/icons-react-native/IconShieldQuestion";
119
-import IconTarget from "@tabler/icons-react-native/IconTarget";
120
-import IconTerminal2 from "@tabler/icons-react-native/IconTerminal2";
121
-import IconTextDecrease from "@tabler/icons-react-native/IconTextDecrease";
122
-import IconTextIncrease from "@tabler/icons-react-native/IconTextIncrease";
123
-import IconTool from "@tabler/icons-react-native/IconTool";
124
-import IconTrash from "@tabler/icons-react-native/IconTrash";
125
-import IconTypography from "@tabler/icons-react-native/IconTypography";
126
-import IconDownload from "@tabler/icons-react-native/IconDownload";
127
-import IconSitemap from "@tabler/icons-react-native/IconSitemap";
128
-import IconUpload from "@tabler/icons-react-native/IconUpload";
129
-import IconUserCircle from "@tabler/icons-react-native/IconUserCircle";
130
-import IconUserCheck from "@tabler/icons-react-native/IconUserCheck";
131
-import IconUserX from "@tabler/icons-react-native/IconUserX";
132
-import IconUserQuestion from "@tabler/icons-react-native/IconUserQuestion";
133
-import IconUserPlus from "@tabler/icons-react-native/IconUserPlus";
134
-import IconUsers from "@tabler/icons-react-native/IconUsers";
135
-import IconWifi from "@tabler/icons-react-native/IconWifi";
136
-import IconWifiOff from "@tabler/icons-react-native/IconWifiOff";
137
-import IconWorld from "@tabler/icons-react-native/IconWorld";
138
-import IconX from "@tabler/icons-react-native/IconX";
139
-import type { AndroidSymbol, SFSymbol, SymbolViewProps } from "expo-symbols";
8
+import IconFileDiff from "@tabler/icons-react-native/IconFileDiff";
9
+import { SymbolView as ExpoSymbolView } from "expo-symbols";
10
import { withUniwind } from "uniwind";
11
+import type { AppSymbolViewProps } from "./AppSymbol.android";
12
+
13
+export type { SFSymbol } from "expo-symbols";
14
+export type { AppSymbolName, AppSymbolViewProps } from "./AppSymbol.android";
15
142
-const ANDROID_ICON_BY_SF_SYMBOL = {
143
- plusminus: IconPlusMinus,
16
+const CUSTOM_ICONS = {
17
+ "file.diff": IconFileDiff,
18
+ "arrow.triangle.pull": IconGitPullRequest,
19
+ "arrow.triangle.merge": IconGitMerge,
20
+ "arrow.triangle.branch": IconGitBranch,
21
+ "arrow.branch": IconGitBranch,
22
"git.pull-request.closed": IconGitPullRequestClosed,
23
"git.pull-request.draft": IconGitPullRequestDraft,
24
"git.commit": IconGitCommit,
147
- "arrow.branch": IconGitBranch,
148
- "arrow.left": IconArrowLeft,
149
- "arrow.right": IconArrowRight,
150
- "arrow.left.arrow.right": IconArrowsLeftRight,
151
- "arrow.clockwise": IconRefresh,
152
- "arrow.down": IconArrowDown,
153
- "arrow.down.circle": IconArrowDownCircle,
154
- "arrow.right.circle": IconArrowRightCircle,
155
- "arrow.triangle.branch": IconGitBranch,
156
- "arrow.triangle.merge": IconGitMerge,
157
- "arrow.triangle.pull": IconGitPullRequest,
158
- "square.3.layers.3d": IconStack2,
159
- "arrow.turn.left.up": IconArrowBackUp,
160
- "arrow.up": IconArrowUp,
161
- "arrow.up.circle": IconArrowUpCircle,
162
- "arrow.up.left.and.arrow.down.right": IconArrowsDiagonal2,
163
- "arrow.down.right.and.arrow.up.left": IconArrowsMinimize,
164
- "arrow.up.right": IconArrowUpRight,
165
- "arrow.up.right.circle": IconArrowUpRightCircle,
166
- "arrow.uturn.backward": IconArrowBackUp,
167
- "arrow.uturn.forward": IconArrowForwardUp,
168
- archivebox: IconArchive,
169
- "archivebox.fill": IconArchive,
170
- "bell.badge": IconBellRinging,
171
- "bolt.circle": IconBolt,
172
- "bolt.horizontal.circle": IconBolt,
173
- brain: IconBrain,
174
- "cable.connector": IconPlug,
175
- camera: IconCamera,
176
- car: IconCar,
177
- "chart.bar.xaxis": IconChartBar,
178
- checkmark: IconCheck,
179
- "checkmark.circle": IconCircleCheck,
180
- "checkmark.circle.fill": IconCircleCheck,
181
- circle: IconCircle,
182
- "circle.fill": IconCircleFilled,
183
- "circle.dashed": IconCircleDashed,
184
- "circle.inset.filled": IconCircleDot,
185
- "circle.dashed.inset.filled": IconCircleDot,
186
- "calendar.badge.clock": IconCalendarClock,
187
- clock: IconClock,
188
- timer: IconClock,
189
- "face.smiling": IconMoodPlus,
190
- tag: IconTag,
191
- ticket: IconTicket,
192
- cloud: IconCloud,
193
- cube: IconBox,
194
- "chevron.down": IconChevronDown,
195
- "chevron.left": IconChevronLeft,
196
- "chevron.left.forwardslash.chevron.right": IconCode,
197
- "chevron.right": IconChevronRight,
198
- "chevron.up": IconChevronUp,
199
- desktopcomputer: IconDeviceDesktop,
200
- doc: IconFileText,
201
- "doc.on.doc": IconCopy,
202
- "doc.text": IconFileText,
203
- "file.diff": IconFileDiff,
204
- ellipsis: IconDots,
205
- moon: IconMoon,
206
- "ellipsis.circle": IconDotsCircleHorizontal,
207
- "exclamationmark.triangle": IconAlertTriangle,
208
- "exclamationmark.circle": IconAlertCircle,
209
- eye: IconEye,
210
- "eye.slash": IconEyeOff,
211
- folder: IconFolder,
212
- "folder.badge.plus": IconFolderPlus,
213
- "folder.fill": IconFolder,
214
- gearshape: IconSettings,
215
- globe: IconWorld,
216
- hammer: IconHammer,
217
- headphones: IconHeadphones,
218
- house: IconHome,
219
- "info.circle": IconInfoCircle,
220
- internaldrive: IconDatabase,
221
- iphone: IconDeviceMobile,
222
- keyboard: IconKeyboard,
223
- laptopcomputer: IconDeviceLaptop,
224
- link: IconLink,
225
- "list.number": IconListNumbers,
226
- "line.3.horizontal": IconMenu2,
227
- "line.3.horizontal.decrease": IconFilter,
228
- "line.3.horizontal.decrease.circle": IconFilter,
229
- "line.3.horizontal.decrease.circle.fill": IconFilterFilled,
230
- macmini: IconServer,
231
- macstudio: IconDeviceDesktop,
232
- magnifyingglass: IconSearch,
233
- mic: IconMicrophone,
234
- paintbrush: IconPalette,
235
- pencil: IconPencil,
236
- "person.crop.circle": IconUserCircle,
237
- "person.2": IconUsers,
238
- "person.fill.checkmark": IconUserCheck,
239
- "person.fill.xmark": IconUserX,
240
- "person.badge.clock": IconUserQuestion,
241
- "person.badge.plus": IconUserPlus,
242
- photo: IconPhoto,
243
- pin: IconPin,
244
- "pin.slash": IconPinnedOff,
245
- play: IconPlayerPlay,
246
- pause: IconPlayerPause,
247
- plus: IconPlus,
248
- minus: IconMinus,
249
- "slash.circle": IconBan,
250
- "qrcode.viewfinder": IconQrcode,
251
- "point.3.connected.trianglepath.dotted": IconNetwork,
252
- flowchart: IconSitemap,
253
- "point.topleft.down.curvedto.point.bottomright.up": IconGitMerge,
254
- safari: IconExternalLink,
255
- "server.rack": IconServer,
256
- stethoscope: IconStethoscope,
257
- "sidebar.left": IconLayoutSidebar,
258
- "sidebar.right": IconLayoutSidebarRight,
259
- "slider.horizontal.3": IconAdjustmentsHorizontal,
260
- "square.and.arrow.up": IconShare,
261
- "square.and.pencil": IconEdit,
262
- "square.on.square": IconCopy,
263
- "square.grid.2x2": IconApps,
264
- "square.split.2x1": IconLayoutColumns,
265
- star: IconStar,
266
- "star.fill": IconStarFilled,
267
- "sun.max": IconSun,
268
- "stop.fill": IconPlayerStopFilled,
269
- target: IconTarget,
270
- terminal: IconTerminal2,
271
- "text.alignleft": IconAlignLeft,
272
- "text.bubble": IconMessage,
273
- "questionmark.bubble": IconMessageCircleQuestion,
274
- "exclamationmark.shield": IconShieldQuestion,
275
- "bubble.left.and.bubble.right": IconMessage,
276
- "bubble.left": IconMessage,
277
- sparkles: IconSparkles,
278
- "plus.bubble": IconMessagePlus,
279
- "text.word.spacing": IconLetterSpacing,
280
- "textformat.size": IconTypography,
281
- "textformat.size.larger": IconTextIncrease,
282
- "textformat.size.smaller": IconTextDecrease,
283
- "tray.and.arrow.down": IconDownload,
284
- "tray.and.arrow.up": IconUpload,
285
- trash: IconTrash,
286
- wifi: IconWifi,
287
- "wifi.slash": IconWifiOff,
288
- xmark: IconX,
289
- "xmark.circle.fill": IconCircleXFilled,
290
-} satisfies Partial<
291
- Record<
292
- SFSymbol | "git.pull-request.closed" | "git.pull-request.draft" | "git.commit" | "file.diff",
293
- Icon
294
- >
295
->;
296
-const SF_ICON_LOOKUP: Partial<
297
- Record<
298
- SFSymbol | "git.pull-request.closed" | "git.pull-request.draft" | "git.commit" | "file.diff",
299
- Icon
300
- >
301
-> = ANDROID_ICON_BY_SF_SYMBOL;
302
-
303
-const ANDROID_ICON_BY_MATERIAL_NAME = {
304
- auto_awesome: IconSparkles,
305
- bolt: IconBolt,
306
- build: IconTool,
307
- chat: IconMessage,
308
- chat_bubble: IconMessage,
309
- check: IconCheck,
310
- close: IconX,
311
- construction: IconHammer,
312
- content_copy: IconCopy,
313
- desktop_windows: IconDeviceDesktop,
314
- edit: IconEdit,
315
- error: IconAlertCircle,
316
- folder: IconFolder,
317
- folder_open: IconFolderOpen,
318
- keyboard: IconKeyboard,
319
- keyboard_arrow_down: IconChevronDown,
320
- keyboard_arrow_up: IconChevronUp,
321
- keyboard_hide: IconKeyboardHide,
322
- lock: IconLock,
323
- more_vert: IconDotsVertical,
324
- merge: IconGitMerge,
325
- psychology: IconBrain,
326
- public: IconWorld,
327
- remove: IconMinus,
328
- smartphone: IconDeviceMobile,
329
- terminal: IconTerminal2,
330
- visibility: IconEye,
331
-} satisfies Partial<Record<AndroidSymbol, Icon>>;
332
-
333
-export type { SFSymbol } from "expo-symbols";
334
-export type AppSymbolName =
335
- | keyof typeof ANDROID_ICON_BY_SF_SYMBOL
336
- | {
337
- ios: SFSymbol;
338
- android: keyof typeof ANDROID_ICON_BY_MATERIAL_NAME;
339
- };
340
-
341
-export type AppSymbolViewProps = Omit<SymbolViewProps, "name"> & { name: AppSymbolName };
342
-
343
-export function isAppSymbolName(name: string): name is Extract<AppSymbolName, string> {
344
- return Object.prototype.hasOwnProperty.call(ANDROID_ICON_BY_SF_SYMBOL, name);
345
-}
25
+};
26
27
function AppSymbolView(props: AppSymbolViewProps) {
348
- const materialName = typeof props.name === "string" ? undefined : props.name.android;
349
- const sfSymbol = typeof props.name === "string" ? props.name : props.name.ios;
350
- const AndroidIcon =
351
- (materialName ? ANDROID_ICON_BY_MATERIAL_NAME[materialName] : undefined) ??
352
- (sfSymbol ? SF_ICON_LOOKUP[sfSymbol] : undefined);
353
-
354
- if (!AndroidIcon) {
355
- return props.fallback ?? null;
28
+ const name = typeof props.name === "string" ? props.name : props.name.ios;
29
+ const CustomIcon = CUSTOM_ICONS[name as keyof typeof CUSTOM_ICONS];
30
+ if (CustomIcon) {
31
+ return (
32
+ <CustomIcon
33
+ accessibilityLabel={props.accessibilityLabel}
34
+ color={props.tintColor}
35
+ size={props.size}
36
+ strokeWidth={2}
37
+ style={props.style}
38
+ testID={props.testID}
39
+ />
40
+ );
41
}
42
358
- return (
359
- <AndroidIcon
360
- accessibilityLabel={props.accessibilityLabel}
361
- color={props.tintColor}
362
- size={props.size}
363
- strokeWidth={2}
364
- style={props.style}
365
- testID={props.testID}
366
- />
367
- );
43
+ return <ExpoSymbolView {...props} name={name as SFSymbol} />;
44
}
45
46
export const SymbolView = withUniwind(AppSymbolView);
apps/mobile/src/components/ui/FilePreviewGallery.tsx
renamed
+1
-1
@@ -1,6 +1,6 @@
1
import { createContext, useContext } from "react";
2
import type { FilePreviewItem, FilePreviewSource } from "./FilePreviewModal.types";
3
-import { filePreviewGallery } from "../lib/filePreviewGallery";
3
+import { filePreviewGallery } from "../../lib/filePreviewGallery";
4
5
export const FilePreviewGallery = createContext<readonly FilePreviewItem[]>([]);
6
apps/mobile/src/components/ui/FilePreviewModal.android.tsx
renamed
+74
-14
@@ -1,20 +1,29 @@
1
-import { Button } from "./ui/Button";
2
-import * as Dialog from "./ui/Dialog";
3
-import { useEffect, useEffectEvent } from "react";
1
+import { Button } from "./Button";
2
+import * as Dialog from "./Dialog";
3
+import { createContext, useContext, useEffect, useEffectEvent } from "react";
4
import { Modal, View } from "react-native";
5
import ImageViewing from "react-native-image-viewing";
6
import { useSafeAreaInsets } from "react-native-safe-area-context";
7
8
-import { openAttachmentInViewer } from "../lib/attachmentDownload";
9
-import { useMediaActions } from "../state/mediaActions";
8
+import { openAttachmentInViewer } from "../../lib/attachmentDownload";
9
+import { useMediaActions } from "../../state/mediaActions";
10
import type {
11
+ FilePreviewImages,
12
+ FilePreviewModalProps,
13
+ FilePreviewViewerProps,
14
ResolvedFilePreviewDocument,
15
+} from "./FilePreviewModal.types";
16
+import { FilePreviewSession } from "./FilePreviewSession";
17
+import { MediaPreviewHeader } from "../MediaPreviewHeader";
18
+
19
+export type {
20
+ FilePreviewItem,
21
+ FilePreviewSource,
22
ResolvedFilePreviewSource,
23
} from "./FilePreviewModal.types";
14
-import { imageViewingProps, MediaImagePreview } from "./MediaImagePreview";
15
-import { PdfPreview } from "./PdfPreview";
16
-import { SheetHeader } from "./ui/SheetHeader";
17
-import { AppText as Text } from "./ui/AppText";
24
+import { PdfPreview } from "../PdfPreview";
25
+import { SheetHeader } from "./SheetHeader";
26
+import { AppText as Text } from "./AppText";
27
28
function PdfDocumentPreview(props: {
29
readonly source: ResolvedFilePreviewDocument;
@@ -113,16 +122,62 @@ function DocumentPreview(props: {
122
);
123
}
124
116
-export function FilePreview(props: {
117
- readonly source: ResolvedFilePreviewSource;
125
+type ImagePreviewProps = {
126
+ readonly source: FilePreviewImages;
127
readonly onRequestClose: () => void;
119
- readonly onOpenError?: (error: unknown) => void;
120
-}) {
128
+};
129
+
130
+const ImagePreviewContext = createContext<ImagePreviewProps | null>(null);
131
+
132
+function ImagePreviewHeader(header: { readonly imageIndex: number }) {
133
+ const props = useContext(ImagePreviewContext)!;
134
+ const source = props.source.images[header.imageIndex];
135
+ const insets = useSafeAreaInsets();
136
+ const mediaActions = useMediaActions(source?.actionsSource, props.onRequestClose);
137
+ return (
138
+ <View className="bg-black/70" style={{ paddingTop: insets.top }}>
139
+ <MediaPreviewHeader
140
+ title={source?.name ?? "Image"}
141
+ media={mediaActions}
142
+ closeAccessibilityLabel="Close image"
143
+ onClose={props.onRequestClose}
144
+ />
145
+ </View>
146
+ );
147
+}
148
+
149
+// Images still resolving show the viewer's loading page, and remount by key once their URL arrives.
150
+function imageViewingProps(source: FilePreviewImages) {
151
+ return {
152
+ images: source.images.map((image) => (image.uri ? { uri: image.uri } : {})),
153
+ keyExtractor: (_: unknown, index: number) => source.images[index]?.uri ?? `pending:${index}`,
154
+ // Stays fixed: react-native-image-viewing remounts the Modal and replays its fade when it changes.
155
+ imageIndex: source.selectedIndex,
156
+ };
157
+}
158
+
159
+function ImagePreview(props: ImagePreviewProps) {
160
+ return (
161
+ <ImagePreviewContext value={props}>
162
+ <ImageViewing
163
+ {...imageViewingProps(props.source)}
164
+ visible
165
+ presentationStyle="fullScreen"
166
+ onRequestClose={props.onRequestClose}
167
+ swipeToCloseEnabled={false}
168
+ doubleTapToZoomEnabled
169
+ HeaderComponent={ImagePreviewHeader}
170
+ />
171
+ </ImagePreviewContext>
172
+ );
173
+}
174
+
175
+function AndroidFilePreview(props: FilePreviewViewerProps) {
176
const { source } = props;
177
if (source.kind === "pdf") return <PdfDocumentPreview {...props} source={source} />;
178
if (source.kind !== "image") return <DocumentPreview {...props} source={source} />;
179
if (source.images[source.selectedIndex]?.actionsSource)
125
- return <MediaImagePreview source={source} onRequestClose={props.onRequestClose} />;
180
+ return <ImagePreview source={source} onRequestClose={props.onRequestClose} />;
181
return (
182
<ImageViewing
183
{...imageViewingProps(source)}
@@ -133,3 +188,8 @@ export function FilePreview(props: {
188
/>
189
);
190
}
191
+
192
+/** Shows images, PDFs and documents full screen. */
193
+export function FilePreviewModal(props: FilePreviewModalProps) {
194
+ return <FilePreviewSession {...props} progressiveGallery={false} Viewer={AndroidFilePreview} />;
195
+}
apps/mobile/src/components/ui/FilePreviewModal.tsx
renamed
+17
-13
@@ -1,8 +1,19 @@
1
-import * as Dialog from "./ui/Dialog";
1
+import * as Dialog from "./Dialog";
2
import { requireNativeModule } from "expo";
3
import { useEffect, useEffectEvent, useId, useRef, useState } from "react";
4
5
-import type { FilePreviewImage, ResolvedFilePreviewSource } from "./FilePreviewModal.types";
5
+import type {
6
+ FilePreviewImage,
7
+ FilePreviewModalProps,
8
+ FilePreviewViewerProps,
9
+} from "./FilePreviewModal.types";
10
+import { FilePreviewSession } from "./FilePreviewSession";
11
+
12
+export type {
13
+ FilePreviewItem,
14
+ FilePreviewSource,
15
+ ResolvedFilePreviewSource,
16
+} from "./FilePreviewModal.types";
17
18
const NativeControls = requireNativeModule<{
19
presentFile(
@@ -25,11 +36,7 @@ const NativeControls = requireNativeModule<{
36
// Null tells the viewer an image failed; undefined means its URL has not arrived yet.
37
const nativeUri = (image: FilePreviewImage) => (image.failed ? null : image.uri);
38
28
-function NativeFilePreview(props: {
29
- readonly source: ResolvedFilePreviewSource;
30
- readonly onRequestClose: () => void;
31
- readonly onOpenError?: (error: unknown) => void;
32
-}) {
39
+function NativeFilePreview(props: FilePreviewViewerProps) {
40
const identifier = useId();
41
// Later URLs reach the open viewer through updateFile instead of presenting again.
42
const [presented] = useState(props.source);
@@ -91,10 +98,7 @@ function NativeFilePreview(props: {
98
return null;
99
}
100
94
-export function FilePreview(props: {
95
- readonly source: ResolvedFilePreviewSource;
96
- readonly onRequestClose: () => void;
97
- readonly onOpenError?: (error: unknown) => void;
98
-}) {
99
- return <NativeFilePreview {...props} />;
101
+/** Shows images, PDFs and documents full screen in the native viewer (Android: FilePreviewModal.android.tsx). */
102
+export function FilePreviewModal(props: FilePreviewModalProps) {
103
+ return <FilePreviewSession {...props} progressiveGallery Viewer={NativeFilePreview} />;
104
}
apps/mobile/src/components/ui/FilePreviewModal.types.ts
renamed
+15
-2
@@ -1,7 +1,7 @@
1
import type { AssetResource, EnvironmentId } from "@t3tools/contracts";
2
3
-import type { FileBackedComposerAttachment } from "../lib/composerImages";
4
-import type { MediaActionsSource } from "../lib/mediaActionsSource";
3
+import type { FileBackedComposerAttachment } from "../../lib/composerImages";
4
+import type { MediaActionsSource } from "../../lib/mediaActionsSource";
5
6
interface FilePreviewMetadata {
7
readonly kind: "image" | "pdf" | "document";
@@ -42,3 +42,16 @@ export interface FilePreviewImages {
42
}
43
44
export type ResolvedFilePreviewSource = ResolvedFilePreviewDocument | FilePreviewImages;
45
+
46
+export interface FilePreviewModalProps {
47
+ readonly source: FilePreviewSource | null;
48
+ readonly onRequestClose: () => void;
49
+ readonly onOpenError?: (error: unknown) => void;
50
+}
51
+
52
+/** A platform's viewer for one presentation, once FilePreviewSession has resolved it. */
53
+export interface FilePreviewViewerProps {
54
+ readonly source: ResolvedFilePreviewSource;
55
+ readonly onRequestClose: () => void;
56
+ readonly onOpenError?: (error: unknown) => void;
57
+}
apps/mobile/src/components/ui/FilePreviewSession.test.tsx
new
+146
@@ -0,0 +1,146 @@
1
+import { act, useState } from "react";
2
+import { createRoot } from "react-dom/client";
3
+import { expect, it, vi } from "vite-plus/test";
4
+import { EnvironmentId, SOURCE_CONTROL_MEDIA_ASSET } from "@t3tools/contracts";
5
+
6
+const harness = vi.hoisted(() => ({
7
+ refreshAssetUrl: vi.fn<(environmentId: string, resource: { url: string }) => Promise<string>>(),
8
+ alert: vi.fn(),
9
+ previews: [] as unknown[],
10
+ mounts: 0,
11
+}));
12
+
13
+vi.mock("../../state/assets", () => ({ refreshAssetUrl: harness.refreshAssetUrl }));
14
+vi.mock("../../lib/localAttachmentPreview", () => ({ loadLocalAttachmentPreview: vi.fn() }));
15
+vi.mock("../../lib/attachmentDownload", () => ({
16
+ downloadAndShareAttachment: vi.fn(),
17
+ nativeViewerErrorMessage: () => "",
18
+ shareLocalAttachment: vi.fn(),
19
+}));
20
+vi.mock("../../lib/previewPresentation", () => ({ usePreviewPresentation: () => {} }));
21
+vi.mock("./Dialog", () => ({ alert: harness.alert }));
22
+
23
+import type { FilePreviewItem, FilePreviewViewerProps } from "./FilePreviewModal.types";
24
+import { FilePreviewSession } from "./FilePreviewSession";
25
+
26
+function Viewer(props: FilePreviewViewerProps) {
27
+ useState(() => harness.mounts++);
28
+ harness.previews.push(props.source);
29
+ return null;
30
+}
31
+
32
+const environmentId = EnvironmentId.make("environment");
33
+const image = (url: string): FilePreviewItem => ({
34
+ kind: "image",
35
+ environmentId,
36
+ resource: { _tag: SOURCE_CONTROL_MEDIA_ASSET, cwd: "/repo", url },
37
+});
38
+
39
+async function openGallery(
40
+ selected: FilePreviewItem,
41
+ gallery: readonly FilePreviewItem[],
42
+ progressiveGallery: boolean,
43
+) {
44
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
45
+ harness.previews.length = 0;
46
+ harness.mounts = 0;
47
+ harness.alert.mockClear();
48
+ const root = createRoot(document.createElement("div"));
49
+ const onRequestClose = vi.fn();
50
+ await act(async () =>
51
+ root.render(
52
+ <FilePreviewSession
53
+ source={{ ...selected, gallery }}
54
+ onRequestClose={onRequestClose}
55
+ progressiveGallery={progressiveGallery}
56
+ Viewer={Viewer}
57
+ />,
58
+ ),
59
+ );
60
+ return { onRequestClose, [Symbol.asyncDispose]: () => act(async () => root.unmount()) };
61
+}
62
+
63
+it.each([true, false])(
64
+ "keeps the gallery stable while a sibling is still resolving (progressive: %s)",
65
+ async (progressiveGallery) => {
66
+ const slow = Promise.withResolvers<string>();
67
+ harness.refreshAssetUrl.mockImplementation(async (_environmentId, resource) =>
68
+ resource.url.endsWith("slow.png") ? slow.promise : "https://signed.test/a.png",
69
+ );
70
+ const selected = image("https://github.com/a.png");
71
+ await using _preview = await openGallery(
72
+ selected,
73
+ [image("https://github.com/slow.png"), selected],
74
+ progressiveGallery,
75
+ );
76
+
77
+ if (progressiveGallery) {
78
+ expect(harness.previews.at(-1)).toMatchObject({
79
+ kind: "image",
80
+ selectedIndex: 1,
81
+ images: [
82
+ expect.not.objectContaining({ uri: expect.anything() }),
83
+ { uri: "https://signed.test/a.png" },
84
+ ],
85
+ });
86
+ } else {
87
+ expect(harness.previews).toEqual([]);
88
+ }
89
+ await act(async () => slow.resolve("https://signed.test/slow.png"));
90
+ expect(harness.previews.at(-1)).toMatchObject({
91
+ selectedIndex: 1,
92
+ images: [{ uri: "https://signed.test/slow.png" }, { uri: "https://signed.test/a.png" }],
93
+ });
94
+ expect(harness.mounts).toBe(1);
95
+ },
96
+);
97
+
98
+it.each([true, false])(
99
+ "handles a failed sibling without leaving a pending page (progressive: %s)",
100
+ async (progressiveGallery) => {
101
+ harness.refreshAssetUrl.mockImplementation(async (_environmentId, resource) => {
102
+ if (resource.url.endsWith("missing.png")) throw new Error("not found");
103
+ return `https://signed.test/${resource.url.split("/").pop()}`;
104
+ });
105
+ const selected = image("https://github.com/a.png");
106
+ await using preview = await openGallery(
107
+ selected,
108
+ [selected, image("https://github.com/missing.png"), image("https://github.com/c.png")],
109
+ progressiveGallery,
110
+ );
111
+
112
+ if (!progressiveGallery) {
113
+ expect(preview.onRequestClose).toHaveBeenCalledOnce();
114
+ expect(harness.alert).toHaveBeenCalledOnce();
115
+ expect(harness.previews).toEqual([]);
116
+ return;
117
+ }
118
+
119
+ expect(preview.onRequestClose).not.toHaveBeenCalled();
120
+ expect(harness.alert).not.toHaveBeenCalled();
121
+ expect(harness.previews.at(-1)).toMatchObject({
122
+ selectedIndex: 0,
123
+ images: [
124
+ { uri: "https://signed.test/a.png" },
125
+ { failed: true },
126
+ { uri: "https://signed.test/c.png" },
127
+ ],
128
+ });
129
+ },
130
+);
131
+
132
+it("closes the preview when the selected image cannot be resolved", async () => {
133
+ harness.refreshAssetUrl.mockImplementation(async (_environmentId, resource) => {
134
+ if (resource.url.endsWith("missing.png")) throw new Error("not found");
135
+ return `https://signed.test/${resource.url.split("/").pop()}`;
136
+ });
137
+ const selected = image("https://github.com/missing.png");
138
+ await using preview = await openGallery(
139
+ selected,
140
+ [image("https://github.com/a.png"), selected],
141
+ true,
142
+ );
143
+
144
+ expect(preview.onRequestClose).toHaveBeenCalledOnce();
145
+ expect(harness.alert).toHaveBeenCalledOnce();
146
+});
apps/mobile/src/components/ui/FilePreviewSession.tsx
renamed
+35
-29
@@ -1,28 +1,31 @@
1
import * as Schema from "effect/Schema";
2
-import * as Dialog from "./ui/Dialog";
3
-import { useContext, useEffect, useEffectEvent, useState } from "react";
4
-import { Platform } from "react-native";
2
+import * as Dialog from "./Dialog";
3
+import { useContext, useEffect, useEffectEvent, useState, type ComponentType } from "react";
4
6
-import { loadLocalAttachmentPreview } from "../lib/localAttachmentPreview";
5
+import { loadLocalAttachmentPreview } from "../../lib/localAttachmentPreview";
6
import {
7
downloadAndShareAttachment,
8
nativeViewerErrorMessage,
9
shareLocalAttachment,
11
-} from "../lib/attachmentDownload";
12
-import { usePreviewPresentation } from "../lib/previewPresentation";
13
-import { refreshAssetUrl } from "../state/assets";
14
-import { filePreviewGallery, filePreviewKey, filePreviewName } from "../lib/filePreviewGallery";
10
+} from "../../lib/attachmentDownload";
11
+import { usePreviewPresentation } from "../../lib/previewPresentation";
12
+import { refreshAssetUrl } from "../../state/assets";
13
+import { filePreviewGallery, filePreviewKey, filePreviewName } from "../../lib/filePreviewGallery";
14
import { FilePreviewGallery } from "./FilePreviewGallery";
16
-import { FilePreview } from "./FilePreview";
17
-import type { MediaActionsSource } from "../lib/mediaActionsSource";
18
-import type { FilePreviewItem, FilePreviewSource } from "./FilePreviewModal.types";
19
-
20
-export type {
15
+import type { MediaActionsSource } from "../../lib/mediaActionsSource";
16
+import type {
17
FilePreviewItem,
18
+ FilePreviewModalProps,
19
FilePreviewSource,
23
- ResolvedFilePreviewSource,
20
+ FilePreviewViewerProps,
21
} from "./FilePreviewModal.types";
22
23
+interface FilePreviewSessionOptions {
24
+ /** Opens before every image resolves; the viewer takes later URLs as they arrive. */
25
+ readonly progressiveGallery: boolean;
26
+ readonly Viewer: ComponentType<FilePreviewViewerProps>;
27
+}
28
+
29
class PreviewResolutionError extends Schema.TaggedError<PreviewResolutionError>()(
30
"PreviewResolutionError",
31
{ cause: Schema.Defect(), fallbackMessage: Schema.String },
@@ -80,16 +83,18 @@ function pdfActionsSource(item: FilePreviewItem): MediaActionsSource {
83
return { ...metadata, environmentId: item.environmentId, resource: item.resource };
84
}
85
83
-function ResolvedFilePreview(props: {
84
- readonly source: FilePreviewSource;
85
- readonly onRequestClose: () => void;
86
- readonly onOpenError?: (error: unknown) => void;
87
-}) {
86
+function ResolvedFilePreview(
87
+ props: FilePreviewSessionOptions & {
88
+ readonly source: FilePreviewSource;
89
+ readonly onRequestClose: () => void;
90
+ readonly onOpenError?: (error: unknown) => void;
91
+ },
92
+) {
93
+ const { progressiveGallery, Viewer } = props;
94
// Freeze the group at opening; streaming messages and URL refreshes must not reopen the viewer.
95
const [items] = useState(() => filePreviewGallery(props.source, []));
96
const selectedKey = filePreviewKey(props.source);
97
const selectedIndex = items.findIndex((item) => filePreviewKey(item) === selectedKey);
92
- const progressiveGallery = Platform.OS === "ios";
98
// Undefined while resolving, null once it cannot be.
99
const [uris, setUris] = useState<readonly (string | null | undefined)[]>(() =>
100
items.map((item) => ("uri" in item ? item.uri : undefined)),
@@ -133,7 +138,7 @@ function ResolvedFilePreview(props: {
138
}, [items, selectedIndex, progressiveGallery]);
139
const selected = { ...items[selectedIndex]!, name: filePreviewName(items[selectedIndex]!) };
140
if (selected.kind === "image") {
136
- // Android's viewer resets image gestures when its sources change during a presentation.
141
+ // A viewer that resets image gestures when its sources change waits for every image.
142
if (!progressiveGallery && uris.some((uri) => uri === undefined)) return null;
143
const images = items.map((item, index) => {
144
const uri = uris[index];
@@ -144,7 +149,7 @@ function ResolvedFilePreview(props: {
149
};
150
});
151
return (
147
- <FilePreview
152
+ <Viewer
153
source={{ kind: "image", images, selectedIndex }}
154
onRequestClose={props.onRequestClose}
155
{...(props.onOpenError ? { onOpenError: props.onOpenError } : {})}
@@ -182,7 +187,7 @@ function ResolvedFilePreview(props: {
187
const actionsSource =
188
selected.kind === "pdf" ? (selected.actionsSource ?? pdfActionsSource(selected)) : undefined;
189
return (
185
- <FilePreview
190
+ <Viewer
191
source={{
192
...selected,
193
kind: selected.kind,
@@ -195,12 +200,11 @@ function ResolvedFilePreview(props: {
200
);
201
}
202
198
-export function FilePreviewModal(props: {
199
- readonly source: FilePreviewSource | null;
200
- readonly onRequestClose: () => void;
201
-
202
- readonly onOpenError?: (error: unknown) => void;
203
-}) {
203
+/**
204
+ * The part of FilePreviewModal both platforms share: it resolves sources, freezes the gallery
205
+ * at opening and closes with its screen. Each platform's FilePreviewModal passes its viewer.
206
+ */
207
+export function FilePreviewSession(props: FilePreviewModalProps & FilePreviewSessionOptions) {
208
const group = useContext(FilePreviewGallery);
209
const source =
210
props.source === null
@@ -214,6 +218,8 @@ export function FilePreviewModal(props: {
218
key={filePreviewKey(source)}
219
source={source}
220
onRequestClose={props.onRequestClose}
221
+ progressiveGallery={props.progressiveGallery}
222
+ Viewer={props.Viewer}
223
{...(props.onOpenError ? { onOpenError: props.onOpenError } : {})}
224
/>
225
);
apps/mobile/src/components/ui/FrostedCutout.android.tsx
new
+38
@@ -0,0 +1,38 @@
1
+import { useState } from "react";
2
+import { StyleSheet, View } from "react-native";
3
+import Svg, { Path } from "react-native-svg";
4
+
5
+import type { FrostedCutoutProps } from "./FrostedCutout.types";
6
+
7
+export function FrostedCutout(props: FrostedCutoutProps) {
8
+ const [width, setWidth] = useState(0);
9
+ const [height, setHeight] = useState(0);
10
+ const x = (width - props.cutoutWidth) / 2;
11
+ const y = props.cutoutTop;
12
+ const w = props.cutoutWidth;
13
+ const h = props.cutoutHeight;
14
+ const r = Math.min(props.cutoutRadius, w / 2, h / 2);
15
+ const hole = `M${x + r},${y} H${x + w - r} A${r},${r} 0 0 1 ${x + w},${y + r} V${y + h - r} A${r},${r} 0 0 1 ${x + w - r},${y + h} H${x + r} A${r},${r} 0 0 1 ${x},${y + h - r} V${y + r} A${r},${r} 0 0 1 ${x + r},${y} Z`;
16
+
17
+ return (
18
+ <View
19
+ pointerEvents="none"
20
+ style={StyleSheet.absoluteFill}
21
+ onLayout={(event) => {
22
+ setWidth(event.nativeEvent.layout.width);
23
+ setHeight(event.nativeEvent.layout.height);
24
+ }}
25
+ >
26
+ {width > 0 ? (
27
+ <Svg height={height} width={width}>
28
+ <Path
29
+ d={`M0,0 H${width} V${height} H0 Z ${hole}`}
30
+ fill={props.appearance === "light" ? "#ffffff" : "#000000"}
31
+ fillOpacity={0.55}
32
+ fillRule="evenodd"
33
+ />
34
+ </Svg>
35
+ ) : null}
36
+ </View>
37
+ );
38
+}
apps/mobile/src/components/ui/FrostedCutout.ios.tsx
deleted
-13
@@ -1,13 +0,0 @@
1
-import { requireNativeView } from "expo";
2
-import { StyleSheet, type ViewProps } from "react-native";
3
-
4
-import type { FrostedCutoutProps } from "./FrostedCutout.types";
5
-
6
-const NativeFrostedCutout = requireNativeView<ViewProps & FrostedCutoutProps>(
7
- "T3NativeControls",
8
- "FrostedCutout",
9
-);
10
-
11
-export function FrostedCutout(props: FrostedCutoutProps) {
12
- return <NativeFrostedCutout {...props} pointerEvents="none" style={StyleSheet.absoluteFill} />;
13
-}
apps/mobile/src/components/ui/FrostedCutout.tsx
+8
-33
@@ -1,38 +1,13 @@
1
-import { useState } from "react";
2
-import { StyleSheet, View } from "react-native";
3
-import Svg, { Path } from "react-native-svg";
1
+import { requireNativeView } from "expo";
2
+import { StyleSheet, type ViewProps } from "react-native";
3
4
import type { FrostedCutoutProps } from "./FrostedCutout.types";
5
7
-export function FrostedCutout(props: FrostedCutoutProps) {
8
- const [width, setWidth] = useState(0);
9
- const [height, setHeight] = useState(0);
10
- const x = (width - props.cutoutWidth) / 2;
11
- const y = props.cutoutTop;
12
- const w = props.cutoutWidth;
13
- const h = props.cutoutHeight;
14
- const r = Math.min(props.cutoutRadius, w / 2, h / 2);
15
- const hole = `M${x + r},${y} H${x + w - r} A${r},${r} 0 0 1 ${x + w},${y + r} V${y + h - r} A${r},${r} 0 0 1 ${x + w - r},${y + h} H${x + r} A${r},${r} 0 0 1 ${x},${y + h - r} V${y + r} A${r},${r} 0 0 1 ${x + r},${y} Z`;
6
+const NativeFrostedCutout = requireNativeView<ViewProps & FrostedCutoutProps>(
7
+ "T3NativeControls",
8
+ "FrostedCutout",
9
+);
10
17
- return (
18
- <View
19
- pointerEvents="none"
20
- style={StyleSheet.absoluteFill}
21
- onLayout={(event) => {
22
- setWidth(event.nativeEvent.layout.width);
23
- setHeight(event.nativeEvent.layout.height);
24
- }}
25
- >
26
- {width > 0 ? (
27
- <Svg height={height} width={width}>
28
- <Path
29
- d={`M0,0 H${width} V${height} H0 Z ${hole}`}
30
- fill={props.appearance === "light" ? "#ffffff" : "#000000"}
31
- fillOpacity={0.55}
32
- fillRule="evenodd"
33
- />
34
- </Svg>
35
- ) : null}
36
- </View>
37
- );
11
+export function FrostedCutout(props: FrostedCutoutProps) {
12
+ return <NativeFrostedCutout {...props} pointerEvents="none" style={StyleSheet.absoluteFill} />;
13
}
apps/mobile/src/components/ui/Menu.android.tsx
+1
-1
@@ -1,6 +1,6 @@
1
import * as Haptics from "expo-haptics";
2
import { cloneElement, isValidElement, type ReactElement } from "react";
3
-import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
3
+import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu.android";
4
import type { MenuProps } from "./Menu.types";
5
6
export function Menu(props: MenuProps) {
apps/mobile/src/components/ui/MenuPopup.android.tsx
+1
-1
@@ -15,7 +15,7 @@ import { resolveScaledTextRole } from "../../lib/appearancePreferences";
15
import { useAndroidControlSizing } from "./useAndroidControlSizing";
16
import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";
17
import type { MenuPopupProps } from "./MenuPopup";
18
-import { isAppSymbolName, SymbolView, type AppSymbolName } from "./AppSymbol";
18
+import { isAppSymbolName, SymbolView, type AppSymbolName } from "./AppSymbol.android";
19
20
// The Compose glyph host consumes touches; run the action here and keep accessibility on the row.
21
function MenuIcon(props: {
apps/mobile/src/components/ui/NativePresentation.android.tsx
new
+7
@@ -0,0 +1,7 @@
1
+import { View } from "react-native";
2
+
3
+import type { PresentationSourceProps } from "./NativePresentation";
4
+
5
+export function PresentationSource({ identifier: _identifier, ...props }: PresentationSourceProps) {
6
+ return <View {...props} />;
7
+}
apps/mobile/src/components/ui/NativePresentation.ios.tsx
deleted
-12
@@ -1,12 +0,0 @@
1
-import { requireNativeView } from "expo";
2
-import type { ComponentType } from "react";
3
-import type { PresentationSourceProps } from "./NativePresentation";
4
-
5
-const NativeSource: ComponentType<PresentationSourceProps> = requireNativeView(
6
- "T3NativeControls",
7
- "PresentationSource",
8
-);
9
-
10
-export function PresentationSource(props: PresentationSourceProps) {
11
- return <NativeSource {...props} collapsableChildren={false} />;
12
-}
apps/mobile/src/components/ui/NativePresentation.tsx
+10
-4
@@ -1,11 +1,17 @@
1
-import type { ReactElement } from "react";
2
-import { View, type ViewProps } from "react-native";
1
+import { requireNativeView } from "expo";
2
+import type { ComponentType, ReactElement } from "react";
3
+import type { ViewProps } from "react-native";
4
5
export interface PresentationSourceProps extends ViewProps {
6
readonly children: ReactElement;
7
readonly identifier: string;
8
}
9
9
-export function PresentationSource({ identifier: _identifier, ...props }: PresentationSourceProps) {
10
- return <View {...props} />;
10
+const NativeSource: ComponentType<PresentationSourceProps> = requireNativeView(
11
+ "T3NativeControls",
12
+ "PresentationSource",
13
+);
14
+
15
+export function PresentationSource(props: PresentationSourceProps) {
16
+ return <NativeSource {...props} collapsableChildren={false} />;
17
}
apps/mobile/src/components/ui/ScreenHeaderButton.android.tsx
+1
-1
@@ -1 +1 @@
1
-export { AndroidHeaderIconButton as ScreenHeaderButton } from "./AndroidScreenHeader";
1
+export { AndroidHeaderIconButton as ScreenHeaderButton } from "./AndroidScreenHeader.android";
apps/mobile/src/components/ui/SegmentedControl.android.tsx
new
+1
@@ -0,0 +1 @@
1
+export { SegmentedControl, type SegmentedControlProps } from "./SegmentedControl.shared";
apps/mobile/src/components/ui/SegmentedControl.ios.tsx
deleted
-55
@@ -1,55 +0,0 @@
1
-import { requireNativeView } from "expo";
2
-import { View, type NativeSyntheticEvent, type ViewProps } from "react-native";
3
-
4
-import { SegmentedControl as FlatSegmentedControl } from "./SegmentedControl.shared";
5
-import { segmentedControlColors } from "./segmentedControlColors";
6
-import { useControlTheme } from "./useControlTheme";
7
-import type { SegmentedControlProps } from "./SegmentedControl.types";
8
-
9
-export type { SegmentedControlProps } from "./SegmentedControl.types";
10
-
11
-const NativeSegmentedControl = requireNativeView<
12
- ViewProps & {
13
- labels: string[];
14
- selectedIndex: number;
15
- trackColor: string;
16
- selectedColor: string;
17
- textColor: string;
18
- mutedColor: string;
19
- appearance: string;
20
- onSelectionChange: (event: NativeSyntheticEvent<{ index: number }>) => void;
21
- }
22
->("T3NativeControls", "SegmentedControl");
23
-
24
-export function SegmentedControl<Value extends string | number>(
25
- props: SegmentedControlProps<Value>,
26
-) {
27
- const { colors, colorScheme, themeId } = useControlTheme();
28
- // UIKit adds a gray fill over the sunken card track.
29
- if (props.variant === "card") return <FlatSegmentedControl {...props} />;
30
- const { trackColor, selectedColor, selectedTextColor, mutedColor } = segmentedControlColors(
31
- colors,
32
- colorScheme,
33
- props.variant,
34
- "ios",
35
- themeId,
36
- );
37
- return (
38
- <View className={props.className}>
39
- <NativeSegmentedControl
40
- labels={props.options.map((option) => option.label)}
41
- selectedIndex={props.options.findIndex((option) => option.value === props.selected)}
42
- trackColor={trackColor}
43
- selectedColor={selectedColor}
44
- textColor={selectedTextColor}
45
- mutedColor={mutedColor}
46
- appearance={colorScheme}
47
- onSelectionChange={({ nativeEvent }) => {
48
- const option = props.options[nativeEvent.index];
49
- if (option) props.onSelect(option.value);
50
- }}
51
- style={{ height: props.size === "compact" ? 32 : 36 }}
52
- />
53
- </View>
54
- );
55
-}
apps/mobile/src/components/ui/SegmentedControl.tsx
+55
-1
@@ -1 +1,55 @@
1
-export { SegmentedControl, type SegmentedControlProps } from "./SegmentedControl.shared";
1
+import { requireNativeView } from "expo";
2
+import { View, type NativeSyntheticEvent, type ViewProps } from "react-native";
3
+
4
+import { SegmentedControl as FlatSegmentedControl } from "./SegmentedControl.shared";
5
+import { segmentedControlColors } from "./segmentedControlColors";
6
+import { useControlTheme } from "./useControlTheme";
7
+import type { SegmentedControlProps } from "./SegmentedControl.types";
8
+
9
+export type { SegmentedControlProps } from "./SegmentedControl.types";
10
+
11
+const NativeSegmentedControl = requireNativeView<
12
+ ViewProps & {
13
+ labels: string[];
14
+ selectedIndex: number;
15
+ trackColor: string;
16
+ selectedColor: string;
17
+ textColor: string;
18
+ mutedColor: string;
19
+ appearance: string;
20
+ onSelectionChange: (event: NativeSyntheticEvent<{ index: number }>) => void;
21
+ }
22
+>("T3NativeControls", "SegmentedControl");
23
+
24
+export function SegmentedControl<Value extends string | number>(
25
+ props: SegmentedControlProps<Value>,
26
+) {
27
+ const { colors, colorScheme, themeId } = useControlTheme();
28
+ // UIKit adds a gray fill over the sunken card track.
29
+ if (props.variant === "card") return <FlatSegmentedControl {...props} />;
30
+ const { trackColor, selectedColor, selectedTextColor, mutedColor } = segmentedControlColors(
31
+ colors,
32
+ colorScheme,
33
+ props.variant,
34
+ "ios",
35
+ themeId,
36
+ );
37
+ return (
38
+ <View className={props.className}>
39
+ <NativeSegmentedControl
40
+ labels={props.options.map((option) => option.label)}
41
+ selectedIndex={props.options.findIndex((option) => option.value === props.selected)}
42
+ trackColor={trackColor}
43
+ selectedColor={selectedColor}
44
+ textColor={selectedTextColor}
45
+ mutedColor={mutedColor}
46
+ appearance={colorScheme}
47
+ onSelectionChange={({ nativeEvent }) => {
48
+ const option = props.options[nativeEvent.index];
49
+ if (option) props.onSelect(option.value);
50
+ }}
51
+ style={{ height: props.size === "compact" ? 32 : 36 }}
52
+ />
53
+ </View>
54
+ );
55
+}
apps/mobile/src/components/ui/VideoPreviewModal.android.tsx
renamed
+12
-12
@@ -2,25 +2,25 @@ import { videoMimeType } from "@t3tools/shared/video";
2
import { Modal, Pressable, View } from "react-native";
3
import { useSafeAreaInsets } from "react-native-safe-area-context";
4
5
-import { AppActivityIndicator } from "./ui/AppActivityIndicator";
6
-import { useLocalAttachmentPreview } from "../lib/localAttachmentPreview";
7
-import { usePreviewPresentation, videoPreviewKey } from "../lib/previewPresentation";
8
-import { useMediaActions } from "../state/mediaActions";
9
-import { type MediaActionsSource } from "../lib/mediaActionsSource";
5
+import { AppActivityIndicator } from "./AppActivityIndicator";
6
+import { useLocalAttachmentPreview } from "../../lib/localAttachmentPreview";
7
+import { usePreviewPresentation, videoPreviewKey } from "../../lib/previewPresentation";
8
+import { useMediaActions } from "../../state/mediaActions";
9
+import { type MediaActionsSource } from "../../lib/mediaActionsSource";
10
import {
11
mediaVideoPreviewUri,
12
mediaVideoThumbnailKey,
13
type LocalVideoPreviewSource,
14
type MediaVideoPreviewSource,
15
type VideoPreviewSource,
16
-} from "../lib/videoPreviewSource";
17
-import { useAssetUrlState, useRefreshAssetUrl } from "../state/assets";
18
-import { usePreparedConnection } from "../state/session";
19
-import { AppText } from "./ui/AppText";
20
-import { MediaPreviewHeader } from "./MediaPreviewHeader";
21
-import { MediaVideoPlayer } from "./MediaVideoPlayer";
16
+} from "../../lib/videoPreviewSource";
17
+import { useAssetUrlState, useRefreshAssetUrl } from "../../state/assets";
18
+import { usePreparedConnection } from "../../state/session";
19
+import { AppText } from "./AppText";
20
+import { MediaPreviewHeader } from "../MediaPreviewHeader";
21
+import { MediaVideoPlayer } from "../MediaVideoPlayer";
22
23
-export type { VideoPreviewSource } from "../lib/videoPreviewSource";
23
+export type { VideoPreviewSource } from "../../lib/videoPreviewSource";
24
25
interface PlaybackState {
26
readonly uri: string | null;
apps/mobile/src/components/ui/VideoPreviewModal.tsx
renamed
+9
-9
@@ -1,23 +1,23 @@
1
-import * as Dialog from "./ui/Dialog";
1
+import * as Dialog from "./Dialog";
2
import { requireNativeModule } from "expo";
3
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
4
import { AsyncResult } from "effect/reactivity";
5
import { useEffect, useEffectEvent, useId } from "react";
6
7
-import { loadLocalAttachmentPreview } from "../lib/localAttachmentPreview";
8
-import { usePreviewPresentation, videoPreviewKey } from "../lib/previewPresentation";
9
-import { fullscreenVideoClosed, fullscreenVideoOpened } from "../lib/videoAudioSession";
10
-import { mediaVideoPreviewUri, type VideoPreviewSource } from "../lib/videoPreviewSource";
11
-import { refreshAssetUrl } from "../state/assets";
12
-import { usePreparedConnection } from "../state/session";
7
+import { loadLocalAttachmentPreview } from "../../lib/localAttachmentPreview";
8
+import { usePreviewPresentation, videoPreviewKey } from "../../lib/previewPresentation";
9
+import { fullscreenVideoClosed, fullscreenVideoOpened } from "../../lib/videoAudioSession";
10
+import { mediaVideoPreviewUri, type VideoPreviewSource } from "../../lib/videoPreviewSource";
11
+import { refreshAssetUrl } from "../../state/assets";
12
+import { usePreparedConnection } from "../../state/session";
13
import {
14
acquireAudioSession,
15
activateAudioSession,
16
isAudioSessionOwner,
17
releaseAudioSession,
18
-} from "../lib/audioSession";
18
+} from "../../lib/audioSession";
19
20
-export type { VideoPreviewSource } from "../lib/videoPreviewSource";
20
+export type { VideoPreviewSource } from "../../lib/videoPreviewSource";
21
22
const NativeControls = requireNativeModule<{
23
presentVideo(
apps/mobile/src/components/ui/WorkspaceAppBar.android.tsx
+2
-2
@@ -11,8 +11,8 @@ import {
11
} from "react";
12
import { Pressable, View } from "react-native";
13
14
-import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
15
-import { AndroidHeaderIconButton } from "./AndroidScreenHeader";
14
+import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu.android";
15
+import { AndroidHeaderIconButton } from "./AndroidScreenHeader.android";
16
import { AppText } from "./AppText";
17
import { NativeAppBar } from "./NativeAppBar.android";
18
import { useControlTheme } from "./useControlTheme";
apps/mobile/src/features/files/AttachmentFileScreen.tsx
+1
-1
@@ -9,7 +9,7 @@ import { useRef, useState } from "react";
9
import { View } from "react-native";
10
11
import { AppBar, type AppBarMenu } from "../../components/ui/AppBar";
12
-import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
12
+import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
13
import { useAttachmentDocument } from "../../lib/attachmentDocument";
14
import { nativeViewerErrorMessage } from "../../lib/attachmentDownload";
15
import { isFileBackedComposerAttachment } from "../../lib/composerImages";
apps/mobile/src/features/files/FileMarkdownPreview.tsx
+2
-2
@@ -23,8 +23,8 @@ import {
23
resolveMarkdownLinkPresentation,
24
} from "../../lib/markdownLinks";
25
import { AppText as Text } from "../../components/ui/AppText";
26
-import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
27
-import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
26
+import { VideoPreviewModal, type VideoPreviewSource } from "../../components/ui/VideoPreviewModal";
27
+import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
28
import { useMarkdownImageSource } from "../../native/useMarkdownImageSource";
29
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
30
import {
apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
+1
-1
@@ -20,7 +20,7 @@ import { filePreviewDelimiter, parseDelimitedPreview } from "@t3tools/shared/del
20
import { DelimitedFilePreview } from "./DelimitedFilePreview";
21
import { AudioFilePreview } from "./AudioFilePreview";
22
import { EmptyState } from "../../components/ui/EmptyState";
23
-import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
23
+import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
24
import { LoadingScreen } from "../../components/LoadingScreen";
25
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
26
import { isPdfFile } from "../../lib/filePreview";
apps/mobile/src/features/files/WorkspaceFileImagePreview.tsx
+1
-1
@@ -3,7 +3,7 @@ import { Image, Pressable, View } from "react-native";
3
4
import { FilePreviewLoading } from "./FilePreviewFeedback";
5
import { EmptyState } from "../../components/ui/EmptyState";
6
-import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
6
+import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
7
import { PresentationSource } from "../../components/ui/NativePresentation";
8
import { useMediaActions } from "../../state/mediaActions";
9
import { type MediaActionsSource } from "../../lib/mediaActionsSource";
apps/mobile/src/features/files/ZipArchiveView.test.tsx
+1
-1
@@ -131,7 +131,7 @@ vi.mock("../../components/ui/useBarInset", () => ({ useContentTopInset: () => 0
131
vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
132
vi.mock("../../components/ui/Progress", () => ({ Progress: () => null }));
133
vi.mock("../../components/PierreEntryIcon", () => ({ PierreEntryIcon: () => null }));
134
-vi.mock("../../components/FilePreviewModal", () => ({ FilePreviewModal: () => null }));
134
+vi.mock("../../components/ui/FilePreviewModal", () => ({ FilePreviewModal: () => null }));
135
vi.mock("../../lib/copyTextWithHaptic", () => ({}));
136
vi.mock("./SourceFileSurface", () => ({
137
SourceFileSurface: (props: { readonly contents: string }) => <pre>{props.contents}</pre>,
apps/mobile/src/features/files/ZipArchiveView.tsx
+1
-1
@@ -29,7 +29,7 @@ import { EmptyState } from "../../components/ui/EmptyState";
29
import { Progress } from "../../components/ui/Progress";
30
import { NativeScrollView } from "../../native/NativeScrollViewMarker";
31
import * as Dialog from "../../components/ui/Dialog";
32
-import { FilePreviewModal } from "../../components/FilePreviewModal";
32
+import { FilePreviewModal } from "../../components/ui/FilePreviewModal";
33
import {
34
nativeViewerErrorMessage,
35
shareGeneratedAttachment,
apps/mobile/src/features/pull-requests/PullRequestDescription.tsx
+1
-1
@@ -13,7 +13,7 @@ import { parseMarkdownDocument } from "../../lib/markdownDocument";
13
import { SymbolView } from "../../components/ui/AppSymbol";
14
import { AppText as Text } from "../../components/ui/AppText";
15
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
16
-import type { FilePreviewItem } from "../../components/FilePreviewModal";
16
+import type { FilePreviewItem } from "../../components/ui/FilePreviewModal";
17
import { isBotBadgeImage } from "./botBadgeImages";
18
import { PullRequestMarkdown } from "./PullRequestMarkdown";
19
import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent";
apps/mobile/src/features/pull-requests/PullRequestMarkdown.tsx
+2
-2
@@ -28,13 +28,13 @@ import { useOpenPullRequest } from "../../native/useOpenPullRequest";
28
import { SelectableMarkdownText } from "../../native/SelectableMarkdownText";
29
import { useMarkdownPreviewStyles } from "../files/FileMarkdownPreview";
30
import { markdownImageSources } from "../../lib/markdownImageSources";
31
-import { FilePreviewGallery, useFilePreviewGallery } from "../../components/FilePreviewGallery";
31
+import { FilePreviewGallery, useFilePreviewGallery } from "../../components/ui/FilePreviewGallery";
32
import { pullRequestImageSource } from "./pullRequestMediaSource";
33
import {
34
FilePreviewModal,
35
type FilePreviewSource,
36
type FilePreviewItem,
37
-} from "../../components/FilePreviewModal";
37
+} from "../../components/ui/FilePreviewModal";
38
import { ThreadMarkdownImageView } from "../threads/ThreadMarkdownImage";
39
import type { MarkdownImageRenderer } from "../../native/SelectableMarkdownText";
40
import type { SelectableMarkdownTextProps } from "../../native/SelectableMarkdownText.types";
apps/mobile/src/features/pull-requests/PullRequestMedia.tsx
+3
-3
@@ -4,7 +4,7 @@ import {
4
pullRequestImageSource,
5
type PullRequestMediaLocation,
6
} from "./pullRequestMediaSource";
7
-import { useFilePreviewGallery } from "../../components/FilePreviewGallery";
7
+import { useFilePreviewGallery } from "../../components/ui/FilePreviewGallery";
8
import { videoMimeType } from "@t3tools/shared/video";
9
import { Pressable, View } from "react-native";
10
import { Image } from "expo-image";
@@ -13,13 +13,13 @@ import { useAssetUrlState, useRefreshAssetUrl } from "../../state/assets";
13
import { assetImageCacheKey } from "../../lib/assetImageSource";
14
import { MediaVideoPlayer } from "../../components/MediaVideoPlayer";
15
import { VideoAttachmentTile } from "../../components/VideoAttachmentTile";
16
-import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
16
+import { VideoPreviewModal, type VideoPreviewSource } from "../../components/ui/VideoPreviewModal";
17
import { ThreadMarkdownImageView } from "../threads/ThreadMarkdownImage";
18
import {
19
FilePreviewModal,
20
type FilePreviewSource,
21
type FilePreviewItem,
22
-} from "../../components/FilePreviewModal";
22
+} from "../../components/ui/FilePreviewModal";
23
24
export const PullRequestMediaVisibleContext = createContext(true);
25
apps/mobile/src/features/pull-requests/pullRequestMediaSource.ts
+1
-1
@@ -1,6 +1,6 @@
1
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
2
import { SOURCE_CONTROL_MEDIA_ASSET, type EnvironmentId } from "@t3tools/contracts";
3
-import type { FilePreviewItem } from "../../components/FilePreviewModal.types";
3
+import type { FilePreviewItem } from "../../components/ui/FilePreviewModal.types";
4
5
export interface PullRequestMediaLocation {
6
readonly environmentId: EnvironmentId;
apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx
+1
-1
@@ -5,7 +5,7 @@ import { useMemo, useState } from "react";
5
import { Platform, ScrollView, View, useWindowDimensions } from "react-native";
6
import { KeyboardAvoidingView, KeyboardStickyView } from "react-native-keyboard-controller";
7
import { useSafeAreaInsets } from "react-native-safe-area-context";
8
-import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
8
+import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
9
10
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
11
import { SheetHeader } from "../../components/ui/SheetHeader";
apps/mobile/src/features/threads/QuestionAttachments.tsx
+2
-2
@@ -14,8 +14,8 @@ import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStri
14
import { pickComposerFiles, pickComposerMedia } from "../../lib/composerImages";
15
import { useThreadSelection } from "../../state/use-thread-selection";
16
import { useNavigation } from "@react-navigation/native";
17
-import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
18
-import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
17
+import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
18
+import { VideoPreviewModal, type VideoPreviewSource } from "../../components/ui/VideoPreviewModal";
19
import { useServerConfigs } from "../../state/entities";
20
import { appAtomRegistry } from "../../state/atom-registry";
21
import {
apps/mobile/src/features/threads/ThreadComposer.tsx
+2
-2
@@ -35,7 +35,7 @@ import { useEffect, useEffectEvent, useRef, useState, type RefObject } from "rea
35
import { I18nManager, Keyboard, Platform, View, type ViewStyle } from "react-native";
36
import { composerImageGallery } from "../../lib/composerImageGallery";
37
import { filePreviewGallery } from "../../lib/filePreviewGallery";
38
-import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
38
+import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
39
import {
40
composerAttachmentUploadBlockReason,
41
composerAttachmentsStillUploading,
@@ -76,7 +76,7 @@ import {
76
ComposerAttachmentStrip,
77
ComposerAttachmentThumbnail,
78
} from "../../components/ComposerAttachmentStrip";
79
-import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
79
+import { VideoPreviewModal, type VideoPreviewSource } from "../../components/ui/VideoPreviewModal";
80
import { GlassSurface } from "../../components/ui/GlassSurface";
81
import { ComposerEditor, type ComposerEditorHandle } from "../../components/ComposerEditor";
82
import { fileRoutePathSegments } from "../files/filePath";
apps/mobile/src/features/threads/ThreadFeed.tsx
+3
-3
@@ -133,14 +133,14 @@ import {
133
import { Image as ExpoImage } from "expo-image";
134
import { useResolveClassNames } from "uniwind";
135
import { useReduceMotionEnabled } from "../../lib/appState";
136
-import { useFilePreviewGallery, FilePreviewGallery } from "../../components/FilePreviewGallery";
136
+import { useFilePreviewGallery, FilePreviewGallery } from "../../components/ui/FilePreviewGallery";
137
import { assetImageSource } from "../../lib/assetImageSource";
138
import { composerImageGallery } from "../../lib/composerImageGallery";
139
import { isFileBackedComposerAttachment } from "../../lib/composerImages";
140
import { useLocalAttachmentPreview } from "../../lib/localAttachmentPreview";
141
import { messageImageGallery } from "./messageImageGallery";
142
import { MARKDOWN_IMAGE_MAX_WIDTH, resolveMarkdownImageDisplaySize } from "./markdownImageSize";
143
-import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
143
+import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
144
import { inlineFilePreviewKind, isPdfFile } from "../../lib/filePreview";
145
import { ThreadInlineFilePreview } from "./ThreadInlineFilePreview";
146
import { flattenThemeColor } from "../../lib/mobileTheme";
@@ -166,7 +166,7 @@ import {
166
} from "../../native/SelectableMarkdownText";
167
168
import { AppText as Text } from "../../components/ui/AppText";
169
-import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
169
+import { VideoPreviewModal, type VideoPreviewSource } from "../../components/ui/VideoPreviewModal";
170
import { markdownFileEmbedLabel, resolveMarkdownMediaPreview } from "../../lib/markdownMedia";
171
import { attachmentVideoPreviewSource } from "../../lib/videoPreviewSource";
172
import { CopyTextButton } from "./CopyTextButton";
apps/mobile/src/features/threads/ThreadInlineFilePreview.tsx
+1
-1
@@ -3,7 +3,7 @@ import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments"
3
import { useAudioPlayerStatus } from "expo-audio";
4
import { useContext, useEffect, useRef, useState } from "react";
5
import { AppState, Pressable, View } from "react-native";
6
-import type { FilePreviewSource } from "../../components/FilePreviewModal";
6
+import type { FilePreviewSource } from "../../components/ui/FilePreviewModal";
7
import { filePreviewKey } from "../../lib/filePreviewGallery";
8
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
9
import { AppText as Text } from "../../components/ui/AppText";
apps/mobile/src/features/threads/ThreadMarkdownImage.test.tsx
+1
-1
@@ -30,7 +30,7 @@ vi.mock("expo/fetch", () => ({ fetch: vi.fn() }));
30
vi.mock("react-native-svg", () => ({ parse: vi.fn(), SvgAst: () => null }));
31
vi.mock("@t3tools/client-runtime/state/assets", () => ({ MISSING_FILE_ACCESS_MESSAGE: "" }));
32
vi.mock("../../components/ui/AppActivityIndicator", () => ({ AppActivityIndicator: () => null }));
33
-vi.mock("../../components/FilePreviewGallery", () => ({
33
+vi.mock("../../components/ui/FilePreviewGallery", () => ({
34
useFilePreviewGallery: () => (source: unknown) => source,
35
}));
36
vi.mock("../../components/ui/AppText", () => ({
apps/mobile/src/features/threads/ThreadMarkdownImage.tsx
+2
-2
@@ -11,9 +11,9 @@ import { parse, SvgAst, type JsxAST } from "react-native-svg";
11
import { Pressable, StyleSheet, View, type ViewStyle } from "react-native";
12
13
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
14
-import { useFilePreviewGallery } from "../../components/FilePreviewGallery";
14
+import { useFilePreviewGallery } from "../../components/ui/FilePreviewGallery";
15
import { AppText as Text } from "../../components/ui/AppText";
16
-import type { FilePreviewSource } from "../../components/FilePreviewModal";
16
+import type { FilePreviewSource } from "../../components/ui/FilePreviewModal";
17
import { MediaActionsMenu } from "../../components/MediaActionsMenu";
18
import { PresentationSource } from "../../components/ui/NativePresentation";
19
import { useMediaActions } from "../../state/mediaActions";
apps/mobile/src/features/threads/messageImageGallery.ts
+1
-1
@@ -1,6 +1,6 @@
1
import type { ChatAttachment, EnvironmentId, ThreadId } from "@t3tools/contracts";
2
import { imageMimeType } from "@t3tools/shared/image";
3
-import type { FilePreviewItem } from "../../components/FilePreviewModal.types";
3
+import type { FilePreviewItem } from "../../components/ui/FilePreviewModal.types";
4
import { markdownImageSources } from "../../lib/markdownImageSources";
5
import { resolveMarkdownMediaPreview } from "../../lib/markdownMedia";
6
apps/mobile/src/features/threads/thread-work-log.tsx
+2
-2
@@ -88,8 +88,8 @@ import {
88
import { resolveWorkGroupScrollAnchor } from "@t3tools/client-runtime/work-log/scroll-anchor";
89
import { notificationChildThreadId } from "@t3tools/client-runtime/state/thread-execution";
90
import type { MarkdownImageRenderer } from "../../native/SelectableMarkdownText";
91
-import type { FilePreviewSource } from "../../components/FilePreviewModal";
92
-import { FilePreviewGallery } from "../../components/FilePreviewGallery";
91
+import type { FilePreviewSource } from "../../components/ui/FilePreviewModal";
92
+import { FilePreviewGallery } from "../../components/ui/FilePreviewGallery";
93
import { ThreadMarkdownImage } from "./ThreadMarkdownImage";
94
import Animated, {
95
FadeIn,
apps/mobile/src/lib/composerImageGallery.ts
+1
-1
@@ -1,6 +1,6 @@
1
import { imageMimeType } from "@t3tools/shared/image";
2
import type { EnvironmentId } from "@t3tools/contracts";
3
-import type { FilePreviewItem } from "../components/FilePreviewModal.types";
3
+import type { FilePreviewItem } from "../components/ui/FilePreviewModal.types";
4
import { isFileBackedComposerAttachment, type DraftComposerAttachment } from "./composerImages";
5
6
export function composerImageGallery(
apps/mobile/src/lib/contextImageGallery.ts
+1
-1
@@ -1,6 +1,6 @@
1
import type { ComposerContextRecord, EnvironmentId } from "@t3tools/contracts";
2
import { imageMimeType } from "@t3tools/shared/image";
3
-import type { FilePreviewItem } from "../components/FilePreviewModal.types";
3
+import type { FilePreviewItem } from "../components/ui/FilePreviewModal.types";
4
import { composerImageGallery } from "./composerImageGallery";
5
import type { DraftComposerAttachment } from "./composerImages";
6
apps/mobile/src/lib/filePreview.test.ts
+3
-3
@@ -235,14 +235,14 @@ vi.mock("../components/ui/NativePresentation", () => ({
235
vi.mock("../components/ui/Menu", () => ({
236
Menu: ({ children }: { children?: ReactNode }) => children,
237
}));
238
-vi.mock("../components/FilePreviewGallery", () => ({
238
+vi.mock("../components/ui/FilePreviewGallery", () => ({
239
FilePreviewGallery: ({ children }: { children?: ReactNode }) => children,
240
}));
241
-vi.mock("../components/FilePreviewModal", () => ({
241
+vi.mock("../components/ui/FilePreviewModal", () => ({
242
FilePreviewModal: (props: { source: { name: string } | null }) =>
243
props.source ? createElement("div", { "data-file-preview": props.source.name }) : null,
244
}));
245
-vi.mock("../components/VideoPreviewModal", () => ({ VideoPreviewModal: () => null }));
245
+vi.mock("../components/ui/VideoPreviewModal", () => ({ VideoPreviewModal: () => null }));
246
vi.mock("../components/ComposerContextSheet", () => ({}));
247
vi.mock("../native/useOpenPullRequest", () => ({ useOpenPullRequest: () => vi.fn() }));
248
vi.mock("../native/useMarkdownImageSource", () => ({ useMarkdownImageSource: () => vi.fn() }));
apps/mobile/src/lib/filePreviewGallery.test.ts
+1
-1
@@ -1,6 +1,6 @@
1
import { describe, expect, it, vi } from "vite-plus/test";
2
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
3
-import type { FilePreviewItem } from "../components/FilePreviewModal.types";
3
+import type { FilePreviewItem } from "../components/ui/FilePreviewModal.types";
4
import type { DraftComposerAttachment } from "./composerImages";
5
import { composerImageGallery } from "./composerImageGallery";
6
import { messageImageGallery } from "../features/threads/messageImageGallery";
apps/mobile/src/lib/filePreviewGallery.ts
+1
-1
@@ -1,4 +1,4 @@
1
-import type { FilePreviewItem, FilePreviewSource } from "../components/FilePreviewModal.types";
1
+import type { FilePreviewItem, FilePreviewSource } from "../components/ui/FilePreviewModal.types";
2
3
export function filePreviewKey(source: FilePreviewItem): string {
4
if ("resource" in source)
apps/mobile/src/lib/markdownMedia.ts
+1
-1
@@ -17,7 +17,7 @@ import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
17
import { normalizeNativeMarkdownUrl, resolveMarkdownLinkPresentation } from "./markdownLinks";
18
import { resolveMobileMarkdownMediaSource } from "./markdownMediaSource";
19
20
-import type { FilePreviewSource } from "../components/FilePreviewModal";
20
+import type { FilePreviewSource } from "../components/ui/FilePreviewModal";
21
import type { MediaVideoPreviewSource } from "./videoPreviewSource";
22
import type { MediaActionsSource } from "./mediaActionsSource";
23
apps/mobile/src/lib/useMediaVideoPlayback.test.tsx
+3
-3
@@ -103,11 +103,11 @@ vi.mock("./videoThumbnails", () => ({
103
cachedVideoThumbnail: () => null,
104
loadVideoThumbnail: mocks.thumbnail,
105
}));
106
-vi.mock("../components/FilePreviewGallery", () => ({
106
+vi.mock("../components/ui/FilePreviewGallery", () => ({
107
useFilePreviewGallery: () => (value: unknown) => value,
108
}));
109
-vi.mock("../components/FilePreviewModal", () => ({ FilePreviewModal: () => null }));
110
-vi.mock("../components/VideoPreviewModal", () => ({ VideoPreviewModal: () => null }));
109
+vi.mock("../components/ui/FilePreviewModal", () => ({ FilePreviewModal: () => null }));
110
+vi.mock("../components/ui/VideoPreviewModal", () => ({ VideoPreviewModal: () => null }));
111
vi.mock("../features/threads/ThreadMarkdownImage", () => ({ ThreadMarkdownImageView: () => null }));
112
113
import {
apps/mobile/src/native/MermaidCodeBlock.tsx
+13
-16
@@ -6,7 +6,7 @@ import { Suspense, use, useRef, useState } from "react";
6
import { PixelRatio, Platform, Pressable, StyleSheet, Text, View } from "react-native";
7
import { parse, Svg, SvgXml } from "react-native-svg";
8
9
-import { MediaImagePreview } from "../components/MediaImagePreview";
9
+import { FilePreviewModal } from "../components/ui/FilePreviewModal";
10
import { SymbolView, type AppSymbolName } from "../components/ui/AppSymbol";
11
import { copyTextWithHaptic } from "../lib/copyTextWithHaptic";
12
import { mermaidSvgForNative, withDiagramBackground } from "../lib/mermaidSvg";
@@ -278,23 +278,20 @@ function MermaidBlock(props: MermaidCodeBlockProps & { readonly diagram: Diagram
278
</View>
279
) : null}
280
{expansion?.status === "open" ? (
281
- <MediaImagePreview
281
+ <FilePreviewModal
282
source={{
283
kind: "image",
284
- selectedIndex: 0,
285
- images: [
286
- {
287
- kind: "image",
288
- uri: expansion.uri,
289
- name: "Mermaid diagram",
290
- mimeType: "image/png",
291
- actionsSource: {
292
- uri: expansion.uri,
293
- name: "Mermaid diagram.png",
294
- mimeType: "image/png",
295
- },
296
- },
297
- ],
284
+ uri: expansion.uri,
285
+ // The viewer titles an image by a name with an extension.
286
+ name: "Mermaid diagram.png",
287
+ mimeType: "image/png",
288
+ // Alone, as on web, rather than paged with the thread's images.
289
+ gallery: [],
290
+ actionsSource: {
291
+ uri: expansion.uri,
292
+ name: "Mermaid diagram.png",
293
+ mimeType: "image/png",
294
+ },
295
}}
296
onRequestClose={() => setExpansion(null)}
297
/>
apps/mobile/vite.config.ts
+1
-1
@@ -27,7 +27,7 @@ const reactTests = [
27
"src/features/settings/components/BranchNamingSettings.test.tsx",
28
"src/features/settings/components/SettingsDragHandle.test.tsx",
29
"src/features/threads/ThreadMarkdownImage.test.tsx",
30
- "src/components/FilePreviewModal.test.tsx",
30
+ "src/components/ui/FilePreviewSession.test.tsx",
31
"src/features/threads/UsageLimitRecoveryCard.test.tsx",
32
"src/features/threads/NewTaskDraftRouteScreen.test.tsx",
33
"src/native/NativeHeaderToolbar.test.tsx",
vite.config.ts
+1
-22
@@ -396,27 +396,6 @@ export default defineConfig({
396
],
397
},
398
},
399
- {
400
- files: ["apps/mobile/src/features/**"],
401
- rules: {
402
- "eslint/no-restricted-imports": [
403
- "error",
404
- {
405
- paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
406
- patterns: [
407
- {
408
- group: [
409
- "**/components/ui/AndroidScreenHeader",
410
- "**/components/ui/WorkspaceAppBar*",
411
- ],
412
- importNames: ["AndroidScreenHeader", "WorkspaceAppBar"],
413
- message: "Use AppBar, so every screen gets the same header and button metrics.",
414
- },
415
- ],
416
- },
417
- ],
418
- },
419
- },
399
{
400
files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
401
rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
@@ -492,7 +471,7 @@ export default defineConfig({
471
files: ["apps/mobile/src/**"],
472
excludeFiles: [
473
"apps/mobile/src/components/ui/AppSymbol.tsx",
495
- "apps/mobile/src/components/ui/AppSymbol.ios.tsx",
474
+ "apps/mobile/src/components/ui/AppSymbol.android.tsx",
475
"apps/mobile/src/features/pull-requests/pullRequestGlyphs.ts",
476
],
477
rules: { "t3code/no-mobile-pull-request-glyph-literals": "error" },