kobakei/MaterialFabSpeedDial

Behavior when no menu items set

usernotnull opened this issue · 2 comments

Currently if no menu items are set, the touch guard appears, and that's it.
In my app, I have a situation where I want the FSD to behave as a FAB when I change fragments, so no menus are available, and I'd want it to have an onClick listener.
So ideally, if no menus are present, the touch guard wouldn't show (since it'd be useless in that case) and a listener would be fired onClick.

The workaround, for now, would be for me to have a FAB on top of this library and I hide/unhide programmatically, but that's very messy.

Will this be available someday?

@RJFares
I'm not sure that this feature should be included in this library.
I think using this library without any child items is rare case and your workaround would be fine.
If many developers need this feature, I will rethink it.

@kobakei I am not so sure this is such a rare case. Just like @RJFares said we might use the library as a navigation menu with content dependent on the currently shown fragment. In cases when we need just one option it is much better UX-wise to react on mainFab click instead of revealing options (one option in that case) and clicking once again.

I noticed a following issue:

  1. We "open" and "close" the menu on a fragment when we set an empty menu
  2. We navigate to another fragment and set a non-empty menu
  3. I guess we end up in an "undefined" state because the main fab is rotated as for the closed menu but the menu is open..

I managed to make a hack which basically doesn't call open/closeMenu() when menu is empty - isOpened flag doesn't change value in that case and makes the menu behave correctly.

Please rethink adding this feature. I you decide to include it I could send you my hack or prepare a PR.