Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to reset selection #20

Closed
AlaaZarifa opened this issue Jan 5, 2021 · 6 comments
Closed

Allow to reset selection #20

AlaaZarifa opened this issue Jan 5, 2021 · 6 comments

Comments

@AlaaZarifa
Copy link

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
                }
            }
@Droppers
Copy link
Owner

Droppers commented Jan 5, 2021

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?

@AlaaZarifa
Copy link
Author

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

@Droppers
Copy link
Owner

Droppers commented Jan 5, 2021

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.

@Droppers
Copy link
Owner

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

@rgocal
Copy link

rgocal commented Jul 26, 2021

was this added yet?

@rgocal
Copy link

rgocal commented Jul 30, 2021

solved my problem by just manually adding library as a module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants