import { useState } from 'react'; import { View, Text, StyleSheet, TouchableOpacity, TextInput, ScrollView, Alert } from 'react-native'; import { useRouter } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { useCreateSaisie } from '@/hooks/useTracker'; import EmotionPicker from '@/components/EmotionPicker'; import { Colors } from '@/lib/colors'; export default function NewEntryScreen() { const router = useRouter(); const createSaisie = useCreateSaisie(); const [step, setStep] = useState(1); const [emotionId, setEmotionId] = useState(); const [intensite, setIntensite] = useState(5); const [note, setNote] = useState(''); const handleSubmit = async () => { if (!emotionId) return; try { await createSaisie.mutateAsync({ emotion_id: emotionId, intensite, note: note.trim() || undefined, date_saisie: new Date().toISOString().split('T')[0], }); Alert.alert('Succes', 'Saisie enregistree !', [ { text: 'OK', onPress: () => router.back() }, ]); } catch { Alert.alert('Erreur', 'Impossible d\'enregistrer la saisie'); } }; return ( {/* Stepper */} {[1, 2, 3].map((s) => ( = s && styles.stepActive]}> {step > s ? ( ) : ( = s && styles.stepNumberActive]}>{s} )} {s < 3 && s && styles.stepLineActive]} />} ))} {/* Step 1: Emotion */} {step === 1 && ( Comment vous sentez-vous ? emotionId && setStep(2)} disabled={!emotionId} > Suivant )} {/* Step 2: Intensity */} {step === 2 && ( A quel point ressentez-vous cette emotion ? {intensite} /10 Faible {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((v) => ( setIntensite(v)} > {v} ))} Forte setStep(1)}> Retour setStep(3)}> Suivant )} {/* Step 3: Note */} {step === 3 && ( Souhaitez-vous ajouter un commentaire ? setStep(2)}> Retour {createSaisie.isPending ? 'Envoi...' : 'Enregistrer'} )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: Colors.white }, content: { padding: 20, paddingBottom: 40 }, stepper: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', marginBottom: 32 }, stepRow: { flexDirection: 'row', alignItems: 'center' }, stepCircle: { width: 32, height: 32, borderRadius: 16, backgroundColor: Colors.gray[200], justifyContent: 'center', alignItems: 'center', }, stepActive: { backgroundColor: Colors.primary }, stepNumber: { fontSize: 14, fontWeight: '700', color: Colors.gray[500] }, stepNumberActive: { color: Colors.white }, stepLine: { width: 40, height: 3, backgroundColor: Colors.gray[200], marginHorizontal: 4 }, stepLineActive: { backgroundColor: Colors.primary }, stepTitle: { fontSize: 20, fontWeight: '700', color: Colors.black, marginBottom: 20 }, intensityContainer: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'center', marginBottom: 24 }, intensityValue: { fontSize: 64, fontWeight: '800', color: Colors.black }, intensityLabel: { fontSize: 24, color: Colors.gray[400], marginLeft: 4 }, sliderContainer: { flexDirection: 'row', alignItems: 'center', gap: 8, marginBottom: 32 }, sliderLabel: { fontSize: 12, color: Colors.gray[400] }, sliderWrapper: { flex: 1 }, nativeSlider: {}, sliderTrack: { height: 6, backgroundColor: Colors.gray[200], borderRadius: 3, marginBottom: 8 }, sliderFill: { height: 6, backgroundColor: Colors.primary, borderRadius: 3 }, sliderButtons: { flexDirection: 'row', justifyContent: 'space-between' }, sliderDot: { width: 28, height: 28, borderRadius: 4, backgroundColor: Colors.gray[100], justifyContent: 'center', alignItems: 'center' }, sliderDotActive: { backgroundColor: Colors.primary }, sliderDotText: { fontSize: 12, fontWeight: '600', color: Colors.gray[500] }, sliderDotTextActive: { color: Colors.white }, textArea: { backgroundColor: Colors.gray[100], borderTopLeftRadius: 4, borderTopRightRadius: 4, borderBottomWidth: 2, borderBottomColor: Colors.black, padding: 16, fontSize: 15, color: Colors.black, minHeight: 120, marginBottom: 24, }, navRow: { flexDirection: 'row', justifyContent: 'space-between', marginTop: 16 }, backBtn: { flexDirection: 'row', alignItems: 'center', gap: 8, paddingVertical: 14, paddingHorizontal: 20, borderRadius: 4, backgroundColor: Colors.white, borderWidth: 1, borderColor: Colors.primary }, backBtnText: { fontSize: 15, fontWeight: '600', color: Colors.primary }, nextBtn: { flexDirection: 'row', alignItems: 'center', gap: 8, paddingVertical: 14, paddingHorizontal: 24, borderRadius: 4, backgroundColor: Colors.primary }, submitBtn: { flexDirection: 'row', alignItems: 'center', gap: 8, paddingVertical: 14, paddingHorizontal: 24, borderRadius: 4, backgroundColor: Colors.primary }, nextBtnText: { fontSize: 15, fontWeight: '700', color: Colors.white }, btnDisabled: { opacity: 0.5 }, });