import { useEffect, useState } from 'react' import { View, Text, ScrollView, ActivityIndicator, TouchableOpacity, Share, } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' import { useLocalSearchParams, useRouter } from 'expo-router' import { ArrowLeft, Share2 } from 'lucide-react-native' import { WebView } from 'react-native-webview' import { apiFetch } from '@/lib/api' import { ENDPOINTS } from '@/lib/config' interface Note { id: string title: string content: string updatedAt: string notebookName?: string } // Wrap HTML content in a minimal styled page for WebView rendering function buildHtml(content: string, title: string) { return ` ${content} ` } export default function NoteScreen() { const { id } = useLocalSearchParams<{ id: string }>() const [note, setNote] = useState(null) const [loading, setLoading] = useState(true) const router = useRouter() useEffect(() => { apiFetch(ENDPOINTS.note(id)) .then((r) => r.json()) .then((data) => setNote(data.note ?? null)) .finally(() => setLoading(false)) }, [id]) const handleShare = async () => { if (!note) return await Share.share({ title: note.title, message: `${note.title}\nhttps://memento-note.com`, }) } return ( {/* Header */} router.back()} className="p-1"> {note?.title ?? '…'} {loading ? ( ) : note ? ( ) : ( Note introuvable. )} ) }