import "package:flutter/widgets.dart"; import "package:flutter_lucide/flutter_lucide.dart"; import "button.dart"; /// One step in a [Breadcrumb]. class BreadcrumbItem { const BreadcrumbItem({required this.label, this.onPressed}); final String label; /// null for somewhere you cant go, which is how the last one is drawn /// whatever you pass - its where you allready are. final VoidCallback? onPressed; } /// Where you are, as a run of ghost buttons with a chevron between them. /// /// Buttons rather than links, because everything else on a Garage page that /// takes you somewhere is a button and a row of underlined text would be the /// only thing on the screen that wasnt. /// /// It wraps. A path deeper than the pane is wide goes onto a second line /// instead of scrolling sideways or folding its middle into a menu - you can /// allways see the whole of where you are. class Breadcrumb extends StatelessWidget { const Breadcrumb({super.key, required this.items}); final List items; @override Widget build(BuildContext context) { return Wrap( crossAxisAlignment: WrapCrossAlignment.center, children: [ for (var i = 0; i < items.length; i++) ...[ if (i > 0) const Icon(LucideIcons.chevron_right), Button.ghost( onPressed: i == items.length - 1 ? null : items[i].onPressed, child: Text(items[i].label), ), ], ], ); } }