import React, { useState } from 'react'; import { View, Text, StyleSheet, ScrollView } from 'react-native'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; import { UX4GColors } from '../foundation/colors'; import { Ux4gSwitch, Ux4gSwitchSize } from '../components/switch/Switch'; export const SwitchShowcase: React.FC = () => { const theme = useUx4gTheme(); // Basic toggles state const [wifiChecked, setWifiChecked] = useState(true); const [bluetoothChecked, setBluetoothChecked] = useState(false); const [airplaneChecked, setAirplaneChecked] = useState(false); // Sizes state const [sizeChecked, setSizeChecked] = useState(true); // Label positions state const [leftLabelChecked, setLeftLabelChecked] = useState(false); const [bothSidesChecked, setBothSidesChecked] = useState(true); const [noLabelChecked, setNoLabelChecked] = useState(true); // Description Status Variants state const [helperChecked, setHelperChecked] = useState(true); const [errorChecked, setErrorChecked] = useState(false); const [warningChecked, setWarningChecked] = useState(true); const [successChecked, setSuccessChecked] = useState(true); // Standalone No-Label Switches state const [noLabelS, setNoLabelS] = useState(false); const [noLabelM, setNoLabelM] = useState(true); const [noLabelL, setNoLabelL] = useState(true); const [standaloneRow1, setStandaloneRow1] = useState(true); const [standaloneRow2, setStandaloneRow2] = useState(false); return ( Ux4gSwitch (`Ux4gSwitchProps`) Complete React Native port of Flutter `toggle.dart` (`Ux4gSwitch`), supporting exact sizes, label positioning, secondary labels, and status variants (`helper`, `error`, `warning`, `success`). {/* 1. Basic Switch & States (`checked`, `unchecked`, `disabled`) */} 1. Basic Toggle States (`checked`, `unchecked`, `disabled`) {/* 2. Switch Sizes (`Ux4gSwitchSize`) */} 2. Sizes (`s`/`small`, `m`/`medium`, `l`/`large`) {/* 3. Label Positioning (`Ux4gSwitchLabelPosition`) */} 3. Label Positioning (`right`, `left`, `bothSides`, `noLabel`) No Label (`labelPosition='noLabel'`) Only renders the interactive switch box without any text column wrapper. {/* 4. Description Status Variants (`helper`, `error`, `warning`, `success`) */} 4. Description Status Variants (`descriptionVariant`) {/* 5. Standalone Switches Without Any Label (`labelPosition='noLabel'` / No Label Prop) */} 5. Standalone Switches Without Any Label (`noLabel`) All Sizes Without Label (`s`, `m`, `l`) When `labelPosition='noLabel'` or when `label` and `description` props are omitted, the component renders only the standalone switch box cleanly without any text wrapper or extra margins. Small (`s` / 32x18px) Medium (`m` / 40x22px) Large (`l` / 48x28px) Standalone Switch Toolbar Row (Checked vs Unchecked vs Disabled) Compact standalone toggles placed side-by-side in custom horizontal toolbar layouts: Active On Active Off Disabled On Disabled Off ); }; const styles = StyleSheet.create({ container: { flex: 1, }, contentContainer: { padding: 16, paddingBottom: 40, }, header: { paddingBottom: 16, marginBottom: 20, borderBottomWidth: 1, }, title: { fontSize: 24, fontWeight: '700', marginBottom: 6, }, subtitle: { fontSize: 14, lineHeight: 20, }, section: { marginBottom: 24, }, sectionTitle: { fontSize: 18, fontWeight: '700', marginBottom: 12, }, card: { borderWidth: 1, borderRadius: 12, padding: 16, }, spacer: { height: 20, }, cardSubheading: { fontSize: 14, fontWeight: '600', marginBottom: 8, }, noLabelRow: { flexDirection: 'row', alignItems: 'center', }, standaloneGridRow: { flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center', paddingVertical: 12, }, standaloneGridItem: { alignItems: 'center', }, standaloneLabelText: { fontSize: 13, fontWeight: '500', marginTop: 8, }, standaloneToolbarRow: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center', paddingTop: 8, }, toolbarToggleWrapper: { flexDirection: 'row', alignItems: 'center', marginRight: 12, marginBottom: 12, }, toolbarText: { fontSize: 12, marginLeft: 8, }, });