diff --git a/frontend/lib/models/user_registration_data.dart b/frontend/lib/models/user_registration_data.dart index d2c6954..cf3db49 100644 --- a/frontend/lib/models/user_registration_data.dart +++ b/frontend/lib/models/user_registration_data.dart @@ -28,22 +28,24 @@ class ParentData { class ChildData { String firstName; String lastName; - String dob; // Date de naissance ou prévisionnelle + String dob; + String gender; bool photoConsent; bool multipleBirth; bool isUnbornChild; File? imageFile; - CardColorVertical cardColor; // Nouveau champ pour la couleur de la carte + CardColorVertical cardColor; ChildData({ this.firstName = '', this.lastName = '', this.dob = '', + this.gender = 'F', this.photoConsent = false, this.multipleBirth = false, this.isUnbornChild = false, this.imageFile, - required this.cardColor, // Rendre requis dans le constructeur + required this.cardColor, }); } diff --git a/frontend/lib/screens/auth/parent_register_step3_screen.dart b/frontend/lib/screens/auth/parent_register_step3_screen.dart index ac9daff..264bb65 100644 --- a/frontend/lib/screens/auth/parent_register_step3_screen.dart +++ b/frontend/lib/screens/auth/parent_register_step3_screen.dart @@ -1,19 +1,16 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'dart:math' as math; // Pour la rotation du chevron -import 'package:flutter/gestures.dart'; // Pour PointerDeviceKind -import '../../widgets/hover_relief_widget.dart'; // Import du nouveau widget +import 'dart:math' as math; +import 'package:flutter/gestures.dart'; +import '../../widgets/hover_relief_widget.dart'; import 'package:image_picker/image_picker.dart'; -// import 'package:image_cropper/image_cropper.dart'; // Supprimé -import 'dart:io' show File, Platform; // Ajout de Platform -import 'package:flutter/foundation.dart' show kIsWeb; // Import pour kIsWeb -import '../../widgets/custom_app_text_field.dart'; // Import du nouveau widget TextField -import '../../widgets/app_custom_checkbox.dart'; // Import du nouveau widget Checkbox -import '../../models/user_registration_data.dart'; // Import du modèle de données -import '../../utils/data_generator.dart'; // Import du générateur -import '../../models/card_assets.dart'; // Import des enums de cartes - -// La classe _ChildFormData est supprimée car on utilise ChildData du modèle +import 'dart:io' show File, Platform; +import 'package:flutter/foundation.dart' show kIsWeb; +import '../../widgets/custom_app_text_field.dart'; +import '../../widgets/app_custom_checkbox.dart'; +import '../../models/user_registration_data.dart'; +import '../../utils/data_generator.dart'; +import '../../models/card_assets.dart'; class ParentRegisterStep3Screen extends StatefulWidget { final UserRegistrationData registrationData; // Accepte les données @@ -25,16 +22,15 @@ class ParentRegisterStep3Screen extends StatefulWidget { } class _ParentRegisterStep3ScreenState extends State { - late UserRegistrationData _registrationData; // Stocke l'état complet - final ScrollController _scrollController = ScrollController(); // Pour le défilement horizontal + late UserRegistrationData _registrationData; + final ScrollController _scrollController = ScrollController(); bool _isScrollable = false; bool _showLeftFade = false; bool _showRightFade = false; - static const double _fadeExtent = 0.05; // Pourcentage de fondu + static const double _fadeExtent = 0.05; - // Liste ordonnée des couleurs de cartes pour les enfants static const List _childCardColors = [ - CardColorVertical.lavender, // Premier enfant toujours lavande + CardColorVertical.lavender, CardColorVertical.pink, CardColorVertical.peach, CardColorVertical.lime, @@ -43,11 +39,7 @@ class _ParentRegisterStep3ScreenState extends State { CardColorVertical.blue, ]; - // Garder une trace des couleurs déjà utilisées - final Set _usedColors = {}; - - // Utilisation de GlobalKey pour les cartes enfants si validation complexe future - // Map> _childFormKeys = {}; + final Set _usedColors = {}; @override void initState() { @@ -101,6 +93,7 @@ class _ParentRegisterStep3ScreenState extends State { lastName: _registrationData.parent1.lastName, firstName: DataGenerator.firstName(), dob: DataGenerator.dob(isUnborn: isUnborn), + gender: DataGenerator.gender(), isUnbornChild: isUnborn, photoConsent: DataGenerator.boolean(), multipleBirth: DataGenerator.boolean(), @@ -138,8 +131,10 @@ class _ParentRegisterStep3ScreenState extends State { _registrationData.children[childIndex].imageFile = File(pickedFile.path); } }); - } - } catch (e) { print("Erreur image: $e"); } + } + } catch (e) { + // Gestion silencieuse de l'erreur + } } Future _selectDate(BuildContext context, int childIndex) async { @@ -194,7 +189,7 @@ class _ParentRegisterStep3ScreenState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('Étape 3/5', style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54)), + Text('Étape 3/6', style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54)), const SizedBox(height: 10), Text( 'Informations Enfants', @@ -228,18 +223,18 @@ class _ParentRegisterStep3ScreenState extends State { return Padding( padding: const EdgeInsets.only(right: 20.0), child: _ChildCardWidget( - key: ValueKey(_registrationData.children[index].hashCode), // Utiliser une clé basée sur les données + key: ValueKey(_registrationData.children[index].hashCode), childData: _registrationData.children[index], childIndex: index, onPickImage: () => _pickImage(index), onDateSelect: () => _selectDate(context, index), onFirstNameChanged: (value) => setState(() => _registrationData.children[index].firstName = value), onLastNameChanged: (value) => setState(() => _registrationData.children[index].lastName = value), + onGenderChanged: (value) => setState(() => _registrationData.children[index].gender = value), onTogglePhotoConsent: (newValue) => setState(() => _registrationData.children[index].photoConsent = newValue), onToggleMultipleBirth: (newValue) => setState(() => _registrationData.children[index].multipleBirth = newValue), onToggleIsUnborn: (newValue) => setState(() { _registrationData.children[index].isUnbornChild = newValue; - // Générer une nouvelle date si on change le statut _registrationData.children[index].dob = DataGenerator.dob(isUnborn: newValue); }), onRemove: () => _removeChild(index), @@ -295,13 +290,14 @@ class _ParentRegisterStep3ScreenState extends State { } // Widget pour la carte enfant (adapté pour prendre ChildData et des callbacks) -class _ChildCardWidget extends StatefulWidget { // Transformé en StatefulWidget pour gérer les contrôleurs internes +class _ChildCardWidget extends StatefulWidget { final ChildData childData; final int childIndex; final VoidCallback onPickImage; final VoidCallback onDateSelect; final ValueChanged onFirstNameChanged; final ValueChanged onLastNameChanged; + final ValueChanged onGenderChanged; final ValueChanged onTogglePhotoConsent; final ValueChanged onToggleMultipleBirth; final ValueChanged onToggleIsUnborn; @@ -316,6 +312,7 @@ class _ChildCardWidget extends StatefulWidget { // Transformé en StatefulWidget required this.onDateSelect, required this.onFirstNameChanged, required this.onLastNameChanged, + required this.onGenderChanged, required this.onTogglePhotoConsent, required this.onToggleMultipleBirth, required this.onToggleIsUnborn, @@ -436,6 +433,32 @@ class _ChildCardWidgetState extends State<_ChildCardWidget> { fieldHeight: 55.0 * 1.1, // 60.5 ), const SizedBox(height: 9.0 * 1.1), // 9.9 + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Genre', style: GoogleFonts.merienda(fontSize: 16 * 1.1, fontWeight: FontWeight.w600)), + Row( + children: [ + Radio( + value: 'H', + groupValue: widget.childData.gender, + onChanged: (value) => widget.onGenderChanged(value!), + activeColor: Theme.of(context).primaryColor, + ), + Text('H', style: GoogleFonts.merienda(fontSize: 16 * 1.1)), + const SizedBox(width: 20), + Radio( + value: 'F', + groupValue: widget.childData.gender, + onChanged: (value) => widget.onGenderChanged(value!), + activeColor: Theme.of(context).primaryColor, + ), + Text('F', style: GoogleFonts.merienda(fontSize: 16 * 1.1)), + ], + ), + ], + ), + const SizedBox(height: 9.0 * 1.1), // 9.9 CustomAppTextField( controller: _dobController, labelText: widget.childData.isUnbornChild ? 'Date prévisionnelle de naissance' : 'Date de naissance', diff --git a/frontend/lib/utils/data_generator.dart b/frontend/lib/utils/data_generator.dart index a6f9077..f68b91e 100644 --- a/frontend/lib/utils/data_generator.dart +++ b/frontend/lib/utils/data_generator.dart @@ -51,6 +51,8 @@ class DataGenerator { static bool boolean() => _random.nextBool(); + static String gender() => _random.nextBool() ? 'H' : 'F'; + static String motivation() { int count = _random.nextInt(3) + 2; // 2 à 4 phrases List chosenSnippets = [];