import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:go_router/go_router.dart'; import 'package:google_fonts/google_fonts.dart'; import 'dart:math' as math; import '../../../models/nanny_registration_data.dart'; import '../../../widgets/custom_decorated_text_field.dart'; import '../../../models/card_assets.dart'; class NannyRegisterStep3Screen extends StatefulWidget { const NannyRegisterStep3Screen({super.key}); @override State createState() => _NannyRegisterStep3ScreenState(); } class _NannyRegisterStep3ScreenState extends State { final _formKey = GlobalKey(); final _presentationController = TextEditingController(); bool _cguAccepted = false; @override void initState() { super.initState(); final data = Provider.of(context, listen: false); _presentationController.text = 'Disponible immédiatement, expérience avec les tout-petits.'; _cguAccepted = true; } @override void dispose() { _presentationController.dispose(); super.dispose(); } void _submitForm() { final nannyData = Provider.of(context, listen: false); nannyData.updatePresentationAndCgu(presentationText: _presentationController.text); // Validation CGU désactivée temporairement nannyData.updatePresentationAndCgu(cguAccepted: _cguAccepted); context.go('/nanny-register-step4'); } @override Widget build(BuildContext context) { final nannyData = Provider.of(context, listen: false); final screenSize = MediaQuery.of(context).size; const cardColor = CardColorHorizontal.peach; // Couleur différente return Scaffold( body: Stack( children: [ Positioned.fill( child: Image.asset('assets/images/paper2.png', fit: BoxFit.cover, repeat: ImageRepeat.repeat), ), Center( child: SingleChildScrollView( padding: const EdgeInsets.symmetric(vertical: 40.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Étape 3/4', style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54)), const SizedBox(height: 10), Container( width: screenSize.width * 0.7, padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 50), constraints: const BoxConstraints(minHeight: 500), // Ajuster hauteur decoration: BoxDecoration( image: DecorationImage(image: AssetImage(cardColor.path), fit: BoxFit.fill), ), child: Form( // Garder Form même si validation simple key: _formKey, child: Column( mainAxisSize: MainAxisSize.min, children: [ Text( 'Présentation et Conditions', style: GoogleFonts.merienda(fontSize: 24, fontWeight: FontWeight.bold, color: Colors.black87), textAlign: TextAlign.center, ), const SizedBox(height: 30), Text( 'Rédigez un court message à destination du gestionnaire (facultatif) :', style: TextStyle(fontSize: 16, color: Colors.black87), ), const SizedBox(height: 10), CustomDecoratedTextField( controller: _presentationController, hintText: 'Ex: Disponible immédiatement, formation premiers secours...', maxLines: 6, // style: cardColor.textFieldStyle, // Utiliser style par défaut ou adapter ), const SizedBox(height: 30), CheckboxListTile( title: const Text('J\'ai lu et j\'accepte les Conditions Générales d\'Utilisation et la Politique de confidentialité de P\'titsPas.', style: TextStyle(fontSize: 14)), subtitle: Text('Vous devez accepter pour continuer.', style: TextStyle(color: Colors.black54.withOpacity(0.7))), value: _cguAccepted, onChanged: (bool? value) { setState(() { _cguAccepted = value ?? false; }); }, controlAffinity: ListTileControlAffinity.leading, dense: true, activeColor: Theme.of(context).primaryColor, ), // TODO: Ajouter lien vers CGU ], ), ), ), ], ), ), ), // Chevron Gauche (Retour) Positioned( top: screenSize.height / 2 - 20, left: 40, child: IconButton( icon: Transform(alignment: Alignment.center, transform: Matrix4.rotationY(math.pi), child: Image.asset('assets/images/chevron_right.png', height: 40)), onPressed: () { if (context.canPop()) { context.pop(); } else { context.go('/nanny-register-step2'); } }, tooltip: 'Précédent', ), ), // Chevron Droit (Suivant) Positioned( top: screenSize.height / 2 - 20, right: 40, child: IconButton( icon: Image.asset('assets/images/chevron_right.png', height: 40), onPressed: _submitForm, tooltip: 'Suivant', ), ), ], ), ); } }