Skip to content

Commit

Permalink
Added click event
Browse files Browse the repository at this point in the history
  • Loading branch information
YDA93 committed Oct 19, 2022
1 parent 8e01543 commit b60827c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/src/gnav.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,32 @@ class GNavState extends State<GNav> {
late int selectedIndex;
bool clickable = true;

// Animation only
Future<void> animateTo(int toIndex) async {
setState(() {
selectedIndex = toIndex;
});
}

// Fire click event
Future<void> clickIndex(int toIndex) async {
if (!clickable) return;
setState(() {
selectedIndex = toIndex;
clickable = false;
});

widget.tabs[selectedIndex].onPressed?.call();

widget.onTabChange?.call(selectedIndex);

Future.delayed(widget.duration, () {
setState(() {
clickable = true;
});
});
}

@override
void initState() {
super.initState();
Expand Down

0 comments on commit b60827c

Please sign in to comment.