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 für commit-heavy Layer. */ warning?: string; }; export function LayerSwitchCard({ icon, title, subtitle, active, onActivate, warning }: 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} )} ); }