import React, { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator, Platform } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import type { NavigationProp } from '@react-navigation/native'; import { useDevice } from '../contexts/DeviceContext'; export function DeviceSetupScreen() { const navigation = useNavigation>(); const { register, deviceName } = useDevice(); const [name, setName] = useState(deviceName || `${Platform.OS.charAt(0).toUpperCase() + Platform.OS.slice(1)} de ${Platform.OS === 'ios' ? 'l\'utilisateur' : 'utilisateur'}`); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const handleRegister = async () => { if (!name.trim()) return; setIsLoading(true); setError(null); try { await register(name.trim()); navigation.reset({ index: 0, routes: [{ name: 'Home' }] }); } catch (err: any) { setError(err?.message || "Échec de l'enregistrement"); } finally { setIsLoading(false); } }; return ( 📱 Enregistrement du device Ce device doit être enregistré comme espace de stockage pour utiliser VaultDrop. {error && {error}} {isLoading ? ( ) : ( Enregistrer )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#f5f5f5', justifyContent: 'center', padding: 24, }, content: { backgroundColor: '#fff', borderRadius: 16, padding: 24, alignItems: 'center', gap: 16, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 8, elevation: 4, }, icon: { fontSize: 48, }, title: { fontSize: 22, fontWeight: '700', color: '#333', textAlign: 'center', }, subtitle: { fontSize: 15, color: '#666', textAlign: 'center', lineHeight: 22, }, input: { width: '100%', borderWidth: 1, borderColor: '#ddd', borderRadius: 8, paddingHorizontal: 14, paddingVertical: 12, fontSize: 16, color: '#333', }, error: { color: '#E53935', fontSize: 14, textAlign: 'center', }, button: { width: '100%', backgroundColor: '#1976D2', paddingVertical: 14, borderRadius: 8, alignItems: 'center', }, buttonDisabled: { backgroundColor: '#ccc', }, buttonText: { color: '#fff', fontSize: 16, fontWeight: '600', }, });