feat: mise en place du projet et création de la page de login

This commit is contained in:
Julien Martin
2025-05-02 21:30:31 +02:00
parent d5015b9c42
commit d3663a28ad
91 changed files with 9494 additions and 191 deletions
+539
View File
@@ -0,0 +1,539 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:url_launcher/url_launcher.dart';
import 'package:p_tits_pas/services/bug_report_service.dart';
import 'package:go_router/go_router.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final _formKey = GlobalKey<FormState>();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
@override
void dispose() {
_emailController.dispose();
_passwordController.dispose();
super.dispose();
}
String? _validateEmail(String? value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre email';
}
if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(value)) {
return 'Veuillez entrer un email valide';
}
return null;
}
String? _validatePassword(String? value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre mot de passe';
}
if (value.length < 6) {
return 'Le mot de passe doit contenir au moins 6 caractères';
}
return null;
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: LayoutBuilder(
builder: (context, constraints) {
// Version desktop (web)
if (kIsWeb) {
final w = constraints.maxWidth;
final h = constraints.maxHeight;
return FutureBuilder(
future: _getImageDimensions(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}
final imageDimensions = snapshot.data!;
final imageHeight = h;
final imageWidth = imageHeight * (imageDimensions.width / imageDimensions.height);
final remainingWidth = w - imageWidth;
final leftMargin = remainingWidth / 4;
return Stack(
children: [
// Fond en papier
Positioned.fill(
child: Image.asset(
'assets/images/paper2.png',
fit: BoxFit.cover,
repeat: ImageRepeat.repeat,
),
),
// Image principale
Positioned(
left: leftMargin,
top: 0,
height: imageHeight,
width: imageWidth,
child: Image.asset(
'assets/images/river_logo_desktop.png',
fit: BoxFit.contain,
),
),
// Formulaire dans le cadran en bas à droite
Positioned(
right: 0,
bottom: 0,
width: w * 0.6, // 60% de la largeur de l'écran
height: h * 0.5, // 50% de la hauteur de l'écran
child: Padding(
padding: EdgeInsets.all(w * 0.02), // 2% de padding
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Labels au-dessus des champs
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
'Email',
style: GoogleFonts.merienda(
fontSize: 20,
color: Colors.black87,
fontWeight: FontWeight.w600,
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
'Mot de passe',
style: GoogleFonts.merienda(
fontSize: 20,
color: Colors.black87,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
const SizedBox(height: 10),
// Champs côte à côte
Row(
children: [
Expanded(
child: _ImageTextField(
bg: 'assets/images/field_email.png',
width: 400,
height: 53,
hint: 'Email',
controller: _emailController,
validator: _validateEmail,
),
),
const SizedBox(width: 20),
Expanded(
child: _ImageTextField(
bg: 'assets/images/field_password.png',
width: 400,
height: 53,
hint: 'Mot de passe',
obscure: true,
controller: _passwordController,
validator: _validatePassword,
),
),
],
),
const SizedBox(height: 20), // Réduit l'espacement
// Bouton centré
Center(
child: _ImageButton(
bg: 'assets/images/btn_green.png',
width: 300,
height: 40,
text: 'Se connecter',
textColor: const Color(0xFF2D6A4F),
onPressed: () {
if (_formKey.currentState?.validate() ?? false) {
// TODO: Implémenter la logique de connexion
}
},
),
),
const SizedBox(height: 10),
// Lien mot de passe oublié
Center(
child: TextButton(
onPressed: () {
// TODO: Implémenter la logique de récupération de mot de passe
},
child: Text(
'Mot de passe oublié ?',
style: GoogleFonts.merienda(
fontSize: 14,
color: const Color(0xFF2D6A4F),
decoration: TextDecoration.underline,
),
),
),
),
const SizedBox(height: 10),
// Lien de création de compte
Center(
child: TextButton(
onPressed: () {
Navigator.pushNamed(context, '/parent-register');
},
child: Text(
'Créer un compte',
style: GoogleFonts.merienda(
fontSize: 16,
color: const Color(0xFF2D6A4F),
decoration: TextDecoration.underline,
),
),
),
),
const SizedBox(height: 20), // Réduit l'espacement en bas
],
),
),
),
),
// Pied de page
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 8.0),
decoration: BoxDecoration(
color: Colors.transparent,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_FooterLink(
text: 'Contact support',
onTap: () async {
final Uri emailLaunchUri = Uri(
scheme: 'mailto',
path: 'support@supernounou.local',
);
if (await canLaunchUrl(emailLaunchUri)) {
await launchUrl(emailLaunchUri);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Impossible d\'ouvrir le client mail',
style: GoogleFonts.merienda(),
),
),
);
}
},
),
_FooterLink(
text: 'Signaler un bug',
onTap: () {
_showBugReportDialog(context);
},
),
_FooterLink(
text: 'Mentions légales',
onTap: () {
Navigator.pushNamed(context, '/legal');
},
),
_FooterLink(
text: 'Politique de confidentialité',
onTap: () {
Navigator.pushNamed(context, '/privacy');
},
),
],
),
),
),
],
);
},
);
}
// Version mobile (à implémenter)
return const Center(
child: Text('Version mobile à implémenter'),
);
},
),
);
}
void _showBugReportDialog(BuildContext context) {
final TextEditingController controller = TextEditingController();
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(
'Signaler un bug',
style: GoogleFonts.merienda(),
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: controller,
maxLines: 5,
decoration: InputDecoration(
hintText: 'Décrivez le problème rencontré...',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(
'Annuler',
style: GoogleFonts.merienda(),
),
),
TextButton(
onPressed: () async {
if (controller.text.trim().isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Veuillez décrire le problème',
style: GoogleFonts.merienda(),
),
),
);
return;
}
try {
await BugReportService.sendReport(controller.text);
if (context.mounted) {
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Rapport envoyé avec succès',
style: GoogleFonts.merienda(),
),
),
);
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Erreur lors de l\'envoi du rapport',
style: GoogleFonts.merienda(),
),
),
);
}
}
},
child: Text(
'Envoyer',
style: GoogleFonts.merienda(),
),
),
],
),
);
}
Future<ImageDimensions> _getImageDimensions() async {
final image = Image.asset('assets/images/river_logo_desktop.png');
final completer = Completer<ImageDimensions>();
image.image.resolve(const ImageConfiguration()).addListener(
ImageStreamListener((info, _) {
completer.complete(ImageDimensions(
width: info.image.width.toDouble(),
height: info.image.height.toDouble(),
));
}),
);
return completer.future;
}
}
class ImageDimensions {
final double width;
final double height;
ImageDimensions({required this.width, required this.height});
}
// ───────────────────────────────────────────────────────────────
// Champ texte avec fond image
// ───────────────────────────────────────────────────────────────
class _ImageTextField extends StatelessWidget {
final String bg;
final double width;
final double height;
final String hint;
final bool obscure;
final TextEditingController? controller;
final String? Function(String?)? validator;
const _ImageTextField({
required this.bg,
required this.width,
required this.height,
required this.hint,
this.obscure = false,
this.controller,
this.validator,
});
@override
Widget build(BuildContext context) {
return Container(
width: width,
height: height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(bg),
fit: BoxFit.fill,
),
),
child: TextFormField(
controller: controller,
obscureText: obscure,
textAlign: TextAlign.left,
style: GoogleFonts.merienda(
fontSize: height * 0.25,
color: Colors.black87,
),
validator: validator,
decoration: InputDecoration(
border: InputBorder.none,
hintText: hint,
hintStyle: GoogleFonts.merienda(
fontSize: height * 0.25,
color: Colors.black38,
),
contentPadding: EdgeInsets.symmetric(
horizontal: width * 0.1,
vertical: height * 0.3,
),
errorStyle: GoogleFonts.merienda(
fontSize: height * 0.2,
color: Colors.red,
),
),
),
);
}
}
// ───────────────────────────────────────────────────────────────
// Bouton avec fond image
// ───────────────────────────────────────────────────────────────
class _ImageButton extends StatelessWidget {
final String bg;
final double width;
final double height;
final String text;
final Color textColor;
final VoidCallback onPressed;
const _ImageButton({
required this.bg,
required this.width,
required this.height,
required this.text,
required this.textColor,
required this.onPressed,
});
@override
Widget build(BuildContext context) {
return Container(
width: width,
height: height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(bg),
fit: BoxFit.fill,
),
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onPressed,
child: Center(
child: Text(
text,
style: GoogleFonts.merienda(
fontSize: height * 0.4,
color: textColor,
fontWeight: FontWeight.w600,
),
),
),
),
),
);
}
}
// ───────────────────────────────────────────────────────────────
// Lien du pied de page
// ───────────────────────────────────────────────────────────────
class _FooterLink extends StatelessWidget {
final String text;
final VoidCallback onTap;
const _FooterLink({
required this.text,
required this.onTap,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text(
text,
style: GoogleFonts.merienda(
fontSize: 14,
color: Colors.black87,
decoration: TextDecoration.underline,
),
),
),
);
}
}
@@ -0,0 +1,752 @@
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:go_router/go_router.dart';
import '../../services/auth_service.dart';
import '../../theme/app_theme.dart';
import 'dart:convert';
class ChildData {
final TextEditingController firstNameController = TextEditingController();
final TextEditingController lastNameController = TextEditingController();
DateTime? birthDate;
DateTime? expectedBirthDate;
XFile? photo;
bool hasPhotoConsent = false;
bool isMultipleBirth = false;
bool isUnborn = false;
}
class ParentRegisterScreen extends StatefulWidget {
const ParentRegisterScreen({super.key});
@override
State<ParentRegisterScreen> createState() => _ParentRegisterScreenState();
}
class _ParentRegisterScreenState extends State<ParentRegisterScreen> {
final _formKey = GlobalKey<FormState>();
final _authService = AuthService();
int _currentStep = 0;
bool _isLoading = false;
bool _hasPartner = false;
bool _hasAcceptedCGU = false;
bool _partnerSameAddress = false;
// Contrôleurs pour le parent 1
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
final _firstNameController = TextEditingController();
final _lastNameController = TextEditingController();
final _phoneController = TextEditingController();
final _addressController = TextEditingController();
final _cityController = TextEditingController();
final _postalCodeController = TextEditingController();
final _presentationController = TextEditingController();
// Contrôleurs pour le parent 2
final _partnerFirstNameController = TextEditingController();
final _partnerLastNameController = TextEditingController();
final _partnerEmailController = TextEditingController();
final _partnerPhoneController = TextEditingController();
final _partnerAddressController = TextEditingController();
final _partnerCityController = TextEditingController();
final _partnerPostalCodeController = TextEditingController();
// Liste des enfants
final List<ChildData> _children = [ChildData()];
final _motivationController = TextEditingController();
@override
void dispose() {
_emailController.dispose();
_passwordController.dispose();
_firstNameController.dispose();
_lastNameController.dispose();
_phoneController.dispose();
_addressController.dispose();
_cityController.dispose();
_postalCodeController.dispose();
_presentationController.dispose();
_partnerFirstNameController.dispose();
_partnerLastNameController.dispose();
_partnerEmailController.dispose();
_partnerPhoneController.dispose();
_partnerAddressController.dispose();
_partnerCityController.dispose();
_partnerPostalCodeController.dispose();
for (var child in _children) {
child.firstNameController.dispose();
child.lastNameController.dispose();
}
_motivationController.dispose();
super.dispose();
}
Future<void> _pickImage(ChildData child) async {
final ImagePicker picker = ImagePicker();
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
if (image != null) {
setState(() {
child.photo = image;
});
}
}
Future<String?> _uploadImage(XFile image, String userId) async {
// En mode démonstration, on retourne juste un chemin local
return image.path;
}
Future<void> _register() async {
if (!_formKey.currentState!.validate()) return;
setState(() => _isLoading = true);
try {
final List<Map<String, dynamic>> childrenData = [];
for (var child in _children) {
childrenData.add({
'firstName': child.firstNameController.text,
'lastName': child.lastNameController.text,
'birthDate': child.isUnborn ? null : child.birthDate,
'expectedBirthDate': child.isUnborn ? child.expectedBirthDate : null,
'photo': child.photo != null ? base64Encode(child.photo!.readAsBytesSync()) : null,
'hasPhotoConsent': child.hasPhotoConsent,
'isMultipleBirth': child.isMultipleBirth,
});
}
await _authService.registerParent(
email: _emailController.text,
password: _passwordController.text,
firstName: _firstNameController.text,
lastName: _lastNameController.text,
phoneNumber: _phoneController.text,
address: _addressController.text,
city: _cityController.text,
postalCode: _postalCodeController.text,
presentation: _presentationController.text,
hasAcceptedCGU: _hasAcceptedCGU,
partnerFirstName: _hasPartner ? _partnerFirstNameController.text : null,
partnerLastName: _hasPartner ? _partnerLastNameController.text : null,
partnerEmail: _hasPartner ? _partnerEmailController.text : null,
partnerPhoneNumber: _hasPartner ? _partnerPhoneController.text : null,
partnerAddress: _hasPartner
? (_partnerSameAddress
? _addressController.text
: _partnerAddressController.text)
: null,
partnerCity: _hasPartner
? (_partnerSameAddress ? _cityController.text : _partnerCityController.text)
: null,
partnerPostalCode: _hasPartner
? (_partnerSameAddress ? _postalCodeController.text : _partnerPostalCodeController.text)
: null,
children: childrenData,
motivation: _motivationController.text,
);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Inscription réussie ! Votre compte est en attente de validation.'),
backgroundColor: Colors.green,
),
);
context.pop();
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Erreur lors de l\'inscription: $e'),
backgroundColor: Colors.red,
),
);
}
} finally {
if (mounted) {
setState(() => _isLoading = false);
}
}
}
Widget _buildChildForm(ChildData child, int index) {
return Card(
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Enfant ${index + 1}',
style: Theme.of(context).textTheme.titleMedium,
),
if (index > 0)
IconButton(
icon: const Icon(Icons.delete),
onPressed: () {
setState(() {
_children.removeAt(index);
});
},
),
],
),
if (child.photo != null)
CircleAvatar(
radius: 50,
backgroundImage: NetworkImage(child.photo!.path),
),
TextButton(
onPressed: () => _pickImage(child),
child: const Text('Ajouter une photo'),
),
SwitchListTile(
title: const Text('Enfant à naître'),
value: child.isUnborn,
onChanged: (value) => setState(() => child.isUnborn = value),
),
TextFormField(
controller: child.firstNameController,
decoration: const InputDecoration(labelText: 'Prénom de l\'enfant'),
),
TextFormField(
controller: child.lastNameController,
decoration: const InputDecoration(labelText: 'Nom de l\'enfant'),
),
if (!child.isUnborn)
ListTile(
title: const Text('Date de naissance'),
subtitle: Text(child.birthDate != null
? '${child.birthDate!.day}/${child.birthDate!.month}/${child.birthDate!.year}'
: 'Non définie'),
trailing: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () async {
final date = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime.now(),
);
if (date != null) {
setState(() => child.birthDate = date);
}
},
),
),
if (child.isUnborn)
ListTile(
title: const Text('Date prévue'),
subtitle: Text(child.expectedBirthDate != null
? '${child.expectedBirthDate!.day}/${child.expectedBirthDate!.month}/${child.expectedBirthDate!.year}'
: 'Non définie'),
trailing: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () async {
final date = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime.now().add(const Duration(days: 365)),
);
if (date != null) {
setState(() => child.expectedBirthDate = date);
}
},
),
),
SwitchListTile(
title: const Text('Naissance multiple'),
subtitle: const Text('Jumeaux, triplés, etc.'),
value: child.isMultipleBirth,
onChanged: (value) => setState(() => child.isMultipleBirth = value),
),
if (child.photo != null)
SwitchListTile(
title: const Text('Consentement photo'),
subtitle: const Text('J\'autorise l\'utilisation de la photo de mon enfant'),
value: child.hasPhotoConsent,
onChanged: (value) => setState(() => child.hasPhotoConsent = value),
),
],
),
),
);
}
List<Step> _getSteps() {
return [
// Étape 1 : Parent 1
Step(
title: const Text('Informations parent 1'),
content: Column(
children: [
TextFormField(
controller: _emailController,
decoration: const InputDecoration(labelText: 'Email'),
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre email';
}
return null;
},
),
TextFormField(
controller: _passwordController,
decoration: const InputDecoration(labelText: 'Mot de passe'),
obscureText: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer un mot de passe';
}
if (value.length < 6) {
return 'Le mot de passe doit contenir au moins 6 caractères';
}
return null;
},
),
TextFormField(
controller: _firstNameController,
decoration: const InputDecoration(labelText: 'Prénom'),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre prénom';
}
return null;
},
),
TextFormField(
controller: _lastNameController,
decoration: const InputDecoration(labelText: 'Nom'),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre nom';
}
return null;
},
),
TextFormField(
controller: _phoneController,
decoration: const InputDecoration(labelText: 'Téléphone'),
keyboardType: TextInputType.phone,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre numéro de téléphone';
}
return null;
},
),
TextFormField(
controller: _addressController,
decoration: const InputDecoration(labelText: 'Adresse'),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre adresse';
}
return null;
},
),
TextFormField(
controller: _cityController,
decoration: const InputDecoration(labelText: 'Ville'),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre ville';
}
return null;
},
),
TextFormField(
controller: _postalCodeController,
decoration: const InputDecoration(labelText: 'Code postal'),
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez entrer votre code postal';
}
return null;
},
),
TextFormField(
controller: _presentationController,
decoration: const InputDecoration(labelText: 'Présentation'),
maxLines: 3,
),
],
),
isActive: _currentStep >= 0,
),
// Étape 2 : Parent 2
Step(
title: const Text('Parent 2'),
content: Column(
children: [
SwitchListTile(
title: const Text('Ajouter un deuxième parent'),
value: _hasPartner,
onChanged: (value) => setState(() => _hasPartner = value),
),
if (_hasPartner) ...[
SwitchListTile(
title: const Text('Adresse identique au parent 1'),
value: _partnerSameAddress,
onChanged: (value) {
setState(() {
_partnerSameAddress = value;
if (value) {
_partnerAddressController.text = _addressController.text;
_partnerCityController.text = _cityController.text;
_partnerPostalCodeController.text = _postalCodeController.text;
} else {
_partnerAddressController.clear();
_partnerCityController.clear();
_partnerPostalCodeController.clear();
}
});
},
),
TextFormField(
controller: _partnerFirstNameController,
decoration: const InputDecoration(labelText: 'Prénom du deuxième parent'),
validator: (value) {
if (_hasPartner && (value == null || value.isEmpty)) {
return 'Veuillez entrer le prénom';
}
return null;
},
),
TextFormField(
controller: _partnerLastNameController,
decoration: const InputDecoration(labelText: 'Nom du deuxième parent'),
validator: (value) {
if (_hasPartner && (value == null || value.isEmpty)) {
return 'Veuillez entrer le nom';
}
return null;
},
),
TextFormField(
controller: _partnerEmailController,
decoration: const InputDecoration(labelText: 'Email du deuxième parent'),
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (_hasPartner && (value == null || value.isEmpty)) {
return 'Veuillez entrer l\'email';
}
return null;
},
),
TextFormField(
controller: _partnerPhoneController,
decoration: const InputDecoration(labelText: 'Téléphone du deuxième parent'),
keyboardType: TextInputType.phone,
),
if (!_partnerSameAddress) ...[
TextFormField(
controller: _partnerAddressController,
decoration: const InputDecoration(labelText: 'Adresse du deuxième parent'),
validator: (value) {
if (_hasPartner && !_partnerSameAddress && (value == null || value.isEmpty)) {
return 'Veuillez entrer l\'adresse';
}
return null;
},
),
TextFormField(
controller: _partnerCityController,
decoration: const InputDecoration(labelText: 'Ville du deuxième parent'),
validator: (value) {
if (_hasPartner && !_partnerSameAddress && (value == null || value.isEmpty)) {
return 'Veuillez entrer la ville';
}
return null;
},
),
TextFormField(
controller: _partnerPostalCodeController,
decoration: const InputDecoration(labelText: 'Code postal du deuxième parent'),
keyboardType: TextInputType.number,
validator: (value) {
if (_hasPartner && !_partnerSameAddress && (value == null || value.isEmpty)) {
return 'Veuillez entrer le code postal';
}
return null;
},
),
],
],
],
),
isActive: _currentStep >= 1,
),
// Étape 3 : Enfants
Step(
title: const Text('Enfants'),
content: Column(
children: [
..._children.asMap().entries.map((entry) => _buildChildForm(entry.value, entry.key)),
const SizedBox(height: 16),
ElevatedButton.icon(
onPressed: () {
setState(() {
_children.add(ChildData());
});
},
icon: const Icon(Icons.add),
label: const Text('Ajouter un autre enfant'),
),
],
),
isActive: _currentStep >= 2,
),
// Étape 4 : Description de la situation
Step(
title: const Text('Description de votre situation'),
content: Column(
children: [
TextFormField(
controller: _motivationController,
decoration: const InputDecoration(
labelText: 'Décrivez votre situation',
hintText: 'Expliquez-nous votre situation familiale et vos besoins...',
),
maxLines: 5,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Veuillez nous décrire votre situation';
}
return null;
},
),
],
),
isActive: _currentStep >= 3,
),
// Étape 5 : CGU
Step(
title: const Text('Conditions générales'),
content: Column(
children: [
SwitchListTile(
title: const Text('Conditions générales'),
subtitle: const Text('J\'accepte les conditions générales d\'utilisation'),
value: _hasAcceptedCGU,
onChanged: (value) => setState(() => _hasAcceptedCGU = value),
),
if (!_hasAcceptedCGU)
const Text(
'Vous devez accepter les conditions générales pour continuer',
style: TextStyle(color: Colors.red),
),
],
),
isActive: _currentStep >= 4,
),
// Étape 6 : Résumé
Step(
title: const Text('Résumé'),
content: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Veuillez vérifier vos informations avant validation :',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
const SizedBox(height: 16),
// Parent 1
const Text('Parent 1', style: TextStyle(fontWeight: FontWeight.bold)),
ListTile(
title: const Text('Email'),
subtitle: Text(_emailController.text),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 0),
),
),
ListTile(
title: const Text('Nom complet'),
subtitle: Text('${_firstNameController.text} ${_lastNameController.text}'),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 0),
),
),
ListTile(
title: const Text('Adresse'),
subtitle: Text('${_addressController.text}\n${_postalCodeController.text} ${_cityController.text}'),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 0),
),
),
ListTile(
title: const Text('Téléphone'),
subtitle: Text(_phoneController.text),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 0),
),
),
if (_presentationController.text.isNotEmpty)
ListTile(
title: const Text('Présentation'),
subtitle: Text(_presentationController.text),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 0),
),
),
// Parent 2
if (_hasPartner) ...[
const SizedBox(height: 16),
const Text('Parent 2', style: TextStyle(fontWeight: FontWeight.bold)),
ListTile(
title: const Text('Email'),
subtitle: Text(_partnerEmailController.text),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 1),
),
),
ListTile(
title: const Text('Nom complet'),
subtitle: Text('${_partnerFirstNameController.text} ${_partnerLastNameController.text}'),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 1),
),
),
ListTile(
title: const Text('Téléphone'),
subtitle: Text(_partnerPhoneController.text),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 1),
),
),
ListTile(
title: const Text('Adresse'),
subtitle: _partnerSameAddress
? const Text('Identique au parent 1')
: Text('${_partnerAddressController.text}\n${_partnerPostalCodeController.text} ${_partnerCityController.text}'),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 1),
),
),
],
// Enfants
const SizedBox(height: 16),
const Text('Enfants', style: TextStyle(fontWeight: FontWeight.bold)),
..._children.asMap().entries.map((entry) {
final child = entry.value;
return ListTile(
title: Text('Enfant ${entry.key + 1}'),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Prénom : ${child.firstNameController.text} ${child.lastNameController.text}'),
if (child.isUnborn)
Text('Date prévue : ${child.expectedBirthDate?.day}/${child.expectedBirthDate?.month}/${child.expectedBirthDate?.year}')
else
Text('Date de naissance : ${child.birthDate?.day}/${child.birthDate?.month}/${child.birthDate?.year}'),
if (child.isMultipleBirth)
const Text('Naissance multiple'),
],
),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 2),
),
);
}),
// Motivation
const SizedBox(height: 16),
const Text('Motivation', style: TextStyle(fontWeight: FontWeight.bold)),
ListTile(
title: const Text('Votre message'),
subtitle: Text(_motivationController.text),
trailing: IconButton(
icon: const Icon(Icons.edit),
onPressed: () => setState(() => _currentStep = 3),
),
),
],
),
),
isActive: _currentStep >= 5,
),
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Inscription Parent'),
),
body: Form(
key: _formKey,
child: Stepper(
currentStep: _currentStep,
onStepContinue: () {
if (_currentStep < _getSteps().length - 1) {
setState(() => _currentStep++);
} else if (_hasAcceptedCGU) {
_register();
}
},
onStepCancel: () {
if (_currentStep > 0) {
setState(() => _currentStep--);
} else {
Navigator.pop(context);
}
},
controlsBuilder: (context, details) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Row(
children: [
if (_currentStep > 0)
OutlinedButton(
onPressed: details.onStepCancel,
child: const Text('Retour'),
),
const SizedBox(width: 16),
if (_currentStep < _getSteps().length - 1)
ElevatedButton(
onPressed: details.onStepContinue,
child: const Text('Suivant'),
)
else
ElevatedButton(
onPressed: _hasAcceptedCGU ? details.onStepContinue : null,
child: _isLoading
? const CircularProgressIndicator()
: const Text('S\'inscrire'),
),
],
),
);
},
steps: _getSteps(),
),
),
);
}
}
@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../theme/theme_provider.dart';
import '../../theme/app_theme.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
String _getThemeName(ThemeType type) {
switch (type) {
case ThemeType.defaultTheme:
return "P'titsPas";
case ThemeType.pastelTheme:
return "Pastel";
case ThemeType.darkTheme:
return "Sombre";
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Accueil'),
actions: [
Consumer<ThemeProvider>(
builder: (context, themeProvider, child) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: DropdownButton<ThemeType>(
value: themeProvider.currentTheme,
items: ThemeType.values.map((ThemeType type) {
return DropdownMenuItem<ThemeType>(
value: type,
child: Text(_getThemeName(type)),
);
}).toList(),
onChanged: (ThemeType? newValue) {
if (newValue != null) {
themeProvider.setTheme(newValue);
}
},
),
);
},
),
],
),
body: const Center(
child: Text('Bienvenue sur P\'titsPas !'),
),
);
}
}
@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class LegalPage extends StatelessWidget {
const LegalPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Mentions légales',
style: GoogleFonts.merienda(),
),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Éditeur',
style: GoogleFonts.merienda(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Text(
'P\'titsPas est une application développée pour les collectivités locales.',
style: GoogleFonts.merienda(),
),
const SizedBox(height: 32),
Text(
'Hébergeur',
style: GoogleFonts.merienda(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Text(
'Les données sont hébergées sur des serveurs sécurisés en France.',
style: GoogleFonts.merienda(),
),
const SizedBox(height: 32),
Text(
'Responsable du traitement',
style: GoogleFonts.merienda(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Text(
'Le responsable du traitement des données est la collectivité locale utilisatrice de l\'application.',
style: GoogleFonts.merienda(),
),
],
),
),
);
}
}
@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class PrivacyPage extends StatelessWidget {
const PrivacyPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Politique de confidentialité',
style: GoogleFonts.merienda(),
),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Protection des données personnelles',
style: GoogleFonts.merienda(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Text(
'P\'titsPas s\'engage à protéger vos données personnelles conformément au RGPD.',
style: GoogleFonts.merienda(),
),
const SizedBox(height: 32),
Text(
'Données collectées',
style: GoogleFonts.merienda(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Text(
'Les données collectées sont nécessaires au bon fonctionnement de l\'application et à la gestion des contrats de garde d\'enfants.',
style: GoogleFonts.merienda(),
),
const SizedBox(height: 32),
Text(
'Vos droits',
style: GoogleFonts.merienda(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Text(
'Vous disposez d\'un droit d\'accès, de rectification, d\'effacement et de portabilité de vos données.',
style: GoogleFonts.merienda(),
),
],
),
),
);
}
}