blob: 0283d17988578a9b31867922957d42ff74cc4efd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
import { useState } from "react";
import { Modal, Pressable, ScrollView, View } from "react-native";
import { router } from "expo-router";
import { ExternalLink, NotepadText, X } from "lucide-react-native";
import { useColorScheme } from "nativewind";
import { Button } from "../ui/Button";
import { Text } from "../ui/Text";
interface NotePreviewProps {
note: string;
bookmarkId: string;
readOnly?: boolean;
}
export function NotePreview({
note,
bookmarkId,
readOnly = false,
}: NotePreviewProps) {
const [isModalVisible, setIsModalVisible] = useState(false);
const { colorScheme } = useColorScheme();
const iconColor = colorScheme === "dark" ? "#9ca3af" : "#6b7280";
const modalIconColor = colorScheme === "dark" ? "#d1d5db" : "#374151";
if (!note?.trim()) {
return null;
}
return (
<>
<Pressable onPress={() => setIsModalVisible(true)}>
<View className="flex flex-row items-center gap-2">
<NotepadText size={24} color={iconColor} />
<Text
className="flex-1 text-sm italic text-gray-500 dark:text-gray-400"
numberOfLines={2}
>
{note}
</Text>
</View>
</Pressable>
<Modal
visible={isModalVisible}
transparent
animationType="slide"
onRequestClose={() => setIsModalVisible(false)}
>
<View className="flex-1 justify-end bg-black/50">
<View className="max-h-[80%] rounded-t-3xl bg-card p-6">
{/* Header */}
<View className="mb-4 flex flex-row items-center justify-between">
<Text className="text-lg font-semibold">Note</Text>
<Pressable
onPress={() => setIsModalVisible(false)}
className="p-2"
>
<X size={24} color={modalIconColor} />
</Pressable>
</View>
{/* Note Content */}
<ScrollView className="mb-4 max-h-96">
<Text className="text-sm text-gray-700 dark:text-gray-300">
{note}
</Text>
</ScrollView>
{/* Action Button */}
{!readOnly && (
<View className="flex flex-row justify-end border-t border-border pt-4">
<Button
variant="secondary"
onPress={() => {
setIsModalVisible(false);
router.push(`/dashboard/bookmarks/${bookmarkId}/info`);
}}
>
<Text className="text-sm">Edit Notes</Text>
<ExternalLink size={14} color={modalIconColor} />
</Button>
</View>
)}
</View>
</View>
</Modal>
</>
);
}
|