hacktons / convex_bottom_bar

A Flutter package which implements a ConvexAppBar to show a convex tab in the bottom bar. Theming supported.
https://bar.hacktons.cn
Apache License 2.0
801 stars 150 forks source link

Question: How to not change selected index when another item is pressed? #202

Open evanrich opened 1 year ago

evanrich commented 1 year ago

Is it possible to not change the selected index when the circle button is selected? for example: image

bottomNavigationBar: ConvexAppBar(
            style: TabStyle.fixedCircle,
            height: 60,
            backgroundColor: Color.fromARGB(255, 26, 26, 26),
            activeColor: Colors.orange,

            items: [
              TabItem(icon: Icons.home, title: 'Home'),
              TabItem(icon: Icons.folder_shared, title: 'Models'),
              TabItem(icon: Icons.add, title: 'Add'),
              TabItem(icon: Icons.camera_indoor, title: 'Studios'),
              TabItem(icon: Icons.perm_media, title: 'Shoots'),
            ],
            onTap: (index) => {
              print('click $index'),
              // check if index is the add button, and if so don't do anything
              if (index < 2) {
                controller.jumpToPage((index))
              }  else if (index >2) {
                controller.jumpToPage((index - 1))
              }  else {
                print('Add button clicked'),
              }
            },
          )

If the 1st, 2nd, 4th or 5th bar icons are selected, I want them to stay selected, but allow the middle "+" button to create new items on the selected page, similar to the how venmo works: image

the pay/request button in the middle launches a new page, but hitting "back" on your device still has home/cards/crypto/me selected. In otherwords ,the center icon should just function as a action item to do something, not change index on the bottom navigation bar. Thanks!

This is with the latest version of the convex_bottom_bar, fyi.