From 4f4de73637667829c89fb8b581c29a855d5f8583 Mon Sep 17 00:00:00 2001 From: SMahdiFaghih Date: Fri, 2 Jul 2021 17:17:46 +0430 Subject: [PATCH 1/2] Fixed issue #52 (Independent colors for text and background) --- example/lib/main.dart | 2 ++ lib/bottom_navy_bar.dart | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index dfdffb1..b48ad0a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -60,12 +60,14 @@ class _MyHomePageState extends State { icon: Icon(Icons.apps), title: Text('Home'), activeColor: Colors.red, + expandedBackground: Colors.black, textAlign: TextAlign.center, ), BottomNavyBarItem( icon: Icon(Icons.people), title: Text('Users'), activeColor: Colors.purpleAccent, + expandedBackground: Colors.yellowAccent, textAlign: TextAlign.center, ), BottomNavyBarItem( diff --git a/lib/bottom_navy_bar.dart b/lib/bottom_navy_bar.dart index 97ab25b..9e014d1 100644 --- a/lib/bottom_navy_bar.dart +++ b/lib/bottom_navy_bar.dart @@ -137,8 +137,11 @@ class _ItemWidget extends StatelessWidget { duration: animationDuration, curve: curve, decoration: BoxDecoration( - color: - isSelected ? item.activeColor.withOpacity(0.2) : backgroundColor, + color: isSelected + ? item.expandedBackground != null + ? item.expandedBackground + : item.activeColor.withOpacity(0.2) + : backgroundColor, borderRadius: BorderRadius.circular(itemCornerRadius), ), child: SingleChildScrollView( @@ -195,6 +198,7 @@ class BottomNavyBarItem { this.activeColor = Colors.blue, this.textAlign, this.inactiveColor, + this.expandedBackground }); /// Defines this item's icon which is placed in the right side of the [title]. @@ -210,6 +214,9 @@ class BottomNavyBarItem { /// The [icon] and [title] color defined when this item is not selected. final Color? inactiveColor; + /// The background color defined when this item is selected. + final Color? expandedBackground; + /// The alignment for the [title]. /// /// This will take effect only if [title] it a [Text] widget. From ed0d03a12c7cc49fb028a1d3d3cbc985db16501a Mon Sep 17 00:00:00 2001 From: SMahdiFaghih Date: Fri, 2 Jul 2021 17:19:04 +0430 Subject: [PATCH 2/2] changed variable name --- example/lib/main.dart | 4 ++-- lib/bottom_navy_bar.dart | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index b48ad0a..48d3343 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -60,14 +60,14 @@ class _MyHomePageState extends State { icon: Icon(Icons.apps), title: Text('Home'), activeColor: Colors.red, - expandedBackground: Colors.black, + expandedBackgroundColor: Colors.black, textAlign: TextAlign.center, ), BottomNavyBarItem( icon: Icon(Icons.people), title: Text('Users'), activeColor: Colors.purpleAccent, - expandedBackground: Colors.yellowAccent, + expandedBackgroundColor: Colors.yellowAccent, textAlign: TextAlign.center, ), BottomNavyBarItem( diff --git a/lib/bottom_navy_bar.dart b/lib/bottom_navy_bar.dart index 9e014d1..882585b 100644 --- a/lib/bottom_navy_bar.dart +++ b/lib/bottom_navy_bar.dart @@ -138,8 +138,8 @@ class _ItemWidget extends StatelessWidget { curve: curve, decoration: BoxDecoration( color: isSelected - ? item.expandedBackground != null - ? item.expandedBackground + ? item.expandedBackgroundColor != null + ? item.expandedBackgroundColor : item.activeColor.withOpacity(0.2) : backgroundColor, borderRadius: BorderRadius.circular(itemCornerRadius), @@ -198,7 +198,7 @@ class BottomNavyBarItem { this.activeColor = Colors.blue, this.textAlign, this.inactiveColor, - this.expandedBackground + this.expandedBackgroundColor }); /// Defines this item's icon which is placed in the right side of the [title]. @@ -215,7 +215,7 @@ class BottomNavyBarItem { final Color? inactiveColor; /// The background color defined when this item is selected. - final Color? expandedBackground; + final Color? expandedBackgroundColor; /// The alignment for the [title]. ///