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 GOAL_OPTIONS = [ { id: 'identify', icon: 'scan-outline' as const }, { id: 'care', icon: 'water-outline' as const }, { id: 'collection', icon: 'albums-outline' as const }, { id: 'learn', icon: 'book-outline' as const }, ]; export default function OnboardingGoalScreen() { const router = useRouter(); const posthog = usePostHog(); const { session, isDarkMode, colorPalette, t } = useApp(); const colors = useColors(isDarkMode, colorPalette); const [selectedGoal, setSelectedGoal] = useState(null); const goalLabels = useMemo( () => ({ identify: t.goalOptionIdentify, care: t.goalOptionCare, collection: t.goalOptionCollection, learn: t.goalOptionLearn, }), [t.goalOptionCare, t.goalOptionCollection, t.goalOptionIdentify, t.goalOptionLearn], ); const finish = (goal: string | null) => { if (session?.userId && goal) { OnboardingProgressService.setPrimaryGoal(session.userId, goal); } posthog.capture('onboarding_goal_completed', { goal: goal ?? 'skipped', }); router.replace('/onboarding/experience'); }; return ( {t.goalOnboardingTitle} {t.goalOnboardingSubtitle} {GOAL_OPTIONS.map((option) => { const isActive = selectedGoal === option.id; return ( setSelectedGoal(option.id)} activeOpacity={0.85} > {goalLabels[option.id as keyof typeof goalLabels]} {isActive && } ); })} finish(null)} > {t.goalOnboardingSkip} finish(selectedGoal)} disabled={!selectedGoal} > {t.goalOnboardingContinue} ); } 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' }, });