import React from 'react'; import { View, TextInput, TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native'; import { WalletType } from 'rnwalletman'; import { useOTPBind } from '../hooks/useOTPBind'; interface OTPBindUIProps { walletType: WalletType; title: string; otpLength?: number; mobileLength?: number; onRequestOTP: (walletType: WalletType, params: any) => Promise; onVerifyOTP: (walletType: WalletType, params: any) => Promise; onSuccess: (result: any) => void; onError: (error: string) => void; isDebug: boolean; additionalParams?: any; } export const OTPBindUI: React.FC = ({ walletType, title, otpLength = 6, mobileLength = 10, onRequestOTP, onVerifyOTP, onSuccess, onError, isDebug, additionalParams = {}, }) => { const [state, actions] = useOTPBind( walletType, { onRequestOTP, onVerifyOTP, onSuccess, onError, isDebug, }, { otpLength, mobileLength, additionalParams, } ); if (state.step === 'processing') { return ( 处理中... ); } return ( {title} {state.step === 'mobile' && ( <> {state.loading ? ( ) : ( 获取验证码 )} )} {state.step === 'otp' && ( <> 验证码已发送至 {state.mobile} {state.loading ? ( ) : ( 验证并绑定 )} 重新输入手机号 )} ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'rgba(0,0,0,0.8)', justifyContent: 'center', alignItems: 'center', }, form: { width: '80%', backgroundColor: '#fff', borderRadius: 10, padding: 20, }, title: { fontSize: 20, fontWeight: 'bold', textAlign: 'center', marginBottom: 20, }, input: { borderWidth: 1, borderColor: '#ddd', borderRadius: 5, padding: 12, fontSize: 16, marginBottom: 15, }, button: { backgroundColor: '#007AFF', borderRadius: 5, padding: 15, alignItems: 'center', }, buttonDisabled: { backgroundColor: '#ccc', }, buttonText: { color: '#fff', fontSize: 16, fontWeight: 'bold', }, linkButton: { marginTop: 10, alignItems: 'center', }, linkText: { color: '#007AFF', fontSize: 14, }, hint: { fontSize: 14, color: '#666', marginBottom: 10, textAlign: 'center', }, processingText: { color: '#fff', fontSize: 16, marginTop: 10, }, });