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:
parent
dbd56637e1
commit
29bee9fa80
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart'; // Import pour la localisation
|
import 'package:flutter_localizations/flutter_localizations.dart'; // Import pour la localisation
|
||||||
// import 'package:provider/provider.dart'; // Supprimer Provider
|
// import 'package:provider/provider.dart'; // Supprimer Provider
|
||||||
import 'navigation/app_router.dart';
|
import 'config/app_router.dart'; // <-- Importer le bon routeur (GoRouter)
|
||||||
// import 'theme/app_theme.dart'; // Supprimer AppTheme
|
// import 'theme/app_theme.dart'; // Supprimer AppTheme
|
||||||
// import 'theme/theme_provider.dart'; // Supprimer ThemeProvider
|
// import 'theme/theme_provider.dart'; // Supprimer ThemeProvider
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ class MyApp extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Pas besoin de Provider.of ici
|
// Pas besoin de Provider.of ici
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp.router( // <-- Utilisation de MaterialApp.router
|
||||||
title: 'P\'titsPas',
|
title: 'P\'titsPas',
|
||||||
theme: ThemeData.light().copyWith( // Utiliser un thème simple par défaut
|
theme: ThemeData.light().copyWith( // Utiliser un thème simple par défaut
|
||||||
textTheme: GoogleFonts.meriendaTextTheme(
|
textTheme: GoogleFonts.meriendaTextTheme(
|
||||||
@ -35,8 +35,7 @@ class MyApp extends StatelessWidget {
|
|||||||
// Locale('en', 'US'), // Anglais, si besoin
|
// Locale('en', 'US'), // Anglais, si besoin
|
||||||
],
|
],
|
||||||
locale: const Locale('fr', 'FR'), // Forcer la locale française par défaut
|
locale: const Locale('fr', 'FR'), // Forcer la locale française par défaut
|
||||||
initialRoute: AppRouter.login,
|
routerConfig: AppRouter.router, // <-- Passer la configuration du GoRouter
|
||||||
onGenerateRoute: AppRouter.generateRoute,
|
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import 'dart:io'; // Pour File
|
import 'dart:io'; // Pour File
|
||||||
import '../models/card_assets.dart'; // Import de l'enum CardColorVertical
|
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 {
|
class ParentData {
|
||||||
String firstName;
|
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 parent1;
|
||||||
ParentData? parent2; // Optionnel
|
ParentData? parent2; // Optionnel
|
||||||
List<ChildData> children;
|
List<ChildData> children;
|
||||||
String motivationText;
|
String motivationText;
|
||||||
bool cguAccepted;
|
bool cguAccepted;
|
||||||
|
BankDetails? bankDetails; // Ajouté
|
||||||
|
String attestationCafNumber; // Ajouté
|
||||||
|
bool consentQuotientFamilial; // Ajouté
|
||||||
|
|
||||||
UserRegistrationData({
|
UserRegistrationData({
|
||||||
ParentData? parent1Data,
|
ParentData? parent1Data,
|
||||||
@ -60,38 +79,77 @@ class UserRegistrationData {
|
|||||||
List<ChildData>? childrenData,
|
List<ChildData>? childrenData,
|
||||||
this.motivationText = '',
|
this.motivationText = '',
|
||||||
this.cguAccepted = false,
|
this.cguAccepted = false,
|
||||||
|
this.bankDetails, // Ajouté
|
||||||
|
this.attestationCafNumber = '', // Ajouté
|
||||||
|
this.consentQuotientFamilial = false, // Ajouté
|
||||||
}) : parent1 = parent1Data ?? ParentData(),
|
}) : parent1 = parent1Data ?? ParentData(),
|
||||||
children = childrenData ?? [];
|
children = childrenData ?? [];
|
||||||
|
|
||||||
// Méthode pour ajouter/mettre à jour le parent 1
|
// Méthode pour ajouter/mettre à jour le parent 1
|
||||||
void updateParent1(ParentData data) {
|
void updateParent1(ParentData data) {
|
||||||
parent1 = data;
|
parent1 = data;
|
||||||
|
notifyListeners(); // Notifier les changements
|
||||||
}
|
}
|
||||||
|
|
||||||
// Méthode pour ajouter/mettre à jour le parent 2
|
// Méthode pour ajouter/mettre à jour le parent 2
|
||||||
void updateParent2(ParentData? data) {
|
void updateParent2(ParentData? data) {
|
||||||
parent2 = data;
|
parent2 = data;
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Méthode pour ajouter un enfant
|
// Méthode pour ajouter un enfant
|
||||||
void addChild(ChildData child) {
|
void addChild(ChildData child) {
|
||||||
children.add(child);
|
children.add(child);
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Méthode pour mettre à jour un enfant (si nécessaire plus tard)
|
// Méthode pour mettre à jour un enfant (si nécessaire plus tard)
|
||||||
void updateChild(int index, ChildData child) {
|
void updateChild(int index, ChildData child) {
|
||||||
if (index >= 0 && index < children.length) {
|
if (index >= 0 && index < children.length) {
|
||||||
children[index] = child;
|
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
|
// Mettre à jour la motivation
|
||||||
void updateMotivation(String text) {
|
void updateMotivation(String text) {
|
||||||
motivationText = 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
|
// Accepter les CGU
|
||||||
void acceptCGU() {
|
void acceptCGU(bool accepted) { // Prend un booléen
|
||||||
cguAccepted = true;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,11 +67,7 @@ class AppRouter {
|
|||||||
slideTransition = true;
|
slideTransition = true;
|
||||||
break;
|
break;
|
||||||
case parentRegisterStep5:
|
case parentRegisterStep5:
|
||||||
if (args is UserRegistrationData) {
|
screen = const ParentRegisterStep5Screen();
|
||||||
screen = ParentRegisterStep5Screen(registrationData: args);
|
|
||||||
} else {
|
|
||||||
screen = buildErrorScreen('5');
|
|
||||||
}
|
|
||||||
slideTransition = true;
|
slideTransition = true;
|
||||||
break;
|
break;
|
||||||
case home:
|
case home:
|
||||||
|
|||||||
@ -8,14 +8,14 @@ import 'package:go_router/go_router.dart';
|
|||||||
import '../../widgets/image_button.dart';
|
import '../../widgets/image_button.dart';
|
||||||
import '../../widgets/custom_app_text_field.dart';
|
import '../../widgets/custom_app_text_field.dart';
|
||||||
|
|
||||||
class LoginPage extends StatefulWidget {
|
class LoginScreen extends StatefulWidget {
|
||||||
const LoginPage({super.key});
|
const LoginScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<LoginPage> createState() => _LoginPageState();
|
State<LoginScreen> createState() => _LoginPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LoginPageState extends State<LoginPage> {
|
class _LoginPageState extends State<LoginScreen> {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
final _emailController = TextEditingController();
|
final _emailController = TextEditingController();
|
||||||
final _passwordController = TextEditingController();
|
final _passwordController = TextEditingController();
|
||||||
@ -168,12 +168,12 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 20),
|
||||||
// Lien de création de compte
|
// Lien de création de compte (version originale)
|
||||||
Center(
|
Center(
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamed(context, '/register-choice');
|
context.go('/register-choice');
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'Créer un compte',
|
'Créer un compte',
|
||||||
@ -185,7 +185,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20), // Réduit l'espacement en bas
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -234,13 +233,13 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
_FooterLink(
|
_FooterLink(
|
||||||
text: 'Mentions légales',
|
text: 'Mentions légales',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushNamed(context, '/legal');
|
context.go('/legal');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
_FooterLink(
|
_FooterLink(
|
||||||
text: 'Politique de confidentialité',
|
text: 'Politique de confidentialité',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushNamed(context, '/privacy');
|
context.go('/privacy');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import '../../models/user_registration_data.dart'; // Import du modèle de donn
|
|||||||
import '../../utils/data_generator.dart'; // Import du générateur de données
|
import '../../utils/data_generator.dart'; // Import du générateur de données
|
||||||
import '../../widgets/custom_app_text_field.dart'; // Import du widget CustomAppTextField
|
import '../../widgets/custom_app_text_field.dart'; // Import du widget CustomAppTextField
|
||||||
import '../../models/card_assets.dart'; // Import des enums de cartes
|
import '../../models/card_assets.dart'; // Import des enums de cartes
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:provider/provider.dart'; // Importer Provider
|
||||||
|
|
||||||
class ParentRegisterStep1Screen extends StatefulWidget {
|
class ParentRegisterStep1Screen extends StatefulWidget {
|
||||||
const ParentRegisterStep1Screen({super.key});
|
const ParentRegisterStep1Screen({super.key});
|
||||||
@ -15,31 +17,44 @@ class ParentRegisterStep1Screen extends StatefulWidget {
|
|||||||
|
|
||||||
class _ParentRegisterStep1ScreenState extends State<ParentRegisterStep1Screen> {
|
class _ParentRegisterStep1ScreenState extends State<ParentRegisterStep1Screen> {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
late UserRegistrationData _registrationData;
|
// late UserRegistrationData _registrationData; // Supprimé, on utilisera le Provider
|
||||||
|
|
||||||
// Contrôleurs pour les champs (restauration CP et Ville)
|
// Contrôleurs pour les champs
|
||||||
final _lastNameController = TextEditingController();
|
final _lastNameController = TextEditingController();
|
||||||
final _firstNameController = TextEditingController();
|
final _firstNameController = TextEditingController();
|
||||||
final _phoneController = TextEditingController();
|
final _phoneController = TextEditingController();
|
||||||
final _emailController = TextEditingController();
|
final _emailController = TextEditingController();
|
||||||
final _passwordController = TextEditingController();
|
final _passwordController = TextEditingController();
|
||||||
final _confirmPasswordController = TextEditingController();
|
final _confirmPasswordController = TextEditingController();
|
||||||
final _addressController = TextEditingController(); // Rue seule
|
final _addressController = TextEditingController();
|
||||||
final _postalCodeController = TextEditingController(); // Restauré
|
final _postalCodeController = TextEditingController();
|
||||||
final _cityController = TextEditingController(); // Restauré
|
final _cityController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_registrationData = UserRegistrationData();
|
// Récupérer les données existantes du Provider pour pré-remplir si l'utilisateur revient
|
||||||
_generateAndFillData();
|
final registrationDataFromProvider = Provider.of<UserRegistrationData>(context, listen: false);
|
||||||
|
_firstNameController.text = registrationDataFromProvider.parent1.firstName;
|
||||||
|
_lastNameController.text = registrationDataFromProvider.parent1.lastName;
|
||||||
|
_phoneController.text = registrationDataFromProvider.parent1.phone;
|
||||||
|
_emailController.text = registrationDataFromProvider.parent1.email;
|
||||||
|
_passwordController.text = registrationDataFromProvider.parent1.password;
|
||||||
|
_confirmPasswordController.text = registrationDataFromProvider.parent1.password; // Ou laisser vide pour reconfirmation
|
||||||
|
_addressController.text = registrationDataFromProvider.parent1.address;
|
||||||
|
_postalCodeController.text = registrationDataFromProvider.parent1.postalCode;
|
||||||
|
_cityController.text = registrationDataFromProvider.parent1.city;
|
||||||
|
|
||||||
|
// Si les champs sont vides (première visite), générer des données
|
||||||
|
if (registrationDataFromProvider.parent1.firstName.isEmpty) {
|
||||||
|
_generateAndFillData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _generateAndFillData() {
|
void _generateAndFillData() {
|
||||||
final String genFirstName = DataGenerator.firstName();
|
final String genFirstName = DataGenerator.firstName();
|
||||||
final String genLastName = DataGenerator.lastName();
|
final String genLastName = DataGenerator.lastName();
|
||||||
|
|
||||||
// Utilisation des méthodes publiques de DataGenerator
|
|
||||||
_addressController.text = DataGenerator.address();
|
_addressController.text = DataGenerator.address();
|
||||||
_postalCodeController.text = DataGenerator.postalCode();
|
_postalCodeController.text = DataGenerator.postalCode();
|
||||||
_cityController.text = DataGenerator.city();
|
_cityController.text = DataGenerator.city();
|
||||||
@ -66,6 +81,25 @@ class _ParentRegisterStep1ScreenState extends State<ParentRegisterStep1Screen> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _submitForm() {
|
||||||
|
if (_formKey.currentState?.validate() ?? false) {
|
||||||
|
final registrationData = Provider.of<UserRegistrationData>(context, listen: false);
|
||||||
|
registrationData.updateParent1(
|
||||||
|
ParentData(
|
||||||
|
firstName: _firstNameController.text,
|
||||||
|
lastName: _lastNameController.text,
|
||||||
|
address: _addressController.text,
|
||||||
|
postalCode: _postalCodeController.text,
|
||||||
|
city: _cityController.text,
|
||||||
|
phone: _phoneController.text,
|
||||||
|
email: _emailController.text,
|
||||||
|
password: _passwordController.text, // Sauvegarder le mot de passe
|
||||||
|
)
|
||||||
|
);
|
||||||
|
context.go('/parent-register-step2');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final screenSize = MediaQuery.of(context).size;
|
final screenSize = MediaQuery.of(context).size;
|
||||||
@ -188,7 +222,13 @@ class _ParentRegisterStep1ScreenState extends State<ParentRegisterStep1Screen> {
|
|||||||
transform: Matrix4.rotationY(math.pi), // Inverse horizontalement
|
transform: Matrix4.rotationY(math.pi), // Inverse horizontalement
|
||||||
child: Image.asset('assets/images/chevron_right.png', height: 40),
|
child: Image.asset('assets/images/chevron_right.png', height: 40),
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.pop(context), // Retour à l'écran de choix
|
onPressed: () {
|
||||||
|
if (context.canPop()) {
|
||||||
|
context.pop();
|
||||||
|
} else {
|
||||||
|
context.go('/register-choice');
|
||||||
|
}
|
||||||
|
},
|
||||||
tooltip: 'Retour',
|
tooltip: 'Retour',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -199,23 +239,7 @@ class _ParentRegisterStep1ScreenState extends State<ParentRegisterStep1Screen> {
|
|||||||
right: 40,
|
right: 40,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Image.asset('assets/images/chevron_right.png', height: 40),
|
icon: Image.asset('assets/images/chevron_right.png', height: 40),
|
||||||
onPressed: () {
|
onPressed: _submitForm, // Appel de la fonction de soumission
|
||||||
if (_formKey.currentState?.validate() ?? false) {
|
|
||||||
_registrationData.updateParent1(
|
|
||||||
ParentData(
|
|
||||||
firstName: _firstNameController.text,
|
|
||||||
lastName: _lastNameController.text,
|
|
||||||
address: _addressController.text, // Rue
|
|
||||||
postalCode: _postalCodeController.text, // Ajout
|
|
||||||
city: _cityController.text, // Ajout
|
|
||||||
phone: _phoneController.text,
|
|
||||||
email: _emailController.text,
|
|
||||||
password: _passwordController.text,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
Navigator.pushNamed(context, '/parent-register/step2', arguments: _registrationData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tooltip: 'Suivant',
|
tooltip: 'Suivant',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -5,19 +5,22 @@ import '../../models/user_registration_data.dart'; // Import du modèle
|
|||||||
import '../../utils/data_generator.dart'; // Import du générateur
|
import '../../utils/data_generator.dart'; // Import du générateur
|
||||||
import '../../widgets/custom_app_text_field.dart'; // Import du widget
|
import '../../widgets/custom_app_text_field.dart'; // Import du widget
|
||||||
import '../../models/card_assets.dart'; // Import des enums de cartes
|
import '../../models/card_assets.dart'; // Import des enums de cartes
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:go_router/go_router.dart'; // Importer GoRouter
|
||||||
|
|
||||||
class ParentRegisterStep2Screen extends StatefulWidget {
|
class ParentRegisterStep2Screen extends StatefulWidget {
|
||||||
final UserRegistrationData registrationData; // Accepte les données de l'étape 1
|
// final UserRegistrationData registrationData; // Supprimé
|
||||||
|
|
||||||
const ParentRegisterStep2Screen({super.key, required this.registrationData});
|
const ParentRegisterStep2Screen({super.key /*, required this.registrationData */}); // Modifié
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ParentRegisterStep2Screen> createState() => _ParentRegisterStep2ScreenState();
|
_ParentRegisterStep2ScreenState createState() =>
|
||||||
|
_ParentRegisterStep2ScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
late UserRegistrationData _registrationData; // Copie locale pour modification
|
// late UserRegistrationData _registrationData; // Supprimé
|
||||||
|
|
||||||
bool _addParent2 = true; // Pour le test, on ajoute toujours le parent 2
|
bool _addParent2 = true; // Pour le test, on ajoute toujours le parent 2
|
||||||
bool _sameAddressAsParent1 = false; // Peut être généré aléatoirement aussi
|
bool _sameAddressAsParent1 = false; // Peut être généré aléatoirement aussi
|
||||||
@ -36,13 +39,19 @@ class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_registrationData = widget.registrationData; // Récupère les données de l'étape 1
|
// On ne récupère plus _registrationData ici
|
||||||
|
// Mais on peut récupérer les données initiales pour les contrôleurs si nécessaire
|
||||||
|
final initialData = Provider.of<UserRegistrationData>(context, listen: false);
|
||||||
|
_addParent2 = initialData.parent2 != null;
|
||||||
if (_addParent2) {
|
if (_addParent2) {
|
||||||
_generateAndFillParent2Data();
|
_fillParent2Data(initialData.parent2!, initialData.parent1);
|
||||||
|
} else {
|
||||||
|
_generateAndFillParent2Data(initialData.parent1); // Ou générer si pas de données
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _generateAndFillParent2Data() {
|
// Modifié pour prendre les données parent1
|
||||||
|
void _generateAndFillParent2Data(ParentData parent1Data) {
|
||||||
final String genFirstName = DataGenerator.firstName();
|
final String genFirstName = DataGenerator.firstName();
|
||||||
final String genLastName = DataGenerator.lastName();
|
final String genLastName = DataGenerator.lastName();
|
||||||
_firstNameController.text = genFirstName;
|
_firstNameController.text = genFirstName;
|
||||||
@ -60,12 +69,30 @@ class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
|||||||
_cityController.text = DataGenerator.city();
|
_cityController.text = DataGenerator.city();
|
||||||
} else {
|
} else {
|
||||||
// Vider les champs si même adresse (seront désactivés)
|
// Vider les champs si même adresse (seront désactivés)
|
||||||
_addressController.clear();
|
_addressController.text = parent1Data.address;
|
||||||
_postalCodeController.clear();
|
_postalCodeController.text = parent1Data.postalCode;
|
||||||
_cityController.clear();
|
_cityController.text = parent1Data.city;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Nouvelle fonction pour remplir depuis les données existantes
|
||||||
|
void _fillParent2Data(ParentData parent2Data, ParentData parent1Data) {
|
||||||
|
_firstNameController.text = parent2Data.firstName;
|
||||||
|
_lastNameController.text = parent2Data.lastName;
|
||||||
|
_phoneController.text = parent2Data.phone;
|
||||||
|
_emailController.text = parent2Data.email;
|
||||||
|
_passwordController.text = parent2Data.password; // Attention à la sécurité
|
||||||
|
_confirmPasswordController.text = parent2Data.password;
|
||||||
|
|
||||||
|
_sameAddressAsParent1 = (parent2Data.address == parent1Data.address &&
|
||||||
|
parent2Data.postalCode == parent1Data.postalCode &&
|
||||||
|
parent2Data.city == parent1Data.city);
|
||||||
|
|
||||||
|
_addressController.text = parent2Data.address;
|
||||||
|
_postalCodeController.text = parent2Data.postalCode;
|
||||||
|
_cityController.text = parent2Data.city;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_lastNameController.dispose();
|
_lastNameController.dispose();
|
||||||
@ -85,6 +112,8 @@ class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final registrationData = Provider.of<UserRegistrationData>(context, listen: false);
|
||||||
|
final parent1Data = registrationData.parent1;
|
||||||
final screenSize = MediaQuery.of(context).size;
|
final screenSize = MediaQuery.of(context).size;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -129,7 +158,7 @@ class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
|||||||
const Spacer(),
|
const Spacer(),
|
||||||
Switch(value: _addParent2, onChanged: (val) => setState(() {
|
Switch(value: _addParent2, onChanged: (val) => setState(() {
|
||||||
_addParent2 = val ?? false;
|
_addParent2 = val ?? false;
|
||||||
if (_addParent2) _generateAndFillParent2Data(); else _clearParent2Fields();
|
if (_addParent2) _generateAndFillParent2Data(parent1Data); else _clearParent2Fields();
|
||||||
}), activeColor: Theme.of(context).primaryColor),
|
}), activeColor: Theme.of(context).primaryColor),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
@ -144,9 +173,9 @@ class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
|||||||
Switch(value: _sameAddressAsParent1, onChanged: _addParent2 ? (val) => setState(() {
|
Switch(value: _sameAddressAsParent1, onChanged: _addParent2 ? (val) => setState(() {
|
||||||
_sameAddressAsParent1 = val ?? false;
|
_sameAddressAsParent1 = val ?? false;
|
||||||
if (_sameAddressAsParent1) {
|
if (_sameAddressAsParent1) {
|
||||||
_addressController.text = _registrationData.parent1.address;
|
_addressController.text = parent1Data.address;
|
||||||
_postalCodeController.text = _registrationData.parent1.postalCode;
|
_postalCodeController.text = parent1Data.postalCode;
|
||||||
_cityController.text = _registrationData.parent1.city;
|
_cityController.text = parent1Data.city;
|
||||||
} else {
|
} else {
|
||||||
_addressController.text = DataGenerator.address();
|
_addressController.text = DataGenerator.address();
|
||||||
_postalCodeController.text = DataGenerator.postalCode();
|
_postalCodeController.text = DataGenerator.postalCode();
|
||||||
@ -204,7 +233,13 @@ class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
|||||||
left: 40,
|
left: 40,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Transform(alignment: Alignment.center, transform: Matrix4.rotationY(math.pi), child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
icon: Transform(alignment: Alignment.center, transform: Matrix4.rotationY(math.pi), child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () {
|
||||||
|
if (context.canPop()) {
|
||||||
|
context.pop();
|
||||||
|
} else {
|
||||||
|
context.go('/parent-register-step1');
|
||||||
|
}
|
||||||
|
},
|
||||||
tooltip: 'Retour',
|
tooltip: 'Retour',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -216,22 +251,22 @@ class _ParentRegisterStep2ScreenState extends State<ParentRegisterStep2Screen> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (!_addParent2 || (_formKey.currentState?.validate() ?? false)) {
|
if (!_addParent2 || (_formKey.currentState?.validate() ?? false)) {
|
||||||
if (_addParent2) {
|
if (_addParent2) {
|
||||||
_registrationData.updateParent2(
|
registrationData.updateParent2(
|
||||||
ParentData(
|
ParentData(
|
||||||
firstName: _firstNameController.text,
|
firstName: _firstNameController.text,
|
||||||
lastName: _lastNameController.text,
|
lastName: _lastNameController.text,
|
||||||
address: _sameAddressAsParent1 ? _registrationData.parent1.address : _addressController.text,
|
address: _sameAddressAsParent1 ? parent1Data.address : _addressController.text,
|
||||||
postalCode: _sameAddressAsParent1 ? _registrationData.parent1.postalCode : _postalCodeController.text,
|
postalCode: _sameAddressAsParent1 ? parent1Data.postalCode : _postalCodeController.text,
|
||||||
city: _sameAddressAsParent1 ? _registrationData.parent1.city : _cityController.text,
|
city: _sameAddressAsParent1 ? parent1Data.city : _cityController.text,
|
||||||
phone: _phoneController.text,
|
phone: _phoneController.text,
|
||||||
email: _emailController.text,
|
email: _emailController.text,
|
||||||
password: _passwordController.text,
|
password: _passwordController.text,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
_registrationData.updateParent2(null);
|
registrationData.updateParent2(null);
|
||||||
}
|
}
|
||||||
Navigator.pushNamed(context, '/parent-register/step3', arguments: _registrationData);
|
context.go('/parent-register-step3');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tooltip: 'Suivant',
|
tooltip: 'Suivant',
|
||||||
|
|||||||
@ -12,20 +12,23 @@ import '../../widgets/app_custom_checkbox.dart'; // Import du nouveau widget Che
|
|||||||
import '../../models/user_registration_data.dart'; // Import du modèle de données
|
import '../../models/user_registration_data.dart'; // Import du modèle de données
|
||||||
import '../../utils/data_generator.dart'; // Import du générateur
|
import '../../utils/data_generator.dart'; // Import du générateur
|
||||||
import '../../models/card_assets.dart'; // Import des enums de cartes
|
import '../../models/card_assets.dart'; // Import des enums de cartes
|
||||||
|
import 'package:provider/provider.dart'; // Assurer l'import
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
// La classe _ChildFormData est supprimée car on utilise ChildData du modèle
|
// La classe _ChildFormData est supprimée car on utilise ChildData du modèle
|
||||||
|
|
||||||
class ParentRegisterStep3Screen extends StatefulWidget {
|
class ParentRegisterStep3Screen extends StatefulWidget {
|
||||||
final UserRegistrationData registrationData; // Accepte les données
|
// final UserRegistrationData registrationData; // Supprimé
|
||||||
|
|
||||||
const ParentRegisterStep3Screen({super.key, required this.registrationData});
|
const ParentRegisterStep3Screen({super.key /*, required this.registrationData */}); // Modifié
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ParentRegisterStep3Screen> createState() => _ParentRegisterStep3ScreenState();
|
_ParentRegisterStep3ScreenState createState() =>
|
||||||
|
_ParentRegisterStep3ScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
||||||
late UserRegistrationData _registrationData; // Stocke l'état complet
|
// late UserRegistrationData _registrationData; // Supprimé
|
||||||
final ScrollController _scrollController = ScrollController(); // Pour le défilement horizontal
|
final ScrollController _scrollController = ScrollController(); // Pour le défilement horizontal
|
||||||
bool _isScrollable = false;
|
bool _isScrollable = false;
|
||||||
bool _showLeftFade = false;
|
bool _showLeftFade = false;
|
||||||
@ -52,14 +55,18 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_registrationData = widget.registrationData;
|
final registrationData = Provider.of<UserRegistrationData>(context, listen: false);
|
||||||
|
// _registrationData = registrationData; // Supprimé
|
||||||
|
|
||||||
// Initialiser les couleurs utilisées avec les enfants existants
|
// Initialiser les couleurs utilisées avec les enfants existants
|
||||||
for (var child in _registrationData.children) {
|
for (var child in registrationData.children) {
|
||||||
_usedColors.add(child.cardColor);
|
_usedColors.add(child.cardColor);
|
||||||
}
|
}
|
||||||
// S'il n'y a pas d'enfant, en ajouter un automatiquement avec des données générées
|
// S'il n'y a pas d'enfant, en ajouter un automatiquement APRÈS le premier build
|
||||||
if (_registrationData.children.isEmpty) {
|
if (registrationData.children.isEmpty) {
|
||||||
_addChild();
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_addChild(registrationData);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
_scrollController.addListener(_scrollListener);
|
_scrollController.addListener(_scrollListener);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollListener());
|
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollListener());
|
||||||
@ -87,7 +94,7 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _addChild() {
|
void _addChild(UserRegistrationData registrationData) { // Prend registrationData
|
||||||
setState(() {
|
setState(() {
|
||||||
bool isUnborn = DataGenerator.boolean();
|
bool isUnborn = DataGenerator.boolean();
|
||||||
|
|
||||||
@ -98,7 +105,7 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final newChild = ChildData(
|
final newChild = ChildData(
|
||||||
lastName: _registrationData.parent1.lastName,
|
lastName: registrationData.parent1.lastName,
|
||||||
firstName: DataGenerator.firstName(),
|
firstName: DataGenerator.firstName(),
|
||||||
dob: DataGenerator.dob(isUnborn: isUnborn),
|
dob: DataGenerator.dob(isUnborn: isUnborn),
|
||||||
isUnbornChild: isUnborn,
|
isUnbornChild: isUnborn,
|
||||||
@ -106,7 +113,7 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
multipleBirth: DataGenerator.boolean(),
|
multipleBirth: DataGenerator.boolean(),
|
||||||
cardColor: cardColor,
|
cardColor: cardColor,
|
||||||
);
|
);
|
||||||
_registrationData.addChild(newChild);
|
registrationData.addChild(newChild);
|
||||||
_usedColors.add(cardColor);
|
_usedColors.add(cardColor);
|
||||||
});
|
});
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
@ -117,33 +124,42 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _removeChild(int index) {
|
void _removeChild(int index, UserRegistrationData registrationData) {
|
||||||
if (_registrationData.children.length > 1 && index >= 0 && index < _registrationData.children.length) {
|
if (registrationData.children.length > 1 && index >= 0 && index < registrationData.children.length) {
|
||||||
setState(() {
|
setState(() {
|
||||||
// Ne pas retirer la couleur de _usedColors pour éviter sa réutilisation
|
// Ne pas retirer la couleur de _usedColors pour éviter sa réutilisation
|
||||||
_registrationData.children.removeAt(index);
|
registrationData.children.removeAt(index);
|
||||||
});
|
});
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollListener());
|
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _pickImage(int childIndex) async {
|
Future<void> _pickImage(int childIndex, UserRegistrationData registrationData) async {
|
||||||
final ImagePicker picker = ImagePicker();
|
final ImagePicker picker = ImagePicker();
|
||||||
try {
|
try {
|
||||||
final XFile? pickedFile = await picker.pickImage(
|
final XFile? pickedFile = await picker.pickImage(
|
||||||
source: ImageSource.gallery, imageQuality: 70, maxWidth: 1024, maxHeight: 1024);
|
source: ImageSource.gallery, imageQuality: 70, maxWidth: 1024, maxHeight: 1024);
|
||||||
if (pickedFile != null) {
|
if (pickedFile != null) {
|
||||||
setState(() {
|
if (childIndex < registrationData.children.length) {
|
||||||
if (childIndex < _registrationData.children.length) {
|
final oldChild = registrationData.children[childIndex];
|
||||||
_registrationData.children[childIndex].imageFile = File(pickedFile.path);
|
final updatedChild = ChildData(
|
||||||
}
|
firstName: oldChild.firstName,
|
||||||
});
|
lastName: oldChild.lastName,
|
||||||
|
dob: oldChild.dob,
|
||||||
|
photoConsent: oldChild.photoConsent,
|
||||||
|
multipleBirth: oldChild.multipleBirth,
|
||||||
|
isUnbornChild: oldChild.isUnbornChild,
|
||||||
|
imageFile: File(pickedFile.path),
|
||||||
|
cardColor: oldChild.cardColor,
|
||||||
|
);
|
||||||
|
registrationData.updateChild(childIndex, updatedChild);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) { print("Erreur image: $e"); }
|
} catch (e) { print("Erreur image: $e"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _selectDate(BuildContext context, int childIndex) async {
|
Future<void> _selectDate(BuildContext context, int childIndex, UserRegistrationData registrationData) async {
|
||||||
final ChildData currentChild = _registrationData.children[childIndex];
|
final ChildData currentChild = registrationData.children[childIndex];
|
||||||
final DateTime now = DateTime.now();
|
final DateTime now = DateTime.now();
|
||||||
DateTime initialDatePickerDate = now;
|
DateTime initialDatePickerDate = now;
|
||||||
DateTime firstDatePickerDate = DateTime(1980); DateTime lastDatePickerDate = now;
|
DateTime firstDatePickerDate = DateTime(1980); DateTime lastDatePickerDate = now;
|
||||||
@ -175,14 +191,24 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
lastDate: lastDatePickerDate, locale: const Locale('fr', 'FR'),
|
lastDate: lastDatePickerDate, locale: const Locale('fr', 'FR'),
|
||||||
);
|
);
|
||||||
if (picked != null) {
|
if (picked != null) {
|
||||||
setState(() {
|
final oldChild = registrationData.children[childIndex];
|
||||||
currentChild.dob = "${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}";
|
final updatedChild = ChildData(
|
||||||
});
|
firstName: oldChild.firstName,
|
||||||
|
lastName: oldChild.lastName,
|
||||||
|
dob: "${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}",
|
||||||
|
photoConsent: oldChild.photoConsent,
|
||||||
|
multipleBirth: oldChild.multipleBirth,
|
||||||
|
isUnbornChild: oldChild.isUnbornChild,
|
||||||
|
imageFile: oldChild.imageFile,
|
||||||
|
cardColor: oldChild.cardColor,
|
||||||
|
);
|
||||||
|
registrationData.updateChild(childIndex, updatedChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final registrationData = Provider.of<UserRegistrationData>(context /*, listen: true par défaut */);
|
||||||
final screenSize = MediaQuery.of(context).size;
|
final screenSize = MediaQuery.of(context).size;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Stack(
|
body: Stack(
|
||||||
@ -221,36 +247,57 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
itemCount: _registrationData.children.length + 1,
|
itemCount: registrationData.children.length + 1,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index < _registrationData.children.length) {
|
if (index < registrationData.children.length) {
|
||||||
// Carte Enfant
|
// Carte Enfant
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(right: 20.0),
|
padding: const EdgeInsets.only(right: 20.0),
|
||||||
child: _ChildCardWidget(
|
child: _ChildCardWidget(
|
||||||
key: ValueKey(_registrationData.children[index].hashCode), // Utiliser une clé basée sur les données
|
key: ValueKey(registrationData.children[index].hashCode), // Utiliser une clé basée sur les données
|
||||||
childData: _registrationData.children[index],
|
childData: registrationData.children[index],
|
||||||
childIndex: index,
|
childIndex: index,
|
||||||
onPickImage: () => _pickImage(index),
|
onPickImage: () => _pickImage(index, registrationData),
|
||||||
onDateSelect: () => _selectDate(context, index),
|
onDateSelect: () => _selectDate(context, index, registrationData),
|
||||||
onFirstNameChanged: (value) => setState(() => _registrationData.children[index].firstName = value),
|
onFirstNameChanged: (value) => setState(() => registrationData.updateChild(index, ChildData(
|
||||||
onLastNameChanged: (value) => setState(() => _registrationData.children[index].lastName = value),
|
firstName: value, lastName: registrationData.children[index].lastName, dob: registrationData.children[index].dob, photoConsent: registrationData.children[index].photoConsent,
|
||||||
onTogglePhotoConsent: (newValue) => setState(() => _registrationData.children[index].photoConsent = newValue),
|
multipleBirth: registrationData.children[index].multipleBirth, isUnbornChild: registrationData.children[index].isUnbornChild, imageFile: registrationData.children[index].imageFile, cardColor: registrationData.children[index].cardColor
|
||||||
onToggleMultipleBirth: (newValue) => setState(() => _registrationData.children[index].multipleBirth = newValue),
|
))),
|
||||||
onToggleIsUnborn: (newValue) => setState(() {
|
onLastNameChanged: (value) => setState(() => registrationData.updateChild(index, ChildData(
|
||||||
_registrationData.children[index].isUnbornChild = newValue;
|
firstName: registrationData.children[index].firstName, lastName: value, dob: registrationData.children[index].dob, photoConsent: registrationData.children[index].photoConsent,
|
||||||
// Générer une nouvelle date si on change le statut
|
multipleBirth: registrationData.children[index].multipleBirth, isUnbornChild: registrationData.children[index].isUnbornChild, imageFile: registrationData.children[index].imageFile, cardColor: registrationData.children[index].cardColor
|
||||||
_registrationData.children[index].dob = DataGenerator.dob(isUnborn: newValue);
|
))),
|
||||||
}),
|
onTogglePhotoConsent: (newValue) {
|
||||||
onRemove: () => _removeChild(index),
|
final oldChild = registrationData.children[index];
|
||||||
canBeRemoved: _registrationData.children.length > 1,
|
registrationData.updateChild(index, ChildData(
|
||||||
|
firstName: oldChild.firstName, lastName: oldChild.lastName, dob: oldChild.dob, photoConsent: newValue,
|
||||||
|
multipleBirth: oldChild.multipleBirth, isUnbornChild: oldChild.isUnbornChild, imageFile: oldChild.imageFile, cardColor: oldChild.cardColor
|
||||||
|
));
|
||||||
|
},
|
||||||
|
onToggleMultipleBirth: (newValue) {
|
||||||
|
final oldChild = registrationData.children[index];
|
||||||
|
registrationData.updateChild(index, ChildData(
|
||||||
|
firstName: oldChild.firstName, lastName: oldChild.lastName, dob: oldChild.dob, photoConsent: oldChild.photoConsent,
|
||||||
|
multipleBirth: newValue, isUnbornChild: oldChild.isUnbornChild, imageFile: oldChild.imageFile, cardColor: oldChild.cardColor
|
||||||
|
));
|
||||||
|
},
|
||||||
|
onToggleIsUnborn: (newValue) {
|
||||||
|
final oldChild = registrationData.children[index];
|
||||||
|
registrationData.updateChild(index, ChildData(
|
||||||
|
firstName: oldChild.firstName, lastName: oldChild.lastName, dob: DataGenerator.dob(isUnborn: newValue),
|
||||||
|
photoConsent: oldChild.photoConsent, multipleBirth: oldChild.multipleBirth, isUnbornChild: newValue,
|
||||||
|
imageFile: oldChild.imageFile, cardColor: oldChild.cardColor
|
||||||
|
));
|
||||||
|
},
|
||||||
|
onRemove: () => _removeChild(index, registrationData),
|
||||||
|
canBeRemoved: registrationData.children.length > 1,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Bouton Ajouter
|
// Bouton Ajouter
|
||||||
return Center(
|
return Center(
|
||||||
child: HoverReliefWidget(
|
child: HoverReliefWidget(
|
||||||
onPressed: _addChild,
|
onPressed: () => _addChild(registrationData),
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
child: Image.asset('assets/images/plus.png', height: 80, width: 80),
|
child: Image.asset('assets/images/plus.png', height: 80, width: 80),
|
||||||
),
|
),
|
||||||
@ -272,7 +319,13 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
left: 40,
|
left: 40,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Transform(alignment: Alignment.center, transform: Matrix4.rotationY(math.pi), child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
icon: Transform(alignment: Alignment.center, transform: Matrix4.rotationY(math.pi), child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () {
|
||||||
|
if (context.canPop()) {
|
||||||
|
context.pop();
|
||||||
|
} else {
|
||||||
|
context.go('/parent-register-step2');
|
||||||
|
}
|
||||||
|
},
|
||||||
tooltip: 'Retour',
|
tooltip: 'Retour',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -282,8 +335,7 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
|||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Image.asset('assets/images/chevron_right.png', height: 40),
|
icon: Image.asset('assets/images/chevron_right.png', height: 40),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// TODO: Validation (si nécessaire)
|
context.go('/parent-register-step4');
|
||||||
Navigator.pushNamed(context, '/parent-register/step4', arguments: _registrationData);
|
|
||||||
},
|
},
|
||||||
tooltip: 'Suivant',
|
tooltip: 'Suivant',
|
||||||
),
|
),
|
||||||
|
|||||||
@ -7,31 +7,50 @@ import 'package:p_tits_pas/widgets/app_custom_checkbox.dart'; // Import de la ch
|
|||||||
import '../../models/user_registration_data.dart'; // Import du vrai modèle
|
import '../../models/user_registration_data.dart'; // Import du vrai modèle
|
||||||
import '../../utils/data_generator.dart'; // Import du générateur
|
import '../../utils/data_generator.dart'; // Import du générateur
|
||||||
import '../../models/card_assets.dart'; // Import des enums de cartes
|
import '../../models/card_assets.dart'; // Import des enums de cartes
|
||||||
|
import 'package:provider/provider.dart'; // Assurer l'import
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class ParentRegisterStep4Screen extends StatefulWidget {
|
class ParentRegisterStep4Screen extends StatefulWidget {
|
||||||
final UserRegistrationData registrationData; // Accepte les données
|
// final UserRegistrationData registrationData; // Supprimé
|
||||||
|
|
||||||
const ParentRegisterStep4Screen({super.key, required this.registrationData});
|
const ParentRegisterStep4Screen({super.key /*, required this.registrationData */}); // Modifié
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ParentRegisterStep4Screen> createState() => _ParentRegisterStep4ScreenState();
|
_ParentRegisterStep4ScreenState createState() =>
|
||||||
|
_ParentRegisterStep4ScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ParentRegisterStep4ScreenState extends State<ParentRegisterStep4Screen> {
|
class _ParentRegisterStep4ScreenState extends State<ParentRegisterStep4Screen> {
|
||||||
late UserRegistrationData _registrationData; // État local
|
// late UserRegistrationData _registrationData; // Supprimé
|
||||||
final _motivationController = TextEditingController();
|
final _motivationController = TextEditingController();
|
||||||
bool _cguAccepted = true; // Pour le test, CGU acceptées par défaut
|
bool _cguAccepted = true; // Pour le test, CGU acceptées par défaut
|
||||||
|
final _bankNameController = TextEditingController();
|
||||||
|
final _ibanController = TextEditingController();
|
||||||
|
final _bicController = TextEditingController();
|
||||||
|
final _attestationController = TextEditingController();
|
||||||
|
bool _consentQuotientFamilial = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_registrationData = widget.registrationData;
|
final registrationData = Provider.of<UserRegistrationData>(context, listen: false);
|
||||||
_motivationController.text = DataGenerator.motivation(); // Générer la motivation
|
// _registrationData = registrationData; // Supprimé
|
||||||
|
_motivationController.text = registrationData.motivationText.isNotEmpty ? registrationData.motivationText : DataGenerator.motivation();
|
||||||
|
_bankNameController.text = registrationData.bankDetails?.bankName ?? '';
|
||||||
|
_ibanController.text = registrationData.bankDetails?.iban ?? '';
|
||||||
|
_bicController.text = registrationData.bankDetails?.bic ?? '';
|
||||||
|
_attestationController.text = registrationData.attestationCafNumber;
|
||||||
|
_consentQuotientFamilial = registrationData.consentQuotientFamilial;
|
||||||
|
_cguAccepted = registrationData.cguAccepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_motivationController.dispose();
|
_motivationController.dispose();
|
||||||
|
_bankNameController.dispose();
|
||||||
|
_ibanController.dispose();
|
||||||
|
_bicController.dispose();
|
||||||
|
_attestationController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +119,7 @@ Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lo
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final registrationData = Provider.of<UserRegistrationData>(context, listen: false); // listen:false car on met à jour
|
||||||
final screenSize = MediaQuery.of(context).size;
|
final screenSize = MediaQuery.of(context).size;
|
||||||
final cardWidth = screenSize.width * 0.6; // Largeur de la carte (60% de l'écran)
|
final cardWidth = screenSize.width * 0.6; // Largeur de la carte (60% de l'écran)
|
||||||
final double imageAspectRatio = 2.0; // Ratio corrigé (1024/512 = 2.0)
|
final double imageAspectRatio = 2.0; // Ratio corrigé (1024/512 = 2.0)
|
||||||
@ -186,7 +206,13 @@ Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lo
|
|||||||
left: 40,
|
left: 40,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Transform(alignment: Alignment.center, transform: Matrix4.rotationY(math.pi), child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
icon: Transform(alignment: Alignment.center, transform: Matrix4.rotationY(math.pi), child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () {
|
||||||
|
if (context.canPop()) {
|
||||||
|
context.pop();
|
||||||
|
} else {
|
||||||
|
context.go('/parent-register-step3');
|
||||||
|
}
|
||||||
|
},
|
||||||
tooltip: 'Retour',
|
tooltip: 'Retour',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -197,14 +223,18 @@ Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lo
|
|||||||
icon: Image.asset('assets/images/chevron_right.png', height: 40),
|
icon: Image.asset('assets/images/chevron_right.png', height: 40),
|
||||||
onPressed: _cguAccepted
|
onPressed: _cguAccepted
|
||||||
? () {
|
? () {
|
||||||
_registrationData.updateMotivation(_motivationController.text);
|
registrationData.updateMotivation(_motivationController.text);
|
||||||
_registrationData.acceptCGU();
|
registrationData.acceptCGU(_cguAccepted);
|
||||||
|
registrationData.updateFinancialInfo(
|
||||||
Navigator.pushNamed(
|
bankDetails: BankDetails(
|
||||||
context,
|
bankName: _bankNameController.text,
|
||||||
'/parent-register/step5',
|
iban: _ibanController.text,
|
||||||
arguments: _registrationData
|
bic: _bicController.text,
|
||||||
|
),
|
||||||
|
attestationCafNumber: _attestationController.text,
|
||||||
|
consentQuotientFamilial: _consentQuotientFamilial,
|
||||||
);
|
);
|
||||||
|
context.go('/parent-register-step5');
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
tooltip: 'Suivant',
|
tooltip: 'Suivant',
|
||||||
|
|||||||
@ -4,69 +4,153 @@ import '../../models/user_registration_data.dart'; // Utilisation du vrai modèl
|
|||||||
import '../../widgets/image_button.dart'; // Import du ImageButton
|
import '../../widgets/image_button.dart'; // Import du ImageButton
|
||||||
import '../../models/card_assets.dart'; // Import des enums de cartes
|
import '../../models/card_assets.dart'; // Import des enums de cartes
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
import '../../widgets/custom_decorated_text_field.dart'; // Import du CustomDecoratedTextField
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
// Nouvelle méthode helper pour afficher un champ de type "lecture seule" stylisé
|
// Nouvelle méthode helper pour afficher un champ de type "lecture seule" stylisé
|
||||||
Widget _buildDisplayFieldValue(BuildContext context, String label, String value, {bool multiLine = false, double fieldHeight = 50.0, double labelFontSize = 18.0}) {
|
Widget _buildDisplayFieldValue(BuildContext context, String label, String value, {bool multiLine = false, double fieldHeight = 50.0, double labelFontSize = 18.0}) {
|
||||||
const FontWeight labelFontWeight = FontWeight.w600;
|
const FontWeight labelFontWeight = FontWeight.w600;
|
||||||
|
|
||||||
// Ne pas afficher le label si labelFontSize est 0 ou si label est vide
|
|
||||||
bool showLabel = label.isNotEmpty && labelFontSize > 0;
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (showLabel)
|
Text(label, style: GoogleFonts.merienda(fontSize: labelFontSize, fontWeight: labelFontWeight)),
|
||||||
Text(label, style: GoogleFonts.merienda(fontSize: labelFontSize, fontWeight: labelFontWeight)),
|
const SizedBox(height: 4),
|
||||||
if (showLabel)
|
Container(
|
||||||
const SizedBox(height: 4),
|
width: double.infinity, // Prendra la largeur allouée par son parent (Expanded)
|
||||||
// Utiliser Expanded si multiLine et pas de hauteur fixe, sinon Container
|
height: multiLine ? null : fieldHeight, // Hauteur flexible pour multiligne, sinon fixe
|
||||||
multiLine && fieldHeight == null
|
constraints: multiLine ? const BoxConstraints(minHeight: 50.0) : null, // Hauteur min pour multiligne
|
||||||
? Expanded(
|
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0), // Ajuster au besoin
|
||||||
child: Container(
|
decoration: BoxDecoration(
|
||||||
width: double.infinity,
|
image: const DecorationImage(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0),
|
image: AssetImage('assets/images/input_field_bg.png'), // Image de fond du champ
|
||||||
decoration: BoxDecoration(
|
fit: BoxFit.fill,
|
||||||
image: const DecorationImage(
|
|
||||||
image: AssetImage('assets/images/input_field_bg.png'),
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: SingleChildScrollView( // Pour le défilement si le texte dépasse
|
|
||||||
child: Text(
|
|
||||||
value.isNotEmpty ? value : '-',
|
|
||||||
style: GoogleFonts.merienda(fontSize: labelFontSize > 0 ? labelFontSize : 18.0), // Garder une taille de texte par défaut si label caché
|
|
||||||
maxLines: null, // Permettre un nombre illimité de lignes
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: multiLine ? null : fieldHeight,
|
|
||||||
constraints: multiLine ? BoxConstraints(minHeight: fieldHeight) : null,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
image: const DecorationImage(
|
|
||||||
image: AssetImage('assets/images/input_field_bg.png'),
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
value.isNotEmpty ? value : '-',
|
|
||||||
style: GoogleFonts.merienda(fontSize: labelFontSize > 0 ? labelFontSize : 18.0),
|
|
||||||
maxLines: multiLine ? null : 1,
|
|
||||||
overflow: multiLine ? TextOverflow.visible : TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
// Si votre image input_field_bg.png a des coins arrondis intrinsèques, ce borderRadius n'est pas nécessaire
|
||||||
|
// ou doit correspondre. Sinon, pour une image rectangulaire, vous pouvez l'ajouter.
|
||||||
|
// borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
value.isNotEmpty ? value : '-',
|
||||||
|
style: GoogleFonts.merienda(fontSize: labelFontSize),
|
||||||
|
maxLines: multiLine ? null : 1, // Permet plusieurs lignes si multiLine est true
|
||||||
|
overflow: multiLine ? TextOverflow.visible : TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ParentRegisterStep5Screen extends StatelessWidget {
|
class ParentRegisterStep5Screen extends StatefulWidget {
|
||||||
final UserRegistrationData registrationData;
|
const ParentRegisterStep5Screen({super.key});
|
||||||
|
|
||||||
const ParentRegisterStep5Screen({super.key, required this.registrationData});
|
@override
|
||||||
|
_ParentRegisterStep5ScreenState createState() => _ParentRegisterStep5ScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ParentRegisterStep5ScreenState extends State<ParentRegisterStep5Screen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final registrationData = Provider.of<UserRegistrationData>(context);
|
||||||
|
final screenSize = MediaQuery.of(context).size;
|
||||||
|
final cardWidth = screenSize.width / 2.0; // Largeur de la carte (50% de l'écran)
|
||||||
|
final double imageAspectRatio = 2.0; // Ratio corrigé (1024/512 = 2.0)
|
||||||
|
final cardHeight = cardWidth / imageAspectRatio;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: Image.asset('assets/images/paper2.png', fit: BoxFit.cover, repeat: ImageRepeat.repeatY),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 40.0), // Padding horizontal supprimé ici
|
||||||
|
child: Padding( // Ajout du Padding horizontal externe
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: screenSize.width / 4.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text('Étape 5/5', style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54)),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text('Récapitulatif de votre demande', style: GoogleFonts.merienda(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black87), textAlign: TextAlign.center),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
|
||||||
|
_buildParent1Card(context, registrationData.parent1),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
if (registrationData.parent2 != null) ...[
|
||||||
|
_buildParent2Card(context, registrationData.parent2!),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
..._buildChildrenCards(context, registrationData.children),
|
||||||
|
_buildMotivationCard(context, registrationData.motivationText),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
ImageButton(
|
||||||
|
bg: 'assets/images/btn_green.png',
|
||||||
|
text: 'Soumettre ma demande',
|
||||||
|
textColor: const Color(0xFF2D6A4F),
|
||||||
|
width: 350,
|
||||||
|
height: 50,
|
||||||
|
fontSize: 18,
|
||||||
|
onPressed: () {
|
||||||
|
print("Données finales: ${registrationData.parent1.firstName}, Enfant(s): ${registrationData.children.length}");
|
||||||
|
_showConfirmationModal(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: screenSize.height / 2 - 20,
|
||||||
|
left: 40,
|
||||||
|
child: IconButton(
|
||||||
|
icon: Transform.flip(flipX: true, child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
||||||
|
onPressed: () {
|
||||||
|
if (context.canPop()) {
|
||||||
|
context.pop();
|
||||||
|
} else {
|
||||||
|
context.go('/parent-register-step4');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tooltip: 'Retour',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showConfirmationModal(BuildContext context) {
|
||||||
|
showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext dialogContext) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(
|
||||||
|
'Demande enregistrée',
|
||||||
|
style: GoogleFonts.merienda(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
content: Text(
|
||||||
|
'Votre dossier a bien été pris en compte. Un gestionnaire le validera bientôt.',
|
||||||
|
style: GoogleFonts.merienda(fontSize: 14),
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: Text('OK', style: GoogleFonts.merienda(fontWeight: FontWeight.bold)),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(dialogContext).pop(); // Ferme la modale
|
||||||
|
// Utiliser go_router pour la navigation
|
||||||
|
context.go('/login');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Méthode pour construire la carte Parent 1
|
// Méthode pour construire la carte Parent 1
|
||||||
Widget _buildParent1Card(BuildContext context, ParentData data) {
|
Widget _buildParent1Card(BuildContext context, ParentData data) {
|
||||||
@ -98,7 +182,7 @@ class ParentRegisterStep5Screen extends StatelessWidget {
|
|||||||
backgroundImagePath: CardColorHorizontal.peach.path,
|
backgroundImagePath: CardColorHorizontal.peach.path,
|
||||||
title: 'Parent Principal',
|
title: 'Parent Principal',
|
||||||
content: details,
|
content: details,
|
||||||
onEdit: () => Navigator.of(context).pushNamed('/parent-register/step1', arguments: registrationData),
|
onEdit: () => context.go('/parent-register-step1'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +215,7 @@ class ParentRegisterStep5Screen extends StatelessWidget {
|
|||||||
backgroundImagePath: CardColorHorizontal.blue.path,
|
backgroundImagePath: CardColorHorizontal.blue.path,
|
||||||
title: 'Deuxième Parent',
|
title: 'Deuxième Parent',
|
||||||
content: details,
|
content: details,
|
||||||
onEdit: () => Navigator.of(context).pushNamed('/parent-register/step2', arguments: registrationData),
|
onEdit: () => context.go('/parent-register-step2'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,10 +260,7 @@ class ParentRegisterStep5Screen extends StatelessWidget {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.edit, color: Colors.black54, size: 28),
|
icon: const Icon(Icons.edit, color: Colors.black54, size: 28),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pushNamed(
|
context.go('/parent-register-step3', extra: {'childIndex': index});
|
||||||
'/parent-register/step3',
|
|
||||||
arguments: registrationData,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
tooltip: 'Modifier',
|
tooltip: 'Modifier',
|
||||||
),
|
),
|
||||||
@ -264,23 +345,17 @@ class ParentRegisterStep5Screen extends StatelessWidget {
|
|||||||
|
|
||||||
// Méthode pour construire la carte Motivation
|
// Méthode pour construire la carte Motivation
|
||||||
Widget _buildMotivationCard(BuildContext context, String motivation) {
|
Widget _buildMotivationCard(BuildContext context, String motivation) {
|
||||||
|
List<Widget> details = [
|
||||||
|
Text(motivation.isNotEmpty ? motivation : 'Aucune motivation renseignée.',
|
||||||
|
style: GoogleFonts.merienda(fontSize: 18),
|
||||||
|
maxLines: 4,
|
||||||
|
overflow: TextOverflow.ellipsis)
|
||||||
|
];
|
||||||
return _SummaryCard(
|
return _SummaryCard(
|
||||||
backgroundImagePath: CardColorHorizontal.green.path,
|
backgroundImagePath: CardColorHorizontal.pink.path,
|
||||||
title: 'Votre Motivation',
|
title: 'Votre Motivation',
|
||||||
content: [
|
content: details,
|
||||||
Expanded(
|
onEdit: () => context.go('/parent-register-step4'),
|
||||||
child: CustomDecoratedTextField(
|
|
||||||
controller: TextEditingController(text: motivation),
|
|
||||||
hintText: 'Aucune motivation renseignée.',
|
|
||||||
fieldHeight: 200,
|
|
||||||
maxLines: 10,
|
|
||||||
expandDynamically: true,
|
|
||||||
readOnly: true,
|
|
||||||
fontSize: 18.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
onEdit: () => Navigator.of(context).pushNamed('/parent-register/step4', arguments: registrationData),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,102 +381,6 @@ class ParentRegisterStep5Screen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final screenSize = MediaQuery.of(context).size;
|
|
||||||
final cardWidth = screenSize.width / 2.0; // Largeur de la carte (50% de l'écran)
|
|
||||||
final double imageAspectRatio = 2.0; // Ratio corrigé (1024/512 = 2.0)
|
|
||||||
final cardHeight = cardWidth / imageAspectRatio;
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
body: Stack(
|
|
||||||
children: [
|
|
||||||
Positioned.fill(
|
|
||||||
child: Image.asset('assets/images/paper2.png', fit: BoxFit.cover, repeat: ImageRepeat.repeatY),
|
|
||||||
),
|
|
||||||
Center(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 40.0), // Padding horizontal supprimé ici
|
|
||||||
child: Padding( // Ajout du Padding horizontal externe
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: screenSize.width / 4.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text('Étape 5/5', style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54)),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Text('Récapitulatif de votre demande', style: GoogleFonts.merienda(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black87), textAlign: TextAlign.center),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
|
|
||||||
_buildParent1Card(context, registrationData.parent1),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
if (registrationData.parent2 != null) ...[
|
|
||||||
_buildParent2Card(context, registrationData.parent2!),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
],
|
|
||||||
..._buildChildrenCards(context, registrationData.children),
|
|
||||||
_buildMotivationCard(context, registrationData.motivationText),
|
|
||||||
const SizedBox(height: 40),
|
|
||||||
ImageButton(
|
|
||||||
bg: 'assets/images/btn_green.png',
|
|
||||||
text: 'Soumettre ma demande',
|
|
||||||
textColor: const Color(0xFF2D6A4F),
|
|
||||||
width: 350,
|
|
||||||
height: 50,
|
|
||||||
fontSize: 18,
|
|
||||||
onPressed: () {
|
|
||||||
print("Données finales: ${registrationData.parent1.firstName}, Enfant(s): ${registrationData.children.length}");
|
|
||||||
_showConfirmationModal(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: screenSize.height / 2 - 20,
|
|
||||||
left: 40,
|
|
||||||
child: IconButton(
|
|
||||||
icon: Transform.flip(flipX: true, child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
|
||||||
onPressed: () => Navigator.pop(context), // Retour à l'étape 4
|
|
||||||
tooltip: 'Retour',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showConfirmationModal(BuildContext context) {
|
|
||||||
showDialog<void>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (BuildContext dialogContext) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(
|
|
||||||
'Demande enregistrée',
|
|
||||||
style: GoogleFonts.merienda(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
content: Text(
|
|
||||||
'Votre dossier a bien été pris en compte. Un gestionnaire le validera bientôt.',
|
|
||||||
style: GoogleFonts.merienda(fontSize: 14),
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text('OK', style: GoogleFonts.merienda(fontWeight: FontWeight.bold)),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(dialogContext).pop(); // Ferme la modale
|
|
||||||
// TODO: Naviguer vers l'écran de connexion ou tableau de bord
|
|
||||||
Navigator.of(context).pushNamedAndRemoveUntil('/login', (Route<dynamic> route) => false);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Widget générique _SummaryCard (ajusté)
|
// Widget générique _SummaryCard (ajusté)
|
||||||
@ -422,7 +401,7 @@ class _SummaryCard extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AspectRatio(
|
return AspectRatio(
|
||||||
aspectRatio: 2.0,
|
aspectRatio: 2.0, // Le ratio largeur/hauteur de nos images de fond
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 20.0, horizontal: 25.0),
|
padding: const EdgeInsets.symmetric(vertical: 20.0, horizontal: 25.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -432,30 +411,31 @@ class _SummaryCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
title,
|
|
||||||
style: GoogleFonts.merienda(fontSize: 28, fontWeight: FontWeight.w600),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.edit, color: Colors.black54, size: 28),
|
|
||||||
onPressed: onEdit,
|
|
||||||
tooltip: 'Modifier',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 18),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: content,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min, // Pour que la colonne prenne la hauteur du contenu
|
||||||
|
children: [
|
||||||
|
Align( // Centrer le titre
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
style: GoogleFonts.merienda(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black87), // Police légèrement augmentée
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12), // Espacement ajusté après le titre
|
||||||
|
...content,
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.edit, color: Colors.black54, size: 28), // Icône un peu plus grande
|
||||||
|
onPressed: onEdit,
|
||||||
|
tooltip: 'Modifier',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import 'dart:math' as math; // Pour la rotation du chevron
|
import 'dart:math' as math; // Pour la rotation du chevron
|
||||||
import '../../widgets/hover_relief_widget.dart'; // Import du widget générique
|
import '../../widgets/hover_relief_widget.dart'; // Import du widget générique
|
||||||
import '../../models/card_assets.dart'; // Import des enums de cartes
|
import '../../models/card_assets.dart'; // Import des enums de cartes
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class RegisterChoiceScreen extends StatelessWidget {
|
class RegisterChoiceScreen extends StatelessWidget {
|
||||||
const RegisterChoiceScreen({super.key});
|
const RegisterChoiceScreen({super.key});
|
||||||
@ -28,12 +29,14 @@ class RegisterChoiceScreen extends StatelessWidget {
|
|||||||
top: 40,
|
top: 40,
|
||||||
left: 40,
|
left: 40,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Transform(
|
icon: Transform.flip(flipX: true, child: Image.asset('assets/images/chevron_right.png', height: 40)),
|
||||||
alignment: Alignment.center,
|
onPressed: () {
|
||||||
transform: Matrix4.rotationY(math.pi),
|
if (context.canPop()) {
|
||||||
child: Image.asset('assets/images/chevron_right.png', height: 40),
|
context.pop();
|
||||||
),
|
} else {
|
||||||
onPressed: () => Navigator.pop(context),
|
context.go('/login');
|
||||||
|
}
|
||||||
|
},
|
||||||
tooltip: 'Retour',
|
tooltip: 'Retour',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -89,7 +92,7 @@ class RegisterChoiceScreen extends StatelessWidget {
|
|||||||
iconPath: 'assets/images/icon_parents.png',
|
iconPath: 'assets/images/icon_parents.png',
|
||||||
label: 'Parents',
|
label: 'Parents',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamed(context, '/parent-register/step1');
|
context.go('/parent-register-step1');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// Bouton "Assistante Maternelle" avec HoverReliefWidget appliqué uniquement à l'image
|
// Bouton "Assistante Maternelle" avec HoverReliefWidget appliqué uniquement à l'image
|
||||||
@ -98,8 +101,7 @@ class RegisterChoiceScreen extends StatelessWidget {
|
|||||||
iconPath: 'assets/images/icon_assmat.png',
|
iconPath: 'assets/images/icon_assmat.png',
|
||||||
label: 'Assistante Maternelle',
|
label: 'Assistante Maternelle',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// TODO: Naviguer vers l'écran d'inscription assmat
|
context.go('/nanny-register-step1');
|
||||||
print('Choix: Assistante Maternelle');
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -3,6 +3,11 @@ import 'dart:math';
|
|||||||
class DataGenerator {
|
class DataGenerator {
|
||||||
static final Random _random = Random();
|
static final Random _random = Random();
|
||||||
|
|
||||||
|
// Méthodes publiques pour la génération de nombres aléatoires
|
||||||
|
static int randomInt(int max) => _random.nextInt(max);
|
||||||
|
static int randomIntInRange(int min, int max) => min + _random.nextInt(max - min);
|
||||||
|
static bool randomBool() => _random.nextBool();
|
||||||
|
|
||||||
static final List<String> _firstNames = [
|
static final List<String> _firstNames = [
|
||||||
'Alice', 'Bob', 'Charlie', 'David', 'Eva', 'Félix', 'Gabrielle', 'Hugo', 'Inès', 'Jules',
|
'Alice', 'Bob', 'Charlie', 'David', 'Eva', 'Félix', 'Gabrielle', 'Hugo', 'Inès', 'Jules',
|
||||||
'Léa', 'Manon', 'Nathan', 'Oscar', 'Pauline', 'Quentin', 'Raphaël', 'Sophie', 'Théo', 'Victoire'
|
'Léa', 'Manon', 'Nathan', 'Oscar', 'Pauline', 'Quentin', 'Raphaël', 'Sophie', 'Théo', 'Victoire'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user