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)
239 lines
11 KiB
Dart
239 lines
11 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'dart:math' as math; // Pour la rotation du chevron
|
|
|
|
import '../../../models/nanny_registration_data.dart';
|
|
import '../../../widgets/custom_app_text_field.dart';
|
|
import '../../../models/card_assets.dart'; // Pour les cartes
|
|
import '../../../utils/data_generator.dart'; // Implied import for DataGenerator
|
|
|
|
class NannyRegisterStep1Screen extends StatefulWidget {
|
|
const NannyRegisterStep1Screen({super.key});
|
|
|
|
@override
|
|
State<NannyRegisterStep1Screen> createState() => _NannyRegisterStep1ScreenState();
|
|
}
|
|
|
|
class _NannyRegisterStep1ScreenState extends State<NannyRegisterStep1Screen> {
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
final _firstNameController = TextEditingController();
|
|
final _lastNameController = TextEditingController();
|
|
final _streetAddressController = TextEditingController();
|
|
final _postalCodeController = TextEditingController();
|
|
final _cityController = TextEditingController();
|
|
final _phoneController = TextEditingController();
|
|
final _emailController = TextEditingController();
|
|
final _passwordController = TextEditingController();
|
|
final _confirmPasswordController = TextEditingController();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
final data = Provider.of<NannyRegistrationData>(context, listen: false);
|
|
|
|
_firstNameController.text = data.firstName;
|
|
_lastNameController.text = data.lastName;
|
|
_streetAddressController.text = data.streetAddress;
|
|
_postalCodeController.text = data.postalCode;
|
|
_cityController.text = data.city;
|
|
_phoneController.text = data.phone;
|
|
_emailController.text = data.email;
|
|
_passwordController.text = data.password;
|
|
_confirmPasswordController.text = data.password.isNotEmpty ? data.password : '';
|
|
|
|
if (data.firstName.isEmpty && data.lastName.isEmpty) {
|
|
final String genFirstName = DataGenerator.firstName();
|
|
final String genLastName = DataGenerator.lastName();
|
|
_firstNameController.text = genFirstName;
|
|
_lastNameController.text = genLastName;
|
|
_streetAddressController.text = DataGenerator.address();
|
|
_postalCodeController.text = DataGenerator.postalCode();
|
|
_cityController.text = DataGenerator.city();
|
|
_phoneController.text = DataGenerator.phone();
|
|
_emailController.text = DataGenerator.email(genFirstName, genLastName);
|
|
_passwordController.text = DataGenerator.password();
|
|
_confirmPasswordController.text = _passwordController.text;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_firstNameController.dispose();
|
|
_lastNameController.dispose();
|
|
_streetAddressController.dispose();
|
|
_postalCodeController.dispose();
|
|
_cityController.dispose();
|
|
_phoneController.dispose();
|
|
_emailController.dispose();
|
|
_passwordController.dispose();
|
|
_confirmPasswordController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _submitForm() {
|
|
if (_formKey.currentState?.validate() ?? false) {
|
|
Provider.of<NannyRegistrationData>(context, listen: false)
|
|
.updateIdentityInfo(
|
|
firstName: _firstNameController.text,
|
|
lastName: _lastNameController.text,
|
|
streetAddress: _streetAddressController.text,
|
|
postalCode: _postalCodeController.text,
|
|
city: _cityController.text,
|
|
phone: _phoneController.text,
|
|
email: _emailController.text,
|
|
password: _passwordController.text,
|
|
);
|
|
context.go('/nanny-register-step2');
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final screenSize = MediaQuery.of(context).size;
|
|
const cardColor = CardColorHorizontal.blue;
|
|
|
|
return Scaffold(
|
|
body: Stack(
|
|
children: [
|
|
Positioned.fill(
|
|
child: Image.asset(
|
|
'assets/images/paper2.png',
|
|
fit: BoxFit.cover,
|
|
repeat: ImageRepeat.repeat,
|
|
),
|
|
),
|
|
Center(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.symmetric(vertical: 40.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'Étape 1/4',
|
|
style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Container(
|
|
width: screenSize.width * 0.7,
|
|
padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 50),
|
|
constraints: const BoxConstraints(minHeight: 600),
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(cardColor.path),
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'Vos informations personnelles',
|
|
style: GoogleFonts.merienda(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 30),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(flex: 12, child: CustomAppTextField(controller: _lastNameController, labelText: 'Nom', hintText: 'Votre nom', fieldWidth: double.infinity)),
|
|
Expanded(flex: 1, child: const SizedBox()),
|
|
Expanded(flex: 12, child: CustomAppTextField(controller: _firstNameController, labelText: 'Prénom', hintText: 'Votre prénom', fieldWidth: double.infinity)),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(flex: 12, child: CustomAppTextField(controller: _phoneController, labelText: 'Téléphone', hintText: 'Votre téléphone', keyboardType: TextInputType.phone, fieldWidth: double.infinity)),
|
|
Expanded(flex: 1, child: const SizedBox()),
|
|
Expanded(flex: 12, child: CustomAppTextField(controller: _emailController, labelText: 'Email', hintText: 'Votre e-mail', keyboardType: TextInputType.emailAddress, fieldWidth: double.infinity)),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(flex: 12, child: CustomAppTextField(controller: _passwordController, labelText: 'Mot de passe', hintText: 'Minimum 6 caractères', obscureText: true, fieldWidth: double.infinity,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) return 'Mot de passe requis';
|
|
if (value.length < 6) return '6 caractères minimum';
|
|
return null;
|
|
}
|
|
)),
|
|
Expanded(flex: 1, child: const SizedBox()),
|
|
Expanded(flex: 12, child: CustomAppTextField(controller: _confirmPasswordController, labelText: 'Confirmation', hintText: 'Confirmez le mot de passe', obscureText: true, fieldWidth: double.infinity,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) return 'Confirmation requise';
|
|
if (value != _passwordController.text) return 'Les mots de passe ne correspondent pas';
|
|
return null;
|
|
}
|
|
)),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
CustomAppTextField(
|
|
controller: _streetAddressController,
|
|
labelText: 'Adresse (N° et Rue)',
|
|
hintText: 'Numéro et nom de votre rue',
|
|
fieldWidth: double.infinity,
|
|
validator: (v) => v!.isEmpty ? 'Adresse requise' : null,
|
|
),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(flex: 5, child: CustomAppTextField(controller: _postalCodeController, labelText: 'Code Postal', hintText: 'C.P.', keyboardType: TextInputType.number, fieldWidth: double.infinity, validator: (v) => v!.isEmpty ? 'C.P. requis' : null)),
|
|
Expanded(flex: 1, child: const SizedBox()),
|
|
Expanded(flex: 12, child: CustomAppTextField(controller: _cityController, labelText: 'Ville', hintText: 'Votre ville', fieldWidth: double.infinity, validator: (v) => v!.isEmpty ? 'Ville requise' : null)),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
top: screenSize.height / 2 - 20,
|
|
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: () {
|
|
if (context.canPop()) {
|
|
context.pop();
|
|
} else {
|
|
context.go('/register-choice');
|
|
}
|
|
},
|
|
tooltip: 'Retour',
|
|
),
|
|
),
|
|
Positioned(
|
|
top: screenSize.height / 2 - 20,
|
|
right: 40,
|
|
child: IconButton(
|
|
icon: Image.asset('assets/images/chevron_right.png', height: 40),
|
|
onPressed: _submitForm,
|
|
tooltip: 'Suivant',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |