From e1a2902b6c4fcd3a5d4e4bee21559601c6ec32c7 Mon Sep 17 00:00:00 2001 From: Matthias Ngeo Date: Wed, 4 Sep 2024 09:59:19 +0800 Subject: [PATCH] Fix navigation bar --- forui/example/lib/main.dart | 76 +++++++++---------- .../bottom_navigation_bar.dart | 2 +- .../bottom_navigation_bar_item.dart | 42 +++++----- 3 files changed, 57 insertions(+), 63 deletions(-) diff --git a/forui/example/lib/main.dart b/forui/example/lib/main.dart index 4375c23e6..07fec19a1 100644 --- a/forui/example/lib/main.dart +++ b/forui/example/lib/main.dart @@ -30,45 +30,45 @@ class _ApplicationState extends State { Widget build(BuildContext context) => MaterialApp( builder: (context, child) => FTheme( data: FThemes.zinc.light, - child: FScaffold( - header: FHeader( - title: const Text('Example'), - actions: [ - FHeaderAction( - icon: FAssets.icons.plus, - onPress: () {}, - ), - ], - ), - content: child!, - footer: FBottomNavigationBar( - index: index, - onChange: (index) => setState(() => this.index = index), - children: [ - FBottomNavigationBarItem( - icon: FAssets.icons.home, - label: 'Home', - ), - FBottomNavigationBarItem( - icon: FAssets.icons.layoutGrid, - label: 'Categories', - ), - FBottomNavigationBarItem( - icon: FAssets.icons.search, - label: 'Search', - ), - FBottomNavigationBarItem( - icon: FAssets.icons.settings, - label: 'Settings', - ), - FBottomNavigationBarItem( - icon: FAssets.icons.castle, - label: 'Sandbox', - ), - ], - ), + child: child!, + ), + home: FScaffold( + header: FHeader( + title: const Text('Example'), + actions: [ + FHeaderAction( + icon: FAssets.icons.plus, + onPress: () {}, + ), + ], + ), + content: _pages[index], + footer: FBottomNavigationBar( + index: index, + onChange: (index) => setState(() => this.index = index), + children: [ + FBottomNavigationBarItem( + icon: FAssets.icons.home, + label: 'Home', + ), + FBottomNavigationBarItem( + icon: FAssets.icons.layoutGrid, + label: 'Categories', + ), + FBottomNavigationBarItem( + icon: FAssets.icons.search, + label: 'Search', + ), + FBottomNavigationBarItem( + icon: FAssets.icons.settings, + label: 'Settings', + ), + FBottomNavigationBarItem( + icon: FAssets.icons.castle, + label: 'Sandbox', + ), + ], ), ), - home: _pages[index], ); } 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 4b6a8baec..f65777877 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 @@ -119,7 +119,7 @@ class FBottomNavigationBarData extends InheritedWidget { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(DiagnosticsProperty('style', itemStyle)) + ..add(DiagnosticsProperty('itemStyle', itemStyle)) ..add(FlagProperty('selected', value: selected, ifTrue: 'selected')); } } 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 b0eb33008..337395f7a 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,6 +1,5 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; - import 'package:meta/meta.dart'; import 'package:forui/forui.dart'; @@ -30,32 +29,27 @@ class FBottomNavigationBarItem extends StatelessWidget { final style = this.style ?? itemStyle; return Semantics( - button: true, - selected: selected, label: label, excludeSemantics: true, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: Padding( - padding: style.padding, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - icon( - height: style.iconSize, - colorFilter: ColorFilter.mode( - selected ? style.activeIconColor : style.inactiveIconColor, - BlendMode.srcIn, - ), - ), - const SizedBox(height: 2), - Text( - label, - overflow: TextOverflow.ellipsis, - style: selected ? style.activeTextStyle : style.inactiveTextStyle, + child: Padding( + padding: style.padding, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + icon( + height: style.iconSize, + colorFilter: ColorFilter.mode( + selected ? style.activeIconColor : style.inactiveIconColor, + BlendMode.srcIn, ), - ], - ), + ), + const SizedBox(height: 2), + Text( + label, + overflow: TextOverflow.ellipsis, + style: selected ? style.activeTextStyle : style.inactiveTextStyle, + ), + ], ), ), );