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; onClose: () => void; /** User triggert "Atmen" → Deflector zur Urge-Page (Click-2 ende, kein Cooldown). */ onBreathe: () => void; /** Click-3 Bestätigung — final destruktive Aktion via ActionSheet. */ onStartCooldown: (reason: string) => Promise; }; /** * Click 2 of 3 (Cooldown-Friction). * * Erklärt was Cooldown bedeutet, bietet [Atmen] als primary Deflector an, * und ein kleines [Cooldown trotzdem starten] das einen nativen ActionSheet * zur finalen Bestätigung öffnet (Click 3). */ export function DeactivationExplainerSheet({ visible, onClose, onBreathe, onStartCooldown, }: Props) { const { t } = useTranslation(); const colors = useColors(); const insets = useSafeAreaInsets(); const [submitting, setSubmitting] = useState(false); function showFinalConfirm() { if (Platform.OS === 'ios') { ActionSheetIOS.showActionSheetWithOptions( { title: t('blocker.deactivation_actionsheet_title'), message: t('blocker.deactivation_actionsheet_message'), options: [t('common.cancel'), t('blocker.deactivation_start_cta')], destructiveButtonIndex: 1, cancelButtonIndex: 0, }, async (idx) => { if (idx === 1) await runCooldown(); }, ); } else { // Android Fallback Alert.alert( t('blocker.deactivation_actionsheet_title'), t('blocker.deactivation_actionsheet_message'), [ { text: t('common.cancel'), style: 'cancel' }, { text: t('blocker.deactivation_start_cta'), style: 'destructive', onPress: runCooldown }, ], ); } } async function runCooldown() { setSubmitting(true); try { await onStartCooldown('user_requested_deactivation'); onClose(); } catch (e: any) { Alert.alert(t('common.error'), e?.message ?? t('blocker.deactivation_failed_msg')); } finally { setSubmitting(false); } } return ( {t('blocker.deactivation_title')} {t('blocker.deactivation_intro')} {/* Was passiert */} {/* Primary Deflector */} {t('blocker.deactivation_breathe_cta')} {/* Destructive secondary */} {submitting ? t('blocker.deactivation_starting') : t('blocker.deactivation_start_anyway')} ); } function BulletRow({ icon, title, text, }: { icon: React.ComponentProps['name']; title: string; text: string; }) { const colors = useColors(); return ( {title} {text} ); }