import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:google_fonts/google_fonts.dart'; import '../theme.dart'; import '../widgets/primary_button.dart'; import 'quiz/quiz_flow.dart'; class ResultScreen extends StatefulWidget { final QuizData data; const ResultScreen({super.key, required this.data}); @override State createState() => _ResultScreenState(); } class _ResultScreenState extends State { bool _revealed = false; @override void initState() { super.initState(); Future.delayed(const Duration(milliseconds: 1800), () { if (mounted) setState(() => _revealed = true); }); } String get _firstName => widget.data.name.split(' ').first; @override Widget build(BuildContext context) { return Scaffold( body: _revealed ? _resultView() : _analyzingView(), ); } Widget _analyzingView() { return Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: [Color(0xFF3D32A8), Color(0xFF5B4FCF), Color(0xFF8B5CF6)], begin: Alignment.topLeft, end: Alignment.bottomRight, ), ), child: SafeArea( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const CircularProgressIndicator( valueColor: AlwaysStoppedAnimation(Colors.white), strokeWidth: 3, ) .animate(onPlay: (c) => c.repeat()) .rotate(duration: 1.seconds), const SizedBox(height: 28), Text( 'Analysing your skin...', style: GoogleFonts.plusJakartaSans( fontSize: 20, fontWeight: FontWeight.w600, color: Colors.white, ), ).animate(onPlay: (c) => c.repeat(reverse: true)) .fadeIn(duration: 800.ms), const SizedBox(height: 8), Text( 'Building your personalised routine', style: GoogleFonts.plusJakartaSans( fontSize: 14, color: Colors.white.withAlpha(180), ), ), ], ), ), ), ); } Widget _resultView() { return Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: [Color(0xFF3D32A8), Color(0xFF5B4FCF), Color(0xFF8B5CF6)], begin: Alignment.topLeft, end: Alignment.bottomRight, ), ), child: SafeArea( child: SingleChildScrollView( padding: const EdgeInsets.symmetric(horizontal: 24), child: Column( children: [ const SizedBox(height: 24), Image.asset( 'assets/images/shaynee_hero.png', height: 180, fit: BoxFit.contain, ) .animate() .fadeIn(duration: 700.ms) .slideY(begin: 0.15, end: 0, duration: 700.ms, curve: Curves.easeOut), const SizedBox(height: 20), Text( 'Your skin report\nis ready, $_firstName! ✨', textAlign: TextAlign.center, style: GoogleFonts.plusJakartaSans( fontSize: 28, fontWeight: FontWeight.w800, color: Colors.white, height: 1.2, ), ) .animate() .fadeIn(duration: 600.ms, delay: 200.ms), const SizedBox(height: 28), _reportCard() .animate() .fadeIn(duration: 600.ms, delay: 400.ms) .slideY(begin: 0.1, end: 0, duration: 600.ms), const SizedBox(height: 20), _routinePreview() .animate() .fadeIn(duration: 600.ms, delay: 600.ms), const SizedBox(height: 28), PrimaryButton( label: 'Start my routine', icon: Icons.arrow_forward_rounded, onTap: () {}, ) .animate() .fadeIn(duration: 400.ms, delay: 800.ms), const SizedBox(height: 32), ], ), ), ), ); } Widget _reportCard() { return Container( padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white.withAlpha(20), borderRadius: BorderRadius.circular(20), border: Border.all(color: Colors.white.withAlpha(40)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Your skin profile', style: GoogleFonts.plusJakartaSans( fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white.withAlpha(160), letterSpacing: 0.8, ), ), const SizedBox(height: 14), _reportRow('Skin type', widget.data.skinType), _reportRow('Age range', widget.data.age), _reportRow('Concerns', widget.data.concerns.join(', ')), _reportRow('Main goal', widget.data.goal), ], ), ); } Widget _reportRow(String label, String value) { if (value.isEmpty) return const SizedBox.shrink(); return Padding( padding: const EdgeInsets.only(bottom: 10), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: GoogleFonts.plusJakartaSans( fontSize: 13, color: Colors.white.withAlpha(160), ), ), const SizedBox(width: 12), Expanded( child: Text( value, textAlign: TextAlign.end, style: GoogleFonts.plusJakartaSans( fontSize: 13, fontWeight: FontWeight.w600, color: Colors.white, ), ), ), ], ), ); } Widget _routinePreview() { const steps = [ ('🌅', 'Morning', 'Cleanser → Vitamin C → SPF 50'), ('🌙', 'Evening', 'Cleanser → Retinol → Moisturiser'), ('✨', 'Weekly', 'Exfoliant + Hydrating mask'), ]; return Container( padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white.withAlpha(20), borderRadius: BorderRadius.circular(20), border: Border.all(color: Colors.white.withAlpha(40)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Your routine preview', style: GoogleFonts.plusJakartaSans( fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white.withAlpha(160), letterSpacing: 0.8, ), ), const SizedBox(height: 14), ...steps.map((s) => Padding( padding: const EdgeInsets.only(bottom: 12), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(s.$1, style: const TextStyle(fontSize: 20)), const SizedBox(width: 12), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( s.$2, style: GoogleFonts.plusJakartaSans( fontSize: 13, fontWeight: FontWeight.w700, color: Colors.white, ), ), Text( s.$3, style: GoogleFonts.plusJakartaSans( fontSize: 12, color: Colors.white.withAlpha(160), ), ), ], ), ], ), )), ], ), ); } }