import React, { useState } from 'react'; import { View, Text, ScrollView, StyleSheet, TouchableOpacity } from 'react-native'; import { Ux4gSelectionDropdown, Ux4gActionDropdown, Ux4gDropdownOption, Ux4gActionDropdownOption, } from '../components/dropdown/Dropdown'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; import { Ux4gIcons } from '../foundation/icons'; export const DropdownShowcase: React.FC = () => { const theme = useUx4gTheme(); const colors = theme.colors; // 1. Single Selection State const [singleSelected, setSingleSelected] = useState(['flight']); const singleOptions: Ux4gDropdownOption[] = [ { id: 'flight', label: '✈️ Flight Booking' }, { id: 'hotel', label: '🏨 Hotel Reservation' }, { id: 'cab', label: '🚖 Cab Service' }, { id: 'train', label: '🚆 Train Ticket' }, { id: 'cruise', label: '🚢 Cruise Vacation' }, ]; // 2. Multi Selection with Search State const [multiSelected, setMultiSelected] = useState(['react-native', 'typescript']); const multiOptions: Ux4gDropdownOption[] = [ { id: 'react-native', label: 'React Native' }, { id: 'flutter', label: 'Flutter' }, { id: 'typescript', label: 'TypeScript' }, { id: 'swift', label: 'Swift / iOS' }, { id: 'kotlin', label: 'Kotlin / Android' }, { id: 'design-systems', label: 'Design Systems Architecture' }, { id: 'figma-tokens', label: 'Figma Token Studio' }, { id: 'redux', label: 'Redux State Management' }, { id: 'graphql', label: 'GraphQL API' }, ]; // 3. Size Variations States const [smallSelected, setSmallSelected] = useState(['hotel']); const [mediumSelected, setMediumSelected] = useState(['flight']); const [largeSelected, setLargeSelected] = useState(['cab']); // 4. Status Verification States (Interactive Error & Disabled) const [errorSelected, setErrorSelected] = useState([]); const [disabledSelected, setDisabledSelected] = useState(['flight']); // 5. Action Dropdown State const [lastAction, setLastAction] = useState('None selected'); const [activeActionId, setActiveActionId] = useState('edit'); const actionOptions: Ux4gActionDropdownOption[] = [ { id: 'edit', label: 'Edit Document', showTrailingArrow: false }, { id: 'duplicate', label: 'Duplicate File', showTrailingArrow: false }, { id: 'share', label: 'Share via Email...', showTrailingArrow: true }, { id: 'archive', label: 'Archive Project', showTrailingArrow: false }, { id: 'delete', label: 'Delete Item', showTrailingArrow: false }, ]; // 6. Search Filter Types Comparison States const [startsWithSelected, setStartsWithSelected] = useState([]); const [containsSelected, setContainsSelected] = useState([]); const countryOptions: Ux4gDropdownOption[] = [ { id: 'ind', label: '🇮🇳 India' }, { id: 'ina', label: '🇮🇩 Indonesia' }, { id: 'irl', label: '🇮🇪 Ireland' }, { id: 'isl', label: '🇮🇸 Iceland' }, { id: 'usa', label: '🇺🇸 United States' }, { id: 'uk', label: '🇬🇧 United Kingdom' }, { id: 'uae', label: '🇦🇪 United Arab Emirates' }, { id: 'aus', label: '🇦🇺 Australia' }, { id: 'can', label: '🇨🇦 Canada' }, ]; const cardStyle = [ styles.card, { backgroundColor: theme.isDark ? '#1F1F1F' : '#FFFFFF', borderColor: theme.isDark ? '#333333' : '#E4E4E7', }, ]; const titleStyle = [ styles.sectionTitle, { color: theme.isDark ? '#F4F4F5' : '#18181B' }, ]; const subtitleStyle = [ styles.subText, { color: theme.isDark ? '#A1A1AA' : '#71717A' }, ]; const isErrorState = errorSelected.length === 0; return ( 🔽 Dropdown Component (`Ux4gSelectionDropdown` & `Ux4gActionDropdown`) All dropdown examples below are 100% interactive with complete working state! Try selecting options, searching inside overlay menus, adding/removing multi-select chips, and testing dynamic form validation. {/* 1. Selection Dropdown - Single Mode */} 1. Single Selection (`mode = 'single'`) Standard single choice selection box (`size = 'm'`). Tapping an option automatically updates state and closes the anchored overlay menu. Current State: {singleSelected[0] || 'None'} {/* 2. Selection Dropdown - Multi Mode + Search Enabled */} 2. Multi Selection + Interactive Search (`searchEnabled = true`) Allows selecting multiple items (`mode = 'multi'`) and displays selected tags via `Ux4gInputChip` in the trigger box. Includes real-time search filtering in the overlay. Selected Tags Count: {multiSelected.length} ({multiSelected.join(', ')}) {/* 3. Dropdown Sizes Comparison */} 3. Sizes Comparison (`s`, `m`, `l`) Fully interactive size variations matching Figma / Flutter dimension tokens. Small Size (`size = 's'`, 32px height): Medium Size (`size = 'm'`, 40px height): Large Size (`size = 'l'`, 48px height): {/* 4. Status Verification (Dynamic Error & Disabled States) */} 4. Interactive Status Validation (`error` vs `disabled`) Notice how the error dropdown dynamically turns valid (`defaultStatus`) right after you pick an option! Dynamic Validation State (`status = '{isErrorState ? 'error' : 'defaultStatus'}'`): Disabled / Locked State (`status = 'disabled'`): {/* 5. Action Dropdown (Floating Action Menu) */} 5. Action Dropdown (`Ux4gActionDropdown`) Trigger a floating action menu attached to any custom button. Tracks active item (`selectedOptionId`). { setLastAction(opt.label); setActiveActionId(opt.id); }} triggerBuilder={(toggle) => ( ⚙️ Actions Menu {Ux4gIcons.arrowDropDown({ size: 18, color: '#FFFFFF' })} )} /> Last Action: {lastAction} Active Option ID: `{activeActionId}` {/* 6. Search Filter Types Comparison */} 6. Search Filter Modes (`filterType` Comparison) Explore the difference between `startsWith` vs `contains` search query algorithms. ); }; const styles = StyleSheet.create({ container: { flex: 1, }, contentContainer: { padding: 16, paddingBottom: 64, }, header: { marginBottom: 20, }, title: { fontSize: 22, fontWeight: '700', marginBottom: 6, }, subText: { fontSize: 14, lineHeight: 20, }, card: { borderWidth: 1, borderRadius: 12, padding: 16, marginBottom: 16, }, sectionTitle: { fontSize: 16, fontWeight: '600', marginBottom: 6, }, label: { fontSize: 13, fontWeight: '600', marginBottom: 8, }, rowSpacing: { marginTop: 14, }, stateMonitorText: { fontSize: 13, marginTop: 10, fontStyle: 'italic', }, actionRow: { flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap', }, actionButton: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 16, paddingVertical: 10, borderRadius: 8, }, actionButtonText: { color: '#FFFFFF', fontWeight: '600', marginRight: 6, }, actionLogBox: { marginLeft: 16, }, actionResult: { fontSize: 14, }, actionResultSmall: { fontSize: 12, marginTop: 2, }, });