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

activeColorOpacity added. #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 12 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);

/// 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,9 @@ class _ItemWidget extends StatelessWidget {
duration: animationDuration,
curve: curve,
decoration: BoxDecoration(
color:
isSelected ? item.activeColor.withOpacity(0.2) : backgroundColor,
color: isSelected
? item.activeColor.withOpacity(item.activeColorOpacity)
: backgroundColor,
borderRadius: BorderRadius.circular(itemCornerRadius),
),
child: SingleChildScrollView(
Expand All @@ -157,7 +157,7 @@ class _ItemWidget extends StatelessWidget {
data: IconThemeData(
size: iconSize,
color: isSelected
? item.activeColor.withOpacity(1)
? item.activeColor.withOpacity(item.activeColorOpacity)
: item.inactiveColor == null
? item.activeColor
: item.inactiveColor,
Expand Down Expand Up @@ -190,11 +190,11 @@ class _ItemWidget extends StatelessWidget {

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

BottomNavyBarItem({
required this.icon,
required this.title,
this.activeColor = Colors.blue,
this.activeColorOpacity = 0.2,
this.textAlign,
this.inactiveColor,
});
Expand All @@ -209,12 +209,15 @@ class BottomNavyBarItem {
/// to [Colors.blue].
final Color activeColor;

/// The [icon] and [title] color's opacity defined when this item is selected. Defaults
/// to [0.2].
final double activeColorOpacity;

/// The [icon] and [title] color defined when this item is not selected.
final Color? inactiveColor;

/// The alignment for the [title].
///
/// This will take effect only if [title] it a [Text] widget.
final TextAlign? textAlign;

}