feat(ui): Ajout des icônes de croix rouge et grise pour la suppression des cartes enfants
This commit is contained in:
parent
1496f7f174
commit
03712bd99b
BIN
frontend/assets/images/cross.png
Normal file
BIN
frontend/assets/images/cross.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 MiB |
BIN
frontend/assets/images/red_cross2.png
Normal file
BIN
frontend/assets/images/red_cross2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 MiB |
@ -43,6 +43,9 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
||||
CardColorVertical.blue,
|
||||
];
|
||||
|
||||
// Garder une trace des couleurs déjà utilisées
|
||||
final Set<CardColorVertical> _usedColors = {};
|
||||
|
||||
// Utilisation de GlobalKey pour les cartes enfants si validation complexe future
|
||||
// Map<int, GlobalKey<FormState>> _childFormKeys = {};
|
||||
|
||||
@ -50,6 +53,10 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
||||
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<ParentRegisterStep3Screen> {
|
||||
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<FormState>();
|
||||
_usedColors.add(cardColor);
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scrollListener();
|
||||
@ -111,10 +120,8 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user