Droppers/AnimatedBottomBar

Allow to reset selection

AlaaZarifa opened this issue · 6 comments

I have a use case where when the user selects a tab, a certain view would show. then if the user reselects that tab that view would disappear, but I can't find a way to deselect the tab or reset the selection.

I managed to handle this using this useful callback:

mainBar.onTabReselected = { tab ->
                when (tab?.id) {
                    R.id.fontSize -> {
                        seekBarView.reverseVisibility()
                         //  mainBar.resetSelection()   or   tab.deselect()
                    }
                   // other code
                }
            }

What does reset the selection mean? You can select a tab programmatically by doing one of the following:

// Selecting a tab by object reference
val tabToSelect = AnimatedBottomBar.tabs[1]
AnimatedBottomBar.selectTab(tabToSelect)

// Selecting a tab at a specific position
AnimatedBottomBar.selectTabAt(1)

// Selecting a tab by the given ID resource
AnimatedBottomBar.selectTabById(R.id.tab_home)

Assuming you mean selecting the previously selected tab, you could keep track of the previously selected tab yourself, and then use one of the selectTab functions?

here's a visual explanation of what I want to achieve.
When the user clicks again on Font Size tab, I want the selection to be gone and return to the original look.

screenshot-1609848761005

If I understand correctly you want a deselect() function which will deselect all tabs? Currently, this is not possible, when I have time I'll look into implementing this, or you could make a pull request of course.

Added a clearSelection() function which will be available in the next version.

was this added yet?

solved my problem by just manually adding library as a module