Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature, solid background #83 #84

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {

@override
_MyHomePageState createState() => _MyHomePageState();
}
Expand Down Expand Up @@ -58,9 +57,10 @@ class _MyHomePageState extends State<MyHomePage> {
onItemSelected: (index) => setState(() => _currentIndex = index),
items: <BottomNavyBarItem>[
BottomNavyBarItem(
solidBackground: true,
icon: Icon(Icons.apps),
title: Text('Home'),
activeColor: Colors.red,
activeColor: Colors.blue,
textAlign: TextAlign.center,
),
BottomNavyBarItem(
Expand Down
27 changes: 18 additions & 9 deletions lib/bottom_navy_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:flutter/widgets.dart';
/// Update [selectedIndex] to change the selected item.
/// [selectedIndex] is required and must not be null.
class BottomNavyBar extends StatelessWidget {

BottomNavyBar({
Key? key,
this.selectedIndex = 0,
Expand All @@ -23,8 +22,8 @@ class BottomNavyBar extends StatelessWidget {
required this.items,
required this.onItemSelected,
this.curve = Curves.linear,
}) : assert(items.length >= 2 && items.length <= 5),
super(key: key);
}) : assert(items.length >= 2 && items.length <= 5),
super(key: key);
Comment on lines +25 to +26
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary changes


/// The selected item is index. Changing this property will change and animate
/// the item being selected. Defaults to zero.
Expand Down Expand Up @@ -125,7 +124,7 @@ class _ItemWidget extends StatelessWidget {
required this.itemCornerRadius,
required this.iconSize,
this.curve = Curves.linear,
}) : super(key: key);
}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -138,8 +137,11 @@ class _ItemWidget extends StatelessWidget {
duration: animationDuration,
curve: curve,
decoration: BoxDecoration(
color:
isSelected ? item.activeColor.withOpacity(0.2) : backgroundColor,
color: isSelected
? item.solidBackground
? item.activeColor
: item.activeColor.withOpacity(0.2)
: backgroundColor,
borderRadius: BorderRadius.circular(itemCornerRadius),
),
child: SingleChildScrollView(
Expand All @@ -157,7 +159,9 @@ class _ItemWidget extends StatelessWidget {
data: IconThemeData(
size: iconSize,
color: isSelected
? item.activeColor.withOpacity(1)
? item.solidBackground
? Colors.white
: item.activeColor.withOpacity(1)
Comment on lines +162 to +164
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused, the property is called solidBackground but it changes the color of the icon as well. You can either rename the property name to something like useSolidColors or revert this change.

: item.inactiveColor == null
? item.activeColor
: item.inactiveColor,
Expand All @@ -170,7 +174,9 @@ class _ItemWidget extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 4),
child: DefaultTextStyle.merge(
style: TextStyle(
color: item.activeColor,
color: item.solidBackground
? Colors.white
: item.activeColor,
Comment on lines +177 to +179
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

fontWeight: FontWeight.bold,
),
maxLines: 1,
Expand All @@ -190,13 +196,13 @@ class _ItemWidget extends StatelessWidget {

/// The [BottomNavyBar.items] definition.
class BottomNavyBarItem {

BottomNavyBarItem({
required this.icon,
required this.title,
this.activeColor = Colors.blue,
this.textAlign,
this.inactiveColor,
this.solidBackground = false,
});

/// Defines this item's icon which is placed in the right side of the [title].
Expand All @@ -217,4 +223,7 @@ class BottomNavyBarItem {
/// This will take effect only if [title] it a [Text] widget.
final TextAlign? textAlign;

/// The [background] solid color defined when this item is selected. Defaults
/// to [false].
final bool solidBackground;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change it to: If [true], use the solid color for the background of this item. Defaults to [false].

}