BilalShahid13 / PersistentBottomNavBar

A highly customizable persistent bottom navigation bar for Flutter
BSD 3-Clause "New" or "Revised" License
507 stars 368 forks source link

haptics? #343

Open 2x2xplz opened 7 months ago

2x2xplz commented 7 months ago

My PersistentTabView with 5 buttons has a PersistentTabController, 3 of the buttons change screens (defined in the screens: attribute), the other 2 raise modals. For the modal buttons, I can insert a haptic feedback instruction within the onPressed() block. However, the buttons which change the active screen (via the TabController) do not use onPressed()

Is there a way to insert haptic feedback when these buttons are pressed?

PersistentTabView(context,
   controller: _controller,
   screens: [ MyFirstScreen(), AnotherScreen(), ThirdScreen(), Container(), Container() ],
   items: [
      PersistentBottomNavBarItem(
         ...  // no onPressed()
      ),
      PersistentBottomNavBarItem(
         ...  // no onPressed()
      ),
      PersistentBottomNavBarItem(
         ...  // no onPressed()
      ),
      PersistentBottomNavBarItem(
         ...
         onPressed: (BuildContext? _context) {
            Gaimon.medium();  // haptics (Gaimon library)
            showMyModal(context);
         },
      ),
      PersistentBottomNavBarItem(
         ...
         onPressed: (BuildContext? _context) {
            Gaimon.medium();
            showAnotherModal(context);
         },
      ),
   ]