nambicompany / expandable-fab

A highly customizable 'speed dial' FloatingActionButton implementation.
https://nambicompany.github.io/expandable-fab/
MIT License
199 stars 20 forks source link

Dynamically managing options #7

Closed neroux closed 3 years ago

neroux commented 3 years ago

Hi Kelvin,

Is my impression wrong or is it currently not really supported to manage options dynamically in the code?

As mentioned in your example, I can use e.g. the following to enable/disable individual options upon a click

getCurrentConfiguration().getFabOptions().get(0).setFabOptionEnabled(false);

However using something like hide() or setVisibility() breaks the UI.

kabumere commented 3 years ago

Hey @neroux,

If by 'manage options' you mean dynamically hide them at run time, then no, the library does not provide a single method call for that. If disabling a FabOption is not enough for you, you'll need to do something like call expandableFabLayout.removeAllViews() then add in the views minus the options you want to remove using expandableFabLayout.addView() or expandableFabLayout.addViews().

NOTE: 'removeAllViews' removes everything from portrait AND landscape orientation. This distinction only matters if you set unique ExpandableFabs to appear in separate orientations. If this is the case for you, you'll need to add back both your portrait and landscape ExpandableFabs, plus their respective FabOptions and Overlays.

neroux commented 3 years ago

Thanks for the clarification, I thought so. It would be lovely if the library offered that feature at some point in the future.

kabumere commented 3 years ago

Hey @neroux,

Good news, the feature you requested has been added to the library! Please use version v1.1.1 now available on Maven Central to access the dynamic FabOption removal feature (or clone the latest changes from the master branch on this repo).