/** * Account Created confirmation screen — dark minimalist. * Показывает адрес + x25519, кнопки copy и export (share) key.json. */ import React, { useState } from 'react'; import { View, Text, ScrollView, Alert, Pressable, Share } from 'react-native'; import { router } from 'expo-router'; import * as Clipboard from 'expo-clipboard'; import { Ionicons } from '@expo/vector-icons'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useStore } from '@/lib/store'; import { Header } from '@/components/Header'; export default function AccountCreatedScreen() { const insets = useSafeAreaInsets(); const keyFile = useStore(s => s.keyFile); const [copied, setCopied] = useState(null); if (!keyFile) { router.replace('/'); return null; } async function copy(value: string, label: string) { await Clipboard.setStringAsync(value); setCopied(label); setTimeout(() => setCopied(null), 1800); } async function exportKey() { try { const json = JSON.stringify(keyFile, null, 2); // Используем плоский Share API — без записи во временный файл. // Получатель (mail, notes, etc.) получит текст целиком; юзер сам // сохраняет как .json если нужно. await Share.share({ message: json, title: 'DChain key file', }); } catch (e: any) { Alert.alert('Export failed', e?.message ?? 'Unknown error'); } } return (
{/* Success badge */} Welcome aboard Keys have been generated and stored securely. {/* Address */} copy(keyFile.pub_key, 'address')} /> {/* X25519 */} copy(keyFile.x25519_pub, 'x25519')} /> {/* Backup */} Backup your key file Export it now and store somewhere safe — password managers, cold storage, printed paper. If you lose it, you lose the account. ({ alignItems: 'center', justifyContent: 'center', paddingVertical: 10, borderRadius: 999, backgroundColor: pressed ? '#2a1f0f' : '#1a1409', borderWidth: 1, borderColor: 'rgba(240,179,90,0.35)', })} > Export key.json {/* Continue */} router.replace('/(app)/chats' as never)} style={({ pressed }) => ({ alignItems: 'center', justifyContent: 'center', paddingVertical: 14, borderRadius: 999, marginTop: 20, backgroundColor: pressed ? '#1a8cd8' : '#1d9bf0', })} > Open messenger ); } function KeyCard({ title, value, copied, onCopy, }: { title: string; value: string; copied: boolean; onCopy: () => void; }) { return ( {title} {value} ({ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingVertical: 9, borderRadius: 999, marginTop: 10, backgroundColor: pressed ? '#1a1a1a' : '#111111', borderWidth: 1, borderColor: '#1f1f1f', })} > {copied ? 'Copied' : 'Copy'} ); }