import React from 'react'; import { View, StyleSheet, Text } from 'react-native'; import Form from '../index'; import Button from '../../Button'; import { ScrollView } from 'react-native'; import BottomSafeArea from '../../BottomSafeArea'; import { Fill, Toast } from '@xrnjs/ui'; import Card from '_global/Card'; import Options from '../../Options'; import { IconXFrontside1, IconXBackside1, } from '../../../icons'; type FormData = { withdrawMethod: string; paymentMethods: string[]; cardType: string; theme: string; currency: string[]; plan: string; region: string; features: string[]; }; const OptionsExamplesDemo: React.FC = () => { const form = Form.useForm({ defaultValues: { withdrawMethod: '', paymentMethods: [], cardType: '', theme: '', currency: [], plan: '', region: '', features: [], }, }); const [regionFixed, setRegionFixed] = React.useState('eu'); const onSubmit = (data: FormData) => { console.log('Form submitted:', data); Toast( `提交成功!\n提现方式: ${ data.withdrawMethod }\n支付方式: ${data.paymentMethods.join(', ')}` ); }; const onError = (errors: Record) => { console.log('Form errors:', errors); }; return ( {/* 组合用法示例 */} { Toast(`${option.label} 暂不可用`); }} /> , }, { label: '深色', description: '护眼模式', value: 'dark', icon: , }, { label: '自动', description: '跟随系统', value: 'auto', }, ]} /> {/* 快捷用法示例 */} { if (!value || value.length === 0) { return '请至少选择一种支付方式'; } if (value.includes('crypto') && !value.includes('bank')) { return '选择加密货币支付需要同时支持银行卡'; } return true; }, }} multiple columns={2} showIcon style={styles.optionsFullWidth} fullColumn options={[ { label: '银行卡', description: '借记卡/信用卡', value: 'bank', }, { label: '支付宝', description: '余额/花呗', value: 'alipay', }, { label: '微信支付', description: '零钱/银行卡', value: 'wechat', }, { label: '加密货币', description: 'USDT/BTC', value: 'crypto', }, ]} /> {/* 图片选项示例 */} { Toast('定制版套餐请联系我们的销售团队'); }} /> {/* 高级配置示例 */} { if (!value || value.length === 0) { return '请至少选择一种货币'; } if (value.length > 5) { return '最多只能选择5种货币'; } return true; }, }} multiple showIcon mode="horizontal" gapHorizontal={8} gapVertical={12} iconProps={{ size: 20 }} optionStyle={styles.currencyOptionStyle} options={[ { label: 'USD', description: '美元', value: 'usd', }, { label: 'EUR', description: '欧元', value: 'eur', }, { label: 'CNY', description: '人民币', value: 'cny', }, { label: 'JPY', description: '日元', value: 'jpy', }, { label: 'GBP', description: '英镑', value: 'gbp', }, { label: 'HKD', description: '港币', value: 'hkd', }, ]} /> {/* 禁用状态示例 */} { if ( value && value.includes('experimental') && value.length === 1 ) { return '实验性功能建议配合其他功能一起使用'; } return true; }, }} multiple showIcon mode="vertical" columns={2} style={styles.optionsFullWidth} fullColumn options={[ { label: '智能推荐', description: '基于AI的内容推荐', value: 'ai-recommend', }, { label: '语音控制', description: '语音操作界面', value: 'voice-control', disabled: true, }, { label: '手势识别', description: '手势操作支持', value: 'gesture', disabled: true, }, { label: '实验性功能', description: '最新测试功能', value: 'experimental', }, ]} onDisabledPress={(option) => { Toast(`${option.label} 功能即将上线,敬请期待!`); }} /> 当前值:{regionFixed} setRegionFixed(v as string)} /> ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#f5f5f5', }, scrollContainer: { flex: 1, padding: 20, paddingBottom: 0, }, cardStyle: { marginBottom: 16, }, fixedButtonContainer: { backgroundColor: '#fff', paddingHorizontal: 20, paddingTop: 16, paddingBottom: 30, borderTopWidth: 1, borderTopColor: '#e5e5e5', flexDirection: 'row', justifyContent: 'center', shadowColor: '#000', shadowOffset: { width: 0, height: -2, }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 8, }, buttonSpacer: { width: 20, }, optionsFullWidth: { paddingHorizontal: 0, }, planImageStyle: { width: 60, height: 60, borderRadius: 8, }, planOptionStyle: { paddingVertical: 12, paddingHorizontal: 8, }, currencyOptionStyle: { minWidth: 80, paddingVertical: 8, }, }); export default OptionsExamplesDemo;