import { View, Text, TouchableOpacity, ScrollView, ActionSheetIOS, Platform, Alert } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { Ionicons } from '@expo/vector-icons'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useColors } from '../../lib/theme'; import { FormSheet } from '../FormSheet'; type Props = { visible: boolean; domain: string; onClose: () => void; onConfirmRemove: () => Promise; }; /** * 3-Click Friction-Gate vor dem Entfernen einer eigenen Web-Domain. * * Selbes UX-Muster wie DeactivationExplainerSheet: * Click 1: User tippt Papierkorb-Icon → Sheet öffnet sich (dieser Component) * Click 2: User liest Kontext → primäre Aktion = "Behalten" (Deflect) * sekundäre Aktion = "Trotzdem entfernen" (klein, destructive) * Click 3: ActionSheet / Alert zur finalen Bestätigung → removeDomain() * * Kein Cooldown wird gestartet — nur der Domain-Delete-Endpoint. * Die Verzögerung entsteht durch das bewusste 3-Schritt-UX, nicht durch * eine zeitliche Sperre (anders als beim Schutz-Deaktivieren). */ export function RemoveDomainSheet({ visible, domain, onClose, onConfirmRemove }: Props) { const { t } = useTranslation(); const colors = useColors(); const insets = useSafeAreaInsets(); const [submitting, setSubmitting] = useState(false); function showFinalConfirm() { const title = t('blocker.remove_domain_actionsheet_title'); const message = t('blocker.remove_domain_actionsheet_message', { domain }); const cancelLabel = t('common.cancel'); const confirmLabel = t('blocker.remove_domain_confirm_cta'); if (Platform.OS === 'ios') { ActionSheetIOS.showActionSheetWithOptions( { title, message, options: [cancelLabel, confirmLabel], destructiveButtonIndex: 1, cancelButtonIndex: 0, }, async (idx) => { if (idx === 1) await runRemove(); }, ); } else { Alert.alert(title, message, [ { text: cancelLabel, style: 'cancel' }, { text: confirmLabel, style: 'destructive', onPress: runRemove }, ]); } } async function runRemove() { setSubmitting(true); try { await onConfirmRemove(); onClose(); } catch (e: any) { Alert.alert(t('common.error'), e?.message ?? t('blocker.remove_domain_failed')); } finally { setSubmitting(false); } } return ( {t('blocker.remove_domain_title')} {domain} {t('blocker.remove_domain_intro')} {t('blocker.remove_domain_keep_cta')} {submitting ? t('blocker.remove_domain_removing') : t('blocker.remove_domain_remove_anyway')} ); } function BulletRow({ icon, title, text, }: { icon: React.ComponentProps['name']; title: string; text: string; }) { const colors = useColors(); return ( {title} {text} ); }