import React, { useState } from 'react'; import { View, Text, TouchableOpacity, ScrollView, StyleSheet, Modal } from 'react-native'; import { useThemeContext } from './ThemeProvider'; import { useTranslation } from '../src/i18n'; import { borderRadius } from '../constants/theme'; interface CookieBannerProps { onConsent: (consents: { essential: boolean; analytics: boolean; preferences: boolean; health_data: boolean }) => void; onPrivacyPress: () => void; } export default function CookieBanner({ onConsent, onPrivacyPress }: CookieBannerProps) { const { colors } = useThemeContext(); const { t } = useTranslation(); const [categories, setCategories] = useState({ analytics: false, preferences: false, health_data: false }); const toggleCategory = (cat: keyof typeof categories) => { setCategories(prev => ({ ...prev, [cat]: !prev[cat] })); }; const categoryKeys = ['analytics', 'preferences', 'health_data'] as const; return ( {t('cookie_banner.title')} {t('cookie_banner.description')} {t('cookie_banner.category.essential')} {t('cookie_banner.category.essential_desc')} ON {categoryKeys.map(cat => ( {t(`cookie_banner.category.${cat}`)} {t(`cookie_banner.category.${cat}_desc`)} toggleCategory(cat)} activeOpacity={0.7}> ))} onConsent({ essential: true, analytics: true, preferences: true, health_data: true })}> {t('cookie_banner.accept_all')} onConsent({ essential: true, analytics: false, preferences: false, health_data: false })}> {t('cookie_banner.reject_optional')} onConsent({ essential: true, ...categories })}> {t('cookie_banner.save')} {t('cookie_banner.more_info')} → ); } const styles = StyleSheet.create({ overlay: { flex: 1, backgroundColor: 'rgba(0,0,0,0.5)', justifyContent: 'flex-end' }, container: { borderTopLeftRadius: borderRadius.lg, borderTopRightRadius: borderRadius.lg, padding: 20, maxHeight: '85%' }, title: { fontSize: 18, fontWeight: '700', marginBottom: 8 }, desc: { fontSize: 14, lineHeight: 20, marginBottom: 16 }, categories: { gap: 10, marginBottom: 16 }, category: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', padding: 12, borderRadius: borderRadius.md, gap: 12 }, categoryInfo: { flex: 1, gap: 2 }, categoryName: { fontSize: 14, fontWeight: '600' }, categoryDesc: { fontSize: 12, lineHeight: 16 }, toggle: { width: 44, height: 24, borderRadius: 12, backgroundColor: '#ccc', justifyContent: 'center', alignItems: 'center', padding: 2 }, toggleLocked: { opacity: 0.6 }, toggleLabel: { fontSize: 9, fontWeight: '700', color: 'white' }, toggleThumb: { width: 20, height: 20, borderRadius: 10, backgroundColor: 'white', alignSelf: 'flex-start' }, toggleThumbOn: { alignSelf: 'flex-end' }, actions: { gap: 8, marginBottom: 12 }, btn: { paddingVertical: 12, borderRadius: 999, alignItems: 'center' }, btnText: { fontSize: 14, fontWeight: '600' }, moreInfo: { textAlign: 'center', fontSize: 12, textDecorationLine: 'underline' }, });