From 8ac1e2074842afa73a64854d7f1de696a3633aed Mon Sep 17 00:00:00 2001 From: Rohan Kandwal Date: Mon, 28 Dec 2020 19:23:12 +0530 Subject: [PATCH 1/2] BottomNavyBar - added border --- example/lib/main.dart | 2 ++ lib/bottom_navy_bar.dart | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/example/lib/main.dart b/example/lib/main.dart index c09bf9b..aa82273 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -62,12 +62,14 @@ class _MyHomePageState extends State { title: Text('Home'), activeColor: Colors.red, textAlign: TextAlign.center, + activeBorderColor: Colors.black ), BottomNavyBarItem( icon: Icon(Icons.people), title: Text('Users'), activeColor: Colors.purpleAccent, textAlign: TextAlign.center, + activeBorderColor: Colors.black ), BottomNavyBarItem( icon: Icon(Icons.message), diff --git a/lib/bottom_navy_bar.dart b/lib/bottom_navy_bar.dart index d852fdb..c7c5fe9 100644 --- a/lib/bottom_navy_bar.dart +++ b/lib/bottom_navy_bar.dart @@ -154,6 +154,7 @@ class _ItemWidget extends StatelessWidget { color: isSelected ? item.activeColor.withOpacity(0.2) : backgroundColor, borderRadius: BorderRadius.circular(itemCornerRadius), + border: Border.all(color: isSelected ? item.activeBorderColor : item.inactiveBorderColor, width: 2) ), child: SingleChildScrollView( scrollDirection: Axis.horizontal, @@ -210,6 +211,8 @@ class BottomNavyBarItem { this.activeColor = Colors.blue, this.textAlign, this.inactiveColor, + this.activeBorderColor = Colors.transparent, + this.inactiveBorderColor = Colors.transparent }) : assert(icon != null), assert(title != null); @@ -226,6 +229,14 @@ class BottomNavyBarItem { /// The [icon] and [title] color defined when this item is not selected. final Color inactiveColor; + /// The [icon] and [title] border color defined when this item is selected. Defaults + /// to [Colors.transparent]. + final Color activeBorderColor; + + /// The [icon] and [title] border color defined when this item is not selected. Defaults + // to [Colors.transparent]. + final Color inactiveBorderColor; + /// The alignment for the [title]. /// /// This will take effect only if [title] it a [Text] widget. From 75b701ba9eedb1a57c2a8c3b6a5d6a8d328533aa Mon Sep 17 00:00:00 2001 From: Rohan Kandwal Date: Tue, 29 Dec 2020 14:25:51 +0530 Subject: [PATCH 2/2] Active color opacity level manual configuration --- example/lib/main.dart | 2 +- lib/bottom_navy_bar.dart | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index aa82273..4ecb394 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -69,7 +69,7 @@ class _MyHomePageState extends State { title: Text('Users'), activeColor: Colors.purpleAccent, textAlign: TextAlign.center, - activeBorderColor: Colors.black + inactiveBorderColor: Colors.brown ), BottomNavyBarItem( icon: Icon(Icons.message), diff --git a/lib/bottom_navy_bar.dart b/lib/bottom_navy_bar.dart index c7c5fe9..323dc27 100644 --- a/lib/bottom_navy_bar.dart +++ b/lib/bottom_navy_bar.dart @@ -152,7 +152,7 @@ class _ItemWidget extends StatelessWidget { curve: curve, decoration: BoxDecoration( color: - isSelected ? item.activeColor.withOpacity(0.2) : backgroundColor, + isSelected ? item.activeColor.withOpacity(item.activeColorOpacityLevel) : backgroundColor, borderRadius: BorderRadius.circular(itemCornerRadius), border: Border.all(color: isSelected ? item.activeBorderColor : item.inactiveBorderColor, width: 2) ), @@ -212,7 +212,8 @@ class BottomNavyBarItem { this.textAlign, this.inactiveColor, this.activeBorderColor = Colors.transparent, - this.inactiveBorderColor = Colors.transparent + this.inactiveBorderColor = Colors.transparent, + this.activeColorOpacityLevel = 0.2 }) : assert(icon != null), assert(title != null); @@ -237,6 +238,9 @@ class BottomNavyBarItem { // to [Colors.transparent]. final Color inactiveBorderColor; + /// Used to configure active background opacity, if not set, it defaults to 0.2. + final double activeColorOpacityLevel; + /// The alignment for the [title]. /// /// This will take effect only if [title] it a [Text] widget.