fix sidebar icon rail overflow
The rail was a fixed Row(center, max) — one button per tab — so adding the Search tab pushed it 54px past its width and threw a RenderFlex overflow. Center the icons when they fit and scroll horizontally when they don't (LayoutBuilder + SingleChildScrollView + a minWidth floor), so the rail stays correct at any tab count. (T-200) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,19 +29,31 @@ class ClideIconRail extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
for (final item in items)
|
||||
_RailButton(
|
||||
item: item,
|
||||
active: item.id == activeId,
|
||||
onTap: () => onSelect(item.id),
|
||||
// Center the icons when they fit; scroll horizontally when there are
|
||||
// more tabs than the rail is wide. The ConstrainedBox minWidth keeps
|
||||
// them centered while there's room but doesn't cap growth, so the
|
||||
// ScrollView takes over instead of the Row overflowing.
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final minWidth = constraints.maxWidth.isFinite ? constraints.maxWidth : 0.0;
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minWidth: minWidth),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
for (final item in items)
|
||||
_RailButton(
|
||||
item: item,
|
||||
active: item.id == activeId,
|
||||
onTap: () => onSelect(item.id),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user