// FormSectionDemo.tsx import React, { useState } from 'react'; import { Platform, PlatformColor, StyleSheet, Text, View } from 'react-native'; import { Checkbox, FormSection, SelectionMenu, Switch, TextField, } from 'react-native-platform-components'; import { useDemoColors } from './DemoUI'; // The grouped forms of Settings and Contacts on iOS: TextField rows with the // label in a leading column, settings rows and a header and footer on a // rounded card. Android and web show the same children as they are. export function FormSectionDemo(): React.JSX.Element { const colors = useDemoColors(); const [name, setName] = useState(''); const [phone, setPhone] = useState(''); const [overnight, setOvernight] = useState(false); const [memo, setMemo] = useState(false); const [memoText, setMemoText] = useState(''); const [receipt, setReceipt] = useState(true); const [signature, setSignature] = useState(false); const [carrier, setCarrier] = useState('usps'); return ( {/* A row that comes and goes: the separators follow */} {memo && ( )} {/* Any view is a row: your own label beside a menu */} Carrier setCarrier(data)} /> {Platform.OS === 'ios' ? "The second section's header stops growing at twice the default text size (maxFontSizeMultiplier)." : 'Android shows the rows as they are, with the header and footer as text.'} ); } const CARRIERS = [ { label: 'USPS', data: 'usps' }, { label: 'UPS', data: 'ups' }, { label: 'FedEx', data: 'fedex' }, ]; const styles = StyleSheet.create({ // iOS: the grouped background the card sits on, out to the screen's edges page: Platform.select({ ios: { marginHorizontal: -20, marginTop: 8, paddingHorizontal: 20, paddingVertical: 20, gap: 32, backgroundColor: PlatformColor('systemGroupedBackground'), }, default: { marginTop: 8, gap: 24 }, }), // Android and web: the rows as they are, spaced out section: Platform.select({ ios: {}, default: { gap: 8 } }), menuRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, }, menuLabel: { flexShrink: 1, fontSize: 17 }, note: { fontSize: 12, paddingHorizontal: 4 }, });