Clean project: remove test files, debug logs, and add documentation
This commit is contained in:
@@ -0,0 +1,403 @@
|
||||
/// Dialogue d'ajout de membre
|
||||
/// Formulaire complet pour créer un nouveau membre
|
||||
library add_member_dialog;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../bloc/membres_bloc.dart';
|
||||
import '../../bloc/membres_event.dart';
|
||||
import '../../data/models/membre_complete_model.dart';
|
||||
|
||||
/// Dialogue d'ajout de membre
|
||||
class AddMemberDialog extends StatefulWidget {
|
||||
const AddMemberDialog({super.key});
|
||||
|
||||
@override
|
||||
State<AddMemberDialog> createState() => _AddMemberDialogState();
|
||||
}
|
||||
|
||||
class _AddMemberDialogState extends State<AddMemberDialog> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
// Contrôleurs de texte
|
||||
final _nomController = TextEditingController();
|
||||
final _prenomController = TextEditingController();
|
||||
final _emailController = TextEditingController();
|
||||
final _telephoneController = TextEditingController();
|
||||
final _adresseController = TextEditingController();
|
||||
final _villeController = TextEditingController();
|
||||
final _codePostalController = TextEditingController();
|
||||
final _regionController = TextEditingController();
|
||||
final _paysController = TextEditingController();
|
||||
final _professionController = TextEditingController();
|
||||
final _nationaliteController = TextEditingController();
|
||||
|
||||
// Valeurs sélectionnées
|
||||
Genre? _selectedGenre;
|
||||
DateTime? _dateNaissance;
|
||||
StatutMembre _selectedStatut = StatutMembre.actif;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nomController.dispose();
|
||||
_prenomController.dispose();
|
||||
_emailController.dispose();
|
||||
_telephoneController.dispose();
|
||||
_adresseController.dispose();
|
||||
_villeController.dispose();
|
||||
_codePostalController.dispose();
|
||||
_regionController.dispose();
|
||||
_paysController.dispose();
|
||||
_professionController.dispose();
|
||||
_nationaliteController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
constraints: const BoxConstraints(maxHeight: 600),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// En-tête
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF6C5CE7),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(4),
|
||||
topRight: Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.person_add, color: Colors.white),
|
||||
const SizedBox(width: 12),
|
||||
const Text(
|
||||
'Ajouter un membre',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Formulaire
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Informations personnelles
|
||||
_buildSectionTitle('Informations personnelles'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _nomController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nom *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.person),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Le nom est obligatoire';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _prenomController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Prénom *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.person_outline),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Le prénom est obligatoire';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.email),
|
||||
),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'L\'email est obligatoire';
|
||||
}
|
||||
if (!value.contains('@')) {
|
||||
return 'Email invalide';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _telephoneController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Téléphone',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.phone),
|
||||
),
|
||||
keyboardType: TextInputType.phone,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Genre
|
||||
DropdownButtonFormField<Genre>(
|
||||
value: _selectedGenre,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Genre',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.wc),
|
||||
),
|
||||
items: Genre.values.map((genre) {
|
||||
return DropdownMenuItem(
|
||||
value: genre,
|
||||
child: Text(_getGenreLabel(genre)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedGenre = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Date de naissance
|
||||
InkWell(
|
||||
onTap: () => _selectDate(context),
|
||||
child: InputDecorator(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Date de naissance',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.calendar_today),
|
||||
),
|
||||
child: Text(
|
||||
_dateNaissance != null
|
||||
? DateFormat('dd/MM/yyyy').format(_dateNaissance!)
|
||||
: 'Sélectionner une date',
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Adresse
|
||||
_buildSectionTitle('Adresse'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _adresseController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Adresse',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.home),
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _villeController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Ville',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _codePostalController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Code postal',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _regionController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Région',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _paysController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Pays',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Informations professionnelles
|
||||
_buildSectionTitle('Informations professionnelles'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _professionController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Profession',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.work),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _nationaliteController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nationalité',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.flag),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Boutons d'action
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
border: Border(top: BorderSide(color: Colors.grey[300]!)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
ElevatedButton(
|
||||
onPressed: _submitForm,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF6C5CE7),
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('Créer le membre'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF6C5CE7),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getGenreLabel(Genre genre) {
|
||||
switch (genre) {
|
||||
case Genre.homme:
|
||||
return 'Homme';
|
||||
case Genre.femme:
|
||||
return 'Femme';
|
||||
case Genre.autre:
|
||||
return 'Autre';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDate(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _dateNaissance ?? DateTime.now().subtract(const Duration(days: 365 * 25)),
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null && picked != _dateNaissance) {
|
||||
setState(() {
|
||||
_dateNaissance = picked;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _submitForm() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Créer le modèle de membre
|
||||
final membre = MembreCompletModel(
|
||||
nom: _nomController.text,
|
||||
prenom: _prenomController.text,
|
||||
email: _emailController.text,
|
||||
telephone: _telephoneController.text.isNotEmpty ? _telephoneController.text : null,
|
||||
dateNaissance: _dateNaissance,
|
||||
genre: _selectedGenre,
|
||||
adresse: _adresseController.text.isNotEmpty ? _adresseController.text : null,
|
||||
ville: _villeController.text.isNotEmpty ? _villeController.text : null,
|
||||
codePostal: _codePostalController.text.isNotEmpty ? _codePostalController.text : null,
|
||||
region: _regionController.text.isNotEmpty ? _regionController.text : null,
|
||||
pays: _paysController.text.isNotEmpty ? _paysController.text : null,
|
||||
profession: _professionController.text.isNotEmpty ? _professionController.text : null,
|
||||
nationalite: _nationaliteController.text.isNotEmpty ? _nationaliteController.text : null,
|
||||
statut: _selectedStatut,
|
||||
);
|
||||
|
||||
// Envoyer l'événement au BLoC
|
||||
context.read<MembresBloc>().add(CreateMembre(membre));
|
||||
|
||||
// Fermer le dialogue
|
||||
Navigator.pop(context);
|
||||
|
||||
// Afficher un message de succès
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Membre créé avec succès'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,441 @@
|
||||
/// Dialogue de modification de membre
|
||||
/// Formulaire complet pour modifier un membre existant
|
||||
library edit_member_dialog;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../bloc/membres_bloc.dart';
|
||||
import '../../bloc/membres_event.dart';
|
||||
import '../../data/models/membre_complete_model.dart';
|
||||
|
||||
/// Dialogue de modification de membre
|
||||
class EditMemberDialog extends StatefulWidget {
|
||||
final MembreCompletModel membre;
|
||||
|
||||
const EditMemberDialog({
|
||||
super.key,
|
||||
required this.membre,
|
||||
});
|
||||
|
||||
@override
|
||||
State<EditMemberDialog> createState() => _EditMemberDialogState();
|
||||
}
|
||||
|
||||
class _EditMemberDialogState extends State<EditMemberDialog> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
// Contrôleurs de texte
|
||||
late final TextEditingController _nomController;
|
||||
late final TextEditingController _prenomController;
|
||||
late final TextEditingController _emailController;
|
||||
late final TextEditingController _telephoneController;
|
||||
late final TextEditingController _adresseController;
|
||||
late final TextEditingController _villeController;
|
||||
late final TextEditingController _codePostalController;
|
||||
late final TextEditingController _regionController;
|
||||
late final TextEditingController _paysController;
|
||||
late final TextEditingController _professionController;
|
||||
late final TextEditingController _nationaliteController;
|
||||
|
||||
// Valeurs sélectionnées
|
||||
Genre? _selectedGenre;
|
||||
DateTime? _dateNaissance;
|
||||
StatutMembre? _selectedStatut;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Initialiser les contrôleurs avec les valeurs existantes
|
||||
_nomController = TextEditingController(text: widget.membre.nom);
|
||||
_prenomController = TextEditingController(text: widget.membre.prenom);
|
||||
_emailController = TextEditingController(text: widget.membre.email);
|
||||
_telephoneController = TextEditingController(text: widget.membre.telephone ?? '');
|
||||
_adresseController = TextEditingController(text: widget.membre.adresse ?? '');
|
||||
_villeController = TextEditingController(text: widget.membre.ville ?? '');
|
||||
_codePostalController = TextEditingController(text: widget.membre.codePostal ?? '');
|
||||
_regionController = TextEditingController(text: widget.membre.region ?? '');
|
||||
_paysController = TextEditingController(text: widget.membre.pays ?? '');
|
||||
_professionController = TextEditingController(text: widget.membre.profession ?? '');
|
||||
_nationaliteController = TextEditingController(text: widget.membre.nationalite ?? '');
|
||||
|
||||
_selectedGenre = widget.membre.genre;
|
||||
_dateNaissance = widget.membre.dateNaissance;
|
||||
_selectedStatut = widget.membre.statut;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nomController.dispose();
|
||||
_prenomController.dispose();
|
||||
_emailController.dispose();
|
||||
_telephoneController.dispose();
|
||||
_adresseController.dispose();
|
||||
_villeController.dispose();
|
||||
_codePostalController.dispose();
|
||||
_regionController.dispose();
|
||||
_paysController.dispose();
|
||||
_professionController.dispose();
|
||||
_nationaliteController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
constraints: const BoxConstraints(maxHeight: 600),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// En-tête
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF6C5CE7),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(4),
|
||||
topRight: Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.edit, color: Colors.white),
|
||||
const SizedBox(width: 12),
|
||||
const Text(
|
||||
'Modifier le membre',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Formulaire
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Informations personnelles
|
||||
_buildSectionTitle('Informations personnelles'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _nomController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nom *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.person),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Le nom est obligatoire';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _prenomController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Prénom *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.person_outline),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Le prénom est obligatoire';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.email),
|
||||
),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'L\'email est obligatoire';
|
||||
}
|
||||
if (!value.contains('@')) {
|
||||
return 'Email invalide';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _telephoneController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Téléphone',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.phone),
|
||||
),
|
||||
keyboardType: TextInputType.phone,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Genre
|
||||
DropdownButtonFormField<Genre>(
|
||||
value: _selectedGenre,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Genre',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.wc),
|
||||
),
|
||||
items: Genre.values.map((genre) {
|
||||
return DropdownMenuItem(
|
||||
value: genre,
|
||||
child: Text(_getGenreLabel(genre)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedGenre = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Statut
|
||||
DropdownButtonFormField<StatutMembre>(
|
||||
value: _selectedStatut,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Statut *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.info),
|
||||
),
|
||||
items: StatutMembre.values.map((statut) {
|
||||
return DropdownMenuItem(
|
||||
value: statut,
|
||||
child: Text(_getStatutLabel(statut)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedStatut = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Date de naissance
|
||||
InkWell(
|
||||
onTap: () => _selectDate(context),
|
||||
child: InputDecorator(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Date de naissance',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.calendar_today),
|
||||
),
|
||||
child: Text(
|
||||
_dateNaissance != null
|
||||
? DateFormat('dd/MM/yyyy').format(_dateNaissance!)
|
||||
: 'Sélectionner une date',
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Adresse
|
||||
_buildSectionTitle('Adresse'),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _adresseController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Adresse',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.home),
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _villeController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Ville',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _codePostalController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Code postal',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _regionController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Région',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
TextFormField(
|
||||
controller: _paysController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Pays',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Boutons d'action
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
border: Border(top: BorderSide(color: Colors.grey[300]!)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
ElevatedButton(
|
||||
onPressed: _submitForm,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF6C5CE7),
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('Enregistrer'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF6C5CE7),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getGenreLabel(Genre genre) {
|
||||
switch (genre) {
|
||||
case Genre.homme:
|
||||
return 'Homme';
|
||||
case Genre.femme:
|
||||
return 'Femme';
|
||||
case Genre.autre:
|
||||
return 'Autre';
|
||||
}
|
||||
}
|
||||
|
||||
String _getStatutLabel(StatutMembre statut) {
|
||||
switch (statut) {
|
||||
case StatutMembre.actif:
|
||||
return 'Actif';
|
||||
case StatutMembre.inactif:
|
||||
return 'Inactif';
|
||||
case StatutMembre.suspendu:
|
||||
return 'Suspendu';
|
||||
case StatutMembre.enAttente:
|
||||
return 'En attente';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDate(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _dateNaissance ?? DateTime.now().subtract(const Duration(days: 365 * 25)),
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null && picked != _dateNaissance) {
|
||||
setState(() {
|
||||
_dateNaissance = picked;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _submitForm() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Créer le modèle de membre mis à jour
|
||||
final membreUpdated = widget.membre.copyWith(
|
||||
nom: _nomController.text,
|
||||
prenom: _prenomController.text,
|
||||
email: _emailController.text,
|
||||
telephone: _telephoneController.text.isNotEmpty ? _telephoneController.text : null,
|
||||
dateNaissance: _dateNaissance,
|
||||
genre: _selectedGenre,
|
||||
adresse: _adresseController.text.isNotEmpty ? _adresseController.text : null,
|
||||
ville: _villeController.text.isNotEmpty ? _villeController.text : null,
|
||||
codePostal: _codePostalController.text.isNotEmpty ? _codePostalController.text : null,
|
||||
region: _regionController.text.isNotEmpty ? _regionController.text : null,
|
||||
pays: _paysController.text.isNotEmpty ? _paysController.text : null,
|
||||
profession: _professionController.text.isNotEmpty ? _professionController.text : null,
|
||||
nationalite: _nationaliteController.text.isNotEmpty ? _nationaliteController.text : null,
|
||||
statut: _selectedStatut!,
|
||||
);
|
||||
|
||||
// Envoyer l'événement au BLoC
|
||||
context.read<MembresBloc>().add(UpdateMembre(widget.membre.id!, membreUpdated));
|
||||
|
||||
// Fermer le dialogue
|
||||
Navigator.pop(context);
|
||||
|
||||
// Afficher un message de succès
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Membre modifié avec succès'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/models/membre_search_result.dart' as search_model;
|
||||
import '../../data/models/membre_model.dart' as member_model;
|
||||
import '../../data/models/membre_complete_model.dart';
|
||||
|
||||
/// Widget d'affichage des résultats de recherche de membres
|
||||
/// Gère la pagination, le tri et l'affichage des membres trouvés
|
||||
class MembreSearchResults extends StatefulWidget {
|
||||
final search_model.MembreSearchResult result;
|
||||
final Function(member_model.MembreModel)? onMembreSelected;
|
||||
final Function(MembreCompletModel)? onMembreSelected;
|
||||
final bool showPagination;
|
||||
|
||||
const MembreSearchResults({
|
||||
@@ -151,12 +151,12 @@ class _MembreSearchResultsState extends State<MembreSearchResults> {
|
||||
}
|
||||
|
||||
/// Carte d'affichage d'un membre
|
||||
Widget _buildMembreCard(member_model.MembreModel membre, int index) {
|
||||
Widget _buildMembreCard(MembreCompletModel membre, int index) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: _getStatusColor(membre.statut ?? 'ACTIF'),
|
||||
backgroundColor: _getStatusColor(membre.statut),
|
||||
child: Text(
|
||||
_getInitials(membre.nom, membre.prenom),
|
||||
style: const TextStyle(
|
||||
@@ -197,14 +197,14 @@ class _MembreSearchResultsState extends State<MembreSearchResults> {
|
||||
),
|
||||
],
|
||||
),
|
||||
if (membre.organisation?.nom?.isNotEmpty == true)
|
||||
if (membre.organisationNom?.isNotEmpty == true)
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.business, size: 14, color: Colors.grey),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
membre.organisation!.nom!,
|
||||
membre.organisationNom!,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -216,7 +216,7 @@ class _MembreSearchResultsState extends State<MembreSearchResults> {
|
||||
trailing: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildStatusChip(membre.statut ?? 'ACTIF'),
|
||||
_buildStatusChip(membre.statut),
|
||||
if (membre.role?.isNotEmpty == true) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
@@ -296,7 +296,7 @@ class _MembreSearchResultsState extends State<MembreSearchResults> {
|
||||
}
|
||||
|
||||
/// Chip de statut
|
||||
Widget _buildStatusChip(String statut) {
|
||||
Widget _buildStatusChip(StatutMembre statut) {
|
||||
final color = _getStatusColor(statut);
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
@@ -317,15 +317,15 @@ class _MembreSearchResultsState extends State<MembreSearchResults> {
|
||||
}
|
||||
|
||||
/// Obtient la couleur du statut
|
||||
Color _getStatusColor(String statut) {
|
||||
switch (statut.toUpperCase()) {
|
||||
case 'ACTIF':
|
||||
Color _getStatusColor(StatutMembre statut) {
|
||||
switch (statut) {
|
||||
case StatutMembre.actif:
|
||||
return Colors.green;
|
||||
case 'INACTIF':
|
||||
case StatutMembre.inactif:
|
||||
return Colors.orange;
|
||||
case 'SUSPENDU':
|
||||
case StatutMembre.suspendu:
|
||||
return Colors.red;
|
||||
case 'RADIE':
|
||||
case StatutMembre.enAttente:
|
||||
return Colors.grey;
|
||||
default:
|
||||
return Colors.grey;
|
||||
@@ -333,18 +333,16 @@ class _MembreSearchResultsState extends State<MembreSearchResults> {
|
||||
}
|
||||
|
||||
/// Obtient le libellé du statut
|
||||
String _getStatusLabel(String statut) {
|
||||
switch (statut.toUpperCase()) {
|
||||
case 'ACTIF':
|
||||
String _getStatusLabel(StatutMembre statut) {
|
||||
switch (statut) {
|
||||
case StatutMembre.actif:
|
||||
return 'Actif';
|
||||
case 'INACTIF':
|
||||
case StatutMembre.inactif:
|
||||
return 'Inactif';
|
||||
case 'SUSPENDU':
|
||||
case StatutMembre.suspendu:
|
||||
return 'Suspendu';
|
||||
case 'RADIE':
|
||||
return 'Radié';
|
||||
default:
|
||||
return statut;
|
||||
case StatutMembre.enAttente:
|
||||
return 'En attente';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user