import { useHeaderHeight } from '@react-navigation/elements' import { NativeStackScreenProps } from '@react-navigation/native-stack' import React, { useLayoutEffect } from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' import { cancelCreateOrRestoreAccount } from 'src/account/actions' import AppAnalytics from 'src/analytics/AppAnalytics' import { OnboardingEvents } from 'src/analytics/Events' import Card from 'src/components/Card' import Touchable from 'src/components/Touchable' import CloudCheck from 'src/icons/CloudCheck' import Lock from 'src/icons/Lock' import { KeylessBackupFlow, KeylessBackupOrigin } from 'src/keylessBackup/types' import { nuxNavigationOptions } from 'src/navigator/Headers' import { navigate, navigateClearingStack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import TopBarTextButtonOnboarding from 'src/onboarding/TopBarTextButtonOnboarding' import { useDispatch } from 'src/redux/hooks' import colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Shadow, Spacing } from 'src/styles/styles' type Props = NativeStackScreenProps function ActionCard({ title, description, icon, onPress, testID, }: { title: string description: string icon: React.ReactNode onPress?: () => void testID?: string }) { return ( <> {icon} {title} {description} ) } export default function ImportSelect({ navigation }: Props) { const dispatch = useDispatch() const headerHeight = useHeaderHeight() const { t } = useTranslation() const handleNavigateBack = () => { dispatch(cancelCreateOrRestoreAccount()) AppAnalytics.track(OnboardingEvents.restore_account_cancel) navigateClearingStack(Screens.Welcome) } useLayoutEffect(() => { navigation.setOptions({ headerLeft: () => ( ), headerStyle: { backgroundColor: 'transparent', }, }) }, [navigation]) return ( {t('importSelect.title')} {t('importSelect.description')} } onPress={() => navigate(Screens.SignInWithEmail, { keylessBackupFlow: KeylessBackupFlow.Restore, origin: KeylessBackupOrigin.Onboarding, }) } testID="ImportSelect/CloudBackup" /> } onPress={() => navigate(Screens.ImportWallet, { clean: true })} testID="ImportSelect/Mnemonic" /> ) } ImportSelect.navigationOptions = { ...nuxNavigationOptions, // Prevent swipe back on iOS, users have to explicitly press cancel gestureEnabled: false, } const styles = StyleSheet.create({ card: { alignSelf: 'stretch', flex: 1, padding: 0, backgroundColor: colors.backgroundSecondary, }, cardDescription: { ...typeScale.bodySmall, marginLeft: 28, }, cardTitle: { ...typeScale.labelMedium, color: colors.successPrimary, flex: 1, }, safeArea: { backgroundColor: colors.backgroundPrimary, flex: 1, }, screenDescription: { ...typeScale.bodyMedium, textAlign: 'center', }, screenTitle: { ...typeScale.titleSmall, textAlign: 'center', }, screenTextContainer: { gap: Spacing.Regular16, }, topLine: { alignItems: 'center', flex: 1, flexDirection: 'row', gap: Spacing.Smallest8, }, touchable: { padding: Spacing.Regular16, }, viewContainer: { alignItems: 'center', gap: Spacing.Thick24, padding: Spacing.Thick24, }, })