zawadz88/MaterialPopupMenu

Provision for passing drawable object instead of drawable resource id

prscX opened this issue · 5 comments

prscX commented

Hi @zawadz88,

I am basically writing ReactNative native bridge of this library in order to using it with ReactNative projects.

I am stuck at place where from JS I am receiving icon information and using that I am able to create Drawable object, now the challenge is how to pass this drawable to item.setIcon method.

Since this API only except drawable resource, I am not able to pass the created drawable. Is it possible to have one more method which accepts raw drawable, may be we can achieve this by method overloading.

Please find reference below to the ReactNative library which I am working on:
react-native-popover-menu
Bridging Class

In case if you are lined up with other assignments, can you please guide me on how to enable this API. I will try my level best in order to enable this functionality.

P.S: Please consider me as beginner with Kotlin

Thanks
Pranav

Hi Pranav,
Thanks for raising this issue. This seems like a very nice enhancement to the library.
I'm going on holidays now but I'll surely add it once I'm back!

For the time being I believe you could actually make this work by using a custom item introduced in 1.2.0. In customItem you could specify a layoutResId with an ID to the one used for the default item and in viewBoundCallback find the icon ImageView and set the Drawable there.

prscX commented

Thanks @zawadz88 for your valuable feedback. I will try the suggested solution and will share the results here.

Thanks
Pranav

prscX commented

Thanks @zawadz88, I got it working using CustomItem.

Many Thanks for the guidance

Thanks
Pranav

Hi @prscX,
This is available now in 1.3.0.

prscX commented

Many Thanks @zawadz88 for the support and enhancing the API's