| .. | .. |
|---|
| 10 | 10 | View, |
|---|
| 11 | 11 | } from "react-native"; |
|---|
| 12 | 12 | import { cacheDirectory, writeAsStringAsync } from "expo-file-system/legacy"; |
|---|
| 13 | +import * as Clipboard from "expo-clipboard"; |
|---|
| 13 | 14 | import * as Sharing from "expo-sharing"; |
|---|
| 14 | 15 | |
|---|
| 15 | 16 | /** Apple-style share icon (square with upward arrow) */ |
|---|
| .. | .. |
|---|
| 68 | 69 | export function ImageViewer({ visible, imageBase64, onClose }: ImageViewerProps) { |
|---|
| 69 | 70 | const { width, height } = Dimensions.get("window"); |
|---|
| 70 | 71 | |
|---|
| 72 | + const handleCopy = useCallback(async () => { |
|---|
| 73 | + try { |
|---|
| 74 | + await Clipboard.setImageAsync(`data:image/png;base64,${imageBase64}`); |
|---|
| 75 | + } catch (err: any) { |
|---|
| 76 | + Alert.alert("Copy Error", err?.message ?? String(err)); |
|---|
| 77 | + } |
|---|
| 78 | + }, [imageBase64]); |
|---|
| 79 | + |
|---|
| 71 | 80 | const handleShare = useCallback(async () => { |
|---|
| 72 | 81 | try { |
|---|
| 73 | 82 | const fileUri = `${cacheDirectory}pailot-screenshot-${Date.now()}.png`; |
|---|
| .. | .. |
|---|
| 105 | 114 | }} |
|---|
| 106 | 115 | > |
|---|
| 107 | 116 | <Pressable |
|---|
| 117 | + onPress={handleCopy} |
|---|
| 118 | + hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }} |
|---|
| 119 | + style={{ |
|---|
| 120 | + width: 40, |
|---|
| 121 | + height: 40, |
|---|
| 122 | + borderRadius: 20, |
|---|
| 123 | + backgroundColor: "rgba(255,255,255,0.15)", |
|---|
| 124 | + alignItems: "center", |
|---|
| 125 | + justifyContent: "center", |
|---|
| 126 | + }} |
|---|
| 127 | + > |
|---|
| 128 | + <Text style={{ color: "#fff", fontSize: 18 }}>📋</Text> |
|---|
| 129 | + </Pressable> |
|---|
| 130 | + <Pressable |
|---|
| 108 | 131 | onPress={handleShare} |
|---|
| 109 | 132 | hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }} |
|---|
| 110 | 133 | style={{ |
|---|