-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f16df26
commit 36a60e7
Showing
10 changed files
with
389 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:zeta_example/widgets.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
class NavigationBarExample extends StatefulWidget { | ||
static const String name = 'NavigationBar'; | ||
|
||
const NavigationBarExample({super.key}); | ||
|
||
@override | ||
State<NavigationBarExample> createState() => _NavigationBarExampleState(); | ||
} | ||
|
||
class _NavigationBarExampleState extends State<NavigationBarExample> { | ||
int selectedIndex = 0; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final items = [ | ||
ZetaNavigationBarItem(icon: ZetaIcons.star_round, label: 'Label', badge: ZetaIndicator(value: 2)), | ||
ZetaNavigationBarItem(icon: ZetaIcons.star_round, label: 'Label'), | ||
ZetaNavigationBarItem(icon: ZetaIcons.star_round, label: 'Label'), | ||
ZetaNavigationBarItem(icon: ZetaIcons.star_round, label: 'Label'), | ||
]; | ||
|
||
return ExampleScaffold( | ||
name: 'Navigation Bar', | ||
child: Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
ZetaNavigationBar.divided(items: items, dividerIndex: 3), | ||
const SizedBox(height: 16), | ||
ZetaNavigationBar.split(items: items), | ||
const SizedBox(height: 16), | ||
ZetaNavigationBar.action( | ||
items: items, | ||
action: ZetaButton.primary( | ||
label: 'Button', | ||
onPressed: () {}, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
bottomNavigationBar: ZetaNavigationBar( | ||
items: items, | ||
currentIndex: selectedIndex, | ||
onTap: (val) => setState(() { | ||
selectedIndex = val; | ||
}), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
example/widgetbook/pages/components/navigation_bar_widgetbook.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../test/test_components.dart'; | ||
|
||
Widget navigationBarUseCase(BuildContext context) { | ||
List<ZetaNavigationBarItem> items = List.generate( | ||
context.knobs.int.slider(label: 'Items', min: 2, max: 6, initialValue: 2), | ||
(index) => ZetaNavigationBarItem(icon: ZetaIcons.star_round, label: 'Label $index'), | ||
); | ||
int currIndex = 0; | ||
bool showButton = context.knobs.boolean(label: 'Button'); | ||
int? dividerIndex = context.knobs.intOrNull.slider(label: 'Divider', min: 0, max: 6, initialValue: null); | ||
bool showSplit = context.knobs.boolean(label: 'Split Items'); | ||
return StatefulBuilder(builder: (context, setState) { | ||
double width = (items.length * 90) + (showSplit ? 90 : 0) + (dividerIndex != null ? 90 : 0) + (showButton ? 90 : 0); | ||
return Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Expanded( | ||
child: WidgetbookTestWidget( | ||
screenSize: Size(width, 260), | ||
widget: ZetaNavigationBar( | ||
items: items, | ||
action: showButton ? ZetaButton.primary(label: 'Button', onPressed: () {}) : null, | ||
onTap: (i) => setState(() => currIndex = i), | ||
currentIndex: currIndex, | ||
splitItems: showSplit, | ||
dividerIndex: dividerIndex, | ||
), | ||
), | ||
), | ||
], | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.