import React from "react"; import { ScrollView, View } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { useNavigation } from "../../context/NavigationContext"; import { StatusBar } from "expo-status-bar"; import { Ionicons } from "@expo/vector-icons"; import { useColorScheme } from "nativewind"; import Toast from "react-native-toast-message"; import { MutedText } from "../../components/text"; import { Button } from "../../components/button"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "../../components/card"; import AuthService from "../../services/auth.service"; import { useAuth } from "../../hooks/useAuth"; import { useAppConfig } from "../../context/AppConfigContext"; import { getErrorMessage } from "../../utils/error"; export interface ImportDataScreenProps { /** * Optional custom import flow. When provided, the screen renders this * instead of the default skip-only UI — call `onComplete` after a * successful import and the screen advances onboarding + navigates to * home. Vault wires its `parseBitwardenExport` + `VaultFacade` + key * manager unlock flow through this slot. */ renderImport?: (props: { onComplete: () => void; onSkip: () => void }) => React.ReactNode; } export function ImportDataScreen({ renderImport }: ImportDataScreenProps = {}) { const router = useNavigation(); const { refreshUser } = useAuth(); const { appName, routes } = useAppConfig(); const { colorScheme } = useColorScheme(); const isDark = colorScheme === "dark"; const completeAndNavigate = async () => { try { await AuthService.completeOnboarding(); await refreshUser(); router.replace(routes.home); } catch (e: unknown) { Toast.show({ type: "error", text1: getErrorMessage(e, "Failed to complete onboarding"), visibilityTime: 3000, }); } }; if (renderImport) { return ( {renderImport({ onComplete: completeAndNavigate, onSkip: completeAndNavigate })} ); } return ( You're all set Your {appName} account is ready. Continue to start using it. Nothing to migrate here — apps that need a data-import step wire a custom `renderImport` slot. ); } export default ImportDataScreen;