diff --git a/frontend/assets/images/cross.png b/frontend/assets/images/cross.png new file mode 100644 index 0000000..531d576 Binary files /dev/null and b/frontend/assets/images/cross.png differ diff --git a/frontend/assets/images/red_cross2.png b/frontend/assets/images/red_cross2.png new file mode 100644 index 0000000..8e3e3a1 Binary files /dev/null and b/frontend/assets/images/red_cross2.png differ diff --git a/frontend/lib/screens/auth/parent_register_step3_screen.dart b/frontend/lib/screens/auth/parent_register_step3_screen.dart index dce2488..ac9daff 100644 --- a/frontend/lib/screens/auth/parent_register_step3_screen.dart +++ b/frontend/lib/screens/auth/parent_register_step3_screen.dart @@ -43,6 +43,9 @@ 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 = {}; @@ -50,6 +53,10 @@ class _ParentRegisterStep3ScreenState extends State { void initState() { super.initState(); _registrationData = widget.registrationData; + // Initialiser les couleurs utilisées avec les enfants existants + for (var child in _registrationData.children) { + _usedColors.add(child.cardColor); + } // S'il n'y a pas d'enfant, en ajouter un automatiquement avec des données générées if (_registrationData.children.isEmpty) { _addChild(); @@ -83,22 +90,24 @@ class _ParentRegisterStep3ScreenState extends State { void _addChild() { setState(() { bool isUnborn = DataGenerator.boolean(); - // Déterminer la couleur de la carte pour le nouvel enfant - final cardColor = _childCardColors[_registrationData.children.length % _childCardColors.length]; + + // Trouver la première couleur non utilisée + CardColorVertical cardColor = _childCardColors.firstWhere( + (color) => !_usedColors.contains(color), + orElse: () => _childCardColors[0], // Fallback sur la première couleur si toutes sont utilisées + ); final newChild = ChildData( - lastName: _registrationData.parent1.lastName, // Hérite du nom de famille du parent 1 + lastName: _registrationData.parent1.lastName, firstName: DataGenerator.firstName(), dob: DataGenerator.dob(isUnborn: isUnborn), isUnbornChild: isUnborn, photoConsent: DataGenerator.boolean(), multipleBirth: DataGenerator.boolean(), - cardColor: cardColor, // Assigner la couleur - // imageFile: null, // Pas d'image générée pour l'instant + cardColor: cardColor, ); _registrationData.addChild(newChild); - // Ajouter une clé de formulaire si nécessaire - // _childFormKeys[_registrationData.children.length - 1] = GlobalKey(); + _usedColors.add(cardColor); }); WidgetsBinding.instance.addPostFrameCallback((_) { _scrollListener(); @@ -111,10 +120,8 @@ class _ParentRegisterStep3ScreenState extends State { void _removeChild(int index) { if (_registrationData.children.length > 1 && index >= 0 && index < _registrationData.children.length) { setState(() { + // Ne pas retirer la couleur de _usedColors pour éviter sa réutilisation _registrationData.children.removeAt(index); - // Supprimer aussi la clé de formulaire associée si utilisée - // _childFormKeys.remove(index); - // Il faudrait aussi décaler les clés des enfants suivants si on utilise les index comme clés de map }); WidgetsBinding.instance.addPostFrameCallback((_) => _scrollListener()); } @@ -465,10 +472,11 @@ class _ChildCardWidgetState extends State<_ChildCardWidget> { child: InkWell( onTap: widget.onRemove, customBorder: const CircleBorder(), - child: Container( - padding: const EdgeInsets.all(4), - decoration: BoxDecoration(color: Colors.red.withOpacity(0.8), shape: BoxShape.circle), - child: const Icon(Icons.close, color: Colors.white, size: 18), + child: Image.asset( + 'images/red_cross2.png', + width: 36, + height: 36, + fit: BoxFit.contain, ), ), ),