Compare commits

..
Author SHA1 Message Date
jmartinandCursor 38af471054 feat(#212): état vide Cartes — ours endormi + message
Remplace le texte sec par l’illustration aquarelle et le message soft ; CTA Ajouter une carte inchangé.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-11 11:00:26 +02:00
jmartinandCursor 7f554e2ba3 fix(#211): overflow pastilles bandeau + couple plus centré
Les pastilles se réduisent si la fenêtre est étroite ; le sélecteur couple est poussé vers le centre.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-11 10:44:04 +02:00
jmartinandCursor d05a5e22b2 feat(#211): sélecteur couple compact dans le bandeau
Déplace le contexte de garde (parent/AM) à côté du logo et retire le gros bandeau de la colonne Cartes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-11 10:37:04 +02:00
jmartinandCursor e6be1dffc4 feat(#207): polish affichage bulles soin + icônes sous-types
Layout type congés (date/heure puis détail italique), assets flacon/pansement/thermo_verre.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-09 16:46:29 +02:00
jmartinandCursor cec1fc2ba7 feat(front): alignement avec la spec backend soins enfant
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-09 16:46:29 +02:00
jmartinandCursor 1c0ff71f26 feat(front): implémentation UI soins enfant (#207)
- Ajout des formulaires spécifiques (fièvre, bobo, médicament) dans la modale d'ajout
- Formatage personnalisé du résumé des soins dans le feed
- Boutons supprimer / corriger (24h) pour l'AM
- Icônes contextuelles selon le sous-type de soin

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-09 16:46:29 +02:00
jmartinandCursor a5d1616a17 fix(cards): resolve typescript errors with payload typing
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-08 18:09:15 +02:00
jmartinandCursor 1e4e2d5198 fix(cards): allow payload object in DTOs
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-08 18:03:24 +02:00
13 changed files with 396 additions and 270 deletions
+40 -40
View File
@@ -137,7 +137,7 @@ export class CardsService {
const absenceType = this.mapAbsenceType(dto.type_code);
let motif = dto.motif ?? null;
let finalPayload = {
let finalPayload: Record<string, any> = {
date_debut: dto.date_debut,
date_fin: dto.date_fin,
motif,
@@ -145,40 +145,40 @@ export class CardsService {
};
if (dto.type_code === 'soin_enfant') {
const p = dto.payload;
if (!p || !p.sous_type || !p.heure_releve) {
const p = dto.payload as Record<string, any>;
if (!p || !p?.sous_type || !p?.heure_releve) {
throw new BadRequestException('sous_type et heure_releve requis pour soin_enfant');
}
if (!/^([01]\d|2[0-3]):([0-5]\d)$/.test(p.heure_releve)) {
if (!/^([01]\d|2[0-3]):([0-5]\d)$/.test(p?.heure_releve)) {
throw new BadRequestException('Format heure_releve invalide (HH:mm)');
}
if (p.sous_type === 'fievre') {
if (typeof p.temperature_c !== 'number' || p.temperature_c < 34.0 || p.temperature_c > 43.0) {
if (p?.sous_type === 'fievre') {
if (typeof p?.temperature_c !== 'number' || p?.temperature_c < 34.0 || p?.temperature_c > 43.0) {
throw new BadRequestException('temperature_c invalide (34.0 - 43.0)');
}
motif = `${p.temperature_c.toFixed(1).replace('.', ',')} °C à ${p.heure_releve}`;
if (p.medicament_donne && typeof p.medicament_donne === 'string' && p.medicament_donne.trim()) {
motif += ` (Médicament : ${p.medicament_donne.trim()})`;
motif = `${p?.temperature_c.toFixed(1).replace('.', ',')} °C à ${p?.heure_releve}`;
if (p?.medicament_donne && typeof p?.medicament_donne === 'string' && p?.medicament_donne.trim()) {
motif += ` (Médicament : ${p?.medicament_donne.trim()})`;
}
} else if (p.sous_type === 'bobo') {
} else if (p?.sous_type === 'bobo') {
const natures = ['chute', 'coup', 'egratignure', 'piqure', 'brulure', 'autre'];
if (!natures.includes(p.bobo_nature)) {
if (!natures.includes(p?.bobo_nature)) {
throw new BadRequestException('bobo_nature invalide');
}
motif = `Bobo (${p.bobo_nature}) à ${p.heure_releve}`;
if (p.description && typeof p.description === 'string' && p.description.trim()) {
const desc = p.description.trim();
motif = `Bobo (${p?.bobo_nature}) à ${p?.heure_releve}`;
if (p?.description && typeof p?.description === 'string' && p?.description.trim()) {
const desc = p?.description.trim();
if (desc.length > 120) throw new BadRequestException('description trop longue (max 120)');
motif += ` : ${desc.length > 30 ? desc.substring(0, 30) + '...' : desc}`;
}
} else if (p.sous_type === 'medicament') {
if (!p.medicament_nom || typeof p.medicament_nom !== 'string' || !p.medicament_nom.trim()) {
} else if (p?.sous_type === 'medicament') {
if (!p?.medicament_nom || typeof p?.medicament_nom !== 'string' || !p?.medicament_nom.trim()) {
throw new BadRequestException('medicament_nom requis');
}
motif = `Médicament (${p.medicament_nom.trim()}) à ${p.heure_releve}`;
if (p.contexte && typeof p.contexte === 'string' && p.contexte.trim()) {
if (p.contexte.trim().length > 120) throw new BadRequestException('contexte trop long (max 120)');
motif = `Médicament (${p?.medicament_nom.trim()}) à ${p?.heure_releve}`;
if (p?.contexte && typeof p?.contexte === 'string' && p?.contexte.trim()) {
if (p?.contexte.trim().length > 120) throw new BadRequestException('contexte trop long (max 120)');
}
} else {
throw new BadRequestException('sous_type invalide pour soin_enfant');
@@ -192,7 +192,7 @@ export class CardsService {
type: absenceType,
date_debut: dto.date_debut,
date_fin: dto.date_fin,
motif: motif ?? undefined,
motif: motif ? String(motif) : undefined,
});
absenceId = absence.id;
} else {
@@ -205,7 +205,7 @@ export class CardsService {
await this.evenementsService.maj(userId, role, absenceId, {
date_debut: dto.date_debut,
date_fin: dto.date_fin,
motif: motif ?? undefined,
motif: motif ? String(motif) : undefined,
// Congé accepté modifié → repasse en attente via cartes respond flow;
// pour absence enfant update immédiat déjà fait.
...(dto.type_code === 'conge_am'
@@ -352,7 +352,7 @@ export class CardsService {
}
let motif = dto.motif ?? card.payload?.['motif'] ?? null;
let finalPayload = {
let finalPayload: Record<string, any> = {
...card.payload,
date_debut: debut,
date_fin: fin,
@@ -361,39 +361,39 @@ export class CardsService {
if (card.type_code === 'soin_enfant') {
const p = finalPayload;
if (!p || !p.sous_type || !p.heure_releve) {
if (!p || !p?.sous_type || !p?.heure_releve) {
throw new BadRequestException('sous_type et heure_releve requis pour soin_enfant');
}
if (!/^([01]\d|2[0-3]):([0-5]\d)$/.test(p.heure_releve)) {
if (!/^([01]\d|2[0-3]):([0-5]\d)$/.test(p?.heure_releve)) {
throw new BadRequestException('Format heure_releve invalide (HH:mm)');
}
if (p.sous_type === 'fievre') {
if (typeof p.temperature_c !== 'number' || p.temperature_c < 34.0 || p.temperature_c > 43.0) {
if (p?.sous_type === 'fievre') {
if (typeof p?.temperature_c !== 'number' || p?.temperature_c < 34.0 || p?.temperature_c > 43.0) {
throw new BadRequestException('temperature_c invalide (34.0 - 43.0)');
}
motif = `${p.temperature_c.toFixed(1).replace('.', ',')} °C à ${p.heure_releve}`;
if (p.medicament_donne && typeof p.medicament_donne === 'string' && p.medicament_donne.trim()) {
motif += ` (Médicament : ${p.medicament_donne.trim()})`;
motif = `${p?.temperature_c.toFixed(1).replace('.', ',')} °C à ${p?.heure_releve}`;
if (p?.medicament_donne && typeof p?.medicament_donne === 'string' && p?.medicament_donne.trim()) {
motif += ` (Médicament : ${p?.medicament_donne.trim()})`;
}
} else if (p.sous_type === 'bobo') {
} else if (p?.sous_type === 'bobo') {
const natures = ['chute', 'coup', 'egratignure', 'piqure', 'brulure', 'autre'];
if (!natures.includes(p.bobo_nature)) {
if (!natures.includes(p?.bobo_nature)) {
throw new BadRequestException('bobo_nature invalide');
}
motif = `Bobo (${p.bobo_nature}) à ${p.heure_releve}`;
if (p.description && typeof p.description === 'string' && p.description.trim()) {
const desc = p.description.trim();
motif = `Bobo (${p?.bobo_nature}) à ${p?.heure_releve}`;
if (p?.description && typeof p?.description === 'string' && p?.description.trim()) {
const desc = p?.description.trim();
if (desc.length > 120) throw new BadRequestException('description trop longue (max 120)');
motif += ` : ${desc.length > 30 ? desc.substring(0, 30) + '...' : desc}`;
}
} else if (p.sous_type === 'medicament') {
if (!p.medicament_nom || typeof p.medicament_nom !== 'string' || !p.medicament_nom.trim()) {
} else if (p?.sous_type === 'medicament') {
if (!p?.medicament_nom || typeof p?.medicament_nom !== 'string' || !p?.medicament_nom.trim()) {
throw new BadRequestException('medicament_nom requis');
}
motif = `Médicament (${p.medicament_nom.trim()}) à ${p.heure_releve}`;
if (p.contexte && typeof p.contexte === 'string' && p.contexte.trim()) {
if (p.contexte.trim().length > 120) throw new BadRequestException('contexte trop long (max 120)');
motif = `Médicament (${p?.medicament_nom.trim()}) à ${p?.heure_releve}`;
if (p?.contexte && typeof p?.contexte === 'string' && p?.contexte.trim()) {
if (p?.contexte.trim().length > 120) throw new BadRequestException('contexte trop long (max 120)');
}
} else {
throw new BadRequestException('sous_type invalide pour soin_enfant');
@@ -418,7 +418,7 @@ export class CardsService {
await this.evenementsService.maj(userId, role, card.id_evenement, {
date_debut: debut,
date_fin: fin,
motif: motif ?? undefined,
motif: motif ? String(motif) : undefined,
...(card.type_code !== 'soin_enfant' ? { statut: StatutEvenementAgendaType.EN_ATTENTE } : {}),
});
}
@@ -3,6 +3,7 @@ import {
IsDateString,
IsEnum,
IsOptional,
IsObject,
IsString,
IsUUID,
MaxLength,
@@ -51,6 +52,7 @@ export class CreerCarteDto {
@ApiPropertyOptional()
@IsOptional()
@IsObject()
payload?: Record<string, any>;
}
@@ -86,6 +88,7 @@ export class MajCarteDto {
@ApiPropertyOptional()
@IsOptional()
@IsObject()
payload?: Record<string, any>;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

+52 -7
View File
@@ -110,11 +110,56 @@ class CarteBulle {
String? get dateDebut => payload['date_debut']?.toString();
String? get dateFin => payload['date_fin']?.toString();
String? get motif => payload['motif']?.toString();
/// Helper pour extraire les informations de soin
String? get resumerSoin {
/// Heure de relevé (payload soins), format API `HH:mm`.
String? get heureReleve => payload['heure_releve']?.toString();
/// Heure affichable `18h19` (depuis `heure_releve`).
String? get heureReleveAffichee {
final h = heureReleve?.trim();
if (h == null || h.isEmpty) return null;
final parts = h.split(':');
if (parts.length < 2) return h;
return '${parts[0]}h${parts[1]}';
}
/// Ligne détail soin (sans date/heure) — sous la ligne agenda.
String? get detailSoin {
if (!isSoinEnfant) return null;
return payload['motif']?.toString();
final st = payload['sous_type']?.toString();
if (st == 'fievre') {
final t = payload['temperature_c'];
final med = payload['medicament_donne']?.toString().trim();
String? temp;
if (t is num) {
temp = t.toStringAsFixed(1).replaceAll('.', ',');
} else if (t != null) {
temp = t.toString().replaceAll('.', ',');
}
if (temp == null || temp.isEmpty) return motif;
var s = '$temp °C';
if (med != null && med.isNotEmpty) {
s += ' (Médicament : $med)';
}
return s;
}
if (st == 'bobo') {
final nature = payload['bobo_nature']?.toString() ?? 'bobo';
final desc = payload['description']?.toString().trim();
if (desc != null && desc.isNotEmpty) {
return 'Bobo ($nature) : $desc';
}
return 'Bobo ($nature)';
}
if (st == 'medicament') {
final nom = payload['medicament_nom']?.toString().trim();
final ctx = payload['contexte']?.toString().trim();
final label =
(nom != null && nom.isNotEmpty) ? 'Médicament ($nom)' : 'Médicament';
if (ctx != null && ctx.isNotEmpty) return '$label : $ctx';
return label;
}
return motif;
}
/// Motif de refus : réponse API, sinon motif payload (co-parent / reload).
@@ -174,9 +219,9 @@ class CarteBulle {
return 'assets/images/sac_lapin.png';
case 'soin_enfant':
final st = payload['sous_type']?.toString();
if (st == 'fievre') return 'assets/images/thermo_croix.png';
if (st == 'medicament') return 'assets/images/cuillere.png'; // Using generic fallback or specific if added later. Assuming thermo_croix or similar could work.
if (st == 'bobo') return 'assets/images/sac_lapin.png'; // Will adjust these later if better assets exist. Let's use generic ones for now, or null if no appropriate assets.
if (st == 'fievre') return 'assets/images/thermo_verre.png';
if (st == 'bobo') return 'assets/images/pansement.png';
if (st == 'medicament') return 'assets/images/flacon.png';
return null;
default:
return null;
@@ -10,7 +10,7 @@ import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
import 'package:p_tits_pas/screens/home/parent_screen/agenda_absences_stub.dart';
/// Dashboard assistante maternelle – coquille 3 colonnes quotidien (#169).
/// Colonne gauche : sélecteur couple (#170) + feed bulles (#174).
/// Contexte couple dans le bandeau (#211) ; colonne gauche = feed (#174).
/// Création « Ajouter une carte » : modale générique (#175, réutilisée #176).
class AmDashboardScreen extends StatefulWidget {
const AmDashboardScreen({super.key});
@@ -108,16 +108,17 @@ class _AmDashboardScreenState extends State<AmDashboardScreen> {
userEmail: _user?.email,
onProfileTap: () => _soon('Profil'),
onSettingsTap: () => _soon('Paramètres'),
// L'AM n'a pas de bouton "Recherche AM" dans le bandeau
onSearchAmTap: null,
leftColumn: _LeftColumn(
contextSelector: CoupleSelectorBandeau(
mode: CoupleBandeauMode.assistanteMaternelle,
couples: _couples,
selectedCoupleId: _selectedCoupleId,
loading: _couplesLoading,
error: _couplesError,
errorMessage: _couplesError,
onRetry: _loadCouples,
onCoupleSelected: _selectCouple,
),
leftColumn: _LeftColumn(selectedCoupleId: _selectedCoupleId),
centerColumn: const QuotidienColumnPlaceholder(
title: 'Blog',
subtitle:
@@ -139,49 +140,17 @@ class _AmDashboardScreenState extends State<AmDashboardScreen> {
}
}
/// Colonne gauche : bandeau couple AM (#170) puis flux de cartes (#174 / #175).
/// Colonne gauche : flux de cartes (#174 / #175). Couple = bandeau (#211).
class _LeftColumn extends StatelessWidget {
final List<CoupleGarde> couples;
final String? selectedCoupleId;
final bool loading;
final String? error;
final VoidCallback onRetry;
final ValueChanged<CoupleGarde> onCoupleSelected;
const _LeftColumn({
required this.couples,
required this.selectedCoupleId,
required this.loading,
required this.error,
required this.onRetry,
required this.onCoupleSelected,
});
const _LeftColumn({required this.selectedCoupleId});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
CoupleSelectorBandeau(
mode: CoupleBandeauMode.assistanteMaternelle,
couples: couples,
selectedCoupleId: selectedCoupleId,
loading: loading,
errorMessage: error,
onRetry: onRetry,
onCoupleSelected: onCoupleSelected,
),
const SizedBox(height: 14),
Expanded(
child: CartesFeed(
placementId: selectedCoupleId,
),
),
],
),
child: CartesFeed(placementId: selectedCoupleId),
);
}
}
@@ -10,7 +10,7 @@ import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
import 'package:p_tits_pas/screens/home/parent_screen/agenda_absences_stub.dart';
/// Tableau de bord parent — coquille 3 colonnes quotidien (#166).
/// Colonne gauche : sélecteur de couple (#167) + feed bulles (#173).
/// Contexte couple dans le bandeau (#211) ; colonne gauche = feed (#173).
class ParentDashboardScreen extends StatefulWidget {
const ParentDashboardScreen({super.key});
@@ -108,14 +108,15 @@ class _ParentDashboardScreenState extends State<ParentDashboardScreen> {
onProfileTap: () => _soon('Profil'),
onSearchAmTap: () => _soon('Recherche AM'),
onSettingsTap: () => _soon('Paramètres'),
leftColumn: _LeftColumn(
contextSelector: CoupleSelectorBandeau(
couples: _couples,
selectedCoupleId: _selectedCoupleId,
loading: _couplesLoading,
error: _couplesError,
errorMessage: _couplesError,
onRetry: _loadCouples,
onCoupleSelected: _selectCouple,
),
leftColumn: _LeftColumn(selectedCoupleId: _selectedCoupleId),
centerColumn: const QuotidienColumnPlaceholder(
title: 'Blog',
subtitle:
@@ -137,47 +138,17 @@ class _ParentDashboardScreenState extends State<ParentDashboardScreen> {
}
}
/// Colonne gauche : bandeau couple (#167) puis flux de cartes (#173 / #175).
/// Colonne gauche : flux de cartes (#173 / #175). Couple = bandeau (#211).
class _LeftColumn extends StatelessWidget {
final List<CoupleGarde> couples;
final String? selectedCoupleId;
final bool loading;
final String? error;
final VoidCallback onRetry;
final ValueChanged<CoupleGarde> onCoupleSelected;
const _LeftColumn({
required this.couples,
required this.selectedCoupleId,
required this.loading,
required this.error,
required this.onRetry,
required this.onCoupleSelected,
});
const _LeftColumn({required this.selectedCoupleId});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
CoupleSelectorBandeau(
couples: couples,
selectedCoupleId: selectedCoupleId,
loading: loading,
errorMessage: error,
onRetry: onRetry,
onCoupleSelected: onCoupleSelected,
),
const SizedBox(height: 14),
Expanded(
child: CartesFeed(
placementId: selectedCoupleId,
),
),
],
),
child: CartesFeed(placementId: selectedCoupleId),
);
}
}
+83 -20
View File
@@ -442,17 +442,7 @@ class _CartesFeedState extends State<CartesFeed> {
);
}
if (_items.isEmpty) {
return Center(
child: Text(
'Aucune bulle pour le moment.\nLa file d’attention est vide — c’est normal.',
textAlign: TextAlign.center,
style: GoogleFonts.merriweather(
fontSize: 13,
color: QuotidienTheme.muted,
height: 1.4,
),
),
);
return const _CartesEmptyState();
}
return NotificationListener<ScrollMetricsNotification>(
@@ -612,12 +602,15 @@ class _BulleTile extends StatelessWidget {
}
String _fmtPeriodeUneLigne() {
// Si c'est un soin_enfant en singleDay, on affiche juste "Le ..." ou un résumé si pertinent
// Soin : « Le 08 octobre 2026 à 18h19 » (détail en italique sous la ligne).
if (card.isSoinEnfant) {
final resume = card.resumerSoin;
final jour = card.dateDebut != null ? 'Le ${_fmtLong(card.dateDebut)}' : '';
if (resume != null) return '$jour\n$resume';
return jour;
final jour = card.dateDebut != null
? 'Le ${_fmtLong(card.dateDebut)}'
: '';
final h = card.heureReleveAffichee;
if (jour.isEmpty) return h != null ? 'À $h' : '';
if (h == null || h.isEmpty) return jour;
return '$jour à $h';
}
final d1 = DateTime.tryParse(card.dateDebut ?? '');
@@ -723,8 +716,6 @@ class _BulleTile extends StatelessWidget {
Expanded(
child: Text(
periode,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.merienda(
fontSize: 15,
fontWeight: FontWeight.w600,
@@ -736,14 +727,27 @@ class _BulleTile extends StatelessWidget {
],
),
],
if (card.isSoinEnfant &&
(card.detailSoin?.trim().isNotEmpty ?? false)) ...[
const SizedBox(height: 8),
Text(
card.detailSoin!,
softWrap: true,
style: GoogleFonts.merriweather(
fontSize: 13,
fontStyle: FontStyle.italic,
height: 1.35,
color: encre.ink,
),
),
],
if (card.isCongeAm &&
card.statut == CarteStatut.refusee &&
card.motifRefus != null) ...[
const SizedBox(height: 8),
Text(
'Motif : ${card.motifRefus}',
maxLines: 4,
overflow: TextOverflow.ellipsis,
softWrap: true,
style: GoogleFonts.merriweather(
fontSize: 13,
fontStyle: FontStyle.italic,
@@ -1177,6 +1181,65 @@ class _RefuseDialogState extends State<_RefuseDialog> {
}
}
/// État vide de la file d'attention — ours endormi (#212).
class _CartesEmptyState extends StatelessWidget {
const _CartesEmptyState();
static const _asset = 'assets/images/ours_endormi.png';
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final maxW = constraints.maxWidth;
// ~160–200 px, réduit si colonne étroite.
final imgW =
maxW.isFinite ? maxW.clamp(100.0, 200.0) : 180.0;
return Center(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxW),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
_asset,
width: imgW,
fit: BoxFit.contain,
filterQuality: FilterQuality.high,
semanticLabel: 'Ours endormi',
),
const SizedBox(height: 12),
Text(
'File d’attention au repos.',
textAlign: TextAlign.center,
style: GoogleFonts.merienda(
fontSize: 16,
fontWeight: FontWeight.w600,
color: QuotidienTheme.ink,
),
),
const SizedBox(height: 6),
Text(
'Pas de bulle en attente — on respire.',
textAlign: TextAlign.center,
style: GoogleFonts.merriweather(
fontSize: 13,
color: QuotidienTheme.muted,
height: 1.4,
),
),
],
),
),
),
);
},
);
}
}
/// CTA « Ajouter une carte » — pilule aquarelle en bas du feed (#175).
class _AjouterCarteCta extends StatelessWidget {
final VoidCallback onTap;
@@ -8,12 +8,12 @@ import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
/// Rôle qui consulte le bandeau : côté parent (enfant | nounou) ou côté AM
/// (enfant | parent(s)). Le composant est le même, seule la lecture change.
/// Ticket #167 (parent) ; #170 réutilise en mode AM.
/// Ticket #167 (parent) ; #170 (AM) ; #211 (compact dans le bandeau haut).
enum CoupleBandeauMode { parent, assistanteMaternelle }
/// Bandeau « couple de garde » en haut de la colonne gauche du TdB.
/// Sélecteur « couple de garde » compact dans le bandeau haut (#211).
///
/// - Plusieurs couples → contrôle unique avec chevron (dropdown de bascule).
/// - Plusieurs couples → contrôle unique avec chevron (menu de bascule).
/// - Un seul couple → affichage informatif (pas de chevron, pas de menu).
/// - Aucun couple → état vide discret.
class CoupleSelectorBandeau extends StatelessWidget {
@@ -25,6 +25,9 @@ class CoupleSelectorBandeau extends StatelessWidget {
final String? errorMessage;
final VoidCallback? onRetry;
static const double height = 40;
static const double avatarSize = 28;
const CoupleSelectorBandeau({
super.key,
this.mode = CoupleBandeauMode.parent,
@@ -38,7 +41,7 @@ class CoupleSelectorBandeau extends StatelessWidget {
CoupleGarde? get _selected {
if (couples.isEmpty) return null;
if (selectedCoupleId != null) {
if (selectedCoupleId != null) {
for (final c in couples) {
if (c.id == selectedCoupleId) return c;
}
@@ -79,11 +82,12 @@ class CoupleSelectorBandeau extends StatelessWidget {
),
child: PopupMenuButton<String>(
tooltip: 'Changer de garde',
// L'offset doit être suffisant pour descendre sous la carte (qui fait 90px).
offset: const Offset(0, 95),
color: Colors.transparent, // Le fond devient invisible
elevation: 0, // Pas d'ombre carrée
constraints: BoxConstraints.tightFor(width: constraints.maxWidth),
offset: const Offset(0, height + 6),
color: Colors.transparent,
elevation: 0,
constraints: BoxConstraints.tightFor(
width: constraints.maxWidth.clamp(180, 320),
),
padding: EdgeInsets.zero,
onSelected: (id) {
final chosen = couples.firstWhere((c) => c.id == id);
@@ -95,15 +99,14 @@ class CoupleSelectorBandeau extends StatelessWidget {
PopupMenuItem<String>(
value: c.id,
padding: EdgeInsets.zero,
height: 100, // Hauteur de la carte (90) + un peu de marge (10)
height: height + 8,
child: Padding(
padding: const EdgeInsets.only(bottom: 10),
padding: const EdgeInsets.only(bottom: 6),
child: _CoupleCard(
mode: mode,
couple: c,
showChevron: false,
selected: false,
isMenuItem: true,
colorIndex: couples.indexOf(c),
),
),
@@ -116,13 +119,12 @@ class CoupleSelectorBandeau extends StatelessWidget {
}
}
/// Carte principale : enfant à gauche, séparateur, AM/parents à droite.
/// Carte compacte : enfant | AM/parents (+ chevron si multi).
class _CoupleCard extends StatelessWidget {
final CoupleBandeauMode mode;
final CoupleGarde couple;
final bool showChevron;
final bool selected;
final bool isMenuItem;
final int colorIndex;
const _CoupleCard({
@@ -130,11 +132,9 @@ class _CoupleCard extends StatelessWidget {
required this.couple,
required this.showChevron,
this.selected = true,
this.isMenuItem = false,
required this.colorIndex,
});
/// Libellé parents côté AM : « Sophie » ou « Thomas et Claire ».
static String _parentsLabel(List<CoupleMembre> parents) {
if (parents.isEmpty) return 'Parents';
String prenomOf(CoupleMembre p) {
@@ -142,20 +142,18 @@ class _CoupleCard extends StatelessWidget {
if (prenom.isNotEmpty) return prenom;
return p.displayName(fallback: 'Parent');
}
if (parents.length == 1) return prenomOf(parents.first);
return '${prenomOf(parents[0])} et ${prenomOf(parents[1])}';
}
@override
Widget build(BuildContext context) {
// Parent mode: enfant | AM (photo + prénom)
// AM mode: enfant | parent(s) — texte seul, pas de vignette parent
final isParentMode = mode == CoupleBandeauMode.parent;
Widget amOrParentsWidget;
final Widget right;
if (isParentMode) {
amOrParentsWidget = _MembreTile(
right = _MembreTile(
photoUrl: couple.am?.photoUrl,
name: (couple.am?.prenom != null && couple.am!.prenom!.isNotEmpty)
? couple.am!.prenom!
@@ -163,28 +161,28 @@ class _CoupleCard extends StatelessWidget {
fallbackIcon: Icons.volunteer_activism,
);
} else {
amOrParentsWidget = Text(
right = Text(
_parentsLabel(couple.parents),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.merienda(
fontSize: 22,
fontWeight: FontWeight.bold,
fontSize: 13,
fontWeight: FontWeight.w600,
color: QuotidienTheme.ink,
),
);
}
return Carte.bandeau(
assetPath: QuotidienTheme
.bandeauColors[colorIndex % QuotidienTheme.bandeauColors.length],
height: 90,
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(right: 12),
return Opacity(
opacity: selected ? 1 : 0.92,
child: Carte.bandeau(
assetPath: QuotidienTheme
.bandeauColors[colorIndex % QuotidienTheme.bandeauColors.length],
height: CoupleSelectorBandeau.height,
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Row(
children: [
Expanded(
child: _MembreTile(
photoUrl: couple.enfant.photoUrl,
name: (couple.enfant.prenom != null &&
@@ -194,39 +192,34 @@ class _CoupleCard extends StatelessWidget {
fallbackIcon: Icons.child_care,
),
),
),
Container(
width: 8,
height: 44,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(QuotidienTheme.pencilLineVerticalAsset),
fit: BoxFit.contain,
Container(
width: 5,
height: 22,
margin: const EdgeInsets.symmetric(horizontal: 4),
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(QuotidienTheme.pencilLineVerticalAsset),
fit: BoxFit.contain,
),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 12),
child: amOrParentsWidget,
),
),
SizedBox(
width: 28,
child: showChevron
? const Icon(
Icons.keyboard_arrow_down,
color: QuotidienTheme.ink,
)
: null,
),
],
Expanded(child: right),
if (showChevron)
const Icon(
Icons.keyboard_arrow_down,
size: 18,
color: QuotidienTheme.ink,
)
else
const SizedBox(width: 4),
],
),
),
);
}
}
/// Photo ronde + nom (une moitié du couple).
/// Photo ronde + prénom (une moitié du couple).
class _MembreTile extends StatelessWidget {
final String? photoUrl;
final String name;
@@ -242,16 +235,20 @@ class _MembreTile extends StatelessWidget {
Widget build(BuildContext context) {
return Row(
children: [
_Avatar(photoUrl: photoUrl, fallbackIcon: fallbackIcon, size: 64),
const SizedBox(width: 12),
_Avatar(
photoUrl: photoUrl,
fallbackIcon: fallbackIcon,
size: CoupleSelectorBandeau.avatarSize,
),
const SizedBox(width: 6),
Expanded(
child: Text(
name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.merienda(
fontSize: 22,
fontWeight: FontWeight.bold,
fontSize: 13,
fontWeight: FontWeight.w600,
color: QuotidienTheme.ink,
),
),
@@ -279,7 +276,7 @@ class _Avatar extends StatelessWidget {
width: size,
height: size,
color: QuotidienTheme.lavender.withValues(alpha: 0.35),
child: Icon(fallbackIcon, size: size * 0.5, color: QuotidienTheme.ink),
child: Icon(fallbackIcon, size: size * 0.55, color: QuotidienTheme.ink),
);
return ClipOval(
child: SizedBox(
@@ -311,11 +308,11 @@ class _CoupleBandeauSkeleton extends StatelessWidget {
),
child: Carte.bandeau(
assetPath: QuotidienTheme.bandeauLime,
height: 90,
height: CoupleSelectorBandeau.height,
child: const Center(
child: SizedBox(
width: 26,
height: 26,
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
),
),
@@ -331,17 +328,19 @@ class _CoupleBandeauEmpty extends StatelessWidget {
Widget build(BuildContext context) {
return Carte.bandeau(
assetPath: QuotidienTheme.bandeauLime,
height: 90,
padding: const EdgeInsets.symmetric(horizontal: 24),
height: CoupleSelectorBandeau.height,
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Row(
children: [
const Icon(Icons.info_outline, color: QuotidienTheme.muted),
const SizedBox(width: 12),
const Icon(Icons.info_outline, size: 18, color: QuotidienTheme.muted),
const SizedBox(width: 8),
Expanded(
child: Text(
'Aucune garde active pour le moment.',
'Aucune garde active',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.merriweather(
fontSize: 14,
fontSize: 12,
color: QuotidienTheme.muted,
),
),
@@ -367,25 +366,30 @@ class _CoupleBandeauError extends StatelessWidget {
),
child: Carte.bandeau(
assetPath: QuotidienTheme.bandeauLime,
height: 90,
padding: const EdgeInsets.symmetric(horizontal: 24),
height: CoupleSelectorBandeau.height,
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: [
const Icon(Icons.error_outline, color: QuotidienTheme.ink),
const SizedBox(width: 12),
const Icon(Icons.error_outline, size: 18, color: QuotidienTheme.ink),
const SizedBox(width: 6),
Expanded(
child: Text(
message,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.merriweather(
fontSize: 13,
fontSize: 11,
color: QuotidienTheme.ink,
),
),
),
if (onRetry != null)
TextButton(
IconButton(
onPressed: onRetry,
child: const Text('Réessayer'),
icon: const Icon(Icons.refresh, size: 18),
tooltip: 'Réessayer',
padding: EdgeInsets.zero,
constraints: const BoxConstraints(minWidth: 28, minHeight: 28),
),
],
),
@@ -5,25 +5,31 @@ import 'package:p_tits_pas/services/auth_service.dart';
import 'package:p_tits_pas/widgets/image_button.dart';
import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
/// Bandeau quotidien pastel : logo · pastilles Cahier de liaison / Agenda /
/// Contrat · menu user.
/// Réutilisable parent (#166) et AM (#169).
/// Bandeau quotidien pastel : logo · [contexte couple] · pastilles · menu user.
/// Réutilisable parent (#166) et AM (#169) ; couple compact (#211).
class QuotidienBandeau extends StatelessWidget {
final QuotidienNavSection selectedSection;
final ValueChanged<QuotidienNavSection> onSectionSelected;
final String userDisplayName;
final String? userEmail;
/// Sélecteur de couple compact, juste après le logo (~280 px).
final Widget? contextSelector;
final VoidCallback? onProfileTap;
final VoidCallback? onSearchAmTap;
final VoidCallback? onSettingsTap;
final VoidCallback? onLogout;
static const double contextSelectorMaxWidth = 280;
const QuotidienBandeau({
super.key,
required this.selectedSection,
required this.onSectionSelected,
required this.userDisplayName,
this.userEmail,
this.contextSelector,
this.onProfileTap,
this.onSearchAmTap,
this.onSettingsTap,
@@ -32,28 +38,61 @@ class QuotidienBandeau extends StatelessWidget {
@override
Widget build(BuildContext context) {
// 3 zones : gauche (logo + couple vers le centre) · pastilles · menu.
// Les Expanded gauche/droite équilibrent le centrage des pastilles.
return Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
child: Row(
children: [
Image.asset(
QuotidienTheme.logoAsset,
height: 44,
fit: BoxFit.contain,
Expanded(
child: Row(
children: [
Image.asset(
QuotidienTheme.logoAsset,
height: 44,
fit: BoxFit.contain,
),
if (contextSelector != null) ...[
const SizedBox(width: 16),
Flexible(
child: Align(
// Pousse le couple vers le centre du bandeau.
alignment: Alignment.centerRight,
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: contextSelectorMaxWidth,
),
child: contextSelector!,
),
),
),
],
],
),
),
const Spacer(),
_NavPills(
selected: selectedSection,
onSelected: onSectionSelected,
const SizedBox(width: 8),
Flexible(
flex: 2,
child: Center(
child: _NavPills(
selected: selectedSection,
onSelected: onSectionSelected,
),
),
),
const Spacer(),
_UserMenu(
displayName: userDisplayName,
email: userEmail,
onProfileTap: onProfileTap,
onSearchAmTap: onSearchAmTap,
onSettingsTap: onSettingsTap,
onLogout: onLogout,
const SizedBox(width: 8),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: _UserMenu(
displayName: userDisplayName,
email: userEmail,
onProfileTap: onProfileTap,
onSearchAmTap: onSearchAmTap,
onSettingsTap: onSettingsTap,
onLogout: onLogout,
),
),
),
],
),
@@ -70,51 +109,78 @@ class _NavPills extends StatelessWidget {
required this.onSelected,
});
static const double _pillHeight = 46;
static const double _gap = 10;
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
_pill(
label: 'Cahier de liaison',
section: QuotidienNavSection.liaison,
),
const SizedBox(width: 10),
_pill(
label: 'Agenda',
section: QuotidienNavSection.agenda,
),
const SizedBox(width: 10),
_pill(
label: 'Contrat',
section: QuotidienNavSection.contrat,
),
],
return LayoutBuilder(
builder: (context, constraints) {
final naturalW = _pillHeight * QuotidienTheme.pillAspectRatio;
final naturalTotal = 3 * naturalW + 2 * _gap;
final maxW = constraints.maxWidth;
// Réduit proportionnellement si la fenêtre est trop étroite
// (évite l’overflow jaune/noir sur les pastilles).
final scale = maxW.isFinite && maxW > 0 && maxW < naturalTotal
? (maxW / naturalTotal).clamp(0.55, 1.0)
: 1.0;
final h = _pillHeight * scale;
final w = naturalW * scale;
final g = _gap * scale;
final fontSize = (14 * scale).clamp(10.0, 14.0);
return Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
_pill(
label: 'Cahier de liaison',
section: QuotidienNavSection.liaison,
width: w,
height: h,
fontSize: fontSize,
),
SizedBox(width: g),
_pill(
label: 'Agenda',
section: QuotidienNavSection.agenda,
width: w,
height: h,
fontSize: fontSize,
),
SizedBox(width: g),
_pill(
label: 'Contrat',
section: QuotidienNavSection.contrat,
width: w,
height: h,
fontSize: fontSize,
),
],
);
},
);
}
Widget _pill({
required String label,
required QuotidienNavSection section,
required double width,
required double height,
required double fontSize,
}) {
final active = selected == section;
// Même famille que l’inscription : fonds « dessinés » (pas Material).
// Les deux pastilles ont la même silhouette (ratio ~4:1) : la largeur
// est dérivée de la hauteur pour ne jamais déformer le PNG.
// Chaque section garde sa couleur ; l'inactive est juste plus claire.
return ImageButton(
bg: QuotidienTheme.pillAssetFor(section),
bgOpacity: active ? 1.0 : QuotidienTheme.pillInactiveOpacity,
width: _pillHeight * QuotidienTheme.pillAspectRatio,
height: _pillHeight,
width: width,
height: height,
text: label,
textColor: QuotidienTheme.ink,
fontSize: 14,
fontSize: fontSize,
onPressed: () => onSelected(section),
);
}
static const double _pillHeight = 46;
}
class _UserMenu extends StatelessWidget {
@@ -16,7 +16,7 @@ class QuotidienShell extends StatelessWidget {
final VoidCallback? onSettingsTap;
final VoidCallback? onLogout;
/// Colonne gauche (couple + cartes + actions).
/// Colonne gauche (cartes + actions).
final Widget leftColumn;
/// Colonne milieu (blog).
@@ -25,6 +25,9 @@ class QuotidienShell extends StatelessWidget {
/// Colonne droite (messagerie).
final Widget rightColumn;
/// Sélecteur de couple compact dans le bandeau haut (#211).
final Widget? contextSelector;
/// Corps affiché hors Cahier de liaison (Agenda / Contrat stubs).
final Widget? agendaBody;
final Widget? contratBody;
@@ -37,6 +40,7 @@ class QuotidienShell extends StatelessWidget {
required this.leftColumn,
required this.centerColumn,
required this.rightColumn,
this.contextSelector,
this.userEmail,
this.onProfileTap,
this.onSearchAmTap,
@@ -59,6 +63,7 @@ class QuotidienShell extends StatelessWidget {
onSectionSelected: onSectionSelected,
userDisplayName: userDisplayName,
userEmail: userEmail,
contextSelector: contextSelector,
onProfileTap: onProfileTap,
onSearchAmTap: onSearchAmTap,
onSettingsTap: onSettingsTap,