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:
@@ -38,39 +38,61 @@ 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(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Expanded(
|
||||||
QuotidienTheme.logoAsset,
|
child: Row(
|
||||||
height: 44,
|
children: [
|
||||||
fit: BoxFit.contain,
|
Image.asset(
|
||||||
),
|
QuotidienTheme.logoAsset,
|
||||||
if (contextSelector != null) ...[
|
height: 44,
|
||||||
const SizedBox(width: 12),
|
fit: BoxFit.contain,
|
||||||
ConstrainedBox(
|
),
|
||||||
constraints: const BoxConstraints(
|
if (contextSelector != null) ...[
|
||||||
maxWidth: contextSelectorMaxWidth,
|
const SizedBox(width: 16),
|
||||||
),
|
Flexible(
|
||||||
child: contextSelector!,
|
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(
|
Flexible(
|
||||||
child: _NavPills(
|
flex: 2,
|
||||||
selected: selectedSection,
|
child: Center(
|
||||||
onSelected: onSectionSelected,
|
child: _NavPills(
|
||||||
|
selected: selectedSection,
|
||||||
|
onSelected: onSectionSelected,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const SizedBox(width: 8),
|
||||||
_UserMenu(
|
Expanded(
|
||||||
displayName: userDisplayName,
|
child: Align(
|
||||||
email: userEmail,
|
alignment: Alignment.centerRight,
|
||||||
onProfileTap: onProfileTap,
|
child: _UserMenu(
|
||||||
onSearchAmTap: onSearchAmTap,
|
displayName: userDisplayName,
|
||||||
onSettingsTap: onSettingsTap,
|
email: userEmail,
|
||||||
onLogout: onLogout,
|
onProfileTap: onProfileTap,
|
||||||
|
onSearchAmTap: onSearchAmTap,
|
||||||
|
onSettingsTap: onSettingsTap,
|
||||||
|
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 Row(
|
return LayoutBuilder(
|
||||||
mainAxisSize: MainAxisSize.min,
|
builder: (context, constraints) {
|
||||||
children: [
|
final naturalW = _pillHeight * QuotidienTheme.pillAspectRatio;
|
||||||
_pill(
|
final naturalTotal = 3 * naturalW + 2 * _gap;
|
||||||
label: 'Cahier de liaison',
|
final maxW = constraints.maxWidth;
|
||||||
section: QuotidienNavSection.liaison,
|
// Réduit proportionnellement si la fenêtre est trop étroite
|
||||||
),
|
// (évite l’overflow jaune/noir sur les pastilles).
|
||||||
const SizedBox(width: 10),
|
final scale = maxW.isFinite && maxW > 0 && maxW < naturalTotal
|
||||||
_pill(
|
? (maxW / naturalTotal).clamp(0.55, 1.0)
|
||||||
label: 'Agenda',
|
: 1.0;
|
||||||
section: QuotidienNavSection.agenda,
|
final h = _pillHeight * scale;
|
||||||
),
|
final w = naturalW * scale;
|
||||||
const SizedBox(width: 10),
|
final g = _gap * scale;
|
||||||
_pill(
|
final fontSize = (14 * scale).clamp(10.0, 14.0);
|
||||||
label: 'Contrat',
|
|
||||||
section: QuotidienNavSection.contrat,
|
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({
|
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user