From 7f554e2ba3d4cc70fdb97cbe10807857a5f43a44 Mon Sep 17 00:00:00 2001 From: Julien Martin Date: Sun, 11 Oct 2026 10:44:04 +0200 Subject: [PATCH] =?UTF-8?q?fix(#211):=20overflow=20pastilles=20bandeau=20+?= =?UTF-8?q?=20couple=20plus=20centr=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les pastilles se réduisent si la fenêtre est étroite ; le sélecteur couple est poussé vers le centre. Co-authored-by: Cursor --- .../widgets/quotidien/quotidien_bandeau.dart | 153 ++++++++++++------ 1 file changed, 101 insertions(+), 52 deletions(-) diff --git a/frontend/lib/widgets/quotidien/quotidien_bandeau.dart b/frontend/lib/widgets/quotidien/quotidien_bandeau.dart index 29bba7c..adc427c 100644 --- a/frontend/lib/widgets/quotidien/quotidien_bandeau.dart +++ b/frontend/lib/widgets/quotidien/quotidien_bandeau.dart @@ -38,39 +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, - ), - if (contextSelector != null) ...[ - const SizedBox(width: 12), - ConstrainedBox( - constraints: const BoxConstraints( - maxWidth: contextSelectorMaxWidth, - ), - child: contextSelector!, + 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(), + ), + const SizedBox(width: 8), Flexible( - child: _NavPills( - selected: selectedSection, - onSelected: onSectionSelected, + 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, + ), + ), ), ], ), @@ -87,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 {