diff --git a/example/lib/pages/components/breadcrumbs_example.dart b/example/lib/pages/components/breadcrumbs_example.dart index a9eaf235..12566eda 100644 --- a/example/lib/pages/components/breadcrumbs_example.dart +++ b/example/lib/pages/components/breadcrumbs_example.dart @@ -12,9 +12,15 @@ class BreadCrumbsExample extends StatefulWidget { } class _BreadCrumbsExampleState extends State { - List _children = [ - 'Icon before with seperator', + List _children = [ + BreadCrumb( + label: 'Icon before with seperator', + onPressed: () { + print("Breadcrumb " + 0.toString() + "Clicked"); + }, + ), ]; + int index = 1; @override Widget build(BuildContext context) { @@ -32,7 +38,15 @@ class _BreadCrumbsExampleState extends State { FilledButton( onPressed: () { setState(() { - _children.add('Icon before with seperator'); + _children.add( + BreadCrumb( + label: 'Icon before with seperator', + onPressed: () { + print("Breadcrumb clicked"); + }, + ), + ); + index++; }); }, child: Text("Add Breadcrumb")) diff --git a/example/widgetbook/pages/components/breadcrumbs_widgetbook.dart b/example/widgetbook/pages/components/breadcrumbs_widgetbook.dart index 9c867267..2ecdb9e2 100644 --- a/example/widgetbook/pages/components/breadcrumbs_widgetbook.dart +++ b/example/widgetbook/pages/components/breadcrumbs_widgetbook.dart @@ -18,9 +18,15 @@ class BreadCrumbExample extends StatefulWidget { } class _BreadCrumbExampleState extends State { - List _children = [ - 'Icon before with seperator', + List _children = [ + BreadCrumb( + label: 'Icon before with seperator', + onPressed: () { + print("Breadcrumb " + 0.toString() + "Clicked"); + }, + ), ]; + int index = 1; @override Widget build(BuildContext _) { @@ -58,7 +64,15 @@ class _BreadCrumbExampleState extends State { FilledButton( onPressed: () { setState(() { - _children.add('Icon before with seperator'); + _children.add( + BreadCrumb( + label: 'Icon before with seperator', + onPressed: () { + print("Breadcrumb clicked"); + }, + ), + ); + index++; }); }, child: Text("Add Breadcrumb")) diff --git a/lib/src/components/breadcrumbs/breadcrumbs.dart b/lib/src/components/breadcrumbs/breadcrumbs.dart index 59fac935..2c0dce9f 100644 --- a/lib/src/components/breadcrumbs/breadcrumbs.dart +++ b/lib/src/components/breadcrumbs/breadcrumbs.dart @@ -14,7 +14,7 @@ class ZetaBreadCrumbs extends StatefulWidget { }); /// Breadcrumb children - final List children; + final List children; /// {@macro zeta-component-rounded} final bool rounded; @@ -29,7 +29,7 @@ class ZetaBreadCrumbs extends StatefulWidget { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(IterableProperty('children', children)) + ..add(IterableProperty('children', children)) ..add(DiagnosticsProperty('rounded', rounded)) ..add(DiagnosticsProperty('activeIcon', activeIcon)); } @@ -37,7 +37,7 @@ class ZetaBreadCrumbs extends StatefulWidget { class _ZetaBreadCrumbsState extends State { late int _selectedIndex; - late List _children; + late List _children; @override void initState() { @@ -86,20 +86,21 @@ class _ZetaBreadCrumbsState extends State { } ///Creates breadcumb widget - BreadCrumb createBreadCrumb(String label, int index) { + BreadCrumb createBreadCrumb(BreadCrumb input, int index) { return BreadCrumb( - label: label, + label: input.label, isSelected: _selectedIndex == index, onPressed: () { setState(() { _selectedIndex = index; }); + input.onPressed.call(); }, activeIcon: widget.activeIcon, ); } - List renderedChildren(List children) { + List renderedChildren(List children) { final List returnList = []; if (children.length > 3) { returnList.add(createBreadCrumb(children.first, 0)); @@ -134,7 +135,7 @@ class BreadCrumb extends StatelessWidget { super.key, required this.label, this.icon, - required this.isSelected, + this.isSelected = false, required this.onPressed, this.activeIcon, });