import React, { useState } from 'react'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity } from 'react-native'; import { Ux4gAadhaarInputField, validateAadhaar } from '../components/aadhaar-input-field/AadhaarInputField'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; import { Ux4gIcons } from '../foundation/icons'; /** * **AadhaarInputFieldShowcase** * * Comprehensive, exhaustive demonstration of `Ux4gAadhaarInputField`, exhibiting every single * configuration and validation state: live auto-formatting (`XXXX XXXX XXXX`), Verhoeff checksum validation, * eye toggle for masking (`showMaskToggle`), explicit validation statuses (`defaultStatus`, `success`, `error`, `warning`), * required states, custom icons, sizes (`small`, `medium`, `large`), and read-only/disabled locked states. */ export const AadhaarInputFieldShowcase: React.FC = () => { const { colors, typography, isDark } = useUx4gTheme(); // Interactive live validation state const [aadhaarValue, setAadhaarValue] = useState(''); const [iconValue, setIconValue] = useState('3675 9834 6015'); // Eye toggle masking showcase states const [maskedValue1, setMaskedValue1] = useState('3675 9834 6015'); const [maskedValue2, setMaskedValue2] = useState(''); const [controlledMaskedValue, setControlledMaskedValue] = useState('4982 1735 9012'); const [isCustomMasked, setIsCustomMasked] = useState(true); // Sizing variants state const [smallValue, setSmallValue] = useState('3675 9834 6015'); const [mediumValue, setMediumValue] = useState('3675 9834 6015'); const [largeValue, setLargeValue] = useState('3675 9834 6015'); const cardStyle = [ styles.card, { backgroundColor: colors.surface ?? (isDark ? '#18181B' : '#FFFFFF'), borderColor: isDark ? '#27272A' : '#E4E4E7', }, ]; const titleStyle = [styles.cardTitle, { color: colors.onSurface }]; const subtitleStyle = [ styles.cardSubtitle, { color: isDark ? '#A1A1AA' : '#71717A' }, ]; // Quick fill samples for Section 1 const handleSetValidSample = () => { setAadhaarValue('3675 9834 6015'); }; const handleSetInvalidSample = () => { setAadhaarValue('2345 6789 0123'); // Fails Verhoeff checksum }; const isCurrentValid = validateAadhaar(aadhaarValue); return ( 🆔 Aadhaar Input Field All States (`Ux4gAadhaarInputField`) Exhaustive showcase exhibiting all possible states: Verhoeff validation, eye toggle for masking (`showMaskToggle`), explicit statuses (`defaultStatus`, `success`, `error`, `warning`), sizes, icons, and disabled/read-only locks. {/* ── SECTION 1: Interactive Live Checksum & Auto-Formatting ────────── */} 1. Interactive Live Verhoeff Checksum & Auto-Formatting Type any 12 digits or click the quick fill buttons below. When 12 digits are reached, it automatically runs the Verhoeff algorithm and verifies UIDAI rules (no leading 0 or 1). ✓ Fill Valid Aadhaar (3675...) ✕ Fill Invalid Aadhaar (2345...) Current Raw Value: {aadhaarValue.replace(/\s+/g, '') || '(empty)'} Verhoeff Checksum Result: {isCurrentValid ? '✓ VALID' : aadhaarValue.replace(/\s+/g, '').length === 12 ? '✕ INVALID CHECKSUM OR LEADING DIGIT' : '(Enter 12 digits)'} {/* ── SECTION 2: Masking & Eye Toggle (`showMaskToggle`) ────────────── */} 2. Eye Toggle for Masking with 'X' Cross (`showMaskToggle`) Enabling `showMaskToggle = true` renders an interactive eye toggle icon (`visibility` / `visibility_off`) on the right side of the field. When masked, digits are replaced with 'X' cross characters (`XXXX XXXX XXXX`) instead of bullets/stars. {/* 2.1 Full X Masked */} {/* 2.2 UIDAI Standard First-8 Digits Masked */} {/* 2.3 Empty field matching design placeholder */} {/* 2.4 Controlled Masking State */} External Mask State: {isCustomMasked ? '🔒 Masked (X)' : '👁️ Visible'} setIsCustomMasked((prev) => !prev)} > Toggle from External Button {/* ── SECTION 3: All Validation States (`status` prop) ──────────────── */} 3. All Validation Status States (`status` prop) Illustrating all four semantic validation states (`defaultStatus`, `success`, `error`, and `warning`) along with their respective border colors and automatic status icons. {}} status="defaultStatus" placeholder="XXXX XXXX XXXX" caption="Enter your 12-digit Aadhaar number" /> {}} status="success" caption="Valid Aadhaar number verified by Verhoeff checksum" /> {}} status="error" caption="Invalid Aadhaar: Dihedral Group D5 checksum mismatch" /> {}} status="warning" caption="Biometric e-KYC re-verification required within 15 days" /> {/* ── SECTION 4: Field Configurations (`required`, `icons`) ─────────── */} 4. Required & Icon Configurations Demonstrating required red asterisks (`*`) alongside leading (`leadingIcon`) and trailing interactive icons (`trailingIcon`). setIconValue('')} caption="Click the trailing close icon (`✕`) to clear the field input" /> {/* ── SECTION 5: All Sizing Variants (`size` prop) ──────────────────── */} 5. All Sizing Variants (`size` prop) Supporting exact heights: `small` (`32px`), `medium` (`40px`), and `large` (`48px`). {/* ── SECTION 6: Read-Only & Disabled States ─────────────────────────── */} 6. Read-Only & Disabled States Locked non-editable states (`readOnly = true` and `enabled = false`). {}} readOnly={true} status="success" caption="Input locked: value is selectable/copyable but cannot be modified" /> {}} enabled={false} caption="Input disabled: opacities dimmed to 0.38 (`disabledTitleColor`)" /> ); }; const styles = StyleSheet.create({ container: { flex: 1, }, contentContainer: { padding: 16, paddingBottom: 64, }, header: { marginBottom: 20, }, title: { fontSize: 22, fontWeight: '800', marginBottom: 6, }, card: { borderWidth: 1, borderRadius: 12, padding: 16, marginBottom: 20, }, cardTitle: { fontSize: 16, fontWeight: '700', marginBottom: 4, }, cardSubtitle: { fontSize: 13, marginBottom: 16, lineHeight: 18, }, quickFillContainer: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, marginBottom: 16, }, sampleButton: { paddingHorizontal: 12, paddingVertical: 8, borderRadius: 6, }, sampleButtonText: { color: '#FFFFFF', fontSize: 12, fontWeight: '700', }, controlledHeaderRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 10, flexWrap: 'wrap', gap: 8, }, smallActionBtn: { paddingHorizontal: 10, paddingVertical: 6, borderRadius: 6, }, smallActionBtnText: { color: '#FFFFFF', fontSize: 12, fontWeight: '600', }, statusBanner: { marginTop: 14, padding: 12, borderRadius: 8, }, sectionRow: { marginBottom: 16, }, });