/** * FileUploadShowcase * * Interactive showcase for Ux4gFileUpload demonstrating: * - Solid border style (default) * - Dashed border style * - Pre-populated file list with uploading / success / error states * - Real file picking via Upload button (document picker) * - Real camera scanning via Scan button (image picker) */ import React, { useState } from 'react'; import { View, Text, ScrollView, StyleSheet } from 'react-native'; import { Ux4gFileUpload, UploadedFile, UploadStatus } from '../components/file-upload'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; import { UX4GColors } from '../foundation/colors'; // ── Sample pre-populated files for showcasing states ───────────────────── const sampleFiles: UploadedFile[] = [ { id: 'sample-1', name: 'Aadhaar_Card_Verified.pdf', fileSize: 1843200, status: UploadStatus.success, progress: 1.0, }, { id: 'sample-2', name: 'PAN_Card_Front.png', fileSize: 768000, status: UploadStatus.uploading, progress: 0.65, }, { id: 'sample-3', name: 'Income_Tax_Form16.pdf', fileSize: 3276800, status: UploadStatus.error, progress: 0.3, errorMessage: 'Upload failed. Please try again.', }, ]; export const FileUploadShowcase: React.FC = () => { const theme = useUx4gTheme(); // Track files from the interactive instances const [interactiveFiles, setInteractiveFiles] = useState([]); const sectionTitleColor = theme.colors.onBackground; const subtitleColor = theme.isDark ? UX4GColors.neutral400 : UX4GColors.neutral600; return ( {/* Title */} 📁 Ux4gFileUpload File upload component with document picker & camera scanner {/* ─── Section 1: Solid Border (Default) ─── */} Solid Border (Default) Default border style with real file picking & camera integration setInteractiveFiles(files)} onUpload={async (_file) => { // Simulate async upload success await new Promise((r) => setTimeout(r, 300)); return true; }} /> {/* ─── Section 2: Dashed Border ─── */} Dashed Border Dashed border style variant using SVG stroke-dasharray { await new Promise((r) => setTimeout(r, 300)); return true; }} /> {/* ─── Section 3: Pre-populated File States ─── */} File States Showcase Demonstrates success ✅, uploading ⏳, and error ❌ states { await new Promise((r) => setTimeout(r, 500)); return true; }} /> {/* ─── Section 4: Custom Error Messages ─── */} Custom Error Messages Custom errorTitle and errorText with 2 MB file size limit { await new Promise((r) => setTimeout(r, 300)); return Math.random() > 0.5; // 50% failure rate for demo }} /> ); }; const styles = StyleSheet.create({ scrollContent: { padding: 16, paddingBottom: 40, }, mainTitle: { fontSize: 24, fontWeight: '700', marginBottom: 4, }, mainSubtitle: { fontSize: 14, fontWeight: '500', marginBottom: 24, }, section: { marginBottom: 28, }, sectionTitle: { fontSize: 18, fontWeight: '700', marginBottom: 4, }, sectionDesc: { fontSize: 13, fontWeight: '500', marginBottom: 12, }, sectionCard: { paddingHorizontal: 4, }, });