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

IconColor changes when Popup is dismissed #70

Open
rtsketo opened this issue Mar 13, 2020 · 0 comments
Open

IconColor changes when Popup is dismissed #70

rtsketo opened this issue Mar 13, 2020 · 0 comments

Comments

@rtsketo
Copy link

rtsketo commented Mar 13, 2020

popupMenu {
    style = R.style.Widget_MPM_Menu_Custom
    section { attachmentList?.forEach { item {
        iconColor = Color.WHITE
        labelColor = Color.WHITE
        iconDrawable = it.icon
        label = it.title
        callback = { intent(it.url) }
} } }
where R.style.Widget_MPM_Menu_Custom is <style name="Widget.MPM.Menu.Custom"><item name="android:colorBackground">#ffaf00</item></style>

The icons in the above example start white, but when one of them is selected or the dialog is dismissed, they turn black.

 

My solution was to repaint them on dismiss, like below.
val drawables = arrayListOf<Drawable>()
val popup = popupMenu {
    style = R.style.Widget_MPM_Menu_Custom
    dropDownVerticalOffset = toolBar.height
    section { attachmentList?.forEach { item {
        iconColor = white
        labelColor = white
        iconDrawable = it.icon
        iconDrawable?.apply { drawables.add(this) }
        label = it.title
        callback = { intent(it.url) }
    } } }
}

// Junky way to patch this bug.
popup.setOnDismissListener {
    drawables.forEach { drawable ->
        drawable.filter(white) } }

popup.show(context!!, it)
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

1 participant