diff --git a/docs/pages/docs/bottom-navigation-bar.mdx b/docs/pages/docs/bottom-navigation-bar.mdx index e0fdf4106..2f94ae255 100644 --- a/docs/pages/docs/bottom-navigation-bar.mdx +++ b/docs/pages/docs/bottom-navigation-bar.mdx @@ -25,8 +25,8 @@ It is used to navigate between a small number of views, typically between three @override Widget build(BuildContext context) => FBottomNavigationBar( - activeIndex: index, - onSelect: (index) => setState(() => this.index = index), + index: index, + onChange: (index) => setState(() => this.index = index), items: [ FBottomNavigationBarItem( icon: FAssets.icons.home, @@ -65,8 +65,8 @@ It is used to navigate between a small number of views, typically between three ```dart FBottomNavigationBar( - activeIndex: 0, - onSelect: (index) => {}, + index: 0, + onChange: (index) => {}, items: [ FBottomNavigationBarItem( icon: FAssets.icons.home, diff --git a/docs/pages/docs/scaffold.mdx b/docs/pages/docs/scaffold.mdx index 6ff77c025..533bdd0a1 100644 --- a/docs/pages/docs/scaffold.mdx +++ b/docs/pages/docs/scaffold.mdx @@ -82,8 +82,8 @@ Creates a visual scaffold for Forui widgets. header: headers[index], content: contents[index], footer: FBottomNavigationBar( - activeIndex: index, - onSelect: (index) => setState(() => this.index = index), + index: index, + onChange: (index) => setState(() => this.index = index), items: [ FBottomNavigationBarItem( icon: FAssets.icons.home, diff --git a/forui/example/lib/main.dart b/forui/example/lib/main.dart index 07ad362f5..047d3f805 100644 --- a/forui/example/lib/main.dart +++ b/forui/example/lib/main.dart @@ -34,8 +34,8 @@ class _ApplicationState extends State { ), content: child ?? const SizedBox(), footer: FBottomNavigationBar( - activeIndex: index, - onSelect: (index) => setState(() => this.index = index), + index: index, + onChange: (index) => setState(() => this.index = index), items: [ FBottomNavigationBarItem( icon: FAssets.icons.home, diff --git a/forui/lib/src/widgets/bottom_navigation_bar/bottom_navigation_bar.dart b/forui/lib/src/widgets/bottom_navigation_bar/bottom_navigation_bar.dart index 9be8f52da..bb326de21 100644 --- a/forui/lib/src/widgets/bottom_navigation_bar/bottom_navigation_bar.dart +++ b/forui/lib/src/widgets/bottom_navigation_bar/bottom_navigation_bar.dart @@ -25,20 +25,20 @@ class FBottomNavigationBar extends StatelessWidget { final List items; /// A callback for when an item is selected. - final ValueChanged? onSelect; + final ValueChanged? onChange; /// Creates a [FBottomNavigationBar] with [FBottomNavigationBarItem]s. FBottomNavigationBar({ required List items, this.style, - this.onSelect, - int activeIndex = -1, + this.onChange, + int index = -1, super.key, }) : items = items .mapIndexed( - (index, item) => _FBottomNavigationBarWidget( + (currentIndex, item) => _FBottomNavigationBarItem( item: item, - active: index == activeIndex, + current: index == currentIndex, style: style?.item, ), ) @@ -48,7 +48,7 @@ class FBottomNavigationBar extends StatelessWidget { const FBottomNavigationBar.raw({ required this.items, this.style, - this.onSelect, + this.onChange, super.key, }); @@ -72,9 +72,7 @@ class FBottomNavigationBar extends StatelessWidget { (index, item) => Expanded( child: FTappable( child: item, - onTap: () { - onSelect?.call(index); - }, + onTap: () => onChange?.call(index), ), ), ) @@ -91,7 +89,7 @@ class FBottomNavigationBar extends StatelessWidget { properties ..add(DiagnosticsProperty('style', style)) ..add(IterableProperty('items', items)) - ..add(ObjectFlagProperty.has('onSelect', onSelect)); + ..add(ObjectFlagProperty.has('onSelect', onChange)); } } diff --git a/forui/lib/src/widgets/bottom_navigation_bar/bottom_navigation_bar_item.dart b/forui/lib/src/widgets/bottom_navigation_bar/bottom_navigation_bar_item.dart index 07bedabba..2b353b86f 100644 --- a/forui/lib/src/widgets/bottom_navigation_bar/bottom_navigation_bar_item.dart +++ b/forui/lib/src/widgets/bottom_navigation_bar/bottom_navigation_bar_item.dart @@ -1,15 +1,15 @@ part of 'bottom_navigation_bar.dart'; -class _FBottomNavigationBarWidget extends StatelessWidget { +class _FBottomNavigationBarItem extends StatelessWidget { final FBottomNavigationBarItemStyle? style; final FBottomNavigationBarItem item; - final bool active; + final bool current; - const _FBottomNavigationBarWidget({ + const _FBottomNavigationBarItem({ required this.item, - required this.active, + required this.current, this.style, }); @@ -27,7 +27,7 @@ class _FBottomNavigationBarWidget extends StatelessWidget { item.icon( height: style.iconSize, colorFilter: ColorFilter.mode( - active ? style.activeIconColor : style.inactiveIconColor, + current ? style.activeIconColor : style.inactiveIconColor, BlendMode.srcIn, ), ), @@ -35,7 +35,7 @@ class _FBottomNavigationBarWidget extends StatelessWidget { Text( item.label, overflow: TextOverflow.ellipsis, - style: active ? style.activeTextStyle : style.inactiveTextStyle, + style: current ? style.activeTextStyle : style.inactiveTextStyle, ), ], ), @@ -49,7 +49,7 @@ class _FBottomNavigationBarWidget extends StatelessWidget { properties ..add(DiagnosticsProperty('style', style)) ..add(DiagnosticsProperty('item', item)) - ..add(FlagProperty('active', value: active, ifTrue: 'active')); + ..add(FlagProperty('active', value: current, ifTrue: 'active')); } } diff --git a/forui/test/src/widgets/bottom_navigation_bar_golden_test.dart b/forui/test/src/widgets/bottom_navigation_bar_golden_test.dart index fa58ec748..eda459b75 100644 --- a/forui/test/src/widgets/bottom_navigation_bar_golden_test.dart +++ b/forui/test/src/widgets/bottom_navigation_bar_golden_test.dart @@ -15,7 +15,7 @@ void main() { data: theme, background: background, child: FBottomNavigationBar( - activeIndex: 2, + index: 2, items: [ FBottomNavigationBarItem( icon: FAssets.icons.home, diff --git a/samples/lib/widgets/bottom_navigation_bar.dart b/samples/lib/widgets/bottom_navigation_bar.dart index 3fb31baac..6ff466622 100644 --- a/samples/lib/widgets/bottom_navigation_bar.dart +++ b/samples/lib/widgets/bottom_navigation_bar.dart @@ -30,8 +30,8 @@ class _DemoState extends State<_Demo> { @override Widget build(BuildContext context) => FBottomNavigationBar( - activeIndex: index, - onSelect: (index) => setState(() => this.index = index), + index: index, + onChange: (index) => setState(() => this.index = index), items: [ FBottomNavigationBarItem( icon: FAssets.icons.home, diff --git a/samples/lib/widgets/scaffold.dart b/samples/lib/widgets/scaffold.dart index 03a521474..2ee384203 100644 --- a/samples/lib/widgets/scaffold.dart +++ b/samples/lib/widgets/scaffold.dart @@ -95,8 +95,8 @@ class _DemoState extends State<_Demo> { header: headers[index], content: contents[index], footer: FBottomNavigationBar( - activeIndex: index, - onSelect: (index) => setState(() => this.index = index), + index: index, + onChange: (index) => setState(() => this.index = index), items: [ FBottomNavigationBarItem( icon: FAssets.icons.home,