sooxt98 / google_nav_bar

A modern google style nav bar for flutter.
MIT License
735 stars 114 forks source link

How can i disable tabs? #94

Open Vuuux opened 9 months ago

Vuuux commented 9 months ago

Giving that my app is using a same GNav navigator for guest and logged in users, I want to limit guest's access to my app by disabling some nav tabs (grey out icon, disable onPress). But even if I didn't change the _selectedIndex, the navigator still switched the tabs. I see that in your gnav.dart code there is no way to prevent switching tab:

                      onPressed: () {
                        if (!clickable) return;
                        setState(() {
                          selectedIndex = widget.tabs.indexOf(t);
                          clickable = false;
                        });

                        t.onPressed?.call();

                        widget.onTabChange?.call(selectedIndex);

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

Can we add a disable state for GButton?

sooxt98 commented 9 months ago

I think have to implement another attribute for Gnav, maybe an autoNavigateOnTap: false

Vuuux commented 9 months ago

I think have to implement another attribute for Gnav, maybe a autoNavigateOnTap: false

Thanks for your responding!