import 'package:flutter/material.dart'; /// Écran de fin de parcours (équivalent `EndView` de visitapp-web) : version /// escape game (badge + message de fin) et version découverte (stats). class GuidedPathEndView extends StatelessWidget { final bool isGame; final Color primaryColor; final String pathTitle; final int stepsCount; final int? estimatedDurationMinutes; final String gameOutro; final VoidCallback onBack; const GuidedPathEndView({ Key? key, required this.isGame, required this.primaryColor, required this.pathTitle, required this.stepsCount, required this.estimatedDurationMinutes, required this.gameOutro, required this.onBack, }) : super(key: key); static const _gold = Color(0xFFD4AF37); @override Widget build(BuildContext context) { return Scaffold( body: Container( decoration: BoxDecoration( gradient: isGame ? const RadialGradient( center: Alignment(0, -0.6), radius: 1.1, colors: [Color(0xFF1a2436), Color(0xFF0B1018), Color(0xFF05070b)], stops: [0.0, 0.6, 1.0], ) : const RadialGradient( center: Alignment(0, -1), radius: 1.1, colors: [Colors.white, Color(0xFFF6F3EE)], stops: [0.0, 0.6], ), ), child: SafeArea( child: Center( child: SingleChildScrollView( padding: const EdgeInsets.symmetric(horizontal: 34, vertical: 24), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: isGame ? _game(context) : _normal(context), ), ), ), ), ), ); } List _game(BuildContext context) => [ Container( width: 110, height: 110, decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all(color: _gold.withOpacity(0.5), width: 1.5), boxShadow: [BoxShadow(color: _gold.withOpacity(0.35), blurRadius: 60, spreadRadius: 4)], ), child: const Icon(Icons.star, size: 50, color: Color(0xFFE7C765)), ), const SizedBox(height: 24), const Text('ÉNIGME RÉSOLUE', style: TextStyle( color: _gold, fontSize: 11, fontWeight: FontWeight.w700, letterSpacing: 4)), const SizedBox(height: 14), const Text('Le secret est à vous', textAlign: TextAlign.center, style: TextStyle( color: Color(0xFFF4ECD8), fontSize: 30, fontWeight: FontWeight.w600, letterSpacing: -0.5, height: 1.1)), if (gameOutro.isNotEmpty) ...[ const SizedBox(height: 14), Text('« $gameOutro »', textAlign: TextAlign.center, style: const TextStyle( color: Color(0xFFb9ac8c), fontSize: 15, fontStyle: FontStyle.italic, height: 1.6)), ], const SizedBox(height: 20), Container( padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), border: Border.all(color: _gold.withOpacity(0.4)), color: _gold.withOpacity(0.08), ), child: const Row( mainAxisSize: MainAxisSize.min, children: [ Icon(Icons.emoji_events, size: 16, color: Color(0xFFE7C765)), SizedBox(width: 8), Text('Badge obtenu', style: TextStyle( color: Color(0xFFE7C765), fontSize: 13.5, fontWeight: FontWeight.w700)), ], ), ), const SizedBox(height: 28), _button('Terminer l\'aventure'), ]; List _normal(BuildContext context) => [ Container( width: 110, height: 110, decoration: BoxDecoration( shape: BoxShape.circle, color: const Color(0xFF2E9E6B), boxShadow: [ BoxShadow( color: const Color(0xFF2E9E6B).withOpacity(0.4), blurRadius: 32, offset: const Offset(0, 16)) ], ), child: const Icon(Icons.check, size: 44, color: Colors.white), ), const SizedBox(height: 24), const Text('Parcours terminé', textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF1E2A33), fontSize: 28, fontWeight: FontWeight.w600, letterSpacing: -0.4)), const SizedBox(height: 10), Text( 'Vous avez exploré $stepsCount étape${stepsCount > 1 ? 's' : ''} de « $pathTitle ».', textAlign: TextAlign.center, style: const TextStyle(color: Color(0xFF6B7B86), fontSize: 15, height: 1.55), ), const SizedBox(height: 24), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ _statCard('$stepsCount', 'étapes'), if (estimatedDurationMinutes != null) ...[ const SizedBox(width: 12), _statCard('$estimatedDurationMinutes min', 'estimé'), ], ], ), const SizedBox(height: 32), _button('Retour à la section'), ]; Widget _statCard(String value, String label) => Container( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(18), border: Border.all(color: const Color(0xFFEEE9E0)), ), child: Column( children: [ Text(value, style: TextStyle( fontSize: 22, fontWeight: FontWeight.w600, color: primaryColor)), const SizedBox(height: 2), Text(label, style: const TextStyle( fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xFF8A969F))), ], ), ); Widget _button(String label) => SizedBox( width: double.infinity, child: ElevatedButton( onPressed: onBack, style: ElevatedButton.styleFrom( backgroundColor: isGame ? _gold : primaryColor, foregroundColor: isGame ? const Color(0xFF1a1305) : Colors.white, padding: const EdgeInsets.symmetric(vertical: 17), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), elevation: 0, ), child: Text(label, style: TextStyle(fontSize: 16, fontWeight: isGame ? FontWeight.w800 : FontWeight.w700)), ), ); }