Initial commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { DocumentItem } from '@/types/types';
|
||||
import { downloadAndShareDocument } from '@/utils/documentUtils';
|
||||
import { Download, FileText } from 'lucide-react-native';
|
||||
import React, { useState } from 'react';
|
||||
import { ActivityIndicator, Text, TouchableOpacity, View } from 'react-native';
|
||||
|
||||
interface DocumentListCardProps {
|
||||
item: DocumentItem;
|
||||
}
|
||||
|
||||
export default function DocumentListCard({ item }: DocumentListCardProps) {
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
|
||||
const handleDownload = async () => {
|
||||
setIsDownloading(true);
|
||||
try {
|
||||
await downloadAndShareDocument(item.mimetype, item.filename, item.url);
|
||||
} finally {
|
||||
setIsDownloading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="bg-white p-5 rounded-3xl shadow-sm flex-row items-center justify-between border border-gray-100">
|
||||
<View className="flex-row items-center gap-5 flex-1">
|
||||
<View className="bg-blue-50 p-4 rounded-2xl flex-shrink-0">
|
||||
<FileText size={32} color="#1071C2" pointerEvents="none" />
|
||||
</View>
|
||||
<View className="flex-1 mr-2">
|
||||
<Text className="font-bold text-gray-800 text-base leading-tight uppercase" numberOfLines={3}>
|
||||
{item.filename}
|
||||
</Text>
|
||||
<View className="flex-row items-center mt-2">
|
||||
<Text className="text-sm text-gray-400 font-bold">{item.date}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
onPress={handleDownload}
|
||||
disabled={isDownloading}
|
||||
className="p-4 bg-gray-50 rounded-2xl active:bg-gray-100 flex-shrink-0 border border-gray-100"
|
||||
>
|
||||
{isDownloading ? (
|
||||
<ActivityIndicator size="small" color="#1071C2" />
|
||||
) : (
|
||||
<Download size={24} color="#1071C2" pointerEvents="none" />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user