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>
This commit is contained in:
2026-10-11 10:44:04 +02:00
co-authored by Cursor
parent d05a5e22b2
commit 7f554e2ba3
@@ -38,8 +38,13 @@ class QuotidienBandeau extends StatelessWidget {
@override @override
Widget build(BuildContext context) { 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( return Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8), padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
child: Row(
children: [
Expanded(
child: Row( child: Row(
children: [ children: [
Image.asset( Image.asset(
@@ -48,23 +53,38 @@ class QuotidienBandeau extends StatelessWidget {
fit: BoxFit.contain, fit: BoxFit.contain,
), ),
if (contextSelector != null) ...[ if (contextSelector != null) ...[
const SizedBox(width: 12), const SizedBox(width: 16),
ConstrainedBox( Flexible(
child: Align(
// Pousse le couple vers le centre du bandeau.
alignment: Alignment.centerRight,
child: ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
maxWidth: contextSelectorMaxWidth, maxWidth: contextSelectorMaxWidth,
), ),
child: contextSelector!, child: contextSelector!,
), ),
),
),
], ],
const Spacer(), ],
),
),
const SizedBox(width: 8),
Flexible( Flexible(
flex: 2,
child: Center(
child: _NavPills( child: _NavPills(
selected: selectedSection, selected: selectedSection,
onSelected: onSectionSelected, onSelected: onSectionSelected,
), ),
), ),
const Spacer(), ),
_UserMenu( const SizedBox(width: 8),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: _UserMenu(
displayName: userDisplayName, displayName: userDisplayName,
email: userEmail, email: userEmail,
onProfileTap: onProfileTap, onProfileTap: onProfileTap,
@@ -72,6 +92,8 @@ class QuotidienBandeau extends StatelessWidget {
onSettingsTap: onSettingsTap, onSettingsTap: onSettingsTap,
onLogout: onLogout, onLogout: onLogout,
), ),
),
),
], ],
), ),
); );
@@ -87,51 +109,78 @@ class _NavPills extends StatelessWidget {
required this.onSelected, required this.onSelected,
}); });
static const double _pillHeight = 46;
static const double _gap = 10;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
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( return Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
_pill( _pill(
label: 'Cahier de liaison', label: 'Cahier de liaison',
section: QuotidienNavSection.liaison, section: QuotidienNavSection.liaison,
width: w,
height: h,
fontSize: fontSize,
), ),
const SizedBox(width: 10), SizedBox(width: g),
_pill( _pill(
label: 'Agenda', label: 'Agenda',
section: QuotidienNavSection.agenda, section: QuotidienNavSection.agenda,
width: w,
height: h,
fontSize: fontSize,
), ),
const SizedBox(width: 10), SizedBox(width: g),
_pill( _pill(
label: 'Contrat', label: 'Contrat',
section: QuotidienNavSection.contrat, section: QuotidienNavSection.contrat,
width: w,
height: h,
fontSize: fontSize,
), ),
], ],
); );
},
);
} }
Widget _pill({ Widget _pill({
required String label, required String label,
required QuotidienNavSection section, required QuotidienNavSection section,
required double width,
required double height,
required double fontSize,
}) { }) {
final active = selected == section; 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( return ImageButton(
bg: QuotidienTheme.pillAssetFor(section), bg: QuotidienTheme.pillAssetFor(section),
bgOpacity: active ? 1.0 : QuotidienTheme.pillInactiveOpacity, bgOpacity: active ? 1.0 : QuotidienTheme.pillInactiveOpacity,
width: _pillHeight * QuotidienTheme.pillAspectRatio, width: width,
height: _pillHeight, height: height,
text: label, text: label,
textColor: QuotidienTheme.ink, textColor: QuotidienTheme.ink,
fontSize: 14, fontSize: fontSize,
onPressed: () => onSelected(section), onPressed: () => onSelected(section),
); );
} }
static const double _pillHeight = 46;
} }
class _UserMenu extends StatelessWidget { class _UserMenu extends StatelessWidget {