New features
- Support for group dividers (thanks @waseefakhtar!).
- Internal paddings in the popup's background are trimmed automatically if they were picked up from the app's (XML) theme.
cascade
assumes that they were supplied by appcompat
or MaterialComponents
. If paddings are really desired, a custom CascadePopupMenu.Styler.background
will have to be provided with paddings.
- Injectable back navigator:
// A "back" navigator can be used for setting up a menu's navigation before an instance of
// CascadePopupMenu can be created. This is especially useful for overriding Toolbar's popup
// menus where a CascadePopupMenu can only be created AFTER a menu item is clicked
// (to maintain backwards compatibility with PopupMenu).
val navigator = CascadeBackNavigator()
toolbar.menu.addSubMenu("Are you sure?").apply {
add("Cancel").setOnMenuItemClickListener {
backNavigator.navigateBack()
}
}
toolbar.overrideOverflowMenu { context, anchor ->
CascadePopupMenu(context, anchor, backNavigator = navigator)
}
- Experimental API to
steal override all popup menus of a Toolbar with cascade
. This will override both overflow menu and sub menus for action items.
toolbar.overrideAllPopupMenus(with = ::CascadePopupMenu)
Fixes
- Prevent keyboard from getting recreated when cascade is shown.
- Disable drag-to-show gesture when overflow menu is overridden.
- Fix incorrect left spacing of menu items with
MaterialComponents
theme.
- #23: Handle touch and key events on API 22 (thanks @kizitonwose!).