Skip to content

Commit

Permalink
fix: removed active icon prop
Browse files Browse the repository at this point in the history
fix: rounded now affects breadcrumb icons

fix: The icon that was passed in now shows on breadcrumb

fix: truncated only hides any breadcrumbs over the maxItemsShown number

fix: intruduced a value listenable builder to handle hover and pressed states on breadcrumb item
  • Loading branch information
DE7924 committed Nov 14, 2024
1 parent b094a4e commit 6c2ed11
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 157 deletions.
4 changes: 2 additions & 2 deletions example/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:zeta_example/pages/components/avatar_example.dart';
import 'package:zeta_example/pages/components/badges_example.dart';
import 'package:zeta_example/pages/components/banner_example.dart';
import 'package:zeta_example/pages/components/bottom_sheet_example.dart';
import 'package:zeta_example/pages/components/breadcrumbs_example.dart';
import 'package:zeta_example/pages/components/breadcrumb_example.dart';
import 'package:zeta_example/pages/components/button_example.dart';
import 'package:zeta_example/pages/components/chat_item_example.dart';
import 'package:zeta_example/pages/components/checkbox_example.dart';
Expand Down Expand Up @@ -67,7 +67,7 @@ final List<Component> components = [
Component(BannerExample.name, (context) => const BannerExample()),
Component(BadgesExample.name, (context) => const BadgesExample()),
Component(BottomSheetExample.name, (context) => const BottomSheetExample()),
Component(BreadCrumbsExample.name, (context) => const BreadCrumbsExample()),
Component(BreadcrumbExample.name, (context) => const BreadcrumbExample()),
Component(ButtonExample.name, (context) => const ButtonExample()),
Component(ChatItemExample.name, (context) => const ChatItemExample()),
Component(CheckBoxExample.name, (context) => const CheckBoxExample()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import 'package:flutter/material.dart';
import 'package:zeta_example/widgets.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

class BreadCrumbsExample extends StatefulWidget {
static const String name = 'Breadcrumbs';
class BreadcrumbExample extends StatefulWidget {
static const String name = 'Breadcrumb';

const BreadCrumbsExample({super.key});
const BreadcrumbExample({super.key});

@override
State<BreadCrumbsExample> createState() => _BreadCrumbsExampleState();
State<BreadcrumbExample> createState() => _BreadcrumbExampleState();
}

class _BreadCrumbsExampleState extends State<BreadCrumbsExample> {
class _BreadcrumbExampleState extends State<BreadcrumbExample> {
List<ZetaBreadcrumbItem> _children = [];
int index = 3;

@override
void initState() {
Expand All @@ -39,6 +38,7 @@ class _BreadCrumbsExampleState extends State<BreadCrumbsExample> {
),
ZetaBreadcrumbItem(
label: 'Item 3',
icon: ZetaIcons.star,
onPressed: () {
print("Breadcrumb clicked");
},
Expand Down Expand Up @@ -73,7 +73,7 @@ class _BreadCrumbsExampleState extends State<BreadCrumbsExample> {
@override
Widget build(BuildContext context) {
return ExampleScaffold(
name: 'Breadcrumbs',
name: 'Breadcrumb',
child: Center(
child: SingleChildScrollView(
child: SizedBox(
Expand All @@ -91,23 +91,37 @@ class _BreadCrumbsExampleState extends State<BreadCrumbsExample> {
SizedBox(
height: 50,
),
ZetaBreadcrumb(children: _children.sublist(0, 4)),
ZetaBreadcrumb(
children: _children.sublist(0, 4),
maxItemsShown: 3,
),
SizedBox(
height: 50,
),
ZetaBreadcrumb(children: _children.sublist(0, 5)),
ZetaBreadcrumb(
children: _children.sublist(0, 5),
maxItemsShown: 4,
),
SizedBox(
height: 50,
),
ZetaBreadcrumb(children: _children.sublist(0, 6)),
ZetaBreadcrumb(
children: _children.sublist(0, 6),
maxItemsShown: 3,
),
SizedBox(
height: 50,
),
ZetaBreadcrumb(children: _children.sublist(0, 7)),
ZetaBreadcrumb(
children: _children.sublist(0, 7),
),
SizedBox(
height: 50,
),
ZetaBreadcrumb(children: _children),
ZetaBreadcrumb(
children: _children,
maxItemsShown: 1,
),
])),
),
),
Expand Down
4 changes: 2 additions & 2 deletions example/widgetbook/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'pages/components/avatar_widgetbook.dart';
import 'pages/components/badges_widgetbook.dart';
import 'pages/components/banner_widgetbook.dart';
import 'pages/components/bottom_sheet_widgetbook.dart';
import 'pages/components/breadcrumbs_widgetbook.dart';
import 'pages/components/breadcrumb_widgetbook.dart';
import 'pages/components/button_widgetbook.dart';
import 'pages/components/chat_item_widgetbook.dart';
import 'pages/components/checkbox_widgetbook.dart';
Expand Down Expand Up @@ -192,7 +192,7 @@ class _HotReloadState extends State<HotReload> {
WidgetbookUseCase(name: 'Accordion', builder: (context) => accordionUseCase(context)),
WidgetbookUseCase(name: 'Banners', builder: (context) => bannerUseCase(context)),
WidgetbookUseCase(name: 'Bottom Sheet', builder: (context) => bottomSheetContentUseCase(context)),
WidgetbookUseCase(name: 'BreadCrumbs', builder: (context) => breadCrumbUseCase(context)),
WidgetbookUseCase(name: 'Breadcrumb', builder: (context) => breadcrumbUseCase(context)),
WidgetbookUseCase(name: 'Checkbox', builder: (context) => checkboxUseCase(context)),
WidgetbookUseCase(name: 'Comms Button', builder: (context) => commsButtonUseCase(context)),
WidgetbookUseCase(name: 'Date Input', builder: (context) => dateInputUseCase(context)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import 'package:zeta_flutter/zeta_flutter.dart';
import '../../utils/scaffold.dart';
import 'package:widgetbook/widgetbook.dart';

import '../../utils/utils.dart';

final List<ZetaBreadcrumbItem> children = [
ZetaBreadcrumbItem(label: 'Breadcrumb', onPressed: () {}),
ZetaBreadcrumbItem(label: 'Item 1', onPressed: () {}),
Expand All @@ -16,14 +14,14 @@ final List<ZetaBreadcrumbItem> children = [
ZetaBreadcrumbItem(label: 'Item 6', onPressed: () {})
];

Widget breadCrumbUseCase(BuildContext context) => WidgetbookScaffold(
Widget breadcrumbUseCase(BuildContext context) => WidgetbookScaffold(
builder: (context, _) => Center(
child: BreadCrumbExample(context, children),
child: BreadcrumbExample(context, children),
),
);

class BreadCrumbExample extends StatelessWidget {
BreadCrumbExample(this.context, this.children);
class BreadcrumbExample extends StatelessWidget {
BreadcrumbExample(this.context, this.children);
final BuildContext context;
final List<ZetaBreadcrumbItem> children;

Expand All @@ -35,16 +33,22 @@ class BreadCrumbExample extends StatelessWidget {
child: Column(
children: [
ZetaBreadcrumb(
rounded: context.knobs.boolean(label: 'Rounded', initialValue: true),
children: context.knobs.list(
label: 'Items',
labelBuilder: (value) => value.length.toString(),
initialOption: children.sublist(0, 2),
initialOption: children.sublist(0, 4),
options: List.generate(
children.length,
(index) => children.sublist(0, index + 1),
),
),
activeIcon: iconKnob(context),
maxItemsShown: context.knobs.int.slider(
label: 'Max Items Shown',
initialValue: 2,
min: 1,
max: children.length,
),
),
],
),
Expand Down
Loading

0 comments on commit 6c2ed11

Please sign in to comment.