import React, { useEffect } from 'react';
import { View, StyleSheet, Image } from 'react-native';
import Animated, {
  useSharedValue,
  useAnimatedStyle,
  withDelay,
  withTiming,
  FadeIn,
} from 'react-native-reanimated';
import { Ionicons } from '@expo/vector-icons';
import { colors, spacing } from '../../theme/tokens';
import { H1, Body, Button } from '../../components/ui';
import { t } from '../../i18n';

interface Props { onComplete: () => void }

export function QuizStep6({ onComplete }: Props) {
  const checkScale = useSharedValue(0);

  useEffect(() => {
    checkScale.value = withDelay(300, withTiming(1, { duration: 500 }));
  }, []);

  const checkStyle = useAnimatedStyle(() => ({
    transform: [{ scale: checkScale.value }],
    opacity: checkScale.value,
  }));

  return (
    <View style={styles.container}>
      <Animated.View style={[styles.checkCircle, checkStyle]}>
        <Ionicons name="checkmark" size={48} color="#FFFFFF" />
      </Animated.View>

      <Animated.View entering={FadeIn.delay(500).duration(600)}>
        <H1 align="center" style={styles.title}>
          {t('quiz.step6Title')}
        </H1>
        <Body align="center" style={styles.subtitle} color={colors.neutral[500]}>
          {t('quiz.step6Subtitle')}
        </Body>
      </Animated.View>

      <Animated.View entering={FadeIn.delay(800).duration(600)} style={styles.footer}>
        <Button
          title={t('quiz.startApp')}
          onPress={onComplete}
          fullWidth
          size="lg"
        />
      </Animated.View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    paddingHorizontal: spacing['3xl'],
  },
  checkCircle: {
    width: 96,
    height: 96,
    borderRadius: 48,
    backgroundColor: colors.secondary[500],
    alignItems: 'center',
    justifyContent: 'center',
    marginBottom: spacing['3xl'],
  },
  title: {
    marginBottom: spacing.md,
  },
  subtitle: {
    maxWidth: 300,
  },
  footer: {
    position: 'absolute',
    bottom: 60,
    left: spacing['3xl'],
    right: spacing['3xl'],
  },
});
