Refactorisation complète du parcours d'inscription des parents pour utiliser Provider au lieu du passage de données par paramètres de navigation. Modifications principales : - Utilisation de Provider pour partager UserRegistrationData entre les étapes - Simplification du routeur (suppression des paramètres) - Amélioration de la persistance des données entre les étapes - Meilleure expérience utilisateur lors de la navigation Fichiers modifiés : - models/user_registration_data.dart : Modèle avec ChangeNotifier - screens/auth/parent_register_step1-5_screen.dart : Intégration Provider - navigation/app_router.dart : Simplification du routing - main.dart : Configuration du Provider - login_screen.dart : Ajout navigation vers inscription - register_choice_screen.dart : Navigation vers parcours parent/AM - utils/data_generator.dart : Génération de données de test Refs: #38 (Étape 3 Enfants), #39 (Étapes 4-6 Finalisation)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'dart:io'; // Pour File
|
||||
import '../models/card_assets.dart'; // Import de l'enum CardColorVertical
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
// import 'package:p_tits_pas/models/child.dart'; // Commenté car fichier non trouvé
|
||||
|
||||
class ParentData {
|
||||
String firstName;
|
||||
@@ -47,12 +50,28 @@ class ChildData {
|
||||
});
|
||||
}
|
||||
|
||||
class UserRegistrationData {
|
||||
// Nouvelle classe pour les détails bancaires
|
||||
class BankDetails {
|
||||
String bankName;
|
||||
String iban;
|
||||
String bic;
|
||||
|
||||
BankDetails({
|
||||
this.bankName = '',
|
||||
this.iban = '',
|
||||
this.bic = '',
|
||||
});
|
||||
}
|
||||
|
||||
class UserRegistrationData extends ChangeNotifier {
|
||||
ParentData parent1;
|
||||
ParentData? parent2; // Optionnel
|
||||
List<ChildData> children;
|
||||
String motivationText;
|
||||
bool cguAccepted;
|
||||
BankDetails? bankDetails; // Ajouté
|
||||
String attestationCafNumber; // Ajouté
|
||||
bool consentQuotientFamilial; // Ajouté
|
||||
|
||||
UserRegistrationData({
|
||||
ParentData? parent1Data,
|
||||
@@ -60,38 +79,77 @@ class UserRegistrationData {
|
||||
List<ChildData>? childrenData,
|
||||
this.motivationText = '',
|
||||
this.cguAccepted = false,
|
||||
this.bankDetails, // Ajouté
|
||||
this.attestationCafNumber = '', // Ajouté
|
||||
this.consentQuotientFamilial = false, // Ajouté
|
||||
}) : parent1 = parent1Data ?? ParentData(),
|
||||
children = childrenData ?? [];
|
||||
|
||||
// Méthode pour ajouter/mettre à jour le parent 1
|
||||
void updateParent1(ParentData data) {
|
||||
parent1 = data;
|
||||
notifyListeners(); // Notifier les changements
|
||||
}
|
||||
|
||||
// Méthode pour ajouter/mettre à jour le parent 2
|
||||
void updateParent2(ParentData? data) {
|
||||
parent2 = data;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Méthode pour ajouter un enfant
|
||||
void addChild(ChildData child) {
|
||||
children.add(child);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Méthode pour mettre à jour un enfant (si nécessaire plus tard)
|
||||
void updateChild(int index, ChildData child) {
|
||||
if (index >= 0 && index < children.length) {
|
||||
children[index] = child;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// Méthode pour supprimer un enfant
|
||||
void removeChild(int index) {
|
||||
if (index >= 0 && index < children.length) {
|
||||
children.removeAt(index);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// Mettre à jour la motivation
|
||||
void updateMotivation(String text) {
|
||||
motivationText = text;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Mettre à jour les informations bancaires et CAF
|
||||
void updateFinancialInfo({
|
||||
BankDetails? bankDetails,
|
||||
String? attestationCafNumber,
|
||||
bool? consentQuotientFamilial,
|
||||
}) {
|
||||
if (bankDetails != null) this.bankDetails = bankDetails;
|
||||
if (attestationCafNumber != null) this.attestationCafNumber = attestationCafNumber;
|
||||
if (consentQuotientFamilial != null) this.consentQuotientFamilial = consentQuotientFamilial;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Accepter les CGU
|
||||
void acceptCGU() {
|
||||
cguAccepted = true;
|
||||
void acceptCGU(bool accepted) { // Prend un booléen
|
||||
cguAccepted = accepted;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Méthode pour vérifier si toutes les données requises sont là (simplifié)
|
||||
bool isRegistrationComplete() {
|
||||
// Ajouter ici les validations nécessaires
|
||||
// Exemple : parent1 doit avoir des champs remplis, au moins un enfant, CGU acceptées
|
||||
return parent1.firstName.isNotEmpty &&
|
||||
parent1.lastName.isNotEmpty &&
|
||||
children.isNotEmpty &&
|
||||
cguAccepted;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user