import React, { useMemo, useState } from 'react'; import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useRouter } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { usePostHog } from 'posthog-react-native'; import { ThemeBackdrop } from '../../components/ThemeBackdrop'; import { useColors } from '../../constants/Colors'; import { useApp } from '../../context/AppContext'; import { OnboardingProgressService } from '../../services/onboardingProgressService'; const EXPERIENCE_OPTIONS = [ { id: 'beginner', icon: 'leaf-outline' as const }, { id: 'intermediate', icon: 'sunny-outline' as const }, { id: 'advanced', icon: 'flask-outline' as const }, ]; export default function OnboardingExperienceScreen() { const router = useRouter(); const posthog = usePostHog(); const { session, isDarkMode, colorPalette, t } = useApp(); const colors = useColors(isDarkMode, colorPalette); const [selectedLevel, setSelectedLevel] = useState(null); const levelLabels = useMemo( () => ({ beginner: t.experienceOptionBeginner, intermediate: t.experienceOptionIntermediate, advanced: t.experienceOptionAdvanced, }), [t.experienceOptionAdvanced, t.experienceOptionBeginner, t.experienceOptionIntermediate], ); const finish = (level: string | null) => { if (session?.userId && level) { OnboardingProgressService.setExperienceLevel(session.userId, level); } posthog.capture('onboarding_experience_completed', { experience_level: level ?? 'skipped', }); router.replace('/(tabs)'); }; return ( {t.experienceOnboardingTitle} {t.experienceOnboardingSubtitle} {EXPERIENCE_OPTIONS.map((option) => { const isActive = selectedLevel === option.id; return ( setSelectedLevel(option.id)} activeOpacity={0.85} > {levelLabels[option.id as keyof typeof levelLabels]} {isActive && } ); })} finish(null)} > {t.experienceOnboardingSkip} finish(selectedLevel)} disabled={!selectedLevel} > {t.experienceOnboardingContinue} ); } const styles = StyleSheet.create({ container: { flex: 1 }, safeArea: { flex: 1, paddingHorizontal: 20, paddingTop: 24, paddingBottom: 20 }, header: { alignItems: 'center', gap: 10, marginBottom: 28 }, headerIcon: { width: 64, height: 64, borderRadius: 32, alignItems: 'center', justifyContent: 'center' }, title: { fontSize: 28, fontWeight: '800', textAlign: 'center', lineHeight: 32 }, subtitle: { fontSize: 14, textAlign: 'center', lineHeight: 20, maxWidth: 320 }, options: { gap: 12, flex: 1 }, optionCard: { minHeight: 64, borderRadius: 18, borderWidth: 1.5, flexDirection: 'row', alignItems: 'center', paddingHorizontal: 16, gap: 12, }, optionIcon: { width: 36, height: 36, borderRadius: 18, alignItems: 'center', justifyContent: 'center' }, optionLabel: { flex: 1, fontSize: 15, fontWeight: '600' }, footer: { flexDirection: 'row', gap: 12, marginTop: 16 }, secondaryBtn: { flex: 1, height: 52, borderRadius: 16, borderWidth: 1.5, alignItems: 'center', justifyContent: 'center' }, secondaryBtnText: { fontSize: 15, fontWeight: '600' }, primaryBtn: { flex: 1.2, height: 52, borderRadius: 16, alignItems: 'center', justifyContent: 'center' }, primaryBtnText: { fontSize: 15, fontWeight: '700' }, });