import React, { useCallback } from "react"; import { Alert, Dimensions, Image, Modal, Pressable, ScrollView, Text, View, } from "react-native"; import { cacheDirectory, writeAsStringAsync } from "expo-file-system/legacy"; import * as Sharing from "expo-sharing"; /** Apple-style share icon (square with upward arrow) */ function ShareIcon({ size = 18, color = "#fff" }: { size?: number; color?: string }) { const boxSize = size * 0.7; const arrowWidth = 2; return ( {/* Arrow shaft + head */} {/* Open box (3 sides) */} ); } interface ImageViewerProps { visible: boolean; imageBase64: string; onClose: () => void; } export function ImageViewer({ visible, imageBase64, onClose }: ImageViewerProps) { const { width, height } = Dimensions.get("window"); const handleShare = useCallback(async () => { try { const fileUri = `${cacheDirectory}pailot-screenshot-${Date.now()}.png`; await writeAsStringAsync(fileUri, imageBase64, { encoding: "base64", }); if (!(await Sharing.isAvailableAsync())) { Alert.alert("Sharing not available on this device"); return; } await Sharing.shareAsync(fileUri, { mimeType: "image/png" }); } catch (err: any) { if (err?.message?.includes("User did not share")) return; Alert.alert("Share Error", err?.message ?? String(err)); } }, [imageBase64]); return ( {/* Top bar: share + close */} {/* Zoomable image */} ); }