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

Added Tooltip to BottomNavyBar.items #91

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 4 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,29 @@ class _MyHomePageState extends State<MyHomePage> {
title: Text('Home'),
activeColor: Colors.red,
textAlign: TextAlign.center,
tooltipText: "Home Page",
),
BottomNavyBarItem(
icon: Icon(Icons.people),
title: Text('Users'),
activeColor: Colors.purpleAccent,
textAlign: TextAlign.center,
tooltipText: "Users",
),
BottomNavyBarItem(
icon: Icon(Icons.message),
title: Text(
'Messages test for mes teset test test ',
),
tooltipText: "My Messages",
activeColor: Colors.pink,
textAlign: TextAlign.center,
),
BottomNavyBarItem(
icon: Icon(Icons.settings),
title: Text('Settings'),
activeColor: Colors.blue,
tooltipText: "Preferences",
textAlign: TextAlign.center,
),
],
Expand Down
11 changes: 10 additions & 1 deletion lib/bottom_navy_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class _ItemWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Semantics(
Semantics semantic = Semantics(
container: true,
selected: isSelected,
child: AnimatedContainer(
Expand Down Expand Up @@ -184,6 +184,12 @@ class _ItemWidget extends StatelessWidget {
),
),
);
return item.tooltipText == null
? semantic
: Tooltip(
message: item.tooltipText!,
child: semantic,
);
}
}

Expand All @@ -195,6 +201,7 @@ class BottomNavyBarItem {
this.activeColor = Colors.blue,
this.textAlign,
this.inactiveColor,
this.tooltipText,
});

/// Defines this item's icon which is placed in the right side of the [title].
Expand All @@ -214,4 +221,6 @@ class BottomNavyBarItem {
///
/// This will take effect only if [title] it a [Text] widget.
final TextAlign? textAlign;
/// Will show a tooltip for icon if provided.
final String? tooltipText;
}