zawadz88 / MaterialPopupMenu

Shows Material popup menus grouped in sections & more
Apache License 2.0
646 stars 59 forks source link

Provision for passing drawable object instead of drawable resource id #9

Closed prscX closed 6 years ago

prscX commented 6 years ago

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

zawadz88 commented 6 years ago

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 6 years ago

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

Thanks Pranav

prscX commented 6 years ago

Thanks @zawadz88, I got it working using CustomItem.

Many Thanks for the guidance

Thanks Pranav

zawadz88 commented 6 years ago

Hi @prscX, This is available now in 1.3.0.

prscX commented 6 years ago

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