import { useState } from 'react'; import { View, Text, Switch, ActivityIndicator } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; type Props = { icon: React.ComponentProps['name']; title: string; subtitle: string; /** Wenn true: zeigt grünen Check statt Switch (Layer ist an). */ active: boolean; /** Aktivierung (zeigt System-Dialog). UI hat nur read-on-flow, * Toggle-off ist nicht hier — passiert nur über Cooldown. */ onActivate: () => Promise<{ enabled: boolean; error?: string }>; /** Optional: Hinweistext unter Subtitle. Wird OBEN angezeigt wenn inactive * (warnung vor Aktivierung) UND UNTEN wenn active+lockedHint (Hinweis * wo man's wieder deaktiviert — bei Family-Controls/Screen-Time z.B.). */ warning?: string; /** Optional: Hinweis-Text wenn active=true (z.B. "Nur in iOS-Settings * deaktivierbar"). Macht die System-managed-Natur klar. */ lockedHint?: string; }; export function LayerSwitchCard({ icon, title, subtitle, active, onActivate, warning, lockedHint }: Props) { const [busy, setBusy] = useState(false); async function handleSwitch(v: boolean) { if (!v || active || busy) return; setBusy(true); try { await onActivate(); } finally { setBusy(false); } } const iconBg = active ? '#dcfce7' : '#f5f5f5'; const iconColor = active ? '#16a34a' : '#737373'; const borderColor = active ? '#86efac' : '#e5e5e5'; const cardBg = active ? '#f0fdf4' : '#ffffff'; return ( {title} {subtitle} {busy ? ( ) : active ? ( ) : ( )} {warning && !active && ( {warning} )} {lockedHint && active && ( {lockedHint} )} ); }