import { View, Text, ScrollView, Pressable, Modal, } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { useEffect } from "react"; import { StyleSheet } from "react-native-unistyles"; export interface Artifact { id: string; type: "markdown" | "diff" | "image" | "code"; title: string; content: string; isBase64: boolean; } interface ArtifactDrawerProps { artifact: Artifact | null; onClose: () => void; } const styles = StyleSheet.create((theme) => ({ container: { flex: 1, backgroundColor: theme.colors.background, flexDirection: "column", }, header: { paddingBottom: theme.spacing[4], paddingHorizontal: theme.spacing[4], borderBottomWidth: theme.borderWidth[1], borderBottomColor: theme.colors.border, }, headerRow: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", }, titleContainer: { flex: 1, marginRight: theme.spacing[4], }, title: { color: theme.colors.foreground, fontSize: theme.fontSize["2xl"], fontWeight: theme.fontWeight.bold, }, headerActions: { flexDirection: "row", alignItems: "center", gap: theme.spacing[2], }, badge: { paddingHorizontal: theme.spacing[3], paddingVertical: theme.spacing[1], borderRadius: theme.borderRadius.full, }, badgeMarkdown: { backgroundColor: theme.colors.primary, }, badgeDiff: { backgroundColor: theme.colors.palette.purple[600], }, badgeImage: { backgroundColor: theme.colors.palette.green[600], }, badgeCode: { backgroundColor: theme.colors.palette.orange[600], }, badgeText: { color: theme.colors.primaryForeground, fontSize: theme.fontSize.xs, fontWeight: theme.fontWeight.semibold, }, closeButton: { backgroundColor: theme.colors.muted, width: 40, height: 40, borderRadius: 20, alignItems: "center", justifyContent: "center", }, closeButtonText: { color: theme.colors.foreground, fontSize: theme.fontSize["2xl"], fontWeight: theme.fontWeight.bold, }, contentScroll: { flex: 1, backgroundColor: theme.colors.background, }, contentScrollContainer: { padding: theme.spacing[4], flexGrow: 1, }, imagePlaceholder: { flex: 1, alignItems: "center", justifyContent: "center", }, imagePlaceholderText: { color: theme.colors.mutedForeground, fontSize: theme.fontSize.sm, }, imagePlaceholderSubtext: { color: theme.colors.mutedForeground, fontSize: theme.fontSize.xs, marginTop: theme.spacing[2], }, codeContainer: { backgroundColor: theme.colors.card, borderRadius: theme.borderRadius.lg, padding: theme.spacing[4], borderWidth: theme.borderWidth[1], borderColor: theme.colors.border, }, codeText: { color: theme.colors.foreground, fontSize: theme.fontSize.sm, fontFamily: "monospace", }, metadataContainer: { backgroundColor: theme.colors.card, padding: theme.spacing[3], borderTopWidth: theme.borderWidth[1], borderTopColor: theme.colors.border, marginTop: theme.spacing[2], }, metadataTitle: { color: theme.colors.mutedForeground, fontSize: theme.fontSize.xs, fontWeight: theme.fontWeight.semibold, marginBottom: theme.spacing[2], }, metadataRow: { flexDirection: "row", marginBottom: theme.spacing[1], }, metadataLabel: { color: theme.colors.mutedForeground, fontSize: theme.fontSize.xs, width: 80, }, metadataValue: { color: theme.colors.mutedForeground, fontSize: theme.fontSize.xs, flex: 1, fontFamily: "monospace", }, })); export function ArtifactDrawer({ artifact, onClose }: ArtifactDrawerProps) { useEffect(() => { if (!artifact) return; console.log( "[ArtifactDrawer] Showing artifact:", artifact.id, artifact.type, artifact.title ); }, [artifact]); if (!artifact) { return null; } // Decode content if base64 const content = artifact.isBase64 ? atob(artifact.content) : artifact.content; // Type badge style mapping const typeBadgeStyles = { markdown: styles.badgeMarkdown, diff: styles.badgeDiff, image: styles.badgeImage, code: styles.badgeCode, }; return ( {/* Header */} {artifact.title} {artifact.type.toUpperCase()} × {/* Content */} {artifact.type === "image" ? ( Image viewing not yet implemented Base64 image data received ) : ( {content} )} {/* Metadata - Fixed at bottom */} METADATA ID: {artifact.id} Type: {artifact.type} Encoding: {artifact.isBase64 ? "Base64" : "Plain text"} Size: {content.length.toLocaleString()} characters ); }