import React, { useState } from 'react'; import { View, Text, StyleSheet, ScrollView } from 'react-native'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; import { UX4GColors } from '../foundation/colors'; import { Ux4gCheckbox } from '../components/checkbox/Checkbox'; import { Ux4gButton } from '../components/button/Button'; export const CheckboxShowcase: React.FC = () => { const theme = useUx4gTheme(); // Basic Interactive State const [basicState, setBasicState] = useState(false); // Tristate / Indeterminate State const [tristate, setTristate] = useState(null); // Checklist states const [chk1, setChk1] = useState(true); const [chk2, setChk2] = useState(false); const [chk3, setChk3] = useState(true); // Sizes state const [sizeSm, setSizeSm] = useState(true); const [sizeMd, setSizeMd] = useState(true); const [sizeLg, setSizeLg] = useState(true); // Horizontal status grid state const [stateHelper, setStateHelper] = useState(true); const [stateError, setStateError] = useState(false); const [stateWarning, setStateWarning] = useState(true); const [stateSuccess, setStateSuccess] = useState(true); return ( UX4G Checkbox Showcase Direct port of `checkbox.dart` (`Ux4gCheckbox`) featuring checked, unchecked, tristate (`null`), sizes, required mark (`*`), and description variants. {/* 1. Basic & Interactive States */} 1. Basic & Interactive Tristate Toggle Taps automatically cycle across state: if Indeterminate (`null`) → `true` → `false` → `true`. setBasicState(val)} label={`Standard Interactive Checkbox (${ basicState === true ? 'Checked ✓' : basicState === false ? 'Unchecked' : 'Indeterminate —' })`} description="Tap anywhere on this row to toggle the checkbox state smoothly." /> setTristate(val)} label="Tristate / Indeterminate Preset (`value = null`)" description="Displays the horizontal dash vector icon when null. Tap to toggle!" /> setTristate(null)} /> {/* 2. Sizes */} 2. Sizes (`Ux4gCheckboxSize`) Supports `small` (16pt box), `medium` (20pt box, default), and `large` (24pt box). setSizeSm(val)} label="Small Checkbox (16pt box, lM_default typography)" description="Ideal for dense lists and compact tables." /> setSizeMd(val)} label="Medium Checkbox (20pt box, lL_default typography)" description="Standard default size across most UX4G forms." /> setSizeLg(val)} label="Large Checkbox (24pt box, lXL_default typography)" description="Ideal for touch-heavy mobile screens or prominent selection." /> {/* 3. Description Variants & Required Asterisk */} 3. Description Variants (`Ux4gCheckboxDescriptionVariant`) & Required (`*`) Dynamic color support for `helper`, `error`, `warning`, and `success` descriptions. {}} label="Required Terms & Conditions" isRequired={true} description="Helper variant (70% alpha). Notice the red asterisk (*) on the label." descriptionVariant="helper" /> {}} label="Accept Privacy Policy" isRequired={true} hasError={true} description="Error variant (`theme.colors.error`). Highlights border and description." descriptionVariant="error" /> {}} label="Enable Experimental Beta Features" description="Warning variant (`theme.colors.warning`). Please proceed with care." descriptionVariant="warning" /> {}} label="Aadhaar Verification Complete" description="Success variant (`theme.colors.success`). Document verified successfully." descriptionVariant="success" /> Horizontal Status States (`helper`, `error`, `warning`, `success`) Clean side-by-side comparison of all 4 description variant status icons with check and error rings. setStateHelper(val)} label="Label" description="Default description" descriptionVariant="helper" /> setStateError(val)} label="Label" hasError={true} description="Error text" descriptionVariant="error" /> setStateWarning(val)} label="Label" description="Warning text" descriptionVariant="warning" /> setStateSuccess(val)} label="Label" description="Success text" descriptionVariant="success" /> {/* 4. Disabled States */} 4. Disabled States (`enabled = false`) Applies 12% opacity (`1F`) box fill/border and 38% (`61`) text opacity per design specs. {}} label="Disabled Checked Option" description="Cannot be toggled by user interaction." /> {}} label="Disabled Unchecked Option" description="Maintains exact border spacing with disabled opacity." /> {}} label="Disabled Indeterminate Option" description="Tristate dash icon rendered in semi-transparent disabled state." /> {/* 5. Interactive Checklist Example */} 5. Interactive Checklist Demo Combine checkboxes with live form validation and state updates. setChk1(val)} label="Send SMS Notifications" description="Receive real-time OTP and application updates on your registered mobile number." activeColor={theme.colors.success} /> setChk2(val)} label="Subscribe to UX4G Newsletter" description="Monthly design system updates, new Figma tokens, and framework releases." /> setChk3(val)} label="Enable Two-Factor Authentication (2FA)" description="Add an extra layer of biometric/OTP security upon login." /> ); }; const styles = StyleSheet.create({ container: { flex: 1, }, contentContainer: { padding: 20, }, header: { marginBottom: 24, }, title: { fontSize: 26, fontWeight: '800', marginBottom: 8, }, subtitle: { fontSize: 15, lineHeight: 22, }, section: { marginBottom: 28, }, sectionTitle: { fontSize: 18, fontWeight: '700', marginBottom: 6, }, sectionDesc: { fontSize: 14, lineHeight: 20, marginBottom: 14, }, card: { backgroundColor: 'rgba(150, 150, 150, 0.08)', borderRadius: 12, paddingHorizontal: 16, paddingVertical: 12, borderWidth: 1, borderColor: 'rgba(150, 150, 150, 0.15)', }, divider: { height: 1, backgroundColor: 'rgba(150, 150, 150, 0.15)', marginVertical: 6, }, rowActions: { flexDirection: 'row', justifyContent: 'flex-end', marginTop: 10, }, horizontalRowContainer: { flexDirection: 'row', alignItems: 'flex-start', paddingVertical: 4, }, horizontalGridItem: { marginRight: 28, minWidth: 170, }, });