Implémentation du parcours d'inscription des assistantes maternelles en 4 étapes + écran de confirmation, en utilisant Provider pour la gestion d'état. Fonctionnalités implémentées : - Étape 1 : Identité (nom, prénom, adresse, email, mot de passe) - Étape 2 : Infos professionnelles (photo, agrément, NIR, capacité d'accueil) - Étape 3 : Présentation personnelle et acceptation CGU - Étape 4 : Récapitulatif et validation finale - Écran de confirmation post-inscription Fichiers ajoutés : - models/nanny_registration_data.dart : Modèle de données avec Provider - screens/auth/nanny_register_step1_screen.dart : Identité - screens/auth/nanny_register_step2_screen.dart : Infos pro - screens/auth/nanny_register_step3_screen.dart : Présentation - screens/auth/nanny_register_step4_screen.dart : Récapitulatif - screens/auth/nanny_register_confirmation_screen.dart : Confirmation - screens/unknown_screen.dart : Écran pour routes inconnues - config/app_router.dart : Copie du routeur (à intégrer) Refs: #40 (Panneau 1 Identité), #41 (Panneau 2 Infos pro), #42 (Finalisation)
251 lines
12 KiB
Dart
251 lines
12 KiB
Dart
import 'package:flutter/material.dart';
|
|
// import 'package:p_tits_pas/utils/resources/card_color_horizontal.dart'; // Supprimé car incorrect
|
|
import 'package:provider/provider.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'dart:math' as math;
|
|
import 'package:p_tits_pas/models/card_assets.dart';
|
|
import '../../../models/nanny_registration_data.dart';
|
|
// import '../../../widgets/registration_scaffold.dart'; // Widget inexistant
|
|
// import '../../../widgets/recap_card.dart'; // Widget inexistant
|
|
import 'dart:io';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
class NannyRegisterStep4Screen extends StatelessWidget {
|
|
const NannyRegisterStep4Screen({super.key});
|
|
|
|
void _submitRegistration(BuildContext context) {
|
|
final nannyData = Provider.of<NannyRegistrationData>(context, listen: false);
|
|
print('Submitting Nanny Registration: ${nannyData.toString()}');
|
|
// TODO: Implement actual submission logic (e.g., API call)
|
|
context.go('/nanny-register-confirmation');
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final nannyData = Provider.of<NannyRegistrationData>(context);
|
|
final dateFormat = DateFormat('dd/MM/yyyy');
|
|
final size = MediaQuery.of(context).size;
|
|
final bool canSubmit = nannyData.isRegistrationComplete; // Check completeness
|
|
|
|
return Scaffold( // Main scaffold to contain the stack
|
|
body: Stack(
|
|
children: [
|
|
// Background image
|
|
Positioned.fill(
|
|
child: Image.asset(
|
|
'assets/images/paper2.png', // Assurez-vous que le chemin est correct
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
|
|
// Content centered
|
|
Center(
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxWidth: size.width * 0.8, // Adjust width as needed
|
|
maxHeight: size.height * 0.85, // Adjust height as needed
|
|
),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(CardColorHorizontal.blue.path),
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 40.0, bottom: 10.0),
|
|
child: Text(
|
|
'Récapitulatif',
|
|
style: GoogleFonts.merienda(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 15.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Text(
|
|
'Veuillez vérifier attentivement les informations avant de soumettre.',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(color: Colors.white70),
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
// --- Identity Card (Using standard Card for grouping) ---
|
|
Card(
|
|
elevation: 2.0,
|
|
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(15.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildCardTitle(context, 'Informations personnelles', '/nanny-register-step1'),
|
|
const Divider(),
|
|
if (nannyData.photoPath != null && nannyData.photoPath!.isNotEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
|
child: Center(
|
|
child: CircleAvatar(
|
|
radius: 40,
|
|
backgroundImage: FileImage(File(nannyData.photoPath!)),
|
|
onBackgroundImageError: (exception, stackTrace) {
|
|
print("Erreur chargement image: $exception");
|
|
// Optionnel: afficher un placeholder ou icône d'erreur
|
|
},
|
|
),
|
|
),
|
|
),
|
|
_buildRecapRow('Nom:', '${nannyData.firstName} ${nannyData.lastName}'),
|
|
_buildRecapRow('Adresse:', '${nannyData.streetAddress}${nannyData.postalCode.isNotEmpty ? '\n${nannyData.postalCode}' : ''}${nannyData.city.isNotEmpty ? ' ${nannyData.city}' : ''}'.trim()),
|
|
_buildRecapRow('Téléphone:', nannyData.phone),
|
|
_buildRecapRow('Email:', nannyData.email),
|
|
_buildRecapRow('Consentement Photo:', nannyData.photoConsent ? 'Oui' : 'Non'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
// --- Professional Info Card (Using standard Card) ---
|
|
Card(
|
|
elevation: 2.0,
|
|
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(15.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildCardTitle(context, 'Informations professionnelles', '/nanny-register-step2'),
|
|
const Divider(),
|
|
_buildRecapRow('Date de naissance:', nannyData.dateOfBirth != null ? dateFormat.format(nannyData.dateOfBirth!) : 'Non renseigné'),
|
|
_buildRecapRow('Lieu de naissance:', '${nannyData.birthCity}, ${nannyData.birthCountry}'.isNotEmpty ? '${nannyData.birthCity}, ${nannyData.birthCountry}' : 'Non renseigné'),
|
|
_buildRecapRow('N° Sécurité Sociale:', nannyData.nir.isNotEmpty ? nannyData.nir : 'Non renseigné'), // TODO: Mask this?
|
|
_buildRecapRow('N° Agrément:', nannyData.agrementNumber.isNotEmpty ? nannyData.agrementNumber : 'Non renseigné'),
|
|
_buildRecapRow('Capacité d\'accueil:', nannyData.capacity?.toString() ?? 'Non renseigné'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
// --- Presentation Card (Using standard Card) ---
|
|
Card(
|
|
elevation: 2.0,
|
|
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(15.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildCardTitle(context, 'Présentation & CGU', '/nanny-register-step3'),
|
|
const Divider(),
|
|
const Text('Votre présentation (facultatif) :', style: TextStyle(fontWeight: FontWeight.bold)),
|
|
const SizedBox(height: 5),
|
|
Container(
|
|
padding: const EdgeInsets.all(10),
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[100],
|
|
borderRadius: BorderRadius.circular(5),
|
|
border: Border.all(color: Colors.grey[300]!)
|
|
),
|
|
child: Text(
|
|
nannyData.presentationText.isNotEmpty
|
|
? nannyData.presentationText
|
|
: 'Aucune présentation rédigée.',
|
|
style: TextStyle(
|
|
color: nannyData.presentationText.isNotEmpty ? Colors.black87 : Colors.grey,
|
|
fontStyle: nannyData.presentationText.isNotEmpty ? FontStyle.normal : FontStyle.italic
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 15),
|
|
_buildRecapRow('CGU Acceptées:', nannyData.cguAccepted ? 'Oui' : 'Non'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (!canSubmit) // Show warning if incomplete
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 15.0, bottom: 5.0), // Add some space
|
|
child: Text(
|
|
'Veuillez compléter toutes les étapes requises et accepter les CGU pour pouvoir soumettre.',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(color: Theme.of(context).colorScheme.error, fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
// Navigation buttons
|
|
Positioned(
|
|
top: size.height / 2 - 20, // Centré verticalement
|
|
left: 40,
|
|
child: IconButton(
|
|
icon: Transform(
|
|
alignment: Alignment.center,
|
|
transform: Matrix4.rotationY(math.pi),
|
|
child: Image.asset('assets/images/chevron_right.png', height: 40),
|
|
),
|
|
onPressed: () => context.go('/nanny-register-step3'),
|
|
tooltip: 'Précédent',
|
|
),
|
|
),
|
|
Positioned(
|
|
top: size.height / 2 - 20, // Centré verticalement
|
|
right: 40,
|
|
child: IconButton(
|
|
icon: Image.asset('assets/images/chevron_right.png', height: 40),
|
|
onPressed: canSubmit ? () => _submitRegistration(context) : null,
|
|
tooltip: 'Soumettre',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// Helper to build title row with edit button
|
|
Widget _buildCardTitle(BuildContext context, String title, String editRoute) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(title, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
|
IconButton(
|
|
icon: const Icon(Icons.edit, size: 20),
|
|
onPressed: () => context.go(editRoute),
|
|
tooltip: 'Modifier',
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// Helper to build data row
|
|
Widget _buildRecapRow(String label, String value) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('$label ', style: const TextStyle(fontWeight: FontWeight.bold)),
|
|
Expanded(child: Text(value)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |