import React, { useState } from 'react'; import { View, Text, StyleSheet, Modal, Platform, KeyboardAvoidingView, TouchableOpacity, ActivityIndicator, TextInput, ViewStyle } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import Animated, { FadeInDown } from 'react-native-reanimated'; import { GlassCard, GlassButton } from '../../../components/ui'; import { colors, spacing, radius, typography } from '../../../theme'; interface RelationshipDangerZoneProps { onResetProgress?: () => Promise; onDeleteRelationship?: () => Promise; } /** * Danger zone component specifically for relationship-related actions. * Does NOT include delete account - that's in AccountScreen. */ export const RelationshipDangerZone: React.FC = ({ onResetProgress, onDeleteRelationship, }) => { const [showResetModal, setShowResetModal] = useState(false); const [showDeleteRelationshipModal, setShowDeleteRelationshipModal] = useState(false); const [confirmText, setConfirmText] = useState(""); const [isResetting, setIsResetting] = useState(false); const [isDeletingRelationship, setIsDeletingRelationship] = useState(false); const handleResetProgress = async () => { if (confirmText !== "RESET" || !onResetProgress) return; setIsResetting(true); try { await onResetProgress(); setShowResetModal(false); setConfirmText(""); } catch (error) { // Error handling relies on parent } finally { setIsResetting(false); } }; const closeResetModal = () => { if (!isResetting) { setShowResetModal(false); setConfirmText(""); } }; const handleDeleteRelationship = async () => { if (confirmText !== "DELETE" || !onDeleteRelationship) return; setIsDeletingRelationship(true); try { await onDeleteRelationship(); setShowDeleteRelationshipModal(false); setConfirmText(""); } catch (error) { // Error handling relies on parent } finally { setIsDeletingRelationship(false); } }; const closeRelationshipModal = () => { if (!isDeletingRelationship) { setShowDeleteRelationshipModal(false); setConfirmText(""); } }; return ( <> Danger Zone {/* Reset Progress */} {onResetProgress && ( Reset Progress Start fresh by clearing all swipes, matches, and chats. Your partner connection stays. setShowResetModal(true)} activeOpacity={0.7} > Reset )} {/* Delete Relationship */} {onDeleteRelationship && ( Delete Relationship End your connection and delete all shared data. Your account will remain. setShowDeleteRelationshipModal(true)} icon={} style={styles.dangerButton} > Delete )} {/* Reset Progress Modal */} Reset Progress? This will permanently delete: All your swipes All matches All chat messages Your partner connection stays Type RESET to confirm: Cancel {isResetting ? ( ) : ( <> Reset )} {/* Delete Relationship Modal */} Delete Relationship Data? This action cannot be undone. This will permanently delete: Your couple connection All matches and responses All chat messages All shared photos Type DELETE to confirm: Cancel {isDeletingRelationship ? ( ) : ( <> Delete )} ); }; const styles = StyleSheet.create({ section: { paddingHorizontal: spacing.lg, marginBottom: spacing.lg, }, dangerSectionTitle: { ...typography.caption1, color: colors.error, textTransform: "uppercase", letterSpacing: 1.5, marginBottom: spacing.sm, marginLeft: spacing.xs, }, warningCard: { borderColor: 'rgba(243, 156, 18, 0.3)', borderWidth: 1, }, warningIconContainer: { width: 44, height: 44, borderRadius: 22, backgroundColor: 'rgba(243, 156, 18, 0.15)', justifyContent: "center", alignItems: "center", }, warningButton: { flexDirection: "row", alignItems: "center", justifyContent: "center", backgroundColor: 'rgba(243, 156, 18, 0.15)', paddingVertical: spacing.sm, paddingHorizontal: spacing.md, borderRadius: radius.md, borderWidth: 1, borderColor: 'rgba(243, 156, 18, 0.3)', gap: spacing.xs, alignSelf: "flex-end", }, warningButtonText: { ...typography.subhead, color: colors.warning, fontWeight: "600", }, dangerCard: { borderColor: 'rgba(231, 76, 60, 0.3)', borderWidth: 1, }, dangerCardSpacing: { marginTop: spacing.md, }, dangerContent: { gap: spacing.md, }, dangerInfo: { flexDirection: "row", alignItems: "flex-start", }, dangerIconContainer: { width: 44, height: 44, borderRadius: 22, backgroundColor: colors.errorLight, justifyContent: "center", alignItems: "center", }, dangerTextContainer: { flex: 1, marginLeft: spacing.md, }, dangerTitle: { ...typography.headline, color: colors.text, marginBottom: spacing.xs, }, dangerDescription: { ...typography.subhead, color: colors.textSecondary, lineHeight: 20, }, dangerButton: { alignSelf: "flex-end", }, // Modal styles modalOverlay: { flex: 1, backgroundColor: "rgba(0, 0, 0, 0.7)", justifyContent: "center", alignItems: "center", padding: spacing.lg, }, modalContent: { width: "100%", maxWidth: 400, padding: spacing.xl, backgroundColor: colors.backgroundLight, borderRadius: radius.xl, borderWidth: 1, borderColor: colors.border, }, modalHeader: { alignItems: "center", marginBottom: spacing.lg, }, modalIconContainer: { width: 64, height: 64, borderRadius: 32, backgroundColor: colors.errorLight, justifyContent: "center", alignItems: "center", marginBottom: spacing.md, }, modalTitle: { ...typography.title2, color: colors.text, textAlign: "center", }, modalDescription: { ...typography.body, color: colors.textSecondary, marginBottom: spacing.lg, textAlign: "center", }, deleteList: { backgroundColor: "rgba(231, 76, 60, 0.1)", borderRadius: radius.lg, padding: spacing.md, gap: spacing.sm, marginBottom: spacing.xl, borderWidth: 1, borderColor: 'rgba(231, 76, 60, 0.2)', }, warningList: { backgroundColor: "rgba(243, 156, 18, 0.1)", borderRadius: radius.lg, padding: spacing.md, gap: spacing.sm, marginBottom: spacing.md, borderWidth: 1, borderColor: 'rgba(243, 156, 18, 0.2)', }, keepList: { backgroundColor: "rgba(46, 204, 113, 0.1)", borderRadius: radius.lg, padding: spacing.md, gap: spacing.sm, marginBottom: spacing.xl, borderWidth: 1, borderColor: 'rgba(46, 204, 113, 0.2)', }, warningModalIconContainer: { width: 64, height: 64, borderRadius: 32, backgroundColor: 'rgba(243, 156, 18, 0.15)', justifyContent: "center", alignItems: "center", marginBottom: spacing.md, }, warningKeyword: { fontWeight: "bold", color: colors.warning, }, warningInput: { backgroundColor: colors.background, borderRadius: radius.md, borderWidth: 1, borderColor: colors.warning, padding: spacing.md, ...typography.body, color: colors.text, textAlign: 'center', marginBottom: spacing.xl, }, warningActionButton: { flex: 1, backgroundColor: colors.warning, paddingVertical: spacing.md, borderRadius: radius.md, alignItems: "center", flexDirection: "row", justifyContent: "center", gap: spacing.xs, }, deleteListItem: { flexDirection: "row", alignItems: "center", gap: spacing.sm, }, deleteListText: { ...typography.subhead, color: colors.text, }, confirmLabel: { ...typography.subhead, color: colors.textSecondary, marginBottom: spacing.xs, textAlign: "center", }, confirmKeyword: { fontWeight: "bold", color: colors.error, }, confirmInput: { backgroundColor: colors.background, borderRadius: radius.md, borderWidth: 1, borderColor: colors.error, padding: spacing.md, ...typography.body, color: colors.text, textAlign: 'center', marginBottom: spacing.xl, }, modalButtons: { flexDirection: "row", gap: spacing.md, }, cancelButton: { flex: 1, backgroundColor: colors.background, paddingVertical: spacing.md, borderRadius: radius.md, alignItems: "center", borderWidth: 1, borderColor: colors.border, }, cancelButtonText: { ...typography.body, color: colors.textSecondary, fontWeight: "600", }, deleteButton: { flex: 1, backgroundColor: colors.error, paddingVertical: spacing.md, borderRadius: radius.md, alignItems: "center", flexDirection: "row", justifyContent: "center", gap: spacing.xs, }, deleteButtonDisabled: { opacity: 0.5, }, deleteButtonText: { ...typography.body, color: colors.text, fontWeight: "600", }, }); export default RelationshipDangerZone;